今天测试机房的两台服务器之间的网络带宽,发现了一个奇怪的现象:
同时测试上下行带宽:
[root@ptl3m log]# iperf -c 172.28.2.21 -t 60 -i 10 -d -L 8083
------------------------------------------------------------
Server listening on TCP port 8083
TCP window size: 4.00 KByte (default)
------------------------------------------------------------
------------------------------------------------------------
Client connecting to 172.28.2.21, TCP port 5001
TCP window size: 400 KByte (default)
------------------------------------------------------------
[ 3] local 172.28.2.23 port 46174 connected with 172.28.2.21 port 5001
[ 5] local 172.28.2.23 port 8083 connected with 172.28.2.21 port 39939
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 4.37 GBytes 3.75 Gbits/sec
[ 5] 0.0-10.0 sec 552 MBytes 463 Mbits/sec
[ 3] 10.0-20.0 sec 4.84 GBytes 4.16 Gbits/sec
[ 5] 10.0-20.0 sec 221 MBytes 185 Mbits/sec
[ 3] 20.0-30.0 sec 4.87 GBytes 4.19 Gbits/sec
[ 5] 20.0-30.0 sec 303 MBytes 254 Mbits/sec
[ 3] 30.0-40.0 sec 4.01 GBytes 3.45 Gbits/sec
[ 5] 30.0-40.0 sec 1.04 GBytes 891 Mbits/sec
[ 3] 40.0-50.0 sec 4.81 GBytes 4.14 Gbits/sec
[ 5] 40.0-50.0 sec 223 MBytes 187 Mbits/sec
[ 3] 50.0-60.0 sec 4.75 GBytes 4.08 Gbits/sec
[ 3] 0.0-60.0 sec 27.7 GBytes 3.96 Gbits/sec
[ 5] 50.0-60.0 sec 347 MBytes 291 Mbits/sec
[ 5] 0.0-60.0 sec 2.65 GBytes 379 Mbits/sec
从上面可以看到这种测试方法上下行带宽差距较大。但是采用下面的命令测试,带宽差距就没有那么大:
[root@ptl3m log]# iperf -c 172.28.2.21 -t 60 -i 10 -r -L 8083
------------------------------------------------------------
Server listening on TCP port 8083
TCP window size: 4.00 KByte (default)
------------------------------------------------------------
------------------------------------------------------------
Client connecting to 172.28.2.21, TCP port 5001
TCP window size: 400 KByte (default)
------------------------------------------------------------
[ 3] local 172.28.2.23 port 46130 connected with 172.28.2.21 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 4.67 GBytes 4.01 Gbits/sec
[ 3] 10.0-20.0 sec 4.17 GBytes 3.58 Gbits/sec
[ 3] 20.0-30.0 sec 4.70 GBytes 4.04 Gbits/sec
[ 3] 30.0-40.0 sec 4.92 GBytes 4.23 Gbits/sec
[ 3] 40.0-50.0 sec 4.86 GBytes 4.18 Gbits/sec
[ 3] 50.0-60.0 sec 4.28 GBytes 3.68 Gbits/sec
[ 3] 0.0-60.0 sec 27.6 GBytes 3.95 Gbits/sec
[ 5] local 172.28.2.23 port 8083 connected with 172.28.2.21 port 38653
[ 5] 0.0-10.0 sec 3.91 GBytes 3.36 Gbits/sec
[ 5] 10.0-20.0 sec 4.02 GBytes 3.45 Gbits/sec
[ 5] 20.0-30.0 sec 3.92 GBytes 3.37 Gbits/sec
[ 5] 30.0-40.0 sec 4.02 GBytes 3.45 Gbits/sec
[ 5] 40.0-50.0 sec 4.06 GBytes 3.49 Gbits/sec
[ 5] 0.0-60.0 sec 24.1 GBytes 3.44 Gbits/sec
这种-d 和 -r参数对结果产生了影响,那么到底是网卡的全双工有问题,还是其他配置有问题呢。请大佬指教!谢谢
----------------------以下是雷哥2022年6月24日对本文的修改、补充----------------------
我们来看-d和-r的作用:
-d 使用双测试模式。服务端使用-L指定的端口反向连接到客户端,上行下行是同时跑数据进行测试。
-r 往返测试模式。当完成客户端到服务端的带宽测试时,服务器使用-L指定的端口,反向连接到客户端,进行服务端到客户端的带宽测试。
原来的环境没有了,我用本地虚拟机,调整窗口大小做了测试:
# 客户端
[root@web01 ~]# iperf -c 10.0.0.12 -t 30 -i 5 -d -L 8083 -w 130k
------------------------------------------------------------
Server listening on TCP port 8083
TCP window size: -1.00 Byte (WARNING: requested 127 KByte)
------------------------------------------------------------
------------------------------------------------------------
Client connecting to 10.0.0.12, TCP port 5001
TCP window size: 254 KByte (WARNING: requested 127 KByte)
------------------------------------------------------------
[ 3] local 10.0.0.14 port 47904 connected with 10.0.0.12 port 5001
[ 5] local 10.0.0.14 port 8083 connected with 10.0.0.12 port 39944
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 5.0 sec 494 MBytes 828 Mbits/sec
[ 5] 0.0- 5.0 sec 245 MBytes 411 Mbits/sec
[ 3] 5.0-10.0 sec 532 MBytes 892 Mbits/sec
[ 5] 5.0-10.0 sec 250 MBytes 420 Mbits/sec
[ 3] 10.0-15.0 sec 517 MBytes 867 Mbits/sec
[ 5] 10.0-15.0 sec 266 MBytes 447 Mbits/sec
# 服务端
[root@lb01 ~]# iperf -s -w 130k
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 254 KByte (WARNING: requested 127 KByte)
------------------------------------------------------------
[ 4] local 10.0.0.12 port 5001 connected with 10.0.0.14 port 47904
------------------------------------------------------------
Client connecting to 10.0.0.14, TCP port 8083
TCP window size: 254 KByte (WARNING: requested 127 KByte)
------------------------------------------------------------
[ 6] local 10.0.0.12 port 39944 connected with 10.0.0.14 port 8083
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-30.0 sec 2.99 GBytes 857 Mbits/sec
[ 6] 0.0-30.0 sec 1.42 GBytes 405 Mbits/sec
看这意思,我的网卡在同时有上下行的时候,下行受限了,但是我没有配置这种策略啊。求大佬们继续指点。
另外,iperf3已经去掉了双向测试-d和-r选项。我们来看看iperf的使用吧。
iperf使用方法示例
启动服务端(10.0.0.12)
iperf -s
单项测试(客户端到服务端):
iperf -c 10.0.0.12 -t 30 -i 5
双向测试
# 同时进行上传、下载测试(双向测试)
iperf -c 10.0.0.12 -t 30 -i 5 -d -L 8083
# 自动的先进行上传测试;再进行下载测试
iperf -c 10.0.0.12 -t 30 -i 5 -r -L 8083
参数解读:
-s 以服务端的模式启动iperf
-c 以客户端的的形式启动iperf
-t 指定测试时长,后面的数字代表秒数,上面的例子是持续测试30s
-i 指定报告的间隔时间,上例是每5秒输出一次测试结果
-d 同时进行上下行带宽测试。
-L 用来指定服务端反向连接客户端的端口(即客户端同时作为服务端,提供的可连接端口)
-w 指定窗口大小进行测试
指定窗口大小进行测试
# 服务端
iperf -s -w 130k
# 客户端
iperf -c 10.0.0.12 -i 5 -t 30 -r -L 8083 -w 130k