• iperf工具是测量服务器网络速度工具,它通过测量服务器可以处理的最大网络吞吐量来测试网络速度,在遇到网络问题时特别有用。

1、下载源代码(服务端和客户端都要安装)

wget https://iperf.fr/download/source/iperf-2.0.8-source.tar.gz

  • 安装编译环境 yum install gcc-c++ -y
  • 解压并安装iperf
tar -xvf iperf-2.0.8-source.tar.gz

cd iperf-2.0.8/

./configure && make && make install

2、测试

2.1、服务端执行iperf指令

iperf -s -p 12345 -i 1

  • -s表示以服务器模式运行。
  • -p设置服务监听端口,测试时该端口在服务上没有被占用即可。
  • -i设置每次报告之间的时间间隔,单位为s。
iperf -s -p 12345 -i 1
------------------------------------------------------------
Server listening on TCP port 12345
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  4] local 192.168.0.8 port 12345 connected with 192.168.0.10 port 52648
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0- 1.0 sec   119 MBytes   999 Mbits/sec
[  4]  1.0- 2.0 sec  60.3 MBytes   506 Mbits/sec
[  4]  2.0- 3.0 sec  61.7 MBytes   517 Mbits/sec
[  4]  3.0- 4.0 sec  60.9 MBytes   511 Mbits/sec
[  4]  4.0- 5.0 sec  59.9 MBytes   503 Mbits/sec
[  4]  5.0- 6.0 sec  61.1 MBytes   512 Mbits/sec

2.2、客户端执行iperf指令

iperf -c XX.XX.XX.XX -p 1234 -i 1

  • 其中XX.XX.XX.XX为服务端的ip。
  • -p要和服务端设置的相同。
iperf -c 192.168.0.8 -p 12345 -i 1
------------------------------------------------------------
Client connecting to 192.168.0.8, TCP port 12345
TCP window size: 45.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.10 port 52648 connected with 192.168.0.8 port 12345
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec   123 MBytes  1.03 Gbits/sec
[  3]  1.0- 2.0 sec  60.1 MBytes   504 Mbits/sec
[  3]  2.0- 3.0 sec  62.0 MBytes   520 Mbits/sec
[  3]  3.0- 4.0 sec  60.4 MBytes   506 Mbits/sec
[  3]  4.0- 5.0 sec  60.2 MBytes   505 Mbits/sec
[  3]  5.0- 6.0 sec  60.6 MBytes   509 Mbits/sec
[  3]  6.0- 7.0 sec  62.1 MBytes   521 Mbits/sec
[  3]  7.0- 8.0 sec  59.4 MBytes   498 Mbits/sec

参考

iperf