检测结果
一旦测试完成,客户端和服务器都会报告他们的结果:
服务器
server # iperf3 -i 10 -s ---------------------------------------------------------- Server listening on 5201 ---------------------------------------------------------- Accepted connection from 10.0.0.2, port 22216 [ 5] local 10.0.0.1 port 5201 connected to 10.0.0.2 port 22218 [ ID] Interval Transfer Bandwidth [ 5] 0.00-10.00 sec 17.5 GBytes 15.0 Gbits/sec [ 5] 10.00-20.00 sec 17.6 GBytes 15.2 Gbits/sec [ 5] 20.00-30.00 sec 18.4 GBytes 15.8 Gbits/sec [ 5] 30.00-40.00 sec 18.0 GBytes 15.5 Gbits/sec [ 5] 40.00-50.00 sec 17.5 GBytes 15.1 Gbits/sec [ 5] 50.00-60.00 sec 18.1 GBytes 15.5 Gbits/sec [ 5] 60.00-60.04 sec 82.2 MBytes 17.3 Gbits/sec - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bandwidth [ 5] 0.00-60.04 sec 0.00 Bytes 0.00 bits/sec sender [ 5] 0.00-60.04 sec 107 GBytes 15.3 Gbits/sec receiver
客户
client # iperf3 -i 10 -w 1M -t 60 -c 10.0.0.1 Connecting to host 10.0.0.1, port 5201 [ 4] local 10.0.0.2 port 22218 connected to 10.0.0.1 port 5201 [ ID] Interval Transfer Bandwidth Retr Cwnd [ 4] 0.00-10.00 sec 17.6 GBytes 15.1 Gbits/sec 0 6.01 MBytes [ 4] 10.00-20.00 sec 17.6 GBytes 15.1 Gbits/sec 0 6.01 MBytes [ 4] 20.00-30.00 sec 18.4 GBytes 15.8 Gbits/sec 0 6.01 MBytes [ 4] 30.00-40.00 sec 18.0 GBytes 15.5 Gbits/sec 0 6.01 MBytes [ 4] 40.00-50.00 sec 17.5 GBytes 15.1 Gbits/sec 0 6.01 MBytes [ 4] 50.00-60.00 sec 18.1 GBytes 15.5 Gbits/sec 0 6.01 MBytes - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bandwidth Retr [ 4] 0.00-60.00 sec 107 GBytes 15.4 Gbits/sec 0 sender [ 4] 0.00-60.00 sec 107 GBytes 15.4 Gbits/sec receiver
读取结果
在这两个系统之间,我们可以实现每秒 15.4 Gb 或者大约 1835 MiB(兆字节)的带宽。
其中:
Interval 表示测试间隔,默认值为 10 秒,显示为“0.0-10.0 sec”
传输是指在测试过程中两个节点之间传输了多少数据。
带宽是我们使用 iperf 测试的性能指标。
注意:服务器默认侦听 TCP 端口 5201.
需要允许此端口通过任何存在的防火墙。
可以使用 -p 命令行选项更改使用的端口。
iperf 是用于测试两个系统之间网络性能的工具。
iperf 应用程序为网络性能提供了更多指标。
默认情况下不安装 iperf 应用程序,但它由大多数发行版的包管理器提供。
对于 CentOS/RHEL/Fedora 系统,使用 yum 来安装 iperf 包。
# yum install iperf
iperf 具有“客户端”和“服务器”的概念,用于测试两个系统之间的网络吞吐量。
以下示例设置了较大的发送和接收缓冲区大小以最大化吞吐量,并执行 60 秒的测试,这应该足够长以充分运行网络。
服务器
在服务器系统上,iperf 被告知监听客户端连接:
server # iperf3 -i 10 -s
其中:
-i 提供周期性带宽更新的间隔
-s 作为服务器监听
有关特定命令行开关的更多信息,请参阅 man iperf3.
客户
在客户端系统上,iperf 被告知通过主机名或者 IP 地址连接到侦听服务器:
client # iperf3 -i 10 -w 1M -t 60 -c [server hostname or ip address]
其中:
-i 提供周期性带宽更新的间隔
-w 套接字缓冲区大小(影响 TCP 窗口)。
此客户端命令也在服务器上设置缓冲区大小
-t 以秒为单位运行测试的时间
-c 连接到监听服务器...
有关特定命令行开关的更多信息,请参阅 man iperf3.
更改UDP模式下的默认带宽
在UDP模式下,客户端使用默认带宽(1 Mbit/sec)向服务器发送数据包,因此我们可以看到UDP测试结果的带宽为1.05 Mbits/sec。
为了获得最佳的网络带宽,我们可以添加选项“-b value”来增加发送带宽:
# iperf -u -c server -b 1000M ----------------------------------------------------------- Client connecting to 1.1.1.1, UDP port 5001 Sending 1470 byte datagrams UDP buffer size: 124 KByte (default) ----------------------------------------------------------- [ 3] local 1.1.1.2 port 58097 connected with 1.1.1.1 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 1.10 GBytes 948 Mbits/sec [ 3] Sent 806540 datagrams [ 3] Server Report: [ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams [ 3] 0.0-10.0 sec 1.08 GBytes 929 Mbits/sec 0.010 ms 16203/806540 (2%)
使用 UDP 协议测试网络性能
默认的 iperf 使用 TCP 协议进行测试,如上所示。
添加选项“-u”以使用UDP协议进行性能测试。
- 第一步是启动服务器。
# iperf -s -u ----------------------------------------------------------- Server listening on UDP port 5001 Receiving 1470 byte datagrams UDP buffer size: 124 KByte (default) ----------------------------------------------------------- [ 3] local 1.1.1.1 port 5001 connected with 1.1.1.2 port 51598 [ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams [ 3] 0.0-10.0 sec 1.25 MBytes 1.05 Mbits/sec 0.004 ms 0/ 893 (0%)
- 客户端命令如下图所示。
# iperf -u -c server ----------------------------------------------------------- Client connecting to 1.1.1.1, UDP port 5001 Sending 1470 byte datagrams UDP buffer size: 124 KByte (default) ----------------------------------------------------------- [ 3] local 1.1.1.2 port 51598 connected with 1.1.1.1 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 1.25 MBytes 1.05 Mbits/sec [ 3] Sent 893 datagrams [ 3] Server Report: [ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams [ 3] 0.0-10.0 sec 1.25 MBytes 1.05 Mbits/sec 0.004 ms 0/ 893 (0%)
测量最大传输大小 (MTU)
-m 选项指示 iperf 还查找最大传输大小 (MTU):
# iperf -mc 192.168.10.12 ----------------------------------------------------------- Client connecting to 192.168.10.12, TCP port 5001 TCP window size: 19.3 KByte (default) ----------------------------------------------------------- [ 3] local 192.168.10.13 port 46558 connected with 192.168.10.12 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 113 MBytes 94.7 Mbits/sec [ 3] MSS size 1448 bytes (MTU 1500 bytes, ethernet)