Skip to contentSkip to conversation

Testing Dual Ethernet via Loopback

DISCUSSION Nick Popoff 5 participants 5 messages Apr 20, 2004 – Apr 22, 2004

lore
Share & tools
lore
#0 lore raw

Greetings,

I am trying to write some software to test a dual port ethernet card. I was hoping to be able to use an ethernet cable to just connect the ethernet board to itself and then write a program that talks to itself to make sure that both ports are working. However, I've noticed that Linux is smart enough to realize it is talking to its own IP address, and it just delivers the data internally rather than use the network hardware at all.

So what I'm wondering is if there is a way to force Linux to actually utilize its network hardware in sending these packets to itself? In other words, a ping or file transfer from an IP assigned to eth0 to another IP assigned to eth1 should fail if I unplug the network cable connecting the two. Any advice on this would be much appreciated. I'm not afraid of reading kernel source but have no idea where to start on this one.

I'm using 2.4.22 but would use any 2.4 or 2.6 kernel that supported this behavior. The National Semiconductor DP83815 (natsemi.o) is the ethernet chipset.

#1 lore raw
Quoted 6 lines · Nick Popoff

So what I'm wondering is if there is a way to force Linux to actually utilize its network hardware in sending these packets to itself? In other words, a ping or file transfer from an IP assigned to eth0 to another IP assigned to eth1 should fail if I unplug the network cable connecting the two. Any advice on this would be much appreciated.

I don't know if there's some knob for that. What I'm always doing:
tcpdump on one interface and then a broadcast ping on the other one.

If you want to write a hardware test program maybe using raw ethernet packets is the way to go. These can be send directly to a specific interface and don't require it to be IP-configured. man 7 packet

Ciao, ET.

#2 lore raw
In reply to Nick Popoff

Hi!

Quoted 6 lines

So what I'm wondering is if there is a way to force Linux to actually utilize its network hardware in sending these packets to itself? In other words, a ping or file transfer from an IP assigned to eth0 to another IP assigned to eth1 should fail if I unplug the network cable connecting the two. Any advice on this would be much appreciated. I'm not afraid of reading kernel source but have no idea where to start on this one.

tcpdump on eth0, ping non-existant IP on eth1?

Signature · 1 line
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms         
#3 lore raw
Quoted 8 lines · Pavel Machek

Hi!

Quoted 6 lines

So what I'm wondering is if there is a way to force Linux to actually utilize its network hardware in sending these packets to itself? In other words, a ping or file transfer from an IP assigned to eth0 to another IP assigned to eth1 should fail if I unplug the network cable connecting the two. Any advice on this would be much appreciated. I'm not afraid of reading kernel source but have no idea where to start on this one.

ifconfig lo down should do it. This will (should) force linux to actually use the address supplied and not sneak through the loopback device.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5557.45 BogoMips).
Note 96.31% of all statistics are fiction.

#4 lore raw
In reply to Pavel Machek
Quoted 7 lines

So what I'm wondering is if there is a way to force Linux to actually utilize its network hardware in sending these packets to itself? In other words, a ping or file transfer from an IP assigned to eth0 to another IP assigned to eth1 should fail if I unplug the network cable connecting the two. Any advice on this would be much appreciated. I'm not afraid of reading kernel source but have no idea where to start on this one.

Sounds like you need the send-to-self patch:

http://www.ssi.bg/~ja/

We've been using it a lot in the lab, it works well.

Anton