有次在使用iperf测试wifi吞吐率时候发现了问题,上午测的时候速度还可以,下午就不行了,发现上午是linux对linux,下午是window对linux,先贴测试图如下:
# ./iperf -s -w
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[ 4] local 192.168.0.108 port 5001 connected with 192.168.0.100 port 54743
[ ID] Interval Transfer Bandwidth
[ 4] 0.0- 3.4 sec 4.40 MBytes 10.8 Mbits/sec
[ 5] local 192.168.0.108 port 5001 connected with 192.168.0.100 port 54750
[ 5] 0.0- 5.3 sec 18.6 MBytes 29.5 Mbits/sec
C:\Users\Administrator\Desktop\iperf for windows\iperf命令行工具>iperf.exe -c 19
2.168.0.108 -i 1 -t 5
------------------------------------------------------------
Client connecting to 192.168.0.108, TCP port 5001
TCP window size: 8.00 KByte (default)
------------------------------------------------------------
[204] local 192.168.0.100 port 54743 connected with 192.168.0.108 port 5001
[ ID] Interval Transfer Bandwidth
[204] 0.0- 1.0 sec 1.16 MBytes 9.76 Mbits/sec
[204] 1.0- 2.0 sec 1.51 MBytes 12.6 Mbits/sec
[204] 2.0- 3.0 sec 1.27 MBytes 10.7 Mbits/sec
[204] 0.0- 3.4 sec 4.40 MBytes 10.8 Mbits/sec
C:\Users\Administrator\Desktop\iperf for windows\iperf命令行工具>iperf.exe -c 19
2.168.0.108 -i 1 -t 5 -w1M
------------------------------------------------------------
Client connecting to 192.168.0.108, TCP port 5001
TCP window size: 1.00 MByte
------------------------------------------------------------
[204] local 192.168.0.100 port 54750 connected with 192.168.0.108 port 5001
[ ID] Interval Transfer Bandwidth
[204] 0.0- 1.0 sec 3.91 MBytes 32.8 Mbits/sec
[204] 1.0- 2.0 sec 4.09 MBytes 34.3 Mbits/sec
[204] 2.0- 3.0 sec 3.75 MBytes 31.5 Mbits/sec
[204] 3.0- 4.0 sec 3.87 MBytes 32.4 Mbits/sec
[204] 4.0- 5.0 sec 2.99 MBytes 25.1 Mbits/sec
[204] 0.0- 5.3 sec 18.6 MBytes 29.4 Mbits/sec
发现windows端的默认window size是8.00 KByte,而linux是85.3 KByte (default),当linux做server,windows做client上传(反过来没有问题),会因为windows size导致传输速率受限,当在window 端将window size设置成1M时候,iperf速率有明显上升,10.8 Mbits/sec->29.5 Mbits/sec,执行iperf –help发现
-w, –window #[KM] TCP window size (socket buffer size)
window szie 就是socket buffer size,当两端不统一的时候,会造成传输速率下降,影响真实的测量结果
所以建议在iperf测试的时候,在server和client端都加上-w的参数
iperf -s -w 1M
iperf -c 192.168.0.1 -w 1M -i 1 -t 5