0%

网络带宽测试 iPerf3

iPerf3 是一个广泛使用的跨平台的网络性能测试和调优工具,可以为任何 IP 网络提供标准化的性能测试。它通过创建 数据流 来测量两端之间单向或者双向的网络吞吐量、网络抖动以及丢包率,可用于涉及到时间、缓冲区、协议(TCP、UDP、SCTP with IPv4 and IPv6) 等相关的各种参数的调优,并且会输出包含一个有时间标记的数据传输量和吞吐量测量的报告。本文将介绍 iPerf3 的特征和使用方法。

Tuning a TCP Connection

服务端执行 iperf3 -s

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$ iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.0.2, port 46722
[ 5] local 192.168.0.63 port 5201 connected to 192.168.0.2 port 46724
[ ID] Interval Transfer Bitrate
[ 5] 0.00-1.00 sec 2.16 GBytes 18.5 Gbits/sec
[ 5] 1.00-2.00 sec 2.32 GBytes 19.9 Gbits/sec
[ 5] 2.00-3.00 sec 2.13 GBytes 18.3 Gbits/sec
[ 5] 3.00-4.00 sec 2.21 GBytes 19.0 Gbits/sec
[ 5] 4.00-5.00 sec 2.24 GBytes 19.3 Gbits/sec
[ 5] 5.00-6.00 sec 2.30 GBytes 19.7 Gbits/sec
[ 5] 6.00-7.00 sec 2.29 GBytes 19.7 Gbits/sec
[ 5] 7.00-8.00 sec 2.22 GBytes 19.1 Gbits/sec
[ 5] 8.00-9.00 sec 2.19 GBytes 18.8 Gbits/sec
[ 5] 9.00-10.00 sec 2.36 GBytes 20.3 Gbits/sec
[ 5] 10.00-10.04 sec 91.8 MBytes 20.5 Gbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate
[ 5] 0.00-10.04 sec 22.5 GBytes 19.3 Gbits/sec receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

客户端执行 iperf3 -c <serverIP>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ iperf3 -c 192.168.0.63
Connecting to host 192.168.0.63, port 5201
[ 5] local 192.168.0.2 port 46724 connected to 192.168.0.63 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 2.25 GBytes 19.3 Gbits/sec 57 714 KBytes
[ 5] 1.00-2.00 sec 2.32 GBytes 19.9 Gbits/sec 75 771 KBytes
[ 5] 2.00-3.00 sec 2.12 GBytes 18.2 Gbits/sec 35 847 KBytes
[ 5] 3.00-4.00 sec 2.21 GBytes 19.0 Gbits/sec 166 626 KBytes
[ 5] 4.00-5.00 sec 2.25 GBytes 19.3 Gbits/sec 81 759 KBytes
[ 5] 5.00-6.00 sec 2.29 GBytes 19.7 Gbits/sec 174 672 KBytes
[ 5] 6.00-7.00 sec 2.30 GBytes 19.7 Gbits/sec 182 868 KBytes
[ 5] 7.00-8.00 sec 2.22 GBytes 19.1 Gbits/sec 229 764 KBytes
[ 5] 8.00-9.00 sec 2.19 GBytes 18.8 Gbits/sec 132 844 KBytes
[ 5] 9.00-10.00 sec 2.37 GBytes 20.3 Gbits/sec 119 817 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 22.5 GBytes 19.3 Gbits/sec 1250 sender
[ 5] 0.00-10.04 sec 22.5 GBytes 19.3 Gbits/sec receiver

iperf Done.

Tunning a UDP Connection

iPerf 会创建一个连续比特速率的UDP流,你可以通过 -l 参数来设置应用包的大小。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# server side
node2> iperf -s -u -i 1
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size: 60.0 KByte (default)
------------------------------------------------------------
[ 4] local <IP Addr node2> port 5001 connected with <IP Addr node1> port 9726
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 4] 0.0- 1.0 sec 1.3 MBytes 10.0 Mbits/sec 0.209 ms 1/ 894 (0.11%)
[ 4] 1.0- 2.0 sec 1.3 MBytes 10.0 Mbits/sec 0.221 ms 0/ 892 (0%)
[ 4] 2.0- 3.0 sec 1.3 MBytes 10.0 Mbits/sec 0.277 ms 0/ 892 (0%)
[ 4] 3.0- 4.0 sec 1.3 MBytes 10.0 Mbits/sec 0.359 ms 0/ 893 (0%)
[ 4] 4.0- 5.0 sec 1.3 MBytes 10.0 Mbits/sec 0.251 ms 0/ 892 (0%)
[ 4] 5.0- 6.0 sec 1.3 MBytes 10.0 Mbits/sec 0.215 ms 0/ 892 (0%)
[ 4] 6.0- 7.0 sec 1.3 MBytes 10.0 Mbits/sec 0.325 ms 0/ 892 (0%)
[ 4] 7.0- 8.0 sec 1.3 MBytes 10.0 Mbits/sec 0.254 ms 0/ 892 (0%)
[ 4] 8.0- 9.0 sec 1.3 MBytes 10.0 Mbits/sec 0.282 ms 0/ 892 (0%)
[ 4] 0.0-10.0 sec 12.5 MBytes 10.0 Mbits/sec 0.243 ms 1/ 8922 (0.011%)

# client side
node1> iperf -c node2 -u -b 10m
------------------------------------------------------------
Client connecting to node2, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 60.0 KByte (default)
------------------------------------------------------------
[ 3] local <IP Addr node1> port 9726 connected with <IP Addr node2> port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 12.5 MBytes 10.0 Mbits/sec
[ 3] Sent 8922 datagrams

参考资料