10

I need to test network throughput of a server to/from itself (it's a lonnnng story!).

I love Iperf and use it across the network, but, I just can't figure out how to bind it to a single interface and only listen via that.

From the documentation, I would assume that this would work: iperf -B eth0 -s to bind one instance to eth0, then in another session: iperf -B eth1 -c ip.of.eth.1.

This doesn't work at all, and actually fails. If I use the ip instead of interface, it does work, but, throughput is at 29Gb/s - so, unless there is some magic going on where by I have a super server with a 30Gb/s card, I am guessing that I am not even touching the network and this is just going locally.

Can anyone help me here, or know of a better test/tool?

4 Answers4

7

Yes, this traffic is transferred locally without reaching your physical interfaces. It is transferred using the loopback interface. The kernel detects that the destination is a local one, so the traffic is looped back to the machine itself without going through eth0 or eth1.

Khaled
  • 37,789
2

I know this is old, but posting in case it helps anyone else.

Quote from iPerf 2 user documentation

If iPerf is in server mode, then specifying a host with -c will limit the connections that iPerf will accept to the host specified. Does not work well for UDP.

I used this to perform TCP throughput tests on Windows 7 64bit from LAN to WiFi interfaces. Worked fine with either iperf 2.0.8 or 2.0.5, not sure about other versions. See below the commands used.

iperf.exe -B 192.168.0.1 -s -c 192.168.0.2 -P 0 -i 1 -p 5001 -f m

iperf.exe -B 192.168.0.2 -c 192.168.0.1 -P 1 -i 1 -p 5001 -f m -t 100 -F c:\data.bin
masegaloeh
  • 18,498
user305077
  • 21
  • 1
1

The solution proposed by Sam Lewis: https://www.samlewis.me/2020/04/force-ethernet-loopback/

Create a namespace for each adapter

ip netns add ns_eth0
ip netns add ns_eth1

Move the adapters into the namespaces

ip link set eth0 netns ns_eth0
ip link set eth1 netns ns_eth1

Assign ip addresses to each adapter

ip netns exec ns_eth0 ip addr add dev eth0 192.168.1.1/24
ip netns exec ns_eth1 ip addr add dev eth1 192.168.1.2/24

Bring the adapters up

ip netns exec ns_eth0 ip link set eth0 up
ip netns exec ns_eth1 ip link set eth1 up

Check that each adapter can ping the other

ip netns exec ns_eth0 ping 192.168.1.2
ip netns exec ns_eth1 ping 192.168.1.1

Run your tests, happy in the knowledge that the traffic is really going out on the physical interface!

ip netns exec ns_eth0 iperf3 -s
ip netns exec ns_eth1 iperf3 -c 192.168.1.1

Return to the original state

ip netns del ns_eth0
ip netns del ns_eth1
0

Since I cannot comment due to insufficient reputation, I will be adding an answer that isn't an answer, but the "solutions" mentioned in https://stackoverflow.com/questions/2734144/linux-disable-using-loopback-and-send-data-via-wire-between-2-eth-cards-of-one/4490220#4490220 seem good in theory, but neither actually works (at least on Debian/Ubuntu, as iperf cannot assign the IP addresses when you either delete the local routes or try to use the virtual NAT addresses.)

Just to save people the time and effort for something that seems good in theory, but doesn't actually work on (modern) Debian/Ubuntu...