How to use the command iperf (with examples)

How to use the command iperf (with examples)

Iperf is a command-line tool used to measure the network bandwidth between computers. It provides information on the throughput, jitter, and packet loss of a network. This article will illustrate various use cases of the iperf command.

Use case 1: Run iperf on a server

Code:

iperf -s

Motivation: Running iperf in server mode allows the server to listen for incoming connections from the client. This use case is useful when you want to test the network bandwidth between two computers.

Explanation: The -s argument tells iperf to run in server mode. It instructs the iperf program to act as the server and listen for incoming connections.

Example output:

-----------------------------------------------------------
Server listening on TCP port 5001

Use case 2: Run iperf on a server using UDP mode and set the server port to listen on 5001

Code:

iperf -u -s -p 5001

Motivation: UDP (User Datagram Protocol) is a connectionless protocol that is often used for real-time applications such as video streaming or VoIP. Running iperf in UDP mode allows you to test the network bandwidth under UDP traffic conditions.

Explanation: The -u argument enables UDP mode in iperf. The -s argument tells iperf to run in server mode. The -p argument sets the server port to listen on port 5001.

Example output:

-----------------------------------------------------------
Server listening on UDP port 5001

Use case 3: Run iperf on a client

Code:

iperf -c server_address

Motivation: Running iperf on a client allows you to initiate a connection with the iperf server running on the server_address and measure the network bandwidth between the two computers.

Explanation: The -c argument tells iperf to run in client mode. It instructs the iperf program to act as the client and connect to the iperf server on the specified server_address.

Example output:

-----------------------------------------------------------
Client connecting to server_address, TCP port 5001

Use case 4: Run iperf on a client every 2 seconds

Code:

iperf -c server_address -i 2

Motivation: Running iperf with the -i argument allows you to set the interval between successive bandwidth reports. This is useful if you want to monitor the network bandwidth over a period of time.

Explanation: The -i argument sets the interval between bandwidth reports in seconds. In this case, the interval is set to 2 seconds.

Example output:

[ ID] Interval        Transfer        Bandwidth
[  4]  0.0- 2.0 sec   256 KBytes  1.05 Mbits/sec
[  4]  2.0- 4.0 sec   256 KBytes  1.05 Mbits/sec
[  4]  4.0- 6.0 sec   256 KBytes  1.05 Mbits/sec

Use case 5: Run iperf on a client with 5 parallel threads

Code:

iperf -c server_address -P 5

Motivation: Running iperf with multiple parallel threads allows you to simulate concurrent network connections and measure the aggregate network bandwidth between the client and the server.

Explanation: The -P argument sets the number of parallel threads to use. In this case, 5 parallel threads are used.

Example output:

[ ID] Interval        Transfer        Bandwidth
[  4]  0.0-10.0 sec   448 KBytes   366 Kbits/sec
[  5]  0.0-10.0 sec   448 KBytes   366 Kbits/sec
[  6]  0.0-10.0 sec   448 KBytes   366 Kbits/sec
[  7]  0.0-10.0 sec   448 KBytes   366 Kbits/sec
[SUM]  0.0-10.0 sec  1.75 MBytes  1.47 Mbits/sec

Use case 6: Run iperf on a client using UDP mode

Code:

iperf -u -c server_address -p 5001

Motivation: Running iperf in UDP mode on the client allows you to measure the network bandwidth under UDP traffic conditions between the client and the server.

Explanation: The -u argument enables UDP mode in iperf. The -c argument tells iperf to run in client mode. The -p argument specifies the server port to connect to.

Example output:

[  4]  0.0-10.0 sec  1.07 MBytes   899 Kbits/sec   0.087 ms  1055/  762 (79%)

Conclusion:

Iperf is a versatile command-line tool that allows you to measure the network bandwidth between computers. By using different arguments and options, you can customize the behavior of iperf according to your specific use case. Whether you want to test network performance under TCP or UDP traffic conditions, monitor network bandwidth over time, or simulate multiple concurrent connections, iperf provides the flexibility to meet your requirements.

Related Posts

How to use the command 'libtool' (with examples)

How to use the command 'libtool' (with examples)

The command ’libtool’ is a generic library support script that simplifies the usage of shared libraries by providing a consistent and portable interface.

Read More
How to use the command `pnmscalefixed` (with examples)

How to use the command `pnmscalefixed` (with examples)

Description: The pnmscalefixed command is a part of the Netpbm package, and it allows you to scale a PNM (Portable aNyMap) image quickly with possibly reduced quality.

Read More
How to use the command "battop" (with examples)

How to use the command "battop" (with examples)

Battop is an interactive viewer for the batteries installed in your notebook.

Read More