引言
在選購無線路由器等網通裝置時,AC3000、AX6000 以及 BE7000 等規格的路由器已經成為現代家庭網路的主流選擇。
以某品牌為例,其無線速度特性標榜如下:
Wi-Fi 5 (1024 QAM):最高 1733 Mbps。
Wi-Fi 6 (2.4 GHz):最高 574 Mbps。
Wi-Fi 4:最高 300 Mbps。
這些傳輸速度表示當兩個終端裝置(如手機或電腦)連接到這些 Wi-Fi 熱點時的理論最高傳輸速度。如果兩個裝置同時支持 Wi-Fi 5 和 1024 QAM,則其最高傳輸速度可達 1733 Mbps。這樣內網的兩個端點裝置可以進行更高速的數據傳輸。
其中需要注意的一點是,傳輸速度指的是路由器在最佳情況下所能提供的理論最高傳輸速度。實際的傳輸速度會受到許多因素影響,例如:
- 裝置之間的距離。(訊號越弱,通訊裝置解碼越容易出錯)
- 障礙物。(像是牆、轉角)
- 同頻干擾。(藍牙產品)
- 網路擁擠。(同一網路中,有多個裝置同時上傳或下載)
- Quality of Service(QoS)優先權。
- 裝置本身設計不良。(熱、天線、EMI)
- 線材。(網路線)
- 無線訊號的頻段和通道選擇。
- 無線協定和加密方式。
- 終端硬體性能。(處理器速度和記憶體大小)
也因此,若想知道兩裝置之間實際傳輸速度,可以透過 iPerf3 進行測速與評估,同時也可以應用在外網、VPN 或是 Tailscale 速度測試。
需要特別提到的是,如果申請了例如 300 Mbps/300 Mbps(下載/上傳)的網路,實際的傳輸速度會受到多種因素影響:
測試 裝置 A
與 裝置 B
,裝置 A 使用 Wi-Fi 6 網卡連接到 2.4 GHz 頻段(最高 574 Mbps)的無線路由器。無線路由器連接到對外的電信裝置(最高 300 Mbps),然後到用戶端 B 的電信裝置(最高 300 Mbps),最終速度會被限制在最高 300 Mbps。如果用戶端 B 的電信設備是 100 Mbps,則速度會被限制在 100 Mbps。
測試 裝置 A
與 手機
,裝置 A 使用 CAT-5 有線網路(最高 100 Mbps)上網,而手機使用 2.4 GHz 頻段(最高 574 Mbps)連接到路由器。兩個終端裝置在內網
進行測速時,其最高速度會受限於有線的速度而只有 100 Mbps。若要改善網路速度,可以讓裝置 A 使用無線網卡或更換網路線,例如 CAT-5e 支援 1 Gbps。
網路速度受到終端裝置的硬體參數、傳輸協定以及整個通信鏈路(telecommunications link)中最低速度
的影響。
安裝 iPerf3
Linux
官方提供的僅有 Ubuntu / Debian / Mint / Fedora / FreeBSD 的執行檔,大多可透過套件安裝器進行安裝。若為 ARM 架構,可透過 Github 直接下載 ARM 版本的 iPerf3,甚至是下載 source code 自行編譯。
以下說明測試環境為 Ubuntu 20.04 的安裝:
1
2
3
4
5
6
7
8
| # 更新套件列表
sudo apt update
# 安裝 iperf3
sudo apt install -y iperf3
# 顯示 iperf3 的版本
iperf3 --version
|
如果需要移除 iperf3,可以使用以下命令:
安裝好後,檢查輸出版本為 iperf 3.9 (cJSON 1.7.13)
1
2
3
4
| wells@server:~$ iperf3 --version
iperf 3.9 (cJSON 1.7.13)
Linux server 5.15.0-91-generic #101-Ubuntu SMP Tue Nov 14 13:30:08 UTC 2023 x86_64
Optional features available: CPU affinity setting, IPv6 flow label, SCTP, TCP congestion algorithm setting, sendfile / zerocopy, socket pacing, authentication
|
Windows
iPerf3 由能源科學網(Energy Sciences Network,ESnet)所維護,並提供 Linux 的編譯版本。當前 Windows 版本所使用的是由社群開發者進行編譯與維護的。這些貢獻者致力於將 iPerf3 經由 Cygwin 移植到 Windows 平台,並保持其與 Linux 版本的功能一致性。
Windows 平台上使用 iPerf3 需要從官方建議的站點下載。分別為:BudMan或是ar51an。
找到最新日期的壓縮包,例如 iperf-3.17.1-win64.zip,下載後解壓縮即可使用。
指令統整說明
常見的指令如下,如果需要更進階的玩法可以參考 help。
建立伺服器 | iperf3 -s |
---|
建立伺服器,並指定通訊埠 | iperf3 -s -p 5205 |
Client 上傳(到 Server) | iperf3 -c IP/HOST |
Client 下載(從 Server) | iperf3 -c IP/HOST -R |
Client 下載,並使用 4 個並行連線 | iperf3 -c IP/HOST -P 4 |
指定協定版本為 IPv6 | iperf3 -c IP/HOST -6 |
UDP 測試 | iperf3 -c IP/HOST -u |
建立 iPerf3 伺服器
測試兩台裝置之間的網路速度,其中 nodeA 作為伺服器,nodeB 則模擬上傳或下載的行為。
開啟 iperf3 的目錄

在路徑中輸入 cmd

跳出 cmd,確定該路徑為 iperf3 目錄底下

輸入 iperf3 -s
後會建立好 iperf3 伺服器,並打開 port 5201,等待用戶端進行連線。

如果要自行指定 port,可以改為 iperf3 -s -p 5205,往後用戶端在連線需加上對應的通訊埠號碼。
內網 IP 直連
硬體配置:兩台電腦透過有線網路進行內網測速,經過數台路由器。其中 nodeA 作為伺服器(192.168.1.30)。
nodeA 建立好伺服器後,在 nodeB 輸入 iperf3 -c IP/HOST
,便可以測試 nodeB 的上傳速度。即傳輸方向是從 nodeB 到 nodeA:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| wells@nodeB:~$ iperf3 -c 192.168.1.30
Connecting to host 192.168.1.30, port 5201
[ 4] local 192.168.1.20 port 55482 connected to 192.168.1.30 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 85.3 MBytes 715 Mbits/sec 0 219 KBytes
[ 4] 1.00-2.00 sec 78.0 MBytes 655 Mbits/sec 0 219 KBytes
[ 4] 2.00-3.00 sec 86.2 MBytes 723 Mbits/sec 0 219 KBytes
[ 4] 3.00-4.00 sec 88.5 MBytes 742 Mbits/sec 0 219 KBytes
[ 4] 4.00-5.00 sec 86.4 MBytes 725 Mbits/sec 0 219 KBytes
[ 4] 5.00-6.00 sec 90.7 MBytes 761 Mbits/sec 0 219 KBytes
[ 4] 6.00-7.00 sec 85.6 MBytes 718 Mbits/sec 0 219 KBytes
[ 4] 7.00-8.00 sec 85.3 MBytes 715 Mbits/sec 0 219 KBytes
[ 4] 8.00-9.00 sec 78.7 MBytes 660 Mbits/sec 0 219 KBytes
[ 4] 9.00-10.00 sec 82.3 MBytes 691 Mbits/sec 0 219 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 847 MBytes 711 Mbits/sec 0 sender
[ 4] 0.00-10.00 sec 846 MBytes 710 Mbits/sec receiver
|
表格參數的意義如下,其中著重在 Bandwidth 這個參數:
- ID:代表連線編號,用來區分多條測試連線。
- Interval:測量時間區段,用來顯示每秒或固定區間的測試結果。
- Transfer:在該時間區段內實際傳輸的資料量。
- Bandwidth:在該時間區段內的平均傳輸速率(頻寬)。
- Retr:資料丟失或損壞後,必須重新傳送的次數。次數越少,代表網路品質越好。
- Cwnd:擁塞窗口大小,代表發送方可在等待回覆前,連續發送的最大資料量。
由上表可以得知 nodeB 傳資料到 nodeA 的平均速度為 711 Mbps。
若要測試 nodeB 的下載速度,即傳輸方向是從 nodeA 到 nodeB,可使用iperf3 -c IP/HOST -R
:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| wells@nodeB:~$ iperf3 -c 192.168.1.30 -R
Connecting to host 192.168.1.30, port 5201
Reverse mode, remote host 192.168.1.30 is sending
[ 4] local 192.168.1.20 port 42550 connected to 192.168.1.30 port 5201
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-1.00 sec 111 MBytes 930 Mbits/sec
[ 4] 1.00-2.00 sec 106 MBytes 888 Mbits/sec
[ 4] 2.00-3.00 sec 94.4 MBytes 791 Mbits/sec
[ 4] 3.00-4.00 sec 108 MBytes 911 Mbits/sec
[ 4] 4.00-5.00 sec 91.8 MBytes 770 Mbits/sec
[ 4] 5.00-6.00 sec 101 MBytes 844 Mbits/sec
[ 4] 6.00-7.00 sec 101 MBytes 845 Mbits/sec
[ 4] 7.00-8.00 sec 102 MBytes 858 Mbits/sec
[ 4] 8.00-9.00 sec 93.2 MBytes 783 Mbits/sec
[ 4] 9.00-10.00 sec 102 MBytes 859 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-10.00 sec 1011 MBytes 848 Mbits/sec sender
[ 4] 0.00-10.00 sec 1011 MBytes 848 Mbits/sec receiver
|
nodeA 傳資料到 nodeB 的平均速度為 848 Mbps。
內網 IP 經由 Tailscale
經由 Tailscale 組網後,若想要評估兩個節點傳送的速度,可以直接輸入對方的 hostname 進行測試。
以下測試為相同的電腦,但改為 Tailscale 的 hostname 進行測試。
上傳測試結果:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| wells@nodeB:~$ iperf3 -c nodeA
Connecting to host nodeA, port 5201
[ 4] local 100.116.123.164 port 43086 connected to 100.110.114.119 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 46.3 MBytes 388 Mbits/sec 0 216 KBytes
[ 4] 1.00-2.00 sec 34.4 MBytes 289 Mbits/sec 0 216 KBytes
[ 4] 2.00-3.00 sec 41.0 MBytes 344 Mbits/sec 0 216 KBytes
[ 4] 3.00-4.00 sec 45.1 MBytes 379 Mbits/sec 0 216 KBytes
[ 4] 4.00-5.00 sec 44.4 MBytes 373 Mbits/sec 0 216 KBytes
[ 4] 5.00-6.00 sec 47.0 MBytes 395 Mbits/sec 0 216 KBytes
[ 4] 6.00-7.00 sec 45.1 MBytes 378 Mbits/sec 0 216 KBytes
[ 4] 7.00-8.00 sec 46.8 MBytes 393 Mbits/sec 0 216 KBytes
[ 4] 8.00-9.00 sec 45.2 MBytes 379 Mbits/sec 0 216 KBytes
[ 4] 9.00-10.00 sec 44.6 MBytes 374 Mbits/sec 0 216 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 440 MBytes 369 Mbits/sec 0 sender
[ 4] 0.00-10.00 sec 439 MBytes 369 Mbits/sec receiver
|
下載測試結果:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| wells@nodeB:~$ iperf3 -c nodeA -R
Connecting to host nodeA, port 5201
Reverse mode, remote host nodeA is sending
[ 4] local 100.116.123.164 port 32852 connected to 100.110.114.119 port 5201
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-1.00 sec 95.6 MBytes 802 Mbits/sec
[ 4] 1.00-2.00 sec 86.9 MBytes 729 Mbits/sec
[ 4] 2.00-3.00 sec 90.6 MBytes 760 Mbits/sec
[ 4] 3.00-4.00 sec 72.0 MBytes 604 Mbits/sec
[ 4] 4.00-5.00 sec 81.5 MBytes 684 Mbits/sec
[ 4] 5.00-6.00 sec 73.5 MBytes 616 Mbits/sec
[ 4] 6.00-7.00 sec 78.9 MBytes 662 Mbits/sec
[ 4] 7.00-8.00 sec 87.9 MBytes 738 Mbits/sec
[ 4] 8.00-9.00 sec 90.8 MBytes 761 Mbits/sec
[ 4] 9.00-10.00 sec 70.4 MBytes 590 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-10.00 sec 828 MBytes 695 Mbits/sec sender
[ 4] 0.00-10.00 sec 828 MBytes 695 Mbits/sec receiver
|
Tailscale 與 IP 直連對比,上載速度降為原來的 52%,下載速度降為原來的 82%。
多用戶端並行測試(multiple parallel client connection)
如果想要測試伺服器的性能,可以使用 iperf3 -c IP/HOST -P client_counts
進行
3 個使用者同時下傳:
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
| wells@nodeB:~$ iperf3 -c 192.168.1.30 -R -P3
Connecting to host 192.168.1.30, port 5201
Reverse mode, remote host 192.168.1.30 is sending
[ 4] local 192.168.1.20 port 60680 connected to 192.168.1.30 port 5201
[ 6] local 192.168.1.20 port 60694 connected to 192.168.1.30 port 5201
[ 8] local 192.168.1.20 port 60704 connected to 192.168.1.30 port 5201
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-1.00 sec 37.2 MBytes 312 Mbits/sec
[ 6] 0.00-1.00 sec 37.2 MBytes 312 Mbits/sec
[ 8] 0.00-1.00 sec 37.1 MBytes 311 Mbits/sec
[SUM] 0.00-1.00 sec 112 MBytes 935 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 1.00-2.00 sec 37.1 MBytes 312 Mbits/sec
[ 6] 1.00-2.00 sec 37.1 MBytes 312 Mbits/sec
[ 8] 1.00-2.00 sec 37.0 MBytes 311 Mbits/sec
[SUM] 1.00-2.00 sec 111 MBytes 934 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 2.00-3.00 sec 37.2 MBytes 312 Mbits/sec
[ 6] 2.00-3.00 sec 37.0 MBytes 310 Mbits/sec
[ 8] 2.00-3.00 sec 37.1 MBytes 311 Mbits/sec
[SUM] 2.00-3.00 sec 111 MBytes 934 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 3.00-4.00 sec 37.1 MBytes 311 Mbits/sec
[ 6] 3.00-4.00 sec 37.1 MBytes 311 Mbits/sec
[ 8] 3.00-4.00 sec 37.1 MBytes 311 Mbits/sec
[SUM] 3.00-4.00 sec 111 MBytes 934 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 4.00-5.00 sec 37.1 MBytes 311 Mbits/sec
[ 6] 4.00-5.00 sec 37.1 MBytes 311 Mbits/sec
[ 8] 4.00-5.00 sec 37.1 MBytes 311 Mbits/sec
[SUM] 4.00-5.00 sec 111 MBytes 934 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 5.00-6.00 sec 37.1 MBytes 311 Mbits/sec
[ 6] 5.00-6.00 sec 37.1 MBytes 311 Mbits/sec
[ 8] 5.00-6.00 sec 37.1 MBytes 311 Mbits/sec
[SUM] 5.00-6.00 sec 111 MBytes 934 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 6.00-7.00 sec 37.1 MBytes 311 Mbits/sec
[ 6] 6.00-7.00 sec 37.1 MBytes 311 Mbits/sec
[ 8] 6.00-7.00 sec 37.1 MBytes 311 Mbits/sec
[SUM] 6.00-7.00 sec 111 MBytes 934 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 7.00-8.00 sec 37.0 MBytes 311 Mbits/sec
[ 6] 7.00-8.00 sec 37.1 MBytes 312 Mbits/sec
[ 8] 7.00-8.00 sec 37.1 MBytes 312 Mbits/sec
[SUM] 7.00-8.00 sec 111 MBytes 934 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 8.00-9.00 sec 37.1 MBytes 311 Mbits/sec
[ 6] 8.00-9.00 sec 37.1 MBytes 311 Mbits/sec
[ 8] 8.00-9.00 sec 37.1 MBytes 311 Mbits/sec
[SUM] 8.00-9.00 sec 111 MBytes 934 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 9.00-10.00 sec 37.2 MBytes 312 Mbits/sec
[ 6] 9.00-10.00 sec 37.1 MBytes 311 Mbits/sec
[ 8] 9.00-10.00 sec 37.0 MBytes 310 Mbits/sec
[SUM] 9.00-10.00 sec 111 MBytes 934 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-10.00 sec 372 MBytes 312 Mbits/sec sender
[ 4] 0.00-10.00 sec 372 MBytes 312 Mbits/sec receiver
[ 6] 0.00-10.00 sec 372 MBytes 312 Mbits/sec sender
[ 6] 0.00-10.00 sec 372 MBytes 312 Mbits/sec receiver
[ 8] 0.00-10.00 sec 371 MBytes 311 Mbits/sec sender
[ 8] 0.00-10.00 sec 371 MBytes 311 Mbits/sec receiver
[SUM] 0.00-10.00 sec 1.09 GBytes 935 Mbits/sec sender
[SUM] 0.00-10.00 sec 1.09 GBytes 935 Mbits/sec receiver
|
結論
使用 iPerf3 測速後,若網速未達到需求,可進行進一步的除錯。
對於家用內部網路來說,線材品質、裝置設定以及協定支援等因素可能是導致網速不佳的主因。
甚至有時候重開路由器網速就正常了,遇到這種或許可以重新開始評估一台新的路由器了…。
當遇到 Tailscale 速度過慢的問題時,可以使用 tailscale ping host
命令評估裝置是否為直接連接或透過 DERP 中繼轉發。
我自己在使用 Tailscale 時通常是直接連接的,但有時連接某些 Wi-Fi 後開始使用 DERP 中繼。即使斷開 Wi-Fi 並切回原本的網路,仍無法直接連接。在這種情況下,強制重啟 Tailscale 服務有時會解決問題。
參考文獻
- Install iPerf 3 on Ubuntu 20.04
- iPerf3 user manual page
- Iperf - Wikipedia
- iperf3 FAQ — iperf3 documentation