iperf

Network performance testing tools

Supplementary instructions

iperf command is a network performance testing tool. iperf can test TCP and UDP bandwidth quality. iperf can measure maximum TCP bandwidth, with various parameters and UDP characteristics. iperf can report bandwidth, latency jitter and packet loss. Using the feature of iperf, you can test the performance of some network devices such as routers, firewalls, switches, etc.

iperf is divided into two versions, Unix/Linux version and Windows version. The Unix/Linux version is updated faster and has the latest version. The Windows version is slow to update. The Windows version of iperf is called jperf, or xjperf. jperf is based on iperf and develops better UI and new functions.

Linux version download address: http://code.google.com/p/iperf/downloads/list

Install iperf

For the Windows version of iperf, directly copy the decompressed iperf.exe and cygwin1.dll to the %systemroot% directory. For the Linux version of iperf, please use the following command to install it:

gunzip -c iperf-<version>.tar.gz | tar -xvf -
cd iperf-<version>
./configure
make
make install

Options

-f, --format \[bkmaBKMA] # Format bandwidth number output. Supported formats are:
                            # 'b' = bits/sec
                            # 'B' = Bytes/sec
                            # 'k' = Kbits/sec
                            # 'K' = KBytes/sec
                            # 'm' = Mbits/sec
                            # 'M' = MBytes/sec
                            # 'g' = Gbits/sec
                            # 'G' = GBytes/sec
                            # 'a' = adaptive bits/sec
                            # 'A' = adaptive Bytes/sec The adaptive format is one of kilo- and mega-.
                            # Fields except bandwidth are output as bytes, unless the output format is specified, the default parameter is a.
                            # Note: When calculating bytes, Kilo = 1024, Mega = 1024^2, Giga = 1024^3.
                            # Usually, in the network, Kilo = 1000, Mega = 1000^2, and Giga = 1000^3, so Iperf also calculates bits accordingly.
                            # If this bothers you, please use the -f b parameter and calculate it yourself.
-i, --interval # # Set the time interval between each report, in seconds. If set to a non-zero value, test reports will be output at this interval. The default value is zero.
-l, --len #\[KM] # Set the length of the read and write buffer. The default value for TCP mode is 8KB, and the default value for UDP mode is 1470 bytes.
-m, --print\_mss # Output TCP MSS value (supported by TCP\_MAXSEG). The MSS value is generally 40 bytes smaller than the MTU value. Usually
-p, --port # # Set the port to be consistent with the listening port of the server. The default is port 5001, which is the same as ttcp.
-u, --udp # Use UDP instead of TCP. See the -b option.
-w, --window #\[KM] # Set the socket buffer to the specified size. For TCP mode, this setting is the TCP window size.
                            # For UDP mode, this setting is the buffer size for accepting UDP data packets, limiting the maximum value of data packets that can be accepted.
-B, --bind host # Bind to one of multiple addresses of the host. For the client, this parameter sets the pop-out interface. For the server side,
                            # This parameter sets the push interface. This parameter is only used for hosts with multiple network interfaces. In Iperf's UDP mode, this parameter is used to bind and join a multicast group.
                            # Use multicast addresses in the range 224.0.0.0 to 239.255.255.255. Refer to the -T parameter.
-C, --compatibility # When used with a lower version of Iperf, compatibility mode can be used. It is not required that both ends use compatibility mode at the same time, but it is strongly recommended that both ends use compatibility mode at the same time.
                            # In some cases, using certain data streams can cause the 1.7 version of the server to crash or cause unexpected connection attempts.
-M, --mss # Subtract 40 bytes from the ip header. In Ethernet, the MSS value is 1460 bytes (MTU1500 bytes). Many operating systems do not support this option.
-N, --nodelay # Set TCP no-delay option and disable Nagle's algorithm. Normally this option is disabled for interactive programs, such as telnet.
-V (from v1.6 or higher) # Bind an IPv6 address. Server: $ iperf -s -V Client: $ iperf -c -V Note: In versions 1.6.3 or later, specifying an IPv6 address does not require binding with the -B parameter, which is required in versions before 1.6. In most operating systems, the IPv4 client will respond with the mapped IPv4 address.

Server-side specific options

-s, --server # Iperf server mode
-D (v1.2 or higher) # Iperf runs as a background daemon on Unix platforms. Under Win32 platform, Iperf will run as a service.
-R (v1.2 or higher, Windows only) # Uninstall the Iperf service (if it is running).
-o (v1.2 or higher, Windows only) # Redirect output to the specified file
-c, --client host # If Iperf is running in server mode and a host is specified with the -c parameter, Iperf will only accept connections from the specified host. This parameter does not work in UDP mode.
-P, --parallel # # Number of connections to keep before the server is shut down. The default is 0, which means connections are always accepted.

Client-specific options

-b, --bandwidth #\[KM] # Bandwidth used in UDP mode, unit bits/sec. This option is related to the -u option. The default value is 1 Mbit/sec.
-c, --client host # Run Iperf client mode and connect to the specified Iperf server.
-d, --dualtest # Run dual test mode. This will make a reverse connection from the server side to the client,
                              # Use the port specified in the -L parameter (or the default port used by the client to connect to the server).
                              # These are completed immediately while operating. If you want an interactive test, try the -r parameter.
-n, --num #\[KM] # Number of buffers to transfer. Normally, Iperf sends data in 10 seconds.
                              # The -n parameter crosses this limit and sends data of the specified length the specified number of times, regardless of how long the operation takes. See the -l and -t options.
-r, --tradeoff #Traffic test mode. When the client-to-server test ends, the port specified by the -l option on the server side (or defaults to the port on which the client connected to the server side),
                              # Reverse connection to client. When the client connection is terminated, the reverse connection begins. If you need to test both directions simultaneously, try the -d parameter.
-t, --time # # Set the total time of transmission. Iperf repeatedly sends data packets of a specified length within a specified time. The default is 10 seconds. See the -l and -n options.
-L, --listenport # # Specify the port used by the server to reversely connect to the client. By default, the port used by the client to connect to the server is used.
-P, --parallel # # Number of threads. Specify the number of threads used between the client and server. The default is 1 thread. This parameter needs to be used by both the client and the server.
-S, --tos # # Service type for popping packets. Many routers ignore the TOS field. You can specify this value using a hexadecimal number starting with "0x",
                              # Or an octal or decimal number starting with "0". For example, hexadecimal '0x10' = octal '020' = decimal '16'.
                              # TOS value 1349 is: IPTOS\_LOWDELAY minimize delay 0x10 IPTOS\_THROUGHPUT maximize
                              # throughput 0x08 IPTOS\_RELIABILITY maximize reliability 0x04 IPTOS\_LOWCOST minimize cost 0x02
-T, --ttl # # TTL value of multicast packets. This is essentially the number of hops the data takes through the router. The default is 1, link local.
-F (from v1.2 or higher) # Measure bandwidth using a specific data stream, such as a specified file. $ iperf -c -F
-I (from v1.2 or higher) # Same as -F, input data from standard input and output files.

Miscellaneous

-h, --help # Display command line reference and exit.
-v, --version # Display version information and compilation information and exit.

Example

Bandwidth testing usually uses UDP mode because it can measure the ultimate bandwidth, delay jitter, and packet loss rate. When testing, first test with the theoretical bandwidth of the link as the data sending rate. For example, the theoretical bandwidth of the link from the client to the server is 100Mbps. First use -b 100M to test, and then based on the test results (Including actual bandwidth, delay jitter and packet loss rate), and then use the actual bandwidth as the data transmission rate to test, you will find that the delay jitter and packet loss rate are much better than the first time, repeat the test several times, you can get Stable actual bandwidth.

UDP Mode

Service-Terminal:

iperf -u -s

Client:

iperf -u -c 192.168.1.1 -b 100M -t 60

In udp mode, use 100Mbps as the data transmission rate, client to server 192.168.1.1 upload bandwidth test, test the time is 60 seconds.

iperf -u -c 192.168.1.1 -b 5M -P 30 -t 60

The client initiates 30 connection threads to the server at the same time, with a data sending rate of 5Mbps.

iperf -u -c 192.168.1.1 -b 100M -d -t 60

Use 100M as the data transmission rate to conduct uplink and downlink bandwidth tests.

TCP Mode

Service-Terminal:

iperf -s

Client:

iperf -c 192.168.1.1 -t 60

In tcp mode, the client uploads the bandwidth test to the server 192.168.1.1, and the test time is 60 seconds.

iperf -c 192.168.1.1 -P 30 -t 60

The client initiates 30 connection threads to the server at the same time.

iperf -c 192.168.1.1 -d -t 60

Conduct uplink and downlink bandwidth tests.