Testing Network Performance with iperf
iperf is an incredibly useful command-line tool for troubleshooting and assessing network performance. It helps you understand the capacity and quality of your network connection by providing metrics such as bandwidth, delay, jitter, and packet loss. This can be invaluable for diagnosing slow website loading, sluggish file transfers, or other network-related issues.
Important Note: When interpreting iperf results, remember that data transferred is typically expressed in megabytes (MBytes), while network speed (bandwidth) is expressed in megabits (Mbits). There are 8 bits in 1 byte, so 100 Mbits/sec is equal to 12.5 MBytes/sec.
Understanding iperf tests
iperf primarily tests maximum TCP bandwidth at Layer 4 (the Transport Layer) of the network model. Most common internet applications, like HTTP (web browsing), FTP (file transfer), and SMTP (email), rely on TCP. TCP is a “connection-oriented” protocol, meaning it establishes a reliable connection and acknowledges received messages. iperf can also test UDP (User Datagram Protocol) performance, which is “connectionless” and doesn’t guarantee delivery, by using the -u flag.
Installing iperf
iperf needs to be installed on both computers or servers that you intend to test the network connection between. Here are common installation commands for various Linux distributions:
- On CentOS/RHEL:
yum install iperf- On Ubuntu/Debian:
apt-get install iperf- On Arch Linux:
pacman -S iperfUsing iperf for network testing
iperf requires one machine to act as a server and the other as a client. The client connects to the server to perform the speed test.
Step 1: Start iperf in server mode
Run the following command on the server (the machine whose network speed you want to test from the client’s perspective):
iperf -s
Expected Server Output (when listening):
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------The server will now be listening for incoming connections on TCP port 5001 (by default).
Step 2: Run iperf in client mode
From the other server or computer (the client), run the following command, replacing 123.123.123.123 with the actual IP address or hostname of your iperf server:
iperf -c 123.123.123.123
This command will initiate a 10-second TCP bandwidth test from the client to the server.
Expected Client Output (during/after test):
------------------------------------------------------------
Client connecting to 123.123.123.123, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[ 3] local 10.30.6.172 port 56177 connected with 123.123.123.123 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 113 MBytes 94.8 Mbits/sec
Expected Server Output (after test completes):
Once the test completes on the client, the server will also display its results for that connection:
[ 5] local 123.123.123.123 port 5001 connected with 10.30.6.172 port 56177
[ ID] Interval Transfer Bandwidth
[ 5] 0.0-10.1 sec 113 MBytes 94.1 Mbits/sec
Other Useful iperf Flags:
- -u (UDP Test): To test UDP bandwidth instead of TCP:
- Server:
iperf -s -u - Client:
iperf -c <server_ip> -u
- Server:
- -d (Bidirectional Test): To perform a simultaneous bidirectional test (client sends to server, and server sends to client):
- Server:
iperf -s - Client:
iperf -c <server_ip> -d
- Server:
Conclusion
iperf is a fundamental tool for network diagnostics, providing clear, quantifiable data on your network’s performance. By running tests between your servers or between your local machine and a server, you can quickly identify network bottlenecks, verify bandwidth, and ensure your applications have the connectivity they need. For any complex network issues or assistance with iperf results, Liquid Web’s Support team is always ready to help!