This post was originally published on go2linux.org. The domain is no longer mine, but I am the original author. I am republishing it here on garron.me with corrections and improvements.

The speed your ISP sells you is the speed from your home or office to their network. It says nothing about the path to the server you actually care about. Years ago I worked from home for a company abroad, with a VoIP phone on my desk, and the question was not "how fast is my connection" but "how good is the link between my house and the company's office". A speed test website could not answer that.

iperf3 can. You run it on both ends of the link, one as a server and one as a client, and it pushes traffic between them and reports the throughput, retransmissions, and for UDP, jitter and packet loss.

Install

On both machines:

sudo apt install iperf3      # Debian, Ubuntu
sudo dnf install iperf3      # Fedora, RHEL, Rocky, Alma
sudo pacman -S iperf3        # Arch

On Debian and Ubuntu the installer asks whether to start iperf3 as a daemon at boot. Answer no unless you want a permanent test server listening on that machine.

iperf3 and iperf (version 2) are different programs. They do not talk to each other, they use different ports (5201 and 5001), and some options differ. Use the same one on both ends. This post covers iperf3.

Run a test

On the server:

iperf3 -s

It listens on TCP port 5201. On the client, point it at the server's address:

iperf3 -c 203.0.113.10
Connecting to host 203.0.113.10, port 5201
[  5] local 192.168.1.20 port 51234 connected to 203.0.113.10 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  10.9 MBytes  91.2 Mbits/sec    0    402 KBytes
[  5]   1.00-2.00   sec  11.2 MBytes  94.4 Mbits/sec    0    402 KBytes
[  5]   2.00-3.00   sec  11.2 MBytes  94.4 Mbits/sec    0    402 KBytes
...
[  5]   9.00-10.00  sec  11.2 MBytes  94.4 Mbits/sec    2    305 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec   112 MBytes  93.9 Mbits/sec    7             sender
[  5]   0.00-10.03  sec   111 MBytes  93.1 Mbits/sec                  receiver

The test runs for ten seconds and prints one line per second. The two lines at the bottom are the ones that matter:

  • receiver bitrate is the throughput that actually arrived. Quote this one.
  • Retr is the number of TCP retransmissions. A handful is normal. Hundreds mean packet loss somewhere on the path.
  • Cwnd is the TCP congestion window. If it stays small and the bitrate is low on a long-distance link, the limit may be latency rather than bandwidth.

Watch the per-second lines too. When I first ran this test the bitrate kept climbing during the run, and the reason was that I was downloading a file at the same time. Close other traffic before you trust a number.

Test the other direction

By default the client sends and the server receives, so you are measuring upload from the client. Home connections are often asymmetric, so test the download too. -R (reverse) makes the server send:

iperf3 -c 203.0.113.10 -R

Both directions at the same time (iperf3 3.7 or later):

iperf3 -c 203.0.113.10 --bidir

Longer and parallel tests

Run for 30 seconds and report every 5:

iperf3 -c 203.0.113.10 -t 30 -i 5

A single TCP stream sometimes cannot fill a fast or high-latency link. Several streams in parallel get closer to the real capacity:

iperf3 -c 203.0.113.10 -P 4

The [SUM] lines at the end add the streams up. If four streams get much more than one, the bottleneck is per-connection (latency, TCP window) and not the link itself.

UDP: jitter and packet loss

For voice and video, raw throughput matters less than jitter and loss. UDP mode sends at a fixed rate that you choose with -b:

iperf3 -c 203.0.113.10 -u -b 5M
[ ID] Interval           Transfer     Bitrate         Jitter    Lost/Total Datagrams
[  5]   0.00-10.00  sec  5.96 MBytes  5.00 Mbits/sec  0.000 ms  0/4317 (0%)  sender
[  5]   0.00-10.04  sec  5.95 MBytes  4.97 Mbits/sec  1.215 ms  6/4317 (0.14%)  receiver

Read the receiver line:

  • Jitter is the variation in packet arrival time. Below about 30 ms is fine for VoIP.
  • Lost/Total is the packet loss. Under 1% is usually acceptable for voice; above that you start hearing it.

Set -b to the rate you actually need (a few hundred kilobits for a voice call, a few megabits for video), not to the maximum. Without -b, UDP mode sends only 1 Mbit/s.

Firewall

If the client cannot connect, open port 5201 on the server for TCP and UDP:

sudo ufw allow 5201                                   # Ubuntu, Debian with ufw
sudo firewall-cmd --add-port=5201/tcp --add-port=5201/udp   # Fedora, RHEL

The firewall-cmd rule is temporary and goes away at the next reload, which is what you want for a test. Use -p on both sides to pick another port.

Other useful options

  • iperf3 -s -1 — serve a single test and exit, so you do not leave a listener open.
  • iperf3 -s -D — run the server in the background as a daemon.
  • iperf3 -c host -J — output JSON, for scripts and graphs.
  • iperf3 -c host -4 or -6 — force IPv4 or IPv6.
  • iperf3 -c host --logfile result.txt — write the output to a file.

Without a second machine of your own

There are public iperf3 servers, listed at iperf.fr. They are useful to test your internet connection, but they are shared and often busy. To test a specific link, such as an office VPN or the path to your own server, run the server yourself on the far end.

See also

man iperf3. If the numbers are bad and you want to see what is on the wire, capture the traffic with tcpdump.