* testing ethernet device with external loopback
@ 2008-07-27 8:47 Sebastien Fauris
2008-07-27 11:07 ` James Chapman
2008-07-27 16:25 ` David Anders
0 siblings, 2 replies; 3+ messages in thread
From: Sebastien Fauris @ 2008-07-27 8:47 UTC (permalink / raw)
To: linux-embedded
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 !
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 ?
Thanks,
Sebastien.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: testing ethernet device with external loopback
2008-07-27 8:47 testing ethernet device with external loopback Sebastien Fauris
@ 2008-07-27 11:07 ` James Chapman
2008-07-27 16:25 ` David Anders
1 sibling, 0 replies; 3+ messages in thread
From: James Chapman @ 2008-07-27 11:07 UTC (permalink / raw)
To: Sebastien Fauris; +Cc: linux-embedded
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: testing ethernet device with external loopback
2008-07-27 8:47 testing ethernet device with external loopback Sebastien Fauris
2008-07-27 11:07 ` James Chapman
@ 2008-07-27 16:25 ` David Anders
1 sibling, 0 replies; 3+ messages in thread
From: David Anders @ 2008-07-27 16:25 UTC (permalink / raw)
To: linux-embedded, Sebastien Fauris
Sebastien,
check out the snull network driver from the "Linux Device Drivers" book. it has a short explanation on how to "trick" the kernel into sending the packet even though the destination is on the local machine:
http://www.linuxdriver.co.il/ldd3/chp-17-sect-1.shtml
dave aka prpplague
--- On Sun, 7/27/08, Sebastien Fauris <titelive72@gmail.com> wrote:
> From: Sebastien Fauris <titelive72@gmail.com>
> Subject: testing ethernet device with external loopback
> To: linux-embedded@vger.kernel.org
> Date: Sunday, July 27, 2008, 3:47 AM
> 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 !
> 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 ?
>
> Thanks,
>
> Sebastien.
>
> --
> To unsubscribe from this list: send the line
> "unsubscribe linux-embedded" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at
> http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-07-27 16:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-27 8:47 testing ethernet device with external loopback Sebastien Fauris
2008-07-27 11:07 ` James Chapman
2008-07-27 16:25 ` David Anders
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox