1.命令作用
执行网络吞吐量测试(perform network throughput tests);iperf3是一款用于网络性能的工具;需要手动执行安装 "yum install iperf3";iperf3功能相较iperf更多,目前更推荐iperf3
2.命令语法
Usage: iperf [-s|-c host] [options]
iperf [-h|--help] [-v|--version]
3.参数详解
OPTION:
Server or Client:
- -p, --port,指定监听/连接的服务器端口,默认端口5201
- -f, --format,设置带宽输出格式 kmKM -> Kbits, Mbits, KBytes, MBytes
- -i, --interval,设置每次报告之间的时间间隔
- -B, --bind <host>,绑定到指定接口(主机名或IP地址)
- -V, --verbose,更详细的输出
- -J, --json,JSON格式输出
- -d, --debug,发出调试输出
Server specific:
- -s, --server,服务器模式
- -D, --daemon,将服务器作为守护进程运行r
- -1, --one-off,处理一个客户端连接然后退出
Client specific:
- -c, --client <host>,以客户端模式运行,连接到<host>
- -u, --udp,使用UDP而不是TCP
- -b, --bandwidth #[KMG][/#],目标带宽,单位为位/秒(bits/sec);(0代表无限;UDP默认1 Mbit/sec, TCP默认无限)
- -t, --time,传输时间以秒为单位(默认10秒)
- -n, --bytes #[KMG],要传输的字节数(instead of -t)
- -l, --len #[KMG],要读或写的缓冲区长度(TCP默认128 KB,UDP为dynamic or 1)
- -P, --parallel,要运行的并行客户端连接数量
- -R, --reverse,反向运行模式(服务器发送,客户端接收)
- -w, --window #[KMG],设置窗口大小/套接字缓冲区大小
- -Z, --zerocopy,使用“零拷贝”方式发送数据(提升性能)
- -O, --omit N,省略前n秒
4.常用用例
4.1.服务端与客户端及其输出解释
4.1.1.客户端与服务端
iperf3 -s # 启动服务器模式
iperf3 -c 服务器端IP # 启动客户端,默认允许10秒,其中"服务器端IP"是执行"iperf3 -s"的服务器IP
###########################################################################################
# 服务端:
[root@node1 opt]# iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.118.176, port 60214
[ 5] local 192.168.118.201 port 5201 connected to 192.168.118.176 port 60216
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-1.00 sec 374 MBytes 3.14 Gbits/sec
[ 5] 1.00-2.00 sec 464 MBytes 3.89 Gbits/sec
[ 5] 2.00-3.00 sec 472 MBytes 3.96 Gbits/sec
[ 5] 3.00-4.00 sec 484 MBytes 4.06 Gbits/sec
[ 5] 4.00-5.00 sec 477 MBytes 4.00 Gbits/sec
[ 5] 5.00-6.00 sec 463 MBytes 3.89 Gbits/sec
[ 5] 6.00-7.00 sec 478 MBytes 4.01 Gbits/sec
[ 5] 7.00-8.00 sec 473 MBytes 3.97 Gbits/sec
[ 5] 8.00-9.00 sec 486 MBytes 4.07 Gbits/sec
[ 5] 9.00-10.00 sec 500 MBytes 4.19 Gbits/sec
[ 5] 10.00-10.05 sec 23.4 MBytes 4.31 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 4.58 GBytes 3.92 Gbits/sec receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
# 客户端:
[root@node2 opt]# iperf3 -c 192.168.118.201
Connecting to host 192.168.118.201, port 5201
[ 4] local 192.168.118.176 port 60216 connected to 192.168.118.201 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 395 MBytes 3.30 Gbits/sec 0 672 KBytes
[ 4] 1.00-2.00 sec 461 MBytes 3.88 Gbits/sec 0 887 KBytes
[ 4] 2.00-3.00 sec 476 MBytes 3.99 Gbits/sec 24 1.37 MBytes
[ 4] 3.00-4.00 sec 482 MBytes 4.05 Gbits/sec 0 1.57 MBytes
[ 4] 4.00-5.00 sec 478 MBytes 4.01 Gbits/sec 0 1.77 MBytes
[ 4] 5.00-6.00 sec 464 MBytes 3.89 Gbits/sec 16 1.44 MBytes
[ 4] 6.00-7.00 sec 478 MBytes 4.00 Gbits/sec 0 1.66 MBytes
[ 4] 7.00-8.00 sec 472 MBytes 3.96 Gbits/sec 0 1.84 MBytes
[ 4] 8.00-9.00 sec 488 MBytes 4.09 Gbits/sec 3 1.53 MBytes
[ 4] 9.00-10.01 sec 501 MBytes 4.18 Gbits/sec 0 1.75 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.01 sec 4.58 GBytes 3.94 Gbits/sec 43 sender
[ 4] 0.00-10.01 sec 4.58 GBytes 3.94 Gbits/sec receiver
iperf Done.
[root@node2 opt]#
4.1.2.输出解释
ID: 线程标识符,多线程测试时区分不同数据流
Interval: 测试时间范围(1.00-2.00 sec代表1到2秒之间)
Transfer: 时间范围内传输的数据总量(单位GBytes或MBytes)
374 MBytes = 374MB (1 MB = 1,048,576 字节)
Bandwidth: 时间范围的平均带宽(Mbits/sec)--核心性能指标
3.14 Gbits/sec ÷ 8 = 392.5 MB/s(1 Gbit = 1,000,000,000 比特;1字节(Bytes)=8比特(bit))
Retr: 重传数据包数量;0代表TCP该时段没有重传,网络良好;非零代表可能存在网络阻塞或丢包
Cwnd: TCP拥塞窗口大小;动态调整以优化吞吐量;窗口越大,允许未确认的数据包越多,带宽利用率通常越高
- - - - - - - - - - - - - - - - - - - - - - - - -
sender: 发送者
receiver: 接收者
4.2.其他参数用法
4.2.1.服务端
iperf3 -s -D # 服务端后台运行
iperf3 -s -B ens33 # 指定主机名
iperf3 -s -B 192.168.118.201 # 指定IP地址
4.2.2.客户端
iperf3 -c 192.168.118.201 -n 100M # 启动客户端,指定传输数据的总大小结束后退出iperf3程序
iperf3 -c 192.168.118.201 -t 20 # 启动客户端,指定执行时间
iperf3 -c 192.168.118.201 -f B # 启动客户端,指定带宽输出格式
iperf3 -c 192.168.118.201 -R # 启动客户端,反向运行模式(服务器发送,客户端接收)
iperf3 -c 192.168.118.201 -P 4 # 启动客户端,指定并发测试

9万+

被折叠的 条评论
为什么被折叠?



