How to Use Iperf Like a Pro for Network Testing and Optimization

how to use iperf

Introduction:

Iperf is an open-source tool specifically for network testing and troubleshooting, it can help you with measuring the network performance, identifying bottlenecks and issues in the network.

It provides precise details about the traffic, it’s simple, effective and compatible with all platforms and operating systems, making it the go-to tool for network troubleshooting.

In this guide, I’ll discuss how you can get the most out of this Iperf, and the ways to use it for troubleshooting or testing the performance.

What is Iperf?

Iperf is a tool to measure the maximum bandwidth between two points on a network, providing several parameters for more information about the connection, by simulating a real data transfer between these two points on the network.

What does Iperf do?

Mainly Analysing the Network performance and traffic.

Its main Features can include:

1) throughput testing:

Iperf checks the maximum possible bandwidth between two points on a network, ultimately, measuring the throughput.

2) Network Protocols (TCP and UDP) performance testing:

Iperf tests TCP protocol that focus on reliable throughput and connection.

Also, can perform UDP test for connectionless testing, providing metrics like jitter and packet loss.

3) Performance metrics:

Iperf provides information about several metrics, like transfer speed, data size sent, in addition to 

UDP metrics

4) Customize Traffic:

You can customize the traffic for testing by setting limits for bandwidth or packets size or specific duration for the tests.

5) Compatible with Multiple platforms:

Iperf is supported by windows, mac and linux and some other systems, making it flexible with different environments.

How to Install Iperf with the latest version (Iperf3)?

Installing Iperf3 on Windows:

First, Download the Iperf executable file for windows here

Once downloaded, extract the ZIP file and open the exe file to install Iperf ( you might need an admin access):

windows download iperf

Now, to start using Iperf

Click on the path in the bar:

iperf directory windows

Remove the path and write “cmd” instead and hit enter:

open cmd windows

The command prompt will open and you will be in the same directory:

command prompt windows

To open the Iperf Help, write iperf3.exe in the command prompt:

use iperf on windows

Installing Iperf3 on MacOS:

To install Iperf on MacOS, you can use brew, if you don’t have brew installed on your MacOS, you can install it from the brew website.

Open the terminal on your Mac:

MacOS terminal

Enter brew install iperf3 in the terminal:

install iperf on MacOS with brew

Installing Iperf3 on Linux:

On debian or ubuntu you can type the following command to install iperf3:

Also on CentOS/Redhat:

How to Use Iperf?

Iperf uses a client-server model, where one of the points on a network will act as a server waiting for requests, while the other point will act as client initiating requests to the server.

Mostly, it doesn’t matter which point is the server and which one is the client, however, I prefer to give the server role to the higher specification and demand device on the network, as it can handle requests from several clients.

Iperf Client-Server Model:

In this example, I have two machines, windows and windows server, they are on the same network.

There is a switch and access point between them. The topology would look something like this:

iperf test network topology

Setting Up Iperf Server:

On the windows server, open command prompt as administrator and navigate to the folder where you saved iperf3.exe application:

iperf server

Enter the command as below:

The Iperf server will start like this:

use iperf server

Setting up Iperf client:

Now we can run test from the windows machine that will act as an iperf client.

On client machine, Open the command prompt and navigate to the location where you saved iperf (if windows):

iperf client

Running a basic test:

iPerf will perform a default 10-second TCP test and display results, including throughput and data transferred.

Enter the command as follows:

The output will be displayed on the command prompt as follows:

use iperf client

Running UDP test:

To run UPD test enter the following command:

The output will show also the jitter and the packet loss parameters:

use udp with iperf

Set a duration:

You can set a duration in seconds by entering the following command:

Duration should be entered in seconds.

Restrict Bandwidth:

You can setup a bandwidth maximum value to check the performance within a specific bandwidth:

[bandwidth] variable can be in megabits or gigabit or kilobits, for example:

50M means 50 Megabit per second bandwidth

Run Multiple connactions:

You can run multiple connections with parallel data streams:

Here I run 2 connections, iperf will display each packet and the SUM of them:

run multiple iperf connections

Explaining the parameters:

Bandwidth (Mbits/sec): it represents the number of bits, kilobits, megabits or gigabit transmitted over a network during a specific time, typically during a second, so it can be Bps, Kbps, Mbps or Gbps. 

Transfer Size: the total amount of data transferred (sent or received) during the period of testing.

Jitter(UDP): it represents the variations in the packets arrival times.

Packet Loss(UDP): percentage of lost packets during transmission.

More advanced Iperf Options:

Saving the test results to text file:

The result.txt file is our output here, it would look like this:

iperf output to file

Saving the output to JSON format:

Note: the output files will be saved in the same directory where iperf3.exe is saved.

Run iperf in the background:

You can run iperf in the background to keep it for future testing:

Troubleshooting Iperf connection:

If you are having an issue with iperf connection, you can check some of the thing listed below:

– try to ping the server from the client, if the client can’t reach the server through bing, make sure that both are on the same network or connected via VPN.

– if you can ping the server but iperf still won’t connect, check the firewall on your server and the client, try to add a firewall rule to allow connection through 5201 port.

Conclusion:

Iperf is a valuable tool for network performance testing, you can use it at our business or home network.

By following this guide, you’ll be able to use iperf and interpret the parameters it can provide.

You can use it also for reporting about the network performance.

Related Articles