SkillPilotAI

iperf3

iperf3 is the standard tool to measure the maximum achievable bandwidth between two hosts with real traffic, plus UDP jitter and loss. It runs as a server on one machine and a client on the other, and its options cover output formats, server control, protocol, rate, test length, TCP/IP tuning and RSA authentication.

187.1 Why is it used?

  • Prove whether a slow transfer is the network or the host (disk, application).
  • Measure upload, download (-R) and both at once (--bidir) between your own machines.
  • UDP tests (-u) report jitter and loss for voice/video planning.
  • Test QoS markings (--dscp), MSS, congestion control and window sizes.
  • Install: winget install iperf3 (Windows), apt/dnf install iperf3 (Linux), brew install iperf3 (macOS).

187.2 How a test works

iperf3 test: control connection + data stream
  1. 1.Server runs iperf3 -s and listens on TCP 5201 (192.168.207.10)

  2. 2.Client runs iperf3 -c 192.168.207.10 (from 192.168.207.20)

  3. 3.Control connection opens; test parameters are exchanged

  4. 4.Data stream starts: by default client -> server (upload)

  5. 5.With -R the server sends instead (download)

  6. 6.At the end the client prints sender and receiver totals

Lab: both containers on one Docker bridge (n187-lan); every test is 3 seconds

187.3 General options: format and output

Terminal
S=192.168.207.10   # n187-serveriperf3 -c $S -t 3iperf3 -c $S -t 3 -f miperf3 -c $S -t 3 -f M
Output
$ iperf3 -c 192.168.207.10 -t 3 -f M[ ID] Interval           Transfer     Bitrate         Retr  Cwnd[  5]   0.00-1.00   sec   397 MBytes   397 MBytes/sec  225   1.79 MBytes[  5]   1.00-2.00   sec   331 MBytes   331 MBytes/sec    0   1.82 MBytes[  5]   2.00-3.00   sec   333 MBytes   333 MBytes/sec    0   1.84 MBytes[ ID] Interval           Transfer     Bitrate         Retr[  5]   0.00-3.00   sec  1.04 GBytes   356 MBytes/sec  225             sender[  5]   0.00-3.00   sec  1.04 GBytes   356 MBytes/sec                  receiver
Terminal
iperf3 -c $S -t 3 -i 3iperf3 -c $S -t 3 -J > /tmp/r.jsonjq '.end.sum_received.bits_per_second,  .end.cpu_utilization_percent.host_total' \  /tmp/r.jsoniperf3 -c $S -t 3 --logfile /tmp/client.logtail -4 /tmp/client.log
Output
$ iperf3 -c 192.168.207.10 -t 3 --logfile /tmp/client.log; echo "terminal: nothing"; tail -4 /tmp/client.logterminal: nothing[  6]   0.00-3.00   sec  1.15 GBytes  3.29 Gbits/sec  1204             sender[  6]   0.00-3.00   sec  1.15 GBytes  3.29 Gbits/sec                  receiveriperf Done.
Terminal
iperf3 -c $S -t 3 -Viperf3 -c $S -t 3 -d > /tmp/debug.txt 2>&1wc -l /tmp/debug.txtiperf3 -c $S -t 3 --forceflush | catiperf3 -c $S -t 3 --timestamps
Output
$ iperf3 -c 192.168.207.10 -t 3 --timestampsMon Nov  9 10:59:30 2026 [ ID] Interval           Transfer     Bitrate         Retr  CwndMon Nov  9 10:59:30 2026 [  5]   0.00-1.00   sec   327 MBytes  2.74 Gbits/sec    0   1.05 MBytesMon Nov  9 10:59:31 2026 [  5]   1.00-2.01   sec   373 MBytes  3.09 Gbits/sec  1210   1.57 MBytesMon Nov  9 10:59:32 2026 [  5]   2.01-3.01   sec   466 MBytes  3.92 Gbits/sec    0   1.73 MBytesMon Nov  9 10:59:32 2026 [  5]   0.00-3.01   sec  1.14 GBytes  3.25 Gbits/sec  1210             senderMon Nov  9 10:59:32 2026 [  5]   0.00-3.02   sec  1.14 GBytes  3.24 Gbits/sec                  receiver
OptionMeaning
-f k|m|g|t / K|M|G|TBits / bytes units (-f M showed 356 MBytes/sec)
-i N / -i 0Report interval / periodic reports off
-JFull result as JSON (best for scripts, use jq)
--logfile fileOutput into a file, nothing on the terminal
-VVerbose: MSS, CPU, congestion algorithm (sender CPU reached 88%, so the container CPU was the limit)
-dDebug (7713 lines in 3 seconds)
--forceflush / --timestampsFlush every interval in a pipe / date-time on every line
-p 5002Server port (default 5201)
-F fileRead data from a file (storage test)
-A 2,3CPU affinity (client,server)
-B addr / --bind-dev eth0Bind to a local address / interface
--rcv-timeout / --snd-timeout msEnd stuck tests

187.4 Server options

Terminal
iperf3 -s -D -I /tmp/iperf3.pid \  --logfile /tmp/server.logcat /tmp/iperf3.pidss -ltnp | grep 5201tail -6 /tmp/server.log
Output
$ tail -6 /tmp/server.log[  6]   0.00-1.00   sec   327 MBytes  2.74 Gbits/sec[  6]   1.00-2.00   sec   373 MBytes  3.13 Gbits/sec[  6]   2.00-3.00   sec   466 MBytes  3.91 Gbits/sec- - - - - - - - - - - - - - - - - - - - - - - - -[ ID] Interval           Transfer     Bitrate[  6]   0.00-3.02   sec  1.14 GBytes  3.24 Gbits/sec                  receiver
Terminal
iperf3 -s -1 -p 5205 --idle-timeout 3# shared server: cap each testiperf3 -s -1 -p 5203 \  --server-bitrate-limit 50M/1iperf3 -c $S -p 5203 -t 3
Output
$ cat /tmp/limit.txtiperf3: error - total required bandwidth is larger than server limitAccepted connection from 192.168.207.20, port 42806[  5]   0.00-1.00   sec   343 MBytes  2.87 Gbits/sec
Server optionMeaning
-sServer mode (TCP 5201)
-D / -I fileBackground daemon / PID file
-1One test, then exit
--idle-timeout 60Restart/exit when idle (3 s with no client: closed 3 s later)
--server-bitrate-limit 100M[/10]Abort tests above the limit (average window in seconds, default 5)
--rsa-private-key-path, --authorized-users-path, --time-skew-thresholdAuthentication

187.5 Client: protocol and direction

Terminal
iperf3 -c $S -t 3 -uiperf3 -c $S -t 3 -Riperf3 -c $S -t 3 --bidiriperf3 -c $S -t 3 -P 4iperf3 -c $S -t 3 -4
Output
$ iperf3 -c 192.168.207.10 -t 3 -RReverse mode, remote host 192.168.207.10 is sending[ ID] Interval           Transfer     Bitrate[  5]   0.00-1.00   sec   418 MBytes  3.51 Gbits/sec[  5]   1.00-2.00   sec   379 MBytes  3.18 Gbits/sec[  5]   2.00-3.00   sec   415 MBytes  3.48 Gbits/sec[ ID] Interval           Transfer     Bitrate         Retr[  5]   0.00-3.00   sec  1.19 GBytes  3.40 Gbits/sec  1693             sender[  5]   0.00-3.00   sec  1.18 GBytes  3.39 Gbits/sec                  receiver
  • -u without -b runs UDP at 1 Mbit/s (result about 1 Mbit, 0 loss).
  • --bidir: TX-C = client upload, RX-C = download, at the same time.
  • -P 4: four parallel TCP streams, SUM 12.5 Gbits/sec.
  • Others: --sctp, --connect-timeout 3000, -4/-6, --cport 40000 (fixed client port for firewall tests), -c fe80::10%eth0.

187.6 Client: rate, length and buffers

Terminal
iperf3 -c $S -t 3 -b 10Miperf3 -c $S -t 3 -u -b 10M --pacing-timer 100iperf3 -c $S -t 3 --fq-rate 20M
Output
$ iperf3 -c 192.168.207.10 -t 3 --fq-rate 20M[ ID] Interval           Transfer     Bitrate         Retr  Cwnd[  5]   0.00-1.00   sec  2.50 MBytes  21.0 Mbits/sec    0   28.3 KBytes[  5]   1.00-2.00   sec  2.25 MBytes  18.9 Mbits/sec    0   28.3 KBytes[  5]   2.00-3.00   sec  2.38 MBytes  19.9 Mbits/sec    0   28.3 KBytes[ ID] Interval           Transfer     Bitrate         Retr[  5]   0.00-3.00   sec  7.12 MBytes  19.9 Mbits/sec    0             sender[  5]   0.00-3.01   sec  7.00 MBytes  19.5 Mbits/sec                  receiver
OptionMeaning
-b 100M / -b 0 / -b 50M/100Target bitrate per stream / no limit / burst of 100 packets
--pacing-timer 100Pacing timer in microseconds (UDP jitter only 0.139 ms)
--fq-rate 20MSocket pacing rate (Linux socket option, no module)
-t 30 / -n 1G / -k 10000Length by seconds / bytes / blocks
-l 1M / -u -l 1400Buffer length (TCP default 128 KB; -l 16K gave about 2 Gbits) / UDP payload
-w 4MSocket buffer / TCP window
-O 3Omit first 3 s (TCP slow start)
-ZZero-copy (sendfile), saves CPU

187.7 Client: TCP/IP tuning

Terminal
# server: only SYN packetstcpdump -n -v -i eth0 -c 2 \  'tcp[tcpflags] == tcp-syn and dst port 5201'# clientiperf3 -c $S -t 3 -M 1200iperf3 -c $S -t 3 -Ncat /proc/sys/net/ipv4/tcp_available_congestion_controliperf3 -c $S -t 3 -C reno -V |  grep -iE 'congestion|sender|receiver'
Output
$ iperf3 -c 192.168.207.10 -t 3 -C reno -V | grep -iE 'congestion|sender|receiver'[  5]   0.00-3.00   sec  1.24 GBytes  3.56 Gbits/sec   51             sender[  5]   0.00-3.01   sec  1.24 GBytes  3.54 Gbits/sec                  receiverCPU Utilization: local/sender 95.5% (0.4%u/95.1%s), remote/receiver 56.8% (1.9%u/55.0%s)snd_tcp_congestion renorcv_tcp_congestion reno
  • -M 1200: control SYN showed mss 1460, data stream SYN mss 1200.
  • -N: no delay (Nagle off), removes the wait for combining small packets.
  • -C: only reno and cubic were available, so BBR was not tested (asking for an unloaded one may load a module).
  • -S 0x10 / --dscp ef: data SYNs carried tos 0x10 and 0xb8; the control connection stayed tos 0x0, so check the data stream in QoS tests.
  • Also: -6 -L flow label, --sctp --nstreams, --repeating-payload (catches link compression), -u --dont-fragment, --udp-counters-64bit.

187.8 Labelling and authentication

Terminal
iperf3 -c $S -t 3 -T site-Aiperf3 -c $S -t 3 --get-server-output
Output
$ iperf3 -c 192.168.207.10 -t 3 --get-server-output[  5]   0.00-3.03   sec  1.33 GBytes  3.76 Gbits/sec  1597             sender[  5]   0.00-3.03   sec  1.33 GBytes  3.76 Gbits/sec                  receiverServer output:Accepted connection from 192.168.207.20, port 48778[ ID] Interval           Transfer     Bitrate[  6]   0.00-1.00   sec   405 MBytes  3.40 Gbits/sec[ ID] Interval           Transfer     Bitrate[  6]   0.00-3.03   sec  1.33 GBytes  3.76 Gbits/sec                  receiver
RSA authentication setup
  1. 1.openssl genrsa: password-protected private.pem

  2. 2.openssl rsa -pubout: public.pem for the clients

  3. 3.openssl rsa: private_not_protected.pem so the server reads it without a prompt (never share it)

  4. 4.sha256 of '{mario}rossi' goes into credentials.csv as user,hash

  5. 5.Server: --rsa-private-key-path + --authorized-users-path

  6. 6.Client: --username mario + --rsa-public-key-path, password from IPERF3_PASSWORD

Terminal
openssl genrsa -des3 -passout pass:labkey \  -out private.pem 2048openssl rsa -in private.pem \  -passin pass:labkey -outform PEM \  -pubout -out public.pemopenssl rsa -in private.pem \  -passin pass:labkey \  -out private_not_protected.pem -outform PEMecho -n '{mario}rossi' | sha256sum |  awk '{ print $1 }'# serveriperf3 -s -p 5204 \  --rsa-private-key-path \  private_not_protected.pem \  --authorized-users-path credentials.csv# clientIPERF3_PASSWORD=rossi iperf3 -c $S -p 5204 \  -t 3 --username mario \  --rsa-public-key-path /tmp/public.pemiperf3 -c $S -p 5204 -t 3
Output
$ cd /tmp && echo "mario,$(echo -n '{mario}rossi' | sha256sum | awk '{ print $1 }')" > credentials.csv && cat credentials.csvmario,bf7a49a846d44b454a5d11e7acfaf13d138bbe0b7483aa3e050879700572709b$ iperf3 -c 192.168.207.10 -p 5204 -t 3Connecting to host 192.168.207.10, port 5204iperf3: error - test authorization failed(exit 1)
  • Correct password: test ran normally (3.38 Gbits/sec).
  • Wrong password, or no username: test authorization failed.

187.9 Common mistakes

  • Thinking iperf3 -c is a download test: by default the client sends (upload); use -R for download, --bidir for both.
  • Judging a link by one TCP stream: a single stream or small window can be the limit; try -P 4.
  • Ignoring CPU: if -V shows the sender near 100%, the host is the bottleneck, not the network.
  • Including slow start in short tests: use -O to omit the first seconds.

187.10 Interview tips

  • Network or host? TCP test (sender/receiver totals, Retr) -> -R and -P -> -u for jitter/loss; near line rate means look at disk or application.
  • 400 Mbps on a 1 Gbps link with one stream: run -P 4 and check CPU with -V; if the total rises, the limit is one stream or the window.
  • -u reports jitter and loss on the receiver line; TCP shows Retr (retransmits).
  • Server control: -D daemon, -1 one-off, --server-bitrate-limit, RSA auth.