LinuxCommandLibrary

iperf

Measure network bandwidth performance

TLDR

Run on server

$ iperf [[-s|--server]]
copy

Run on server using UDP mode and set server port to listen on 5001
$ iperf [[-u|--udp]] [[-s|--server]] [[-p|--port]] [5001]
copy

Run on client
$ iperf [[-c|--client]] [server_address]
copy

Run on client every 2 seconds
$ iperf [[-c|--client]] [server_address] [[-i|--interval]] [2]
copy

Run on client with 5 parallel threads
$ iperf [[-c|--client]] [server_address] [[-P|--parallel]] [5]
copy

Run on client using UDP mode
$ iperf [[-u|--udp]] [[-c|--client]] [server_address] [[-p|--port]] [5001]
copy

SYNOPSIS

iperf -s [options]
iperf -c <host> [options]
(Common options used for both TCP and UDP modes)

PARAMETERS

-s, --server
    Run iperf in server mode, listening for incoming client connections.

-c, --client <host>
    Run iperf in client mode, connecting to the specified <host>.

-u, --udp
    Use UDP instead of TCP for the test. Default is TCP.

-p, --port <port>
    Specify the port number for the server to listen on or for the client to connect to. Default is 5201.

-i, --interval <seconds>
    Report statistics at fixed <seconds> intervals rather than only at the end.

-t, --time <seconds>
    The time in <seconds> to transmit data. Default is 10 seconds.

-n, --bytes <n[KMGT]>
    The number of bytes to transmit. For example, 1G for 1 Gigabyte.

-P, --parallel <num_streams>
    Number of parallel client streams to run. Useful for testing multi-threaded applications or overcoming single-stream limitations.

-R, --reverse
    Run a reverse test mode, where the server sends data to the client.

-w, --window <size[KMGT]>
    TCP window size or socket buffer size. Can significantly affect TCP throughput over high-latency or high-bandwidth links.

-b, --bandwidth <n[KMGT]>
    Target bandwidth in bits/sec. Primarily used for UDP tests to specify the sending rate. Can also be used for TCP pacing in iperf3.

-J, --json
    Output results in JSON format (iperf3 only). Ideal for programmatic parsing.

-h, --help
    Display help information and exit.

DESCRIPTION

iperf is a powerful command-line tool designed for active measurements of the maximum achievable bandwidth on IP networks. It operates in a client-server model, where one instance acts as a server listening for connections and another as a client initiating data transfers. iperf supports both TCP and UDP protocols, allowing for comprehensive network analysis. It can measure throughput, jitter (for UDP), and packet loss (for UDP), making it an invaluable utility for network troubleshooting, capacity planning, and validating network performance after infrastructure changes. Users can tune various parameters such as port numbers, test duration, buffer sizes, and the number of parallel streams to simulate different network conditions. It's widely used across various operating systems, including Linux, Windows, and macOS.

CAVEATS

There are two main versions: iperf2 and iperf3. They are distinct projects, not fully compatible, and use different sets of options. iperf3 is generally recommended for modern use.
Firewalls must be configured to allow traffic on the chosen port (default 5201).
Results represent the maximum achievable bandwidth under test conditions and might not reflect typical application performance due to other network traffic or system overheads.
High-speed tests might be limited by CPU performance on either the client or server, or by specific OS network stack tunings.

COMMON USE CASES

Measuring throughput between two hosts or within a cloud environment.
Testing network link capacity after infrastructure upgrades or changes.
Diagnosing bandwidth bottlenecks or network congestion issues.
Benchmarking network performance of virtual machines or cloud instances.
Assessing UDP characteristics like jitter and packet loss for real-time applications (e.g., VoIP, video streaming).

INTERPRETING RESULTS

When interpreting iperf output, pay attention to the Interval, Transfer, and Bandwidth columns for throughput. For UDP tests, Jitter and Lost/Total Datagrams are crucial indicators of real-time performance. Always ensure that neither the client nor the server's CPU is saturated during the test, as this can artificially limit reported bandwidth. For TCP tests, a high number of retransmits indicates network issues like congestion or packet loss, which degrade performance even if raw bandwidth looks good.

HISTORY

iperf was originally developed by the Distributed Systems and Networks Research Group (DSNRG) at NLANR. The original project, now often referred to as iperf2, continues to be maintained independently. A significant rewrite, iperf3, was later developed by ESnet (Energy Sciences Network). iperf3 introduced new features like JSON output, authentication, and improved multi-threading support, making it better suited for modern network environments and high-speed testing. While iperf2 remains relevant for some legacy systems, iperf3 is generally preferred for new deployments and advanced network analysis.

SEE ALSO

ping(8), netstat(8), ss(8), traceroute(8), mtr(8), nc(1), tcpdump(1)

Copied to clipboard