How iperf calculates network statistics
Asked Answered
O

2

5

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?

Opener answered 6/5, 2016 at 2:1 Comment(0)
M
3

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

Minim answered 6/5, 2016 at 10:36 Comment(0)
O
4

I looked at the source code, and also took some tcpdumps for iperf3. I have the following understanding for iperf3.

In iperf UDP packets, a time stamp and a sequence number (which iperf source code calls it pcount) is written into the payload by the sender. Once the receiver gets the packet, it extracts time stamp for jitter, and sequence number for packet loss count.

Jitter is calculated by compared the time stamp and the current time to find the delay, D_current, first. Then, find |D_current - D_previous| (the difference cancels the clock insync between the sender and the receiver) to contribute to jitter.

Loss is just to accumulate the the difference between the current pcount and the expected pcount which is previously received pcount plus one.

No matter it is iperf udp (with option -u in client side) or tcp, when iperf starts, a control TCP connection will be established. This control TCP connection is used to exchange client side and server side statistics, which include CPU utils, jitter and loss calculated above, at the end of test.

From iperf2 log, I do not find that control TCP connection.

Opener answered 10/5, 2016 at 1:46 Comment(0)
M
3

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

Minim answered 6/5, 2016 at 10:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.