Using iperf3 for Network Performance Testing
Intrdouction to iperf3
iperf3 is version 3.0 of iperf, a network performance testing tool that transmits data streams in one direction over the network. It can adjust transmission rate and data size as needed, and report bandwidth, jitter, and packet loss.
Download: https://github.com/esnet/iperf/
iperf3 Command Reference
The following commands may vary with iperf3 version. For detailed explanations, refer to: https://github.com/esnet/iperf/
Common Options for Client and Server
| Option | Full Name | Description |
|---|---|---|
| -f | --format [kmgKMG] |
Format to report: kbits, Mbits, KBytes, MBytes. Units: k, m, g, KB, M, G. Conversion: 8 bit = 1 Byte, 1024 Byte = 1 KB, 1024 KB = 1 MB, 1024 MB = 1 GB |
| -i | --interval # |
Seconds between periodic bandwidth reports (default: 0) |
| -p | --port # |
Server port to listen/connect to (default: 5001) |
| -F | --file name |
Transmit/receive the specified file |
| -A | --affinity n/n,m |
Set CPU affinity |
| -B | --bind <host> |
Bind to a specific interface or multicast address (range: 224.0.0.0 to 239.255.255.255) |
| -V | --verbose |
More detailed output |
| -J | --json |
Output in JSON format |
--logfile <file> |
Send output to a log file | |
| -d | --debug |
Emit debugging output |
| -h | --help |
Show help message and exit |
| -v | --version |
Show version information and exit |
Server-Specific Options
| Option | Full Name | Description |
|---|---|---|
| -s | --server |
Run in server mode |
| -D | --daemon |
Run server as a daemon |
| -I | --pidfile <file> |
Write PID file |
| -1 | --one-off |
Handle one client connection then exit |
Client-Specific Options
| Option | Full Name | Description |
|---|---|---|
| -c | --client <host> |
Run in client mode, connecting to |
| -u | --udp |
Use UDP instead of TCP (default: TCP) |
| -b | --bandwidth #[KM] |
Target bandwidth in bits/sec (0 for unlimited, default: 1 Mbit/sec for UDP) |
| -t | --time # |
Time in seconds to transmit (default: 10 sec) |
| -n | --bytes #[KMG] |
Number of bytes to transmit (overrides -t) |
| -r | --tradeoff |
Bidirectional test individually (server reverse connects after client finishes) |
| -b (conflict with bandwidth) | --blockcount #[KMG] |
Number of blocks/packets to transmit (overrides -t or -n) |
| -l | --len #[KM] |
Length of buffer to read/write (default: 128 KB for TCP, 8 KB for UDP) |
--cport <port> |
Bind to a specific client port (default: ephemeral) | |
| -P | --parallel # |
Number of parallel client streams |
| -R | --reverse |
Reverse mode (server sends, client receives) |
| -w | --window #[KMG] |
Set window size / socket buffer size (TCP window or UDP buffer) |
| -C | --congestion <algo> |
Set TCP congestion control algorithm (Linux/FreeBSD only) |
| -M | --set-mss # |
Set TCP/SCTP maximum segment size (MTU - 40 bytes) |
| -N | --no-delay |
Disable Nagle's algorithm |
| -4 | --version4 |
Use IPv4 only |
| -6 | --version6 |
Use IPv6 only |
| -L | --flowlabel N |
Set IPv6 flow label (Linux only) |
| -S | --tos N |
Set IP Type of Service |
| -Z | --zerocopy |
Use zero-copy method for sending data |
| -O | --omit N |
Omit the first N seconds |
| -T | --title str |
Prefix every output line with this string |
| -: | --get-server-output |
Get results from server |
--udp-counters-64bit |
Use 64-bit counters in UDP test packets |
Example Commands
UDP Client
# UDP client with 1-second report interval, 300s duration, 300 Mbps bandwidth
iperf3 -c <server_ip> -i 1 -t 300 -u -b 300m
Server
# Start server in listening mode
iperf3 -s