Search code examples
tcpudpiperf

How iperf calculates network statistics


iperf is a great tool to measure network statistics, such as loss, throughput, jitter. I have used it a lot. But, I am just wondering how it calculates those statistics. For throughput, it can simply measure the number of bytes it received in a certain period of time; For jitter, it can just measure the packet arrival time. But, for UDP loss, how it can calculate. My guess is that it construct its payload specifically by embedding sequence numbers. So, the server can predict what packets are lost. Does anyone know what is the content of iperf packet payload?

The other thing is that, in the end of connection, the iperf client (sender) will receive a server report (which has the statistics). Which port number this report is sent? This report uses TCP or UDP? I cannot capture it using tcpdump.

I tried to search online to find the answers to my above questions. But, I can only find how to USE iperf. Looks like no document/website explain how iperf WORKs. Can someone give some insight or point to some documents?


Solution

  • I am not an iperf developer, but looking at the source code, it was quite easy to find the place where the packet count is copied to the udp message, look for packet_count here: https://github.com/esnet/iperf/blob/master/src/iperf_udp.c