If one executes for example iperf -c 178.62.60.141 -fm -b 100m -u -t 30 -i 10
, then after each 10 second interval, Iperf client prints out the amount of data it has transferred in mebibytes:
root@vserver:~# iperf -c 178.62.60.141 -fm -b 100m -u -t 30 -i 10
WARNING: option -b implies udp testing
------------------------------------------------------------
Client connecting to 178.62.60.141, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 0.22 MByte (default)
------------------------------------------------------------
[ 3] local 146.185.187.148 port 37660 connected with 178.62.60.141 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 119 MBytes 100 Mbits/sec
[ 3] 10.0-20.0 sec 119 MBytes 100 Mbits/sec
[ 3] 20.0-30.0 sec 119 MBytes 100 Mbits/sec
[ 3] 0.0-30.0 sec 358 MBytes 100 Mbits/sec
[ 3] Sent 255661 datagrams
Same is true for TCP. Fact, that transferred data and bandwidth are printed out after the end of each interval and transferred data is sometimes bit more or less than the bandwidth specified with the "-b" flag, should mean that Iperf client actually somehow counts the sent data and doesn't just print the argument of "-b"(bandwidth) flag. Still, how does
Iperf client count the amount of data it sends? It sure doesn't do this on low level because if I introduce 10% packet loss with tc
, execute iperf -c 178.62.60.141 -fm -b 100m -u -t 30 -i 10
and then compare the packets Iperf client thought it sent(from Iperf client output) with the amount of packets actually were put to wire(from ip -s link show dev eth0
output), then Iperf client thought that it sent >250k datagrams while it actually did just bit over 230k. Exactly the same holds true if I police the traffic with tc
Token Bucket Filter queuing discipline, i.e. according to Iperf client it has sent out traffic at 100Mbps while actual traffic rate was policed by policer.
If I try to analyze the source code of Iperf(http://ftp.de.debian.org/debian/pool/main/i/iperf/iperf_2.0.5.orig.tar.gz), then as I understand, client connection is coded in Client.cpp file in src directory using regular connect() system call? I guess the reporting is coded in Reporter.c file, but it gets too complicated for me to understand this.. Could someone please explain(with code samples) how does Iperf 2.x client detect the amount of traffic it has sent?