Tuesday, July 26, 2011

Measure Network Performance: Find Bandwidth, Jitter, Datagram Loss With Iperf


Typically, your user sends network throughput problems reports as they see problem with their applications such as:
[a] FTP Transfer
[b] NFS Performance
[c] HTTP / SMTP / POP3 etc
As a sys admin you should able confirm the throughput problem. iperf is the tool you are looking to find out:
a) Network throughput problem
b) Packet loss problem
c) Datagram loss
d) Delay jitter
From the man page:
iperf is a tool to measure maximum TCP bandwidth, allowing the tuning of various parameters and UDP characteristics.
iperf works on client / server model. You need to install iperf on both client computer and server computer to measure network performance between two nodes.
So by comparing the reported applications throughput with the measured TCP throughput and the measured available bandwidth, it is possible:
a) To Find out applications problems
b) TCP stack problems
c) Network issues
d) Bandwidth bottleneck problems etc
There is also ttcp program, which is a benchmarking tool for determining TCP and UDP performance between 2 systems.

Taks: Install iperf

If you are using Debian / Ubuntu Linux, enter:
$ sudo apt-get install iperf
If you are using FreeBSD, enter:
# cd /usr/ports/benchmarks/iperf
# make install clean

Source code installation for RHEL / CentOS:
# gunzip -c iperf-.tar.gz | tar -xvf -
# cd iperf-
# make; make install

You can also use the yum command as follows with EPEL repo:
# yum install iperf

Start iperf on server

To start iperf on server, type the following command:
root@freebsd42 # /usr/local/bin/iperf -s
Output:
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 64.0 KByte (default)
------------------------------------------------------------

Test iperf from client

Try to connect to your FreeBSD server called freebsd42 using Linux client located in other data center, enter:
$ iperf -c freebsd42
Output (note my freebsd42 server is on slow internet link):
------------------------------------------------------------
Client connecting to freebsdbox, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.106 port 40256 connected with 71.zzz.xxx.yyy port 5001
[  3]  0.0-10.7 sec    624 KBytes    480 Kbits/sec
The last line (the red numbers) specifies the speed.

Use UDP rather than TCP

The -u option force to use UDP. The following example run udp test and bandwidth to send at in bits/sec is specified using the -b option:
$ iperf -c rhelbox -u -l 512 -b 10m

Further readings:

  • iperf project home page
  • iperf man page

Other Recommended Bandwidth Measurement Tools

Apart from iperf, you can also use following tools to evaluate the bandwidth between two points in the network:
  1. Bandwidth Test Controller (BWCTL)
  2. ndt (Network Diagnostic Tool)
  3. Netperf (network performance benchmark)
  4. Thrulay (Improved version)