@qidiandasheng
2019-11-19T16:38:30.000000Z
字数 4409
阅读 3992
使用工具
iperf3是一个网络速度测试工具,支持IPv4与IPv6,支持TCP、UDP、SCTP传输协议,可在Windows、Mac OS X、Linux、FreeBSD等各种平台使用,是一个简单又实用的小工具。 本文介绍安装、使用iperf3 网速测试工具。
sudo apt-get install iperf3
yum install iperf3
brew install iperf3
在使用iperf3测试时,要同时在server端与client端都各执行一个程序,让它们互相传送报文进行测试。
首先在服务端(48.77.234.178)启动server端的程序:
iperf3 -s
接着在client端执行:
iperf3 -c 48.77.234.178
从打印的内容看,缺省参数下,Client将连接Server端的5201端口,持续向Server端发送数据,并统计出每秒传输的字节数、带宽、出现报文重传的次数、拥塞窗口(Congestion Window)大小,整个测试将持续10秒钟;最后将汇总10秒的平均数据,并给出发送和接收端的统计。
Client端
[ ID] Interval Transfer Bitrate Total Datagrams
[ 5] 0.00-1.01 sec 129 KBytes 1.05 Mbits/sec 95
[ 5] 1.01-2.01 sec 125 KBytes 1.02 Mbits/sec 92
[ 5] 2.01-3.00 sec 131 KBytes 1.09 Mbits/sec 97
[ 5] 3.00-4.00 sec 127 KBytes 1.04 Mbits/sec 94
[ 5] 4.00-5.00 sec 129 KBytes 1.05 Mbits/sec 95
[ 5] 5.00-6.00 sec 127 KBytes 1.04 Mbits/sec 94
[ 5] 6.00-7.00 sec 127 KBytes 1.04 Mbits/sec 94
[ 5] 7.00-8.00 sec 129 KBytes 1.06 Mbits/sec 95
[ 5] 8.00-9.00 sec 127 KBytes 1.04 Mbits/sec 94
[ 5] 9.00-10.00 sec 126 KBytes 1.03 Mbits/sec 93
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Jitter Lost/Total Datagrams
[ 5] 0.00-10.00 sec 1.25 MBytes 1.05 Mbits/sec 0.000 ms 0/943 (0%) sender
[ 5] 0.00-10.30 sec 1.24 MBytes 1.01 Mbits/sec 9.435 ms 8/942 (0.85%) receiver
iperf Done.
server端
[ ID] Interval Transfer Bitrate Jitter Lost/Total Datagrams
[ 5] 0.00-1.00 sec 71.8 KBytes 588 Kbits/sec 3431041313.248 ms 0/53 (0%)
[ 5] 1.00-2.00 sec 146 KBytes 1.20 Mbits/sec 3223480.936 ms 0/108 (0%)
[ 5] 2.00-3.00 sec 123 KBytes 1.01 Mbits/sec 9083.840 ms 2/93 (2.2%)
[ 5] 3.00-4.00 sec 130 KBytes 1.07 Mbits/sec 26.471 ms 0/96 (0%)
[ 5] 4.00-5.00 sec 117 KBytes 955 Kbits/sec 6.871 ms 4/90 (4.4%)
[ 5] 5.00-6.00 sec 134 KBytes 1.10 Mbits/sec 11.419 ms 0/99 (0%)
[ 5] 6.00-7.00 sec 126 KBytes 1.03 Mbits/sec 9.642 ms 0/93 (0%)
[ 5] 7.00-8.00 sec 108 KBytes 888 Kbits/sec 7.776 ms 0/80 (0%)
[ 5] 8.00-9.00 sec 145 KBytes 1.19 Mbits/sec 9.401 ms 1/108 (0.93%)
[ 5] 9.00-10.00 sec 129 KBytes 1.05 Mbits/sec 9.824 ms 1/96 (1%)
[ 5] 10.00-10.30 sec 35.2 KBytes 979 Kbits/sec 9.435 ms 0/26 (0%)
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Jitter Lost/Total Datagrams
[ 5] 0.00-10.30 sec 1.24 MBytes 1.01 Mbits/sec 9.435 ms 8/942 (0.85%) receiver
Server or Client:
-p, --port # server port to listen on/connect to 端口
-f, --format [kmgKMG] format to report: Kbits, Mbits, KBytes, MBytes 格式化带宽数输出
-i, --interval # seconds between periodic bandwidth reports 设置每次报告之间的时间间隔,单位为秒。如果设置为非零值,就会按照此时间间隔输出测试报告。默认值为零。
-F, --file name xmit/recv the specified file
-A, --affinity n/n,m set CPU affinity
-B, --bind <host> bind to a specific interface 主机绑定指定接口
-V, --verbose more detailed output 更详细的输出
-J, --json output in JSON format 输出JSON格式
--logfile f send output to a log file 将输出发送到日志文件
-d, --debug emit debugging output 发出调试输出
-v, --version show version information and quit 显示版本信息并退出
-h, --help show this message and quit 显示帮助信息并退出
Server specific:
-s, --server run in server mode 运行服务器模式
-D, --daemon run the server as a daemon 将服务器作为守护进程运行
-I, --pidfile file write PID file 写PID文件
-1, --one-off handle one client connection then exit 处理一个客户端连接,然后退出
Client specific:
-c, --client <host> run in client mode, connecting to <host> 在客户端模式下运行,连接到主机
-u, --udp use UDP rather than TCP 使用UDP而不是TCP
-b, --bandwidth #[KMG][/#] target bandwidth in bits/sec (0 for unlimited) 目标带宽(比特/秒)
(default 1 Mbit/sec for UDP, unlimited for TCP) UDP默认为1 Mbit/秒,TCP没有限制
(optional slash and packet count for burst mode)
-t, --time # time in seconds to transmit for (default 10 secs) 传输时间(默认为10秒)
-n, --bytes #[KMG] number of bytes to transmit (instead of -t) 要传输的字节数(而不是-t)
-k, --blockcount #[KMG] number of blocks (packets) to transmit (instead of -t or -n) 要传输的块(包)数量(而不是-t或-n)
-l, --len #[KMG] length of buffer to read or write 读取或写入缓冲区的长度
(default 128 KB for TCP, 8 KB for UDP) TCP默认为128 KB, UDP默认为8 KB
--cport <port> bind to a specific client port (TCP and UDP, default: ephemeral port) 绑定到特定的客户端端口(TCP和UDP,默认:临时端口)
-P, --parallel # number of parallel client streams to run 要运行的并行客户端流的数量
-R, --reverse run in reverse mode (server sends, client receives) 以反向模式运行(服务器发送,客户端接收)
-w, --window #[KMG] set window size / socket buffer size 设置窗口大小/套接字缓冲区大小
-C, --congestion <algo> set TCP congestion control algorithm (Linux and FreeBSD only) 设置TCP拥塞控制算法(只支持Linux和FreeBSD)
-M, --set-mss # set TCP/SCTP maximum segment size (MTU - 40 bytes) 设置TCP/SCTP最大段大小(MTU - 40字节)
-N, --no-delay set TCP/SCTP no delay, disabling Nagle's Algorithm 设置TCP/SCTP没有延迟,禁用Nagle的算法
-4, --version4 only use IPv4
-6, --version6 only use IPv6
-S, --tos N set the IP 'type of service' 设置IP“服务类型”
-L, --flowlabel N set the IPv6 flow label (only supported on Linux) 设置IPv6流标签(只支持Linux)
-Z, --zerocopy use a 'zero copy' method of sending data 使用“零拷贝”方法发送数据
-O, --omit N omit the first n seconds 省略前N秒
-T, --title str prefix every output line with this string 在每个输出行前面加上这个字符串
--get-server-output get results from server 从服务器获取结果
--udp-counters-64bit use 64-bit counters in UDP test packets 在UDP测试包中使用64位计数器
--no-fq-socket-pacing disable fair-queuing based socket pacing