iPerf3使用简介
介绍
iperf3是用于测试网络中最大可使用带宽的工具,可以支持UDP、TCP、SCTP、IPv4、IPv6协议的各种参数,对于每个测试都会生成测试结果,包括带宽数值,丢包或其他的参数。iPerf最初由NLANR / DAST开发。iPerf3主要由ESnet / Lawrence Berkeley国家实验室开发。它是在三个条款的BSD许可下发布的。本文大部分内容均来自 https://iperf.fr/。若有侵权请告知,谢谢。lvpin333@gmail.com
iPerf3 –help
本文基于 iPerf 3.1.3 for windows 来完成
C:\Users\win7>iPerf3 --help
Usage: iperf [-s|-c host] [options]
iperf [-h|--help] [-v|--version]
Server or Client:
-p, --port # 服务端侦听端口号配置,默认值为5201
-f, --format [kmgKMG] 生成格式时Bandwidth单位设置“-f K 、 -f M 、-f KB 、 -f MB ”
-i, --interval # 生成报告间隔时间,取值范围 0.01 ~ 60
-F, --file name xmit/recv the specified file
-B, --bind <host> 绑定到指定的interface
-V, --verbose 详细输出
-J, --json 以JSON格式进行输出
--logfile f 将结果输出到文件中“--logfile lvpin.txt”
-d, --debug 调试输出
-v, --version 显示版本信息并退出
-h, --help 显示帮助信息并退出
Server specific:
-s, --server 运行在server模式
-D, --daemon 运行server并作为守护进程
-I, --pidfile file 写入PID文件
-1, --one-off 处理1个客户端连接并退出“-1“
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] 需要发送的字节数(bytes)(instead of -t)
-k, --blockcount #[KMG] 需要发送数据包的数量(blocks)(instead of -t or -n)
-l, --len #[KMG] 读取和写入缓冲区的长度,默认值是TCP 128kb、UDP 8 kb
--cport <port> bind to a specific client port (TCP and UDP, default: ephemeral port)
-P, --parallel # 并行客户端的数量“-P 2”
-R, --reverse 反向接收模式(服务器发送,客户端接收)
-w, --window #[KMG] 设置windows size 大小
-M, --set-mss # 设置MMS大小
-N, --no-delay 关闭Nagle's Algorithm
-4, --version4 仅在IPv4模式下运行
-6, --version6 仅在IPv6模式下运行
-S, --tos N 设置IP head TOS值
-Z, --zerocopy use a 'zero copy' method of sending data
-O, --omit N 忽略前 "N" 秒的数据信息(用于跳过TCP慢启动)
-T, --title str 在每行输出前加上特定的字符串
--get-server-output 从服务器上获得结果
--udp-counters-64bit use 64-bit counters in UDP test packets
[KMG] indicates options that support a K/M/G suffix for kilo-, mega-, or giga-
iperf3 homepage at: http://software.es.net/iperf/
Report bugs to: https://github.com/esnet/iperf
iPerf3 示例
基础测试
Server:
C:\Users\lvpin>iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Client:
C:\Users\win7>iperf3 -c 10.24.50.11
Connecting to host 10.24.50.11, port 5201
[ 4] local 10.24.50.12 port 63263 connected to 10.24.50.11 port 5201
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-1.00 sec 106 MBytes 890 Mbits/sec
[ 4] 1.00-2.00 sec 99.6 MBytes 836 Mbits/sec
[ 4] 2.00-3.00 sec 90.6 MBytes 760 Mbits/sec
[ 4] 3.00-4.00 sec 88.2 MBytes 740 Mbits/sec
[ 4] 4.00-5.00 sec 90.4 MBytes 758 Mbits/sec
[ 4] 5.00-6.00 sec 90.0 MBytes 755 Mbits/sec
[ 4] 6.00-7.00 sec 90.6 MBytes 760 Mbits/sec
[ 4] 7.00-8.00 sec 90.1 MBytes 756 Mbits/sec
[ 4] 8.00-9.00 sec 89.9 MBytes 754 Mbits/sec
[ 4] 9.00-10.00 sec 90.2 MBytes 757 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-10.00 sec 926 MBytes 777 Mbits/sec sender
[ 4] 0.00-10.00 sec 926 MBytes 777 Mbits/sec receiver
iperf Done.
UDP发包测试
Server:
C:\Users\lvpin>iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Client:
C:\Users\win7>iperf3 -c 10.24.50.11 -u
Connecting to host 10.24.50.11, port 5201
[ 4] local 10.24.50.12 port 51135 connected to 10.24.50.11 port 5201
[ ID] Interval Transfer Bandwidth Total Datagrams
[ 4] 0.00-1.00 sec 296 KBytes 2.42 Mbits/sec 37
[ 4] 1.00-2.00 sec 160 KBytes 1.31 Mbits/sec 20
[ 4] 2.00-3.01 sec 152 KBytes 1.24 Mbits/sec 19
[ 4] 3.01-4.00 sec 160 KBytes 1.32 Mbits/sec 20
[ 4] 4.00-5.00 sec 160 KBytes 1.31 Mbits/sec 20
[ 4] 5.00-6.00 sec 160 KBytes 1.31 Mbits/sec 20
[ 4] 6.00-7.00 sec 160 KBytes 1.31 Mbits/sec 20
[ 4] 7.00-8.00 sec 160 KBytes 1.31 Mbits/sec 20
[ 4] 8.00-9.00 sec 160 KBytes 1.31 Mbits/sec 20
[ 4] 9.00-10.00 sec 160 KBytes 1.31 Mbits/sec 20
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 4] 0.00-10.00 sec 1.69 MBytes 1.42 Mbits/sec 0.032 ms 0/215 (0%)
[ 4] Sent 215 datagrams
iperf Done.
IPv6测试
Server:
C:\Users\lvpin>iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Client:
C:\Users\win7>iperf3 -c 2123::22
Connecting to host 2123::22, port 5201
[ 4] local 2123::1 port 64568 connected to 2123::22 port 5201
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-1.00 sec 111 MBytes 932 Mbits/sec
[ 4] 1.00-2.00 sec 107 MBytes 899 Mbits/sec
[ 4] 2.00-3.00 sec 100 MBytes 839 Mbits/sec
[ 4] 3.00-4.00 sec 99.4 MBytes 834 Mbits/sec
[ 4] 4.00-5.00 sec 100 MBytes 841 Mbits/sec
[ 4] 5.00-6.00 sec 100 MBytes 841 Mbits/sec
[ 4] 6.00-7.00 sec 100 MBytes 839 Mbits/sec
[ 4] 7.00-8.00 sec 100 MBytes 843 Mbits/sec
[ 4] 8.00-9.00 sec 100 MBytes 843 Mbits/sec
[ 4] 9.00-10.00 sec 100 MBytes 840 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-10.00 sec 1019 MBytes 855 Mbits/sec sender
[ 4] 0.00-10.00 sec 1019 MBytes 855 Mbits/sec receiver
iperf Done.
TCP参数配置测试
Server:
C:\Users\lvpin>iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Client:
windows size:2048
mms :800
缓冲区大小:256
关闭Nagle’s算法
C:\Users\win7>iperf3 -c 10.24.50.11 -w 2048 -M 800 -N -l 256
Connecting to host 10.24.50.11, port 5201
[ 4] local 10.24.50.12 port 64580 connected to 10.24.50.11 port 5201
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-1.00 sec 5.17 MBytes 43.3 Mbits/sec
[ 4] 1.00-2.00 sec 4.97 MBytes 41.7 Mbits/sec
[ 4] 2.00-3.00 sec 4.85 MBytes 40.7 Mbits/sec
[ 4] 3.00-4.00 sec 4.63 MBytes 38.9 Mbits/sec
[ 4] 4.00-5.00 sec 5.25 MBytes 44.1 Mbits/sec
[ 4] 5.00-6.00 sec 5.24 MBytes 43.9 Mbits/sec
[ 4] 6.00-7.00 sec 4.69 MBytes 39.3 Mbits/sec
[ 4] 7.00-8.00 sec 4.82 MBytes 40.5 Mbits/sec
[ 4] 8.00-9.00 sec 5.34 MBytes 44.8 Mbits/sec
[ 4] 9.00-10.00 sec 5.00 MBytes 41.9 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-10.00 sec 50.0 MBytes 41.9 Mbits/sec sender
[ 4] 0.00-10.00 sec 50.0 MBytes 41.9 Mbits/sec receiver
iperf Done.
在Linux环境中模拟广域网延迟
Emulating wide area network delays with Linux
NetEm (already enabled in the Linux kernel) provides Network Emulation functionality for testing protocols by emulating the properties of wide area networks.
To simulate an additional latency of 80 ms, just type sudo tc qdisc add dev eth0 root netem delay 80ms
It just adds a fixed amount of delay to all packets going out of the local Ethernet.
To stop the additional latency, just type sudo tc qdisc change dev eth0 root netem delay 0ms
Lines to add to the file /etc/rc.local before exit 0, to add 40ms of latency :
# Add +40ms latency
tc qdisc add dev eth0 root netem delay 40ms
Note: If your network interface is not eth0, replace eth0 with the name of your network interface
没有评论:
发表评论