Network Performance Measurements with iperf

About iperf

iperf is a client/server program that allows you to measure the performance of a network, in particular, TCP/UDP throughput. iperf is free software to download, available for Unix- and Windows-based operating systems. It is quite easy to use: read the man page for descriptions of all operators or browse one of the many online tutorials (1, 2).

To use iperf you run one copy as a server (which waits for connections/data) and another as a client (which initiates sending data). At the end of the data transfer the server reports the statistics (throughput, packet loss, delay) back to the client. Data transfer can be performed with either TCP or UDP.

Network Configuration

The following examples were performed on a 100Mb/s switched Fast Ethernet network. That is, the iperf client was running on a Pentium III 933MHz (with Ubuntu 8.04) and the server on a Pentium D 2.8GHz (also Ubuntu 8.04). The two computers were connected via switch (ZyXel ADSL Modem/Router/Switch) using Cat5 cabling. The IP address of the client is 192.168.1.3 and the server 192.168.1.2.

In the examples I will use the full command line options such as --server. For almost all the command line options there is a shortened form such as -s. Read the man page for details.

UDP Performance

Lets first consider the performance of UDP over the simple test network. On the server run:

iperf --server --udp

Now start the test on the client. In this test we will send UDP data at 100Mb/s for 10 seconds:

iperf --client 192.168.1.2 --udp --time 10 --bandwidth 100M

When the test is completed the output from the server looks like this:

------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size:   109 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.2 port 5001 connected with 192.168.1.3 port 39253
[  3]  0.0-10.0 sec    114 MBytes  95.7 Mbits/sec  0.013 ms    0/81435 (0%)
[  3]  0.0-10.0 sec  1 datagrams received out-of-order

while the output from the client is:

------------------------------------------------------------
Client connecting to 192.168.1.2, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size:   108 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.3 port 39253 connected with 192.168.1.2 port 5001
[  3]  0.0-10.0 sec    114 MBytes  95.8 Mbits/sec
[  3] Sent 81436 datagrams
[  3] Server Report:
[  3]  0.0-10.0 sec    114 MBytes  95.7 Mbits/sec  0.013 ms    0/81435 (0%)
[  3]  0.0-10.0 sec  1 datagrams received out-of-order

The Server Report gives us the most useful information: throughput of 95.7Mb/s, delay of 0.013ms and 0% packet loss. Note also the default parameters such as the datagram size (1470 bytes) and the buffer size (108 KBytes).

You can run further tests by starting the client again - the server remains running until you close it (e.g. Control-C). To look at details of the packets you could use packet capture software such as Wireshark or tcpdump to record the packets. For example, tcpdump is a simple command-line program to capture all packets, e.g.:

tcpdump -i eth1 -w file.cap

The above will capture all packets on interface eth1 and save them in the file file.cap. If you only want to capture packets belong to iperf (assuming there is other traffic on the network) you can specify a filter (e.g. based on the port number):

tcpdump 'port 5001' -i eth1 -w file.cap

A text summary output of the packets can be printed to the screen by omitting the -w option. Alternatively, you can read the .cap file into tcpdump (e.g. tcpdump -r file.cap) or load it into Wireshark. (Of course, you can just use Wireshark to perform the capture, but tcpdump is sometimes useful when you only have/want command-line access).

For the example capture presented above (with throughput of 95.7Mb/s) I loaded the captured packets into Wireshark. Looking at the Summary Statistics tells us that the average packet size is 1512 bytes and the average traffic is 98.365Mb/s. Does this make sense? Remember Wireshark is reporting the size of the entire frame (payload plus UDP header (8 bytes) plus IP header (20 bytes) plus Ethernet header (14 bytes)) whereas iperf is reporting results based on the 1470 byte payload in the UDP datagram. The 1470 byte payload is 97.2% of the entire 1512 byte frame. The iperf throughput of 95.7Mb/s is approximately 97.2% of the Wireshark reported traffic of 98.365Mb/s. So iperf and Wireshark are reporting the same results.

So in summary, the UDP payload throughput is 95.7Mb/s whereas the raw Ethernet throughput is 98.365Mb/s. Why not 100Mb/s in Fast Ethernet? Well, the Fast Ethernet standards states that there must be a small Inter Frame Gap (IFG) between frames. In addition, there is a physical layer header (that is not reported by Wireshark). Together these amount to the time to transmit 20 bytes at 100Mb/s (1.6usec). That is, the Ethernet MAC frame is 1512 bytes, but the equivalent of 1532 bytes must be transmitted at 100Mb/s. The best case efficiency of the MAC protocol is thus 1512/1532 = 98.695%. We are measuring 98.365%, which is very close to the best case scenario.

If you run further tests with iperf the performance results may differ slightly (e.g. due to other traffic in the network). You should normally run many tests and look at the average (and other statistics). From five tests that I ran the maximum throughput reported by iperf was 95.7Mb/s, with a delay of 0.013ms (and no packets lost). Now lets compare that TCP ...

TCP Performance

The server must be restarted to handle TCP traffic (a protocol option is not needed; by default, iperf uses TCP):

iperf --server 

When running the client we only specific the time, not the sending bandwidth, because the TCP source will try to send as fast as possible:

iperf --client 192.168.1.2 --time 10

The output from the server is:

------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  4] local 192.168.1.2 port 5001 connected with 192.168.1.3 port 54939
[  4]  0.0-10.1 sec    113 MBytes  94.1 Mbits/sec

whereas the output from the client is:

------------------------------------------------------------
Client connecting to 192.168.1.2, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.3 port 54939 connected with 192.168.1.2 port 5001
[  3]  0.0-10.0 sec    113 MBytes  94.8 Mbits/sec

Return to: Course List | Steven Gordon's Home | SIIT