How to use the command iperf3 (with examples)
Iperf3 is a traffic generator used for testing network bandwidth. It allows users to measure the maximum achievable bandwidth between two endpoints. This article will provide examples of various use cases of the iperf3 command.
Use case 1: Run iperf3 as a server
Code:
iperf3 -s
Motivation: Running iperf3 as a server allows you to wait for incoming connections and test the bandwidth between the server and the client.
Explanation: The -s
option is used to start the iperf3 server.
Example output:
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Use case 2: Run an iperf3 server on a specific port
Code:
iperf3 -s -p port
Motivation: Running the iperf3 server on a specific port allows you to define a custom port for the server to listen on.
Explanation: The -p
option followed by the desired port number is used to specify the port on which the iperf3 server will listen.
Example output:
-----------------------------------------------------------
Server listening on port port
-----------------------------------------------------------
Use case 3: Start bandwidth test
Code:
iperf3 -c server
Motivation: Initiating a bandwidth test with iperf3 allows you to measure the network throughput between the client and server.
Explanation: The -c
option followed by the server IP or hostname is used to initiate a bandwidth test to the specified server.
Example output:
-----------------------------------------------------------
Client connecting to server, TCP port 5201
TCP window size: 128 KByte (default)
-----------------------------------------------------------
[ 4] local client_ip port 60292 connected to server_ip port 5201
[ ID] Interval Transfer Bitrate
[ 4] 0.0-10.0 sec 1.09 GBytes 934 Mbits/sec
Use case 4: Run iperf3 in multiple parallel streams
Code:
iperf3 -c server -P streams
Motivation: Running iperf3 with multiple parallel streams allows you to simulate multiple connections and measure the aggregate bandwidth.
Explanation: The -P
option followed by the number of parallel streams is used to specify the number of connections that iperf3 will simulate.
Example output:
-----------------------------------------------------------
Client connecting to server, TCP port 5201
TCP window size: 128 KByte (default)
-----------------------------------------------------------
[ 4] local client_ip port 60396 connected to server_ip port 5201
[ 6] local client_ip port 60398 connected to server_ip port 5201
[ ID] Interval Transfer Bitrate
[ 4] 0.0-10.0 sec 576 MBytes 483 Mbits/sec
[ 4] 10.0-20.0 sec 568 MBytes 476 Mbits/sec
[ 6] 0.0-10.0 sec 392 MBytes 329 Mbits/sec
[ 6] 10.0-20.0 sec 493 MBytes 414 Mbits/sec
Use case 5: Reverse direction of the test (Server sends data to the client)
Code:
iperf3 -c server -R
Motivation: Reversing the direction of the test allows you to measure the network bandwidth in the opposite direction, with the server sending data to the client.
Explanation: The -R
option is used to reverse the direction of the test, causing the server to send data to the client.
Example output:
-----------------------------------------------------------
Client connecting to server, TCP port 5201
TCP window size: 128 KByte (default)
-----------------------------------------------------------
[ 4] local client_ip port 60858 connected to server_ip port 5201
[ ID] Interval Transfer Bitrate
[ 4] 0.0-10.0 sec 1.09 GBytes 934 Mbits/sec
Conclusion:
Iperf3 is a powerful tool for testing network bandwidth and measuring the maximum achievable throughput between two endpoints. By utilizing the various command options described in this article, you can run iperf3 as a server, initiate bandwidth tests, simulate multiple connections, and even reverse the direction of the test. These examples provide a starting point for using iperf3 effectively in network testing scenarios.