iperf3是一种网络性能测试工具,它可以用于测试TCP和UDP带宽、延迟和数据包丢失率等网络性能指标。它是iperf的新版本,相对于旧版本,iperf3增加了一些新特性和改进,例如支持IPv6、多线程、流媒体模式、JSON输出等。使用iperf3可以帮助管理员评估网络性能、排除故障和优化网络配置。
iperf3是一个基于命令行的网络性能测试工具,用于测量TCP和UDP吞吐量,延迟和抖动(jitter)。它支持IPv4和IPv6,多种传输协议,包括TCP,UDP和SCTP。iperf3是iperf的新版本,相对于旧版本,具有更多的功能和改进。
下面是在Linux环境下CentOS系统上安装和使用iperf3的示例:
在终端中输入以下命令来安装iperf3:
sudo yum install iperf3
2. 运行iperf3测试
a. 启动iperf3服务器:
在需要测试的服务器上启动iperf3服务器,以监听来自客户端的测试请求。在服务器终端中输入以下命令:
iperf3 -s
b. 连接到iperf3服务器进行测试:
在客户端终端中输入以下命令来连接到服务器进行测试:
iperf3 -c
其中,<server_ip>
是你需要测试的服务器的IP地址。执行以上命令后,会显示测试结果,包括带宽、延迟、抖动等信息。
[root@localhost netperf-netperf-2.7.0]# yum install iperf3
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.bupt.edu.cn
* epel: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.bupt.edu.cn
* updates: mirrors.bupt.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 iperf3.x86_64.0.3.1.7-2.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
=========================================================================================================================
Package 架构 版本 源 大小
=========================================================================================================================
正在安装:
iperf3 x86_64 3.1.7-2.el7 base 79 k
事务概要
=========================================================================================================================
安装 1 软件包
总下载量:79 k
安装大小:197 k
Is this ok [y/d/N]: y
Downloading packages:
iperf3-3.1.7-2.el7.x86_64.rpm | 79 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : iperf3-3.1.7-2.el7.x86_64 1/1
验证中 : iperf3-3.1.7-2.el7.x86_64 1/1
已安装:
iperf3.x86_64 0:3.1.7-2.el7
完毕!
[root@localhost netperf-netperf-2.7.0]#
[root@localhost netperf-netperf-2.7.0]# iperf3 -v
iperf 3.1.7
Linux localhost.localdomain 3.10.0-1160.71.1.el7.x86_64 #1 SMP Tue Jun 28 15:37:28 UTC 2022 x86_64
Optional features available: CPU affinity setting, IPv6 flow label, TCP congestion algorithm setting, sendfile / zerocopy, socket pacing
[root@localhost netperf-netperf-2.7.0]#
[root@localhost netperf-netperf-2.7.0]# iperf3 -s
-----------------------------------------------------------
Server listening on 5201
3. 更多选项
参考iperf3的帮助文档,可以使用更多选项来定制测试,例如:
iperf3 -u -c <server_ip>
iperf3 -t <time_in_seconds> -c <server_ip>
iperf3 -p <port_number> -c <server_ip>
Server:
[root@localhost ~]# iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.6.212, port 56144
[ 5] local 192.168.6.211 port 5201 connected to 192.168.6.212 port 59248
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 5] 0.00-1.01 sec 117 KBytes 955 Kbits/sec 1421.423 ms 0/83 (0%)
[ 5] 1.01-2.01 sec 127 KBytes 1.04 Mbits/sec 4.691 ms 0/90 (0%)
[ 5] 2.01-3.01 sec 129 KBytes 1.06 Mbits/sec 0.069 ms 0/91 (0%)
[ 5] 3.01-4.01 sec 127 KBytes 1.04 Mbits/sec 0.444 ms 0/90 (0%)
[ 5] 4.01-5.02 sec 129 KBytes 1.05 Mbits/sec 0.061 ms 0/91 (0%)
[ 5] 5.02-6.01 sec 129 KBytes 1.06 Mbits/sec 0.196 ms 0/91 (0%)
[ 5] 6.01-7.02 sec 127 KBytes 1.03 Mbits/sec 0.065 ms 0/90 (0%)
[ 5] 7.02-8.01 sec 130 KBytes 1.08 Mbits/sec 0.146 ms 0/92 (0%)
[ 5] 8.01-9.01 sec 126 KBytes 1.02 Mbits/sec 0.059 ms 0/89 (0%)
[ 5] 9.01-10.01 sec 129 KBytes 1.06 Mbits/sec 0.057 ms 0/91 (0%)
[ 5] 10.01-10.06 sec 0.00 Bytes 0.00 bits/sec 0.057 ms 0/0 (0%)
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 5] 0.00-10.06 sec 0.00 Bytes 0.00 bits/sec 0.057 ms 0/898 (0%)
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.6.212, port 56146
[ 5] local 192.168.6.211 port 5201 connected to 192.168.6.212 port 56148
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-1.00 sec 313 MBytes 2.62 Gbits/sec
[ 5] 1.00-2.00 sec 319 MBytes 2.67 Gbits/sec
[ 5] 2.00-3.02 sec 361 MBytes 2.99 Gbits/sec
[ 5] 3.02-4.00 sec 363 MBytes 3.10 Gbits/sec
[ 5] 4.00-5.01 sec 379 MBytes 3.16 Gbits/sec
[ 5] 5.01-5.04 sec 6.85 MBytes 1.80 Gbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-5.04 sec 0.00 Bytes 0.00 bits/sec sender
[ 5] 0.00-5.04 sec 1.70 GBytes 2.90 Gbits/sec receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.6.212, port 56150
[ 5] local 192.168.6.211 port 5201 connected to 192.168.6.212 port 56152
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-1.00 sec 278 MBytes 2.33 Gbits/sec
[ 5] 1.00-2.00 sec 351 MBytes 2.94 Gbits/sec
[ 5] 2.00-3.00 sec 374 MBytes 3.13 Gbits/sec
[ 5] 3.00-4.00 sec 396 MBytes 3.32 Gbits/sec
[ 5] 4.00-5.00 sec 371 MBytes 3.11 Gbits/sec
[ 5] 5.00-6.00 sec 406 MBytes 3.40 Gbits/sec
[ 5] 6.00-7.01 sec 381 MBytes 3.19 Gbits/sec
[ 5] 7.01-8.00 sec 376 MBytes 3.17 Gbits/sec
[ 5] 8.00-9.00 sec 378 MBytes 3.17 Gbits/sec
[ 5] 9.00-10.00 sec 372 MBytes 3.12 Gbits/sec
[ 5] 10.00-10.05 sec 19.4 MBytes 3.57 Gbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-10.05 sec 0.00 Bytes 0.00 bits/sec sender
[ 5] 0.00-10.05 sec 3.61 GBytes 3.09 Gbits/sec receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Client:
[root@localhost ~]# iperf3 -u -c 192.168.6.211
Connecting to host 192.168.6.211, port 5201
[ 4] local 192.168.6.212 port 59248 connected to 192.168.6.211 port 5201
[ ID] Interval Transfer Bandwidth Total Datagrams
[ 4] 0.00-1.02 sec 117 KBytes 944 Kbits/sec 83
[ 4] 1.02-2.03 sec 127 KBytes 1.03 Mbits/sec 90
[ 4] 2.03-3.02 sec 129 KBytes 1.07 Mbits/sec 91
[ 4] 3.02-4.03 sec 127 KBytes 1.03 Mbits/sec 90
[ 4] 4.03-5.01 sec 129 KBytes 1.07 Mbits/sec 91
[ 4] 5.01-6.02 sec 129 KBytes 1.05 Mbits/sec 91
[ 4] 6.02-7.01 sec 127 KBytes 1.05 Mbits/sec 90
[ 4] 7.01-8.02 sec 130 KBytes 1.06 Mbits/sec 92
[ 4] 8.02-9.01 sec 126 KBytes 1.04 Mbits/sec 89
[ 4] 9.01-10.02 sec 129 KBytes 1.05 Mbits/sec 91
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 4] 0.00-10.02 sec 1.24 MBytes 1.04 Mbits/sec 0.057 ms 0/898 (0%)
[ 4] Sent 898 datagrams
iperf Done.
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# iperf3 -t 5 -c 192.168.6.211
Connecting to host 192.168.6.211, port 5201
[ 4] local 192.168.6.212 port 56148 connected to 192.168.6.211 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 323 MBytes 2.71 Gbits/sec 0 911 KBytes
[ 4] 1.00-2.01 sec 321 MBytes 2.68 Gbits/sec 0 1.24 MBytes
[ 4] 2.01-3.00 sec 366 MBytes 3.09 Gbits/sec 0 1.46 MBytes
[ 4] 3.00-4.00 sec 368 MBytes 3.07 Gbits/sec 0 1.60 MBytes
[ 4] 4.00-5.00 sec 368 MBytes 3.09 Gbits/sec 0 1.69 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-5.00 sec 1.70 GBytes 2.93 Gbits/sec 0 sender
[ 4] 0.00-5.00 sec 1.70 GBytes 2.92 Gbits/sec receiver
iperf Done.
[root@localhost ~]#
[root@localhost ~]# iperf3 -p 5201 -c 192.168.6.211
Connecting to host 192.168.6.211, port 5201
[ 4] local 192.168.6.212 port 56152 connected to 192.168.6.211 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.01 sec 305 MBytes 2.54 Gbits/sec 0 848 KBytes
[ 4] 1.01-2.00 sec 344 MBytes 2.90 Gbits/sec 0 1.21 MBytes
[ 4] 2.00-3.00 sec 375 MBytes 3.14 Gbits/sec 0 1.46 MBytes
[ 4] 3.00-4.00 sec 398 MBytes 3.34 Gbits/sec 0 1.58 MBytes
[ 4] 4.00-5.00 sec 370 MBytes 3.10 Gbits/sec 0 1.67 MBytes
[ 4] 5.00-6.00 sec 416 MBytes 3.49 Gbits/sec 0 1.73 MBytes
[ 4] 6.00-7.00 sec 366 MBytes 3.08 Gbits/sec 2 1.31 MBytes
[ 4] 7.00-8.00 sec 381 MBytes 3.20 Gbits/sec 0 1.45 MBytes
[ 4] 8.00-9.00 sec 376 MBytes 3.15 Gbits/sec 0 1.52 MBytes
[ 4] 9.00-10.00 sec 376 MBytes 3.16 Gbits/sec 0 1.60 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 3.62 GBytes 3.11 Gbits/sec 2 sender
[ 4] 0.00-10.00 sec 3.61 GBytes 3.10 Gbits/sec receiver
iperf Done.
[root@localhost ~]#
解释:
Connecting to host 192.168.6.211, port 5201 [ 4] local 192.168.6.212 port 56152 connected to 192.168.6.211 port 5201 [ ID] Interval Transfer Bandwidth Retr Cwnd [ 4] 0.00-1.01 sec 305 MBytes 2.54 Gbits/sec 0 848 KByte
- 第一行显示了iperf3客户端正在连接的目标主机IP地址(192.168.6.211)和端口号(5201)。
- 第二行显示了客户端本地IP地址(192.168.6.212)和使用的本地端口号(56152),以及已经连接的目标主机IP地址(192.168.6.211)和端口号(5201)。
- 第三行显示了数据传输的时间间隔(0.00-1.01秒)、传输的数据量(305MB)、传输速率(2.54Gbits/sec)、重传的数据包数(0)和TCP拥塞控制窗口大小(848KB)。
Accepted connection from 192.168.6.212, port 56150 [ 5] local 192.168.6.211 port 5201 connected to 192.168.6.212 port 56152 [ ID] Interval Transfer Bandwidth [ 5] 0.00-1.00 sec 278 MBytes 2.33 Gbits/sec [ 5] 1.00-2.00 sec 351 MBytes 2.94 Gbits/sec
- 第一行显示了iperf3服务器端已经接受了来自192.168.6.212的连接请求,并使用本地端口56150进行通信。
- 第二行显示了服务器端本地IP地址(192.168.6.211)和使用的本地端口号(5201),以及已经连接的客户端IP地址(192.168.6.212)和端口号(56152)。
- 第三行显示了数据传输的时间间隔(0.00-1.00秒)、传输的数据量(278MB)和传输速率(2.33 Gbits/sec)。
- 第四行显示了数据传输的时间间隔(1.00-2.00秒)、传输的数据量(351MB)和传输速率(2.94 Gbits/sec)。
以下是iperf3的参数和对应的说明:
使用这些参数的示例命令:
iperf3 -c 192.168.1.2 -t 10
iperf3 -c 192.168.1.2 -u -b 10G -t 5
iperf3 -c 192.168.1.2 -d
iperf3 -c 192.168.1.2 -P 5
iperf3 -c 192.168.1.2 -R
iperf3 -c 192.168.1.2 -B 10.0.0.100
iperf3 -c 192.168.1.2 -Z
iperf3 -h