jump to navigation

How to test Network Throughput using iperf January 21, 2011

Posted by Tournas Dimitrios in Linux.

iperf is a network performance measurement tool  that measures the TCP /UDP throughput of the network . In data transmission , throughput is the amount of data transferred successfully over a link from one end to another in a given period of time , it is usually expressed in bits per second (bps) .

iperf has a client and server functionality , and can measure the throughput  between the two ends , either unidirectional or bi-directional . It allows the user to set various parameters that can be used for testing a network , or alternately for optimizing or tuning a network .

It is capable of generating traffic using TCP and UDP. The TCP and UDP tests are useful for performing the following kinds of tests:

  • Latency (response time or RTT): can be measured with the Ping utility.
  • Jitter: can be measured with an Iperf UDP test
  • Datagram loss: can again, be measured with an Iperf UDP test.
  • Throughput  tests are done using the Iperf TCP tests.

Bandwidth vs Throughput

Bandwidth : Refers how fast a device can send data over a single communication channel .
Throughput: Refers how fast a device is actually sending data over the communication channel.

There are two versions of Iperf being maintained, Iperf 2.x and Iperf3. The latest version is a new implementation from scratch, with the goal of a smaller, simpler code base, and a library version of the functionality that can be used in other programs. iperf3 is not backwards compatible with iperf2.x . My favorite CentOs 5.x repository EPEL provides only the old version (ver 2) , but it is adequate to demonstrate the functionality of this utility . Just istall it : yum  install  iperf

Quick Howto

Here is the iperf quick howto to get started:

  • Run the Iperf Server in a machine with -s
  • Run the Iperf client in another machine using -c and the IP Address of the Iperf Server
  • Finish, you will get your result

I never buy ready-made ethernet cables for my SOHO needs , so iperf is an excellent way to test my ethernet cables under heavy work loads .

Client and Server options
Command line option Description
-f, –format [bkmaBKMA] A letter specifying the format to print bandwidth numbers in.
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 formats choose between kilo- and mega- as appropriate. Fields other than bandwidth always print bytes, but otherwise follow the requested format. Default is ‘a’.
NOTE: here Kilo = 1024, Mega = 1024^2 and Giga = 1024^3 when dealing with bytes. Commonly in networking, Kilo = 1000, Mega = 1000^2, and Giga = 1000^3 so we use this when dealing with bits. If this really bothers you, use -f b and do the math.

-i, --interval Sets the interval time in seconds between periodic bandwidth, jitter, and loss reports. If non-zero, a report is made every interval seconds of the bandwidth since the last report. If zero, no periodic reports are printed. Default is zero.
-p, --port The server port for the server to listen on and the client to connect to. This should be the same in both client and server. Default is 5001, the same as ttcp.
-u, --udp Use UDP rather than TCP. See also the -b option.
-w, --window Sets the socket buffer sizes to the specified value. For TCP, this sets the TCP window size. For UDP it is just the buffer which datagrams are received in, and so limits the largest receivable datagram size.
Server specific options
Command line option Description
-s, --server Run Iperf in server mode.
-D (from v1.2 or higher) Run the server as a daemon (Unix platforms)
On Win32 platforms where services are available, Iperf will start running as a service.
-R (only for Windows, from v1.2 or higher) Remove the Iperf service (if it’s running).
-o (only for Windows, from v1.2 or higher) Redirect output to given file.
-c, --client host If Iperf is in server mode, then specifying a host with -c will limit the connections that Iperf will accept to the host specified. Does not work well for UDP.
Client specific options
Command line option Description
-c, --client host Run Iperf in client mode, connecting to an Iperf server running on host.
-d, --dualtest Run Iperf in dual testing mode. This will cause the server to connect back to the client on the port specified in the -L option (or defaults to the port the client connected to the server on). This is done immediately therefore running the tests simultaneously. If you want an alternating test try -r.
-t, --time The time in seconds to transmit for. Iperf normally works by repeatedly sending an array of len bytes for time seconds. Default is 10 seconds. See also the -l and -n options.
-L, --listenport This specifies the port that the server will connect back to the client on. It defaults to the port used to connect to the server from the client.
-n, --num The number of buffers to transmit. Normally, Iperf sends for 10 seconds. The -n option overrides this and sends an array of len bytes num times, no matter how long that takes. See also the -l and -t options.
-T, --ttl The time-to-live for outgoing multicast packets. This is essentially the number of router hops to go through, and is also used for scoping. Default is 1, link-local.

All these options and more are mentioned in a  file ” /usr/share/doc/iperf-xxx/index.html” copy this file to your web server’s root directory and read it with your browser  or open a browser and type :

Developers in the community have also created a GUI for Iperf called Jperf, which is a Java based GUI that allows you to save settings, and more easily make changes to your settings. For information on Iperf head on over to the Wiki page, or their page over at SourceForge.

Links :

Run the server as a daemon (Unix platforms)
On Win32 platforms where services are available, Iperf will start running as a service.


1. Yunar (@ywinardi) - February 18, 2016

Thank you, this is what i’m looking for because i need to find out what speed that i got from my ISP. Speedtest seems not too accurate to test throughput. I found iperf is more accurate.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s