iperf

networkingLinux/Unix/Windows
The iperf command is one of the most frequently used commands in Linux/Unix-like operating systems. iperf Measure network performance

Quick Reference

Command Name:

iperf

Category:

networking

Platform:

Linux/Unix/Windows

Basic Usage:

iperf [options] [arguments]

Common Use Cases

    Syntax

    iperf [-s|-c host] [options]

    Options

    Option Description
    -s, --server Run in server mode
    -c, --client host Run in client mode, connecting to host
    -p, --port port Server port to listen on/connect to (default 5001)
    -u, --udp Use UDP rather than TCP
    -b, --bandwidth bandwidth Set target bandwidth to bandwidth bits/sec (default 1 Mbit/sec for UDP, unlimited for TCP)
    -t, --time seconds Time to transmit for (default 10 secs)
    -i, --interval seconds Seconds between periodic bandwidth reports (default 0)
    -f, --format [kmgKMG] Format to report: Kbits, Mbits, KBytes, MBytes
    -P, --parallel n Number of parallel client streams to run
    -w, --window size[KM] TCP window size (socket buffer size)
    -M, --mss mss Set TCP maximum segment size (MTU - 40 bytes)
    -N, --nodelay Set TCP no delay, disabling Nagle's algorithm
    -v, --version Print version information and quit
    -V, --verbose More verbose output
    -d, --dualtest Do a bidirectional test simultaneously
    -r, --tradeoff Do a bidirectional test individually
    -L, --listenport port Port to receive bidirectional tests on
    -F, --fileinput file Input the data to be transmitted from a file
    -T, --ttl value Time-to-live for multicast packets

    Examples

    How to Use These Examples

    The examples below show common ways to use the iperf command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    iperf -s
    Run iperf as a server.
    iperf -c 192.168.1.10
    Run iperf as a client, connecting to the server at 192.168.1.10.
    # Advanced Examples Advanced
    iperf -c 192.168.1.10 -t 30 Run a 30-second test to the server at 192.168.1.10. iperf -c 192.168.1.10 -i 2 Display results every 2 seconds during the test. iperf -c 192.168.1.10 -b 100M Limit the bandwidth to 100 Mbps. iperf -c 192.168.1.10 -u Use UDP instead of TCP. iperf -c 192.168.1.10 -P 4 Run 4 parallel client streams. iperf -c 192.168.1.10 -r Run a bidirectional test (run in both directions sequentially). iperf -c 192.168.1.10 -d Run a bidirectional test simultaneously. iperf -c 192.168.1.10 -w 256K Set the TCP window size to 256 KB.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The iperf command is a powerful network performance measurement tool that helps administrators evaluate the bandwidth, latency, jitter, and packet loss of a network connection. It operates in a client-server model and is widely used for network troubleshooting and tuning. Key features of iperf: 1. Bandwidth Testing: iperf's primary function is measuring the maximum achievable bandwidth on IP networks, allowing administrators to identify bottlenecks and verify the quality of network links. 2. Protocol Support: It can test network performance using both TCP and UDP protocols. TCP tests measure bandwidth, while UDP tests can measure jitter, packet loss, and bandwidth. 3. Client-Server Architecture: iperf requires two endpoints: a server that listens for connections and a client that connects to the server to perform tests. 4. Bidirectional Testing: With options like -d (simultaneous bidirectional) and -r (sequential bidirectional), iperf can test performance in both directions between two hosts. 5. Parallel Streams: The -P option allows running multiple parallel streams, which can be useful for saturating high-bandwidth links or testing multi-connection scenarios. 6. Customizable Parameters: iperf offers extensive customization options, including test duration, reporting intervals, window sizes, and bandwidth limits for UDP tests. 7. Detailed Statistics: The tool provides comprehensive statistics on bandwidth, transfer size, jitter, and packet loss, depending on the protocol and options used. iperf is commonly used for: - Benchmarking network performance between data centers or across WAN links - Troubleshooting network issues like congestion or packet loss - Validating network infrastructure after changes or upgrades - Testing Quality of Service (QoS) implementations - Baselining network performance for future comparison - Testing and tuning wireless network performance It's worth noting that there are several versions of iperf: - iperf (version 2): The original and widely deployed version - iperf3: A rewrite with a cleaner codebase, different API, and some additional features While they serve the same basic purpose, they're not interoperable, meaning an iperf2 client cannot connect to an iperf3 server and vice versa. iperf is an essential tool for network professionals and is available on most operating systems, including Linux, macOS, Windows, and various network appliances.

    Related Commands

    These commands are frequently used alongside iperf or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the iperf command works in different scenarios.

    $ iperf
    View All Commands