iperf3是一款优秀的网络性能测试工具,支持 udp 和 tcp 等方式进行测试,可工作在内网与公网中。

实验环境

类型 网卡 带宽
无线网络 wifi1 百兆以上
无线网络 wifi2 1Gb
本机 127.0.0.1 至少 1Gb
内网工作站 192.168.20.4 至少为 1Gb

服务器

在内网工作站中启动 iperf3 的 server 端

  • 参数 -i 为每隔若干秒打印一次报告,这里设置为 5 秒
  • 参数 -p 为端口
1
2
3
4
$ iperf3 -s -i 5
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

测试方法

  • 参数:-c 服务器地址 -b 网卡带宽 -n 数据包大小 -i 报告打印时间 -u 使用tcp协议测试 -p 端口

传输指定大小的包

实验参数:设置网卡为千兆,传输 1Gb 数据

注:网络测试中一般采用 udp ,因为可以测出网络极限

  • ifi1 百兆以上 tcp
1
2
3
4
5
6
7
8
9
$ iperf3 -c 192.168.20.4 -b 1000M -n 1G 
...
[ 5] 950.00-950.21 sec 382 KBytes 14.8 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate
[ 5] 0.00-950.21 sec 1.00 GBytes 9.04 Mbits/sec sender
[ 5] 0.00-950.21 sec 1024 MBytes 9.04 Mbits/sec receiver

iperf Done.

下载网速基本是 10M ,算下来顶多 130M 带宽,符合百兆以上的带宽速度。因为 tcp 为了包的完整性牺牲了大量的性能,以他的结果为网卡的物理极限不太准确,我们来看看 udp 的

  • wifi1 百兆以上 udp
1
2
3
4
5
6
7
8
9
10
$ iperf3 -c 192.168.20.4 -b 1000M -n 1G -u
...
[ 5] 46.00-47.00 sec 0.00 Bytes 0.00 bits/sec 0
[ 5] 47.00-47.18 sec 17.6 MBytes 811 Mbits/sec 13197
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Jitter Lost/Total Datagrams
[ 5] 0.00-47.18 sec 1.00 GBytes 182 Mbits/sec 0.000 ms 0/766981 (0%) sender
[ 5] 0.00-47.18 sec 64.0 MBytes 11.4 Mbits/sec 0.414 ms 717059/764958 (94%) receiver

iperf Done.

下载网速基本 12M ,算下来顶多 150M 带宽,符合百兆以上的带宽速度。

千兆网络

  • wifi2 1Gb udp
1
2
3
4
5
6
7
8
9
$ iperf3 -c 192.168.20.4 -b 1000M -n 1G -u
...
[ 5] 8.00-8.64 sec 78.8 MBytes 1.03 Gbits/sec 57050
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Jitter Lost/Total Datagrams
[ 5] 0.00-8.64 sec 1.00 GBytes 994 Mbits/sec 0.000 ms 0/741555 (0%) sender
[ 5] 0.00-8.64 sec 92.1 MBytes 89.4 Mbits/sec 0.114 ms 674860/741555 (91%) receiver

iperf Done.

下载速度 90M , 算下来 700M 左右,基本符合千兆的带宽速度。

  • wifi2 1Gb tcp
1
2
3
4
5
6
7
8
9
$ iperf3 -c 192.168.20.4 -b 1000M -n 1G -u
...
[ 5] 92.00-92.49 sec 5.52 MBytes 94.4 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate
[ 5] 0.00-92.49 sec 1.00 GBytes 92.9 Mbits/sec sender
[ 5] 0.00-92.49 sec 1023 MBytes 92.8 Mbits/sec receiver

iperf Done.

下载速度 90M+ , 算下来 730M 左右,性能居然优于 udp ,看来网络稳定性也是影响性能的一个大因素,也符合千兆的带宽速度。

传输指定的时间

实验参数:设为网卡为千兆,测试 10 秒

  • wifi2 1Gb tcp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ iperf3 -c 192.168.20.4 -b 1000M -t 10
Connecting to host 192.168.20.4, port 5201
[ 5] local 192.168.10.236 port 52884 connected to 192.168.20.4 port 5201
[ ID] Interval Transfer Bitrate
[ 5] 0.00-1.00 sec 6.64 MBytes 55.7 Mbits/sec
[ 5] 1.00-2.00 sec 7.67 MBytes 64.4 Mbits/sec
[ 5] 2.00-3.00 sec 10.9 MBytes 91.5 Mbits/sec
[ 5] 3.00-4.00 sec 11.2 MBytes 93.9 Mbits/sec
[ 5] 4.00-5.00 sec 11.2 MBytes 94.2 Mbits/sec
[ 5] 5.00-6.00 sec 11.4 MBytes 95.7 Mbits/sec
[ 5] 6.00-7.00 sec 11.3 MBytes 94.9 Mbits/sec
[ 5] 7.00-8.00 sec 8.57 MBytes 71.9 Mbits/sec
[ 5] 8.00-9.00 sec 10.7 MBytes 90.1 Mbits/sec
[ 5] 9.00-10.00 sec 11.4 MBytes 95.3 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate
[ 5] 0.00-10.00 sec 101 MBytes 84.7 Mbits/sec sender
[ 5] 0.00-10.00 sec 101 MBytes 84.4 Mbits/sec receiver

iperf Done.

下载速度 85M , 算下来 700M 左右,符合千兆的带宽速度。

  • wifi2 1Gb udp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ iperf3 -c 192.168.20.4 -b 1000M -t 10 -u
Connecting to host 192.168.20.4, port 5201
[ 5] local 192.168.10.236 port 60169 connected to 192.168.20.4 port 5201
[ ID] Interval Transfer Bitrate Total Datagrams
[ 5] 0.00-1.00 sec 36.3 MBytes 305 Mbits/sec 26325
[ 5] 1.00-2.00 sec 89.2 MBytes 748 Mbits/sec 64581
[ 5] 2.00-3.00 sec 82.1 MBytes 689 Mbits/sec 59442
[ 5] 3.00-4.00 sec 71.0 MBytes 595 Mbits/sec 51409
[ 5] 4.00-5.00 sec 152 MBytes 1.28 Gbits/sec 110337
[ 5] 5.00-6.00 sec 137 MBytes 1.15 Gbits/sec 99050
[ 5] 6.00-7.00 sec 145 MBytes 1.21 Gbits/sec 104738
[ 5] 7.00-8.00 sec 138 MBytes 1.16 Gbits/sec 100057
[ 5] 8.00-9.00 sec 144 MBytes 1.20 Gbits/sec 103952
[ 5] 9.00-10.00 sec 156 MBytes 1.31 Gbits/sec 113108
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Jitter Lost/Total Datagrams
[ 5] 0.00-10.00 sec 1.12 GBytes 965 Mbits/sec 0.000 ms 0/832999 (0%) sender
[ 5] 0.00-10.00 sec 90.5 MBytes 75.9 Mbits/sec 0.137 ms 766346/831888 (92%) receiver

iperf Done.

下载速度 75M , 算下来 600M 左右,udp 又低于tcp 了不知道什么原因

  • wifi1 百兆以上 udp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ iperf3 -c 192.168.20.4 -b 1000M -t 10 -u
Connecting to host 192.168.20.4, port 5201
[ 5] local 192.168.11.27 port 60249 connected to 192.168.20.4 port 5201
[ ID] Interval Transfer Bitrate Total Datagrams
[ 5] 0.00-1.00 sec 48.1 MBytes 403 Mbits/sec 36003
[ 5] 1.00-2.00 sec 0.00 Bytes 0.00 bits/sec 0
[ 5] 2.00-3.00 sec 0.00 Bytes 0.00 bits/sec 0
[ 5] 3.00-4.00 sec 0.00 Bytes 0.00 bits/sec 0
[ 5] 4.00-5.00 sec 0.00 Bytes 0.00 bits/sec 0
[ 5] 5.00-6.00 sec 0.00 Bytes 0.00 bits/sec 0
[ 5] 6.00-7.00 sec 0.00 Bytes 0.00 bits/sec 0
[ 5] 7.00-8.00 sec 0.00 Bytes 0.00 bits/sec 0
[ 5] 8.00-9.00 sec 0.00 Bytes 0.00 bits/sec 0
[ 5] 9.00-10.00 sec 0.00 Bytes 0.00 bits/sec 0
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Jitter Lost/Total Datagrams
[ 5] 0.00-10.00 sec 48.1 MBytes 40.3 Mbits/sec 0.000 ms 0/36003 (0%) sender
[ 5] 0.00-10.00 sec 2.26 MBytes 1.89 Mbits/sec 19.473 ms 33901/35562 (95%) receiver

iperf Done.

完全不符合,tcp 大概要再赢一轮了

  • wifi1 百兆以上 tcp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ $ iperf3 -c 192.168.20.4 -b 1000M -t 10
Connecting to host 192.168.20.4, port 5201
[ 5] local 192.168.11.27 port 53028 connected to 192.168.20.4 port 5201
[ ID] Interval Transfer Bitrate
[ 5] 0.00-1.00 sec 367 KBytes 3.01 Mbits/sec
[ 5] 1.00-2.00 sec 80.3 KBytes 658 Kbits/sec
[ 5] 2.00-3.00 sec 277 KBytes 2.27 Mbits/sec
[ 5] 3.00-4.00 sec 74.2 KBytes 608 Kbits/sec
[ 5] 4.00-5.00 sec 13.9 KBytes 114 Kbits/sec
[ 5] 5.00-6.00 sec 53.4 KBytes 437 Kbits/sec
[ 5] 6.00-7.00 sec 19.7 KBytes 162 Kbits/sec
[ 5] 7.00-8.00 sec 211 KBytes 1.73 Mbits/sec
[ 5] 8.00-9.00 sec 80.1 KBytes 656 Kbits/sec
[ 5] 9.00-10.00 sec 11.6 KBytes 95.0 Kbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate
[ 5] 0.00-10.00 sec 1.16 MBytes 974 Kbits/sec sender
[ 5] 0.00-10.00 sec 1.04 MBytes 869 Kbits/sec receiver

iperf Done.