Linux iperf Command

Linux 命令大全Complete Linux Command Reference


iperf is a professional network performance testing tool used to measure TCP and UDP bandwidth performance. It can report network performance indicators such as bandwidth, latency jitter, and packet loss.

Main features of iperf:

  • Supports TCP and UDP testing
  • Adjustable parameters such as TCP window size, UDP bandwidth, etc.
  • Supports bidirectional testing (simultaneous upload and download)
  • Cross-platform support (Linux, Windows, macOS, etc.)

Install iperf

Linux System Installation

On most Linux distributions, you can install it via the package manager:

Examples

# 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

You can obtain it from theiperf official websitedownload precompiled binary files.


Basic Usage

iperf works in client-server mode. You need to run the server on one machine and use another as a client to connect and test.

Start iperf Server

iperf3 -s

Listens on port 5201 by default; you can use the-pparameter to specify a different port:

iperf3 -s -p 5001

Client Connection Test

iperf3 -c 

For example, test bandwidth to 192.168.1.100:

iperf3 -c 192.168.1.100

Common Parameters Description

General Parameters

Parameter Description
-p Specify port number
-t Test duration (seconds), default 10 seconds
-i Report results every interval (seconds)
-f Display units (Kbits, Mbits, KBytes, MBytes)
-V Show version information and exit
-h Show help information

Server-side Parameters

Parameter Description
-s Run in server mode
-D Run in daemon mode

Client-side Parameters

Parameter Description
-c Run in client mode, followed by server address
-u Use UDP protocol instead of TCP
-b Set target bandwidth (UDP mode)
-w Set TCP window size
-P Number of parallel connections
-R Reverse test (server sends, 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 (testing 100Mbps UDP):

iperf3 -c 192.168.1.100 -u -b 100M

3. Multi-threaded Test

Use 4 parallel connections:

iperf3 -c 192.168.1.100 -P 4

4. Bidirectional Simultaneous 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 Results

iperf test results typically include the following information:

  1. Interval: Time interval
  2. Transfer: Amount of data transferred
  3. Bitrate: Bandwidth (bitrate)
  4. Retr: TCP retransmissions (TCP only)
  5. Jitter: Jitter (UDP only)
  6. Lost/Total Datagrams: Packet loss rate (UDP only)

For network quality assessment:

  • TCP testing is more suitable for measuring maximum available bandwidth
  • UDP testing can measure jitter and packet loss, which is more important for real-time applications (e.g., VoIP, video conferencing)

Advanced Usage

1. Set TCP Window Size

iperf3 -c 192.168.1.100 -w 256K

2. Test a Specific Port

Examples

# Server
iperf3 -s -p 5001

# Client
iperf3 -c 192.168.1.100 -p 5001

3. Output to File

iperf3 -c 192.168.1.100 --logfile result.txt

4. JSON Format Output

iperf3 -c 192.168.1.100 -J

Troubleshooting Common Issues

1. Connection Refused

Make sure:

  • The server-side iperf is started
  • The firewall allows the iperf port (default 5201)
  • The client uses the correct IP and port

2. Bandwidth Test Results Much Lower Than Expected

Possible causes:

  • Bottlenecks in the network (switch/router limitations)
  • Network card settings issues (check duplex mode, speed)
  • Insufficient system resources (high CPU/memory usage)

3. High Packet Loss in UDP Test

Suggestions:

  • Lower the UDP bandwidth target value
  • Check QoS settings on network devices
  • Test network conditions at different times

Practical Application Scenarios

  1. Network device acceptance: Validate performance of newly deployed network devices
  2. Bandwidth monitoring: Periodically test network bandwidth changes
  3. Troubleshooting: Locate network performance issues
  4. QoS verification: Test the effectiveness of QoS policies
  5. Wireless network testing: Evaluate 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
  • How to analyze test results
  • Solutions to common problems

It is recommended to practice testing more in real network environments, become familiar with the effects of different parameter combinations, so that you can quickly and accurately evaluate network performance when needed.


Linux 命令大全Complete Linux Command Reference

Other Extensions