Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a dual port ethernet NIC and let's say I have connected both ports in a loop and assigned the following IPs to the 2 ethernet interfaces:

  • eth2 -> 192.168.2.1
  • eth3 -> 192.168.3.1

I want to send traffic from 1 of the ports to the other over the physical network, e.g. ping 192.168.3.1 from 192.168.2.1. However, the TCP/IP stack in the Linux kernel recognizes that these two addresses are local and instead sends the traffic to the loopback adapter, so the traffic never hits the physical network.

The closest I have to a solution is Anastasov's send-to-self patch, which unfortunately, has been discontinued since kernel 3.6 so it won't work on Ubuntu 13.10 (kernel 3.11) for me. I've tried rewriting the patch for 3.11, but I can't seem to locate these in the Ubuntu distro:

  • include/linux/inetdevice.h
  • net/ipv4/devinet.c
  • net/ipv4/fib_frontend.c
  • net/ipv4/route.c
  • Documentation/networking/ip-sysctl.txt

Is there a way I can get the send-to-self patch to work, or an alternative solution?

share|improve this question
    
In oder to know whether an alternative solution seems to make sense we need to know what the aim of this approach is. –  Hauke Laging Mar 29 at 0:09
    
I want to experiment with the NIC to test its performance, e.g. flood it with 14.88 Mpps (10 Gb) of traffic and see if it drops packets, or do a simple ping test from port-to-port without buying another of the exact same NIC. (This is for a particle physics research project, so our budget is limited.) –  elleciel Mar 29 at 0:16
    
@Braiam: Yes - found the files there - how should I go about patching my Ubuntu distro with the kernel source though? –  elleciel Mar 29 at 0:18

1 Answer 1

I haven't tried that yet but I guess there are several possibilities for workarounds:

virtual machines

Solve the IP stack problem by separating at least one of the NICs from the host's IP stack: Assign it to a virtual machine. For performance tests this may be rather not desirable, though. But if there is enough CPU power maybe the additional software layer does not become a bottleneck (but how do you know?).

different target addresses

You want the packet transferred on layer 2 only for a NIC performance test, I guess. So you may use IP packets with a different IP address (a non-local one so that the packets are sent over the wire in any case). And then you cheat: You use ip neigh for creating a permanent ARP entry which maps this fake IP address to the other NICs MAC address.

You could even make IP connections that way. But you would have to use iptables with SNAT and DNAT so that both NICs believe they are talking to one of the two necessary fake IPs.

raw access

If you are willing to do some non-trivial programming then you can open raw sockets and create the Ethernet frames yourself. This would probably be the fastest solution.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.