Network speed testing discrepancy: iperf vs. iftop vs. iptraf

June 25th, 2015 by bostjan

WARNING: This content is obsolete and inaccurate. Here is updated content, presented with a new approach.

 

When I need to test raw network performance, I usually rely on iperf. It is a simple and solid single-threaded network performance testing tool. But if I want a quick glance of what is going on on the network interface right now, I usually use iptraf. The third tool that is also simple and usually readiliy available is iftop.

But if you run a network bandwidth test with iperf and watch the network throughput with iptraf and/or iperf, you will notice the discrepancy in results.

What we will do is:

  1. conduct a test first
  2. then try to explain where discrepancies come from

 

Results

Let us first conduct a test on an unfortunately 100Mbit network (readily available, clients are modern i5/32GB hardware, but switch is old and rusty 100Mbit. This network link is unused mostly, thus somewhat suitable for testing).

Here are the results (in Mbps probably):

  1. iperf: 94.1, stable on server side, fluctuates a bit on client (1-2%), average is about the same (+/-0.2%)
  2. iptraf: 96.2 on server side, 98.3 on client side (2.2% difference)
  3. iftop: 91.5 on iperf server, 93 on iperf client side (1.7% difference)

 

Additional data:

  • ethernet frame: header 26 bytes, payload max 1500 bytes, if jumbo frames are not used
  • IP packet header: 20 bytes (IPv4)
  • TCP header: min 20 bytes, in our case it seems 32 bytes (see Payload size)
  • UDP header: 8 bytes
  • Payload size: 1448 bytes (checked with tcpdump where whole packet lenght is reported as 1500)

Some max packet size coefficients:

  1. 1500 vs. 1526 = 1.7% difference
  2. 1480 vs 1526 = 3.1% difference
  3. 1448 vs 1526 = 5.2% diff
  4. 1480 vs 1500 = 1.4%
  5. 1448 vs 1500 = 3.5%
  6. 1448 vs 1480 = 2.2%

Some coefficients between measurements:

  1. 94.1 vs 98.3 = 4.3% difference
  2. 94.1 vs 96.2 = 2.2% diff
  3. 93.0 vs 94.1 = 1.2%
  4. 91.5 vs 94.1 = 2.8%
  5. 91.5 vs 96.2 = 4.9%
  6. 93.0 vs 98.3 = 5.3%

Additional coefficient:

  1. 1000 vs 1024 = 2.4% difference
  2. 1000^2 vs 1024^2 = 4.7% difference

 

Discrepancy #1: iftop client vs. server

This discrepancy may come from ethernet frames being calculated in on one side and not on the other. Ethernet header is 26 bytes long, and payload is max 1500bytes. 1500/1526 = 1.8%. This aligns nicely with 1.7% difference we are observing. Confirmation welcome in comments.

 

Discrepancy #2: iptraf client vs. server

This does not align so nicely as #1, but I suppose the reason is quite similar.

 

Discrepancy #3: iptraf vs iperf

This measures around 5%. Direct conclusion would say that one measures on-wire speed, and the other the actual content, but that does not seem to make any sense. Why would iftop, which has “interface” written in its name (the “if” part) measure something else than raw interface speed?

 

Preliminary conclusion

Tools should report raw numbers, in bits per second, or bytes per second.┬áTo be continued…


One Response to “Network speed testing discrepancy: iperf vs. iftop vs. iptraf”

  1. […] the results shown by “iperf” and “iftop“. A fellow blogger also noticed this discrepancy. In order to get to the bottom of this, I did some additional tests using different MTU sizes, and […]

Leave a Reply

 

*