Testing Network Bandwidth with iperf3
This article provides a step-by-step guide to testing network bandwidth using iperf3, a widely-used tool for measuring network performance.
Prerequisites
Two devices (one acting as the server, the other as the client) connected to the same network.
iperf3 installed on both devices. You can install iperf3 on:
Ubuntu/Debian: sudo apt-get install iperf3
CentOS/RHEL: sudo yum install iperf3
macOS: brew install iperf3
Windows: Download the iperf3 binary from the official website or a trusted source.
Administrative or sudo privileges for running iperf3 commands.
Ensure firewall settings allow traffic on the default iperf3 port (5201) or a custom port if specified.
Steps to Test Bandwidth
Step 1: Start the iperf3 Server
On the device designated as the server, open a terminal or command prompt.
Run the following command to start the iperf3 server:
iperf3 -s-s indicates server mode.
Optionally, specify a port with -p <port_number> (e.g., iperf3 -s -p 5202).
The server will listen for incoming connections. Note the server’s IP address (use ip addr or ifconfig on Linux, or ipconfig on Windows to find it).
Step 2: Run the iperf3 Client
On the client device, open a terminal or command prompt.
Run the following command to connect to the server and start the bandwidth test:
iperf3 -c <server_ip>Replace <server_ip> with the IP address of the server (e.g., iperf3 -c 192.168.1.100).
Optionally, use -t <seconds> to set the test duration (default is 10 seconds), e.g., iperf3 -c 192.168.1.100 -t 30.
To test bidirectional bandwidth, add the -R flag for reverse mode or use –bidir for simultaneous bidirectional testing.
Step 3: Interpret the Results
After the test completes, iperf3 will display a summary on both the client and server terminals, including:
Bandwidth: The average data transfer rate (e.g., in Mbps or Gbps).
Data Transferred: Total amount of data sent during the test.
Test Duration: Time taken for the test.
Example output:
[ ID] Interval Transfer Bandwidth [ 5] 0.00-10.00 sec 1.25 GBytes 1.07 Gbits/secThis indicates a bandwidth of approximately 1.07 Gbps over 10 seconds.
Step 4: Optional Configurations
Test UDP instead of TCP: Use -u on the client (e.g., iperf3 -c <server_ip> -u). This measures UDP performance and jitter.
Adjust parallel streams: Use -P <number> to run multiple parallel streams (e.g., iperf3 -c <server_ip> -P 4 for four streams).
Save output to a file: Use –logfile <filename> (e.g., iperf3 -c <server_ip> –logfile results.txt).
Test specific bandwidth: Limit the client’s bandwidth with -b <rate> (e.g., iperf3 -c <server_ip> -u -b 10M for 10 Mbps UDP).
Step 5: Stop the Server
On the server, press Ctrl+C to stop the iperf3 server process.
Troubleshooting
Connection refused: Ensure the server is running, the correct IP and port are used, and firewall settings allow traffic on the specified port.
Low performance: Check for network congestion, hardware limitations, or incorrect MTU settings.
Command not found: Verify iperf3 is installed and added to your system’s PATH.
Notes
iperf3 is not backward compatible with iperf2. Ensure both devices use iperf3.
For accurate results, run tests multiple times and avoid running other bandwidth-intensive applications during the test.
For advanced configurations, refer to the iperf3 documentation (man iperf3 or online resources).
