Linux iperf command
iperf is a professional network performance testing tool used to measure TCP and UDP bandwidth performance. It can report network performance metrics such as bandwidth, latency jitter, and packet loss.
The main features of iperf:
- Supports TCP and UDP tests
- Can adjust various parameters such as TCP window size and UDP bandwidth
- Supports bidirectional testing (uploading and downloading at the same time)
- Cross-platform support (Linux, Windows, macOS, etc.)
Install iperf
Installation on Linux systems
On most Linux distributions, it can be installed via the package manager:
Example
Debian/Ubuntu
sudo
apt-get install
iperf3
CentOS/RHEL
sudo
yum install
iperf3
Fedora
sudo
dnf
install
iperf3
Arch Linux
sudo
pacman
-S
iperf3
Windows Installation
A precompiled binary is available from the iperf official website You can download the precompiled binary file there.
Basic Usage
iperf works in a client-server mode. You need to run the server on one machine and use another machine as the client to connect for testing.
Start the iperf server
iperf3 -s
It listens on port 5201 by default; you can use the -p parameter to specify a different port:
iperf3 -s -p 5001
Client connection test
iperf3 -c
For example, to test the bandwidth to 192.168.1.100:
iperf3 -c 192.168.1.100
Common parameters
General parameters
| Parameters | Description |
|---|---|
-p |
Specify the port number |
-t |
Test duration in seconds, 10 seconds by default |
-i |
Report results once every interval in seconds |
-f |
Display units (Kbits, Mbits, KBytes, MBytes) |
-V |
Display version information and exit |
-h |
Display help information |
Server-side parameters
| Parameters | Description |
|---|---|
-s |
Run in server mode |
-D |
Run in daemon mode |
Client-side parameters
| Parameters | Description |
|---|---|
-c |
Run in client mode, followed by the server address |
-u |
Use the UDP protocol instead of TCP |
-b |
Set the target bandwidth (UDP mode) |
-w |
Set the TCP window size |
-P |
Number of parallel connections |
-R |
Reverse test (the server sends and the client receives) |
Practical Application Examples
1. Basic TCP bandwidth test
Server side:
iperf3 -s
Client:
iperf3 -c 192.168.1.100
Example output:
[ ID] Interval Transfer Bitrate
[ 4] 0.00-10.00 sec 1.10 GBytes 942 Mbits/sec
2. UDP bandwidth test
Server side:
iperf3 -s
Client side (testing 100Mbps UDP):
iperf3 -c 192.168.1.100 -u -b 100M
3. Multi-threaded test
Using 4 parallel connections:
iperf3 -c 192.168.1.100 -P 4
4. Simultaneous bidirectional test
Server side:
iperf3 -s
Client:
iperf3 -c 192.168.1.100 --bidir
5. Long-duration test (60 seconds)
iperf3 -c 192.168.1.100 -t 60
Interpreting the results
iperf test results usually contain the following information:
- Interval: Test time interval
- Transfer: Amount of data transferred
- Bitrate: Bandwidth (bit rate)
- Retr: Number of TCP retransmissions (TCP only)
- Jitter: Jitter (UDP only)
- Lost/Total Datagrams: Packet loss rate (UDP only)
For network quality assessment:
- TCP tests are more suitable for measuring the maximum available bandwidth
- UDP tests can measure jitter and packet loss rate, which are more important for real-time applications (such as VoIP and video conferencing)
Advanced usage
1. Set the TCP window size
iperf3 -c 192.168.1.100 -w 256K
2. Test a specific port
Example
Server
iperf3
-s
-p
5001
Client Side
iperf3
-c
192.168.1.100
-p
5001
3. Output to a file
iperf3 -c 192.168.1.100 --logfile result.txt
4. Output in JSON format
iperf3 -c 192.168.1.100 -J
Common Problem Solutions
1. Connection refused
Make sure:
- The server-side iperf is running
- The firewall allows the iperf port (5201 by default)
- The client uses the correct IP address and port
2. Bandwidth test result far below expectations
Possible reasons:
- There is a bottleneck in the network (switch or router limitations)
- Network card settings issue (check duplex mode and speed)
- Insufficient system resources (high CPU or memory usage)
3. High packet loss rate in UDP tests
Note:
- Lower the target UDP bandwidth
- Check QoS settings on network devices
- Test network conditions at different times of day
Practical Application Scenarios
- Network device acceptance testing: Verify the performance of newly deployed network devices
- Bandwidth monitoring: Regularly test changes in network bandwidth
- Troubleshooting: Locate network performance problems
- QoS verification: Test the effect of quality-of-service policies
- Wireless network testing: Assess WiFi signal strength and stability
Summary
iperf is an essential bandwidth testing tool for network engineers; through this article you should have mastered:
- The basic working principles of iperf
- How to start the server and client
- Common parameters and usage examples
- Methods for analyzing test results
- Solutions to common problems
It is recommended to practice testing in real network environments and become familiar with the effects of different parameter combinations, so that you can assess network performance quickly and accurately when needed.
Linux Command Reference