All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Chapman <jchapman@katalix.com>
To: Sebastien Fauris <titelive72@gmail.com>
Cc: linux-embedded@vger.kernel.org
Subject: Re: testing ethernet device with external loopback
Date: Sun, 27 Jul 2008 12:07:03 +0100	[thread overview]
Message-ID: <488C56D7.6050208@katalix.com> (raw)
In-Reply-To: <488C3608.3000104@gmail.com>

Sebastien Fauris wrote:
> Hi,
> 
> for hardware testing purposes, I would like to perform an external 
> loopback on my ethernet interface. For this, I wrote 2 little 
> executables, one  sending a raw ethernet packet (using 'sendto') on a 
> socket opened with the  parameters PF_PACKET, SOCK_RAW, 
> htons(ETH_P_ALL), the other one doing a recvfrom from a raw socket.
> The problem is that on the reception side, I always receive what I send, 
> even when
> the external RJ45 stub is not plugged !

Presumably you are trying to sendto() a local IP address. When you do 
this, packets are looped back before they get to the ethernet driver. 
Pull out all eth cables and do a ping to one of your local IP addresses 
and you'll see ping responses. :)

> Is there a way to tell to the kernel on the reception side that I want 
> to get only packets coming from the external world ?

Try using pktgen to generate packets from the kernel to the IP address 
of your interface. The packets are generated inside the kernel, below 
the IP stack, so they don't get looped back in software. With pktgen, 
you set MAC addresses, IP addresses, protocol etc using a /proc 
interface. There is documentation in the kernel source tree, or google 
pktgen.


-- 
James Chapman
Katalix Systems Ltd
http://www.katalix.com
Catalysts for your Embedded Linux software development

  reply	other threads:[~2008-07-27 11:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-27  8:47 testing ethernet device with external loopback Sebastien Fauris
2008-07-27 11:07 ` James Chapman [this message]
2008-07-27 16:25 ` David Anders

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=488C56D7.6050208@katalix.com \
    --to=jchapman@katalix.com \
    --cc=linux-embedded@vger.kernel.org \
    --cc=titelive72@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.