How iperf calculates network statistics

﹥>﹥吖頭↗ 提交于 2020-01-04 17:34:13

问题


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?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/37063074/how-iperf-calculates-network-statistics

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!