iperf is a tool to measure the bandwidth and the quality of a network link (latency, packet loss…). With iperf we have a server by default listening by the port 5001/TCP and a client that will generate traffic. You can use also Jperf, a Java frontend of iperf:

Basic use

– Running the server:

freebsd-opentodo# iperf -s
------------------------------------------------------------
Server listening on <strong>TCP port 5001</strong>
TCP window size: 64.0 KByte (default)
------------------------------------------------------------

– Running the client:

[email protected] ~ $ iperf -c 192.168.1.252
------------------------------------------------------------
Client connecting to 192.168.1.252, TCP port 5001
TCP window size: 23.5 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.0.100 port 55135 connected with 192.168.1.252 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.1 sec 99.2 MBytes <strong>82.8 Mbits/sec</strong>

We can see that the bandwidth is the typical of a Fast Ethernet connection.

Measure the traffic in MB/s

By default, iperf measure the traffic in Mb/s. We can change the it with the -f option and measure in megabytes per second.

– Server:

freebsd-opentodo# iperf -s -f MB

– Client:

[email protected] ~ $ iperf -c 192.168.1.252 -f MB
------------------------------------------------------------
Client connecting to 192.168.1.252, TCP port 5001
TCP window size: 0.02 MByte (default)
------------------------------------------------------------
[ 3] local 192.168.0.100 port 55139 connected with 192.168.1.252 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 92.9 MBytes <strong>9.27 MBytes/sec</strong>

Bidirectional bandwidth measurement

With bidirectional measurement (-d option), We can test the performance connectivity with both server and client sending traffic at the same time.

– Server:

freebsd-opentodo# iperf -s

– Client:

[email protected]:~# iperf -c 192.168.1.252 -d
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
------------------------------------------------------------
Client connecting to 192.168.1.252, TCP port 5001
TCP window size: 38.4 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.1.10 port 36137 connected with 192.168.1.252 port 5001
[ 5] local 192.168.1.10 port 5001 connected with 192.168.1.252 port 20320
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 570 MBytes <strong>478 Mbits/sec</strong>
[ 5] 0.0-10.1 sec 267 MBytes <strong>223 Mbits/sec</strong>

Parallel TCP connections

With parallel TCP connections We can simulate simultaneous traffic from the client to the server. With the -P option I’ll simulate 8 simultaneous TCP connections.

– Server:

# iperf -s


– Client:

# iperf -c 192.168.1.252 -P 8

Changing the TCP window size

TCP window size is the number of bytes that one host can receive at one time. This value by default can change with every operating system and can use a value between 2 and 65535 bytes. The Window size can affect to the result of an iperf test and We can see how it affects our performance.

– Server:

# iperf -s -w 2KB
# iperf -s -w 32KB

– Client:

[email protected] ~ $ iperf -c 192.168.1.252 -w 2KB
------------------------------------------------------------
Client connecting to 192.168.1.252, TCP port 5001
TCP window size: 4.00 KByte (<strong>WARNING: requested 2.00 KByte</strong>)
------------------------------------------------------------
[ 3] local 192.168.0.100 port 56083 connected with 192.168.1.252 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-26.8 sec 384 KBytes <strong>117 Kbits/sec</strong> 
[email protected] ~ $ iperf -c 192.168.1.252 -w 32KB
------------------------------------------------------------
Client connecting to 192.168.1.252, TCP port 5001
TCP window size: 64.0 KByte (WARNING: <strong>requested 32.0 KByte</strong>)
------------------------------------------------------------
[ 3] local 192.168.0.100 port 56084 connected with 192.168.1.252 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 69.2 MBytes <strong>58.0 Mbits/sec</strong>

UDP connections

Using the -u option in the client and the server We can generate UDP traffic. With UDP traffic we can specify the bandwidth sent with -b and provides the datagram performance and packet loss.

– Server:

# iperf -s -u

– Client:

[email protected] ~ $ iperf -c 192.168.1.252 -u -b 120MB
------------------------------------------------------------
Client connecting to 192.168.1.252, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 224 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.0.100 port 45347 connected with 192.168.1.252 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 114 MBytes <strong>95.9 Mbits/sec</strong>
[ 3] Sent 81509 datagrams
[ 3] Server Report:
[ 3] 0.0-11.1 sec 1.61 MBytes 1.21 Mbits/sec 15.189 ms <strong>80289/81438 (99%)</strong>
Test network performance with iperf
Tagged on:             

Leave a Reply

Follow

Get every new post delivered to your Inbox

Join other followers: