這是一張有關標題為 Installing and Using iPerf3 for Network Speed Testing 的圖片

Installing and Using iPerf3 for Network Speed Testing

Evaluating network transmission speed between two devices

Introduction

When purchasing wireless routers and other network communication devices, routers with specifications like AC3000, AX6000, and BE7000 have become the mainstream choice for modern home networks.

Take a specific brand as an example, their wireless speed characteristics are highlighted as follows:

Wi-Fi 5 (1024 QAM): up to 1733 Mbps. Wi-Fi 6 (2.4 GHz): up to 574 Mbps. Wi-Fi 4: up to 300 Mbps.

These transmission speeds indicate the theoretical maximum transmission speed when two terminal devices (such as mobile phones or computers) are connected to these Wi-Fi hotspots. If both devices support Wi-Fi 5 and 1024 QAM, their maximum transmission speed can reach 1733 Mbps, allowing higher-speed data transmission between two devices within the internal network.

One important point to note is that transmission speed refers to the theoretical maximum transmission speed the router can provide under optimal conditions. The actual transmission speed is influenced by many factors, such as:

  1. Distance between devices (weaker signal results in higher error rates).
  2. Obstacles (such as walls and corners).
  3. Co-channel interference (Bluetooth products).
  4. Network congestion (multiple devices uploading or downloading simultaneously).
  5. Quality of Service (QoS) priority.
  6. Poor device design (heat, antenna, EMI).
  7. Cables (network cables).
  8. Wireless signal band and channel selection.
  9. Wireless protocols and encryption methods.
  10. Terminal hardware performance (processor speed and memory size).

Therefore, to know the actual transmission speed between two devices, you can use iPerf3 for speed testing and evaluation. This can also be applied to external network, VPN, or Tailscale speed testing.

It’s worth mentioning that if you apply for a network with, for example, 300 Mbps/300 Mbps (download/upload), the actual transmission speed will be affected by various factors:

Testing Device A and Device B: Device A connects to a wireless router using a Wi-Fi 6 network card on the 2.4 GHz band (up to 574 Mbps). The wireless router connects to an external telecom device (up to 300 Mbps), then to client B’s telecom device (up to 300 Mbps), limiting the speed to a maximum of 300 Mbps. If client B’s telecom device is 100 Mbps, the speed will be limited to 100 Mbps.

Testing Device A and Phone: Device A uses a CAT-5 wired network (up to 100 Mbps) to access the internet, while the phone connects to the router using the 2.4 GHz band (up to 574 Mbps). The maximum speed during the test will be limited by the wired speed to only 100 Mbps. To improve network speed, Device A can use a wireless network card or change the network cable, such as CAT-5e supporting 1 Gbps.

Network speed is influenced by terminal device hardware parameters, transmission protocols, and the lowest speed in the entire telecommunications link.

Installing iPerf3

Linux

The official version is available for Ubuntu / Debian / Mint / Fedora / FreeBSD, mostly installable through package managers. For ARM architecture, you can download the ARM version of iPerf3 directly from GitHub or compile the source code yourself.

The following explains the installation for Ubuntu 20.04:

1
2
3
4
5
6
7
8
# Update package list
sudo apt update

# Install iperf3
sudo apt install -y iperf3

# Display iperf3 version
iperf3 --version

To remove iperf3, use the following command:

1
sudo apt remove iperf3

After installation, check the output version, which should be 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 is maintained by the Energy Sciences Network (ESnet) and provides a compiled version for Linux. The current Windows version is compiled and maintained by community developers, who have ported iPerf3 via Cygwin to the Windows platform, maintaining feature parity with the Linux version.

To use iPerf3 on Windows, download it from the recommended sites: BudMan or ar51an.

Find the latest dated zip package, such as iperf-3.17.1-win64.zip, download and extract it to use.

Command Overview

Common commands are as follows. For more advanced usage, refer to the help section.

CommandSyntax
Start a serveriperf3 -s
Start a server on a specific portiperf3 -s -p 5205
Client upload (to Server)iperf3 -c IP/HOST
Client download (from Server)iperf3 -c IP/HOST -R
Client download with 4 parallel streamsiperf3 -c IP/HOST -P 4
Use IPv6 protocol versioniperf3 -c IP/HOST -6
UDP testiperf3 -c IP/HOST -u

Setting up an iPerf3 Server

To test network speed between two devices, nodeA will run as the server, while another device, nodeB, will simulate upload or download behavior.

  1. Open the iperf3 directory.

    Open iperf3 directory

  2. Type cmd in the path bar.

    Type cmd in path bar

  3. Confirm that the command prompt opens in the iperf3 directory.

    Command prompt

  4. Enter iperf3 -s to start the iperf3 server, which will open port 5201 and wait for client connections.

    Run iperf3 server

To specify a different port, use iperf3 -s -p 5205. Clients will need to connect using the corresponding port number.

Direct Connection via Internal Network

Hardware setup: Two computers connected via wired network, passing through several routers. NodeA acts as the server (192.168.1.30).

After nodeA sets up the server, enter iperf3 -c IP/HOST on nodeB to test the upload speed from nodeB to 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

The meanings of the table parameters are as follows, with an emphasis on the Bandwidth parameter:

  • ID: Typically represents the connection number.
  • Interval: The time interval for the test.
  • Transfer: The amount of data transferred during this interval.
  • Bandwidth: The average bandwidth during this interval, represented as the transmission speed.
  • Retr: In network transmission, when data packets are lost or damaged during transmission and cannot be correctly received by the recipient, the recipient requests the sender to resend these data packets. The number of retransmissions can reflect the reliability and stability of the network connection. Ideally, the fewer retransmissions, the better, as this indicates fewer packet loss incidents during data transmission.
  • Cwnd: Congestion window size, measured in KBytes (kilobytes). This value represents the amount of data the sender can transmit before waiting for an acknowledgment.

From the table, it can be seen that the average speed at which nodeB transfers data to nodeA is 711 Mbps.

To test the download speed of nodeB, i.e., the transmission direction from nodeA to nodeB, use 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

The average speed of data transfer from nodeA to nodeB is 848 Mbps.

Internal Network IP via Tailscale

After setting up a network through Tailscale, you can evaluate the transmission speed between two nodes by directly entering the hostname of the other node.

The following test uses the same computers but switches to using the Tailscale hostname for testing.

Upload test results:

 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

Download test results:

 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

Compared to direct IP connection, the upload speed via Tailscale is reduced to 52% of the original speed, and the download speed is reduced to 82% of the original speed.

Multiple Parallel Client Connection

To test the performance of the server, you can use iperf3 -c IP/HOST -P client_counts.

For example, to simulate 3 clients downloading simultaneously:

 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

Conclusion

After using iPerf3 for speed testing, if the network speed does not meet your requirements, further troubleshooting may be necessary.

For home internal networks, factors such as cable quality, device configuration, and protocol support may be the main causes of poor network speed.

Sometimes, simply restarting the router can normalize the speed. If this frequently happens, it might be time to consider evaluating a new router.

When encountering slow speeds with Tailscale, you can use the tailscale ping host command to determine whether the device is directly connected or relayed through a DERP server.

In my experience, Tailscale usually connects directly. However, occasionally, after connecting to certain Wi-Fi networks, it starts using DERP relays. Even disconnecting from Wi-Fi and returning to the original network doesn’t resolve the direct connection issue. In such cases, forcibly restarting the Tailscale service can sometimes fix the problem.

References

  1. Install iPerf 3 on Ubuntu 20.04
  2. iPerf3 user manual page
  3. Iperf - Wikipedia
  4. iperf3 FAQ — iperf3 documentation
Theme Stack designed by Jimmy