Iperf is a very useful utility for network troubleshooting. In this post I’ll share my list of Iperf commands that I have found useful.
What is Iperf?
Iperf is a network performance utility that can generate both TCP and UDP traffic for testing bandwidth, latency, and packet loss. Iperf is very powerful and can easily generate enough traffic to saturate a 1Gb, or 10Gb connection. Iperf is included with most Linux distributions but you can compile Iperf for windows if needed.
In order to use Iperf you’ll need to setup an Iperf server, Iperf clients can then connect to the server in order to run tests. By default Iperf is uni-directional and sends data from the client to the server.
In my examples I’m using 192.168.1.1 as the address of my Iperf server.
Running iperf -s will setup a basic Iperf server, you can also run Iperf in daemon mode by running iperf -D.
Basic TCP Unicast Test
The simplest test you can do with Iperf is a basic TCP test. By default the server will use a TCP window size of 85.3KB. The client will connect to the server on port 5001 using a TCP window size of 16KB. The -t option instructs the client to run the test for 30 seconds instead of the default of 10 seconds.
[Server] – iperf -s -i 1
[Client] – iperf -c 192.168.1.1 -t 30
Parallel TCP connections
Parallel connections can be useful if you need to saturate the bandwidth of a link. The bandwidth of a single TCP session can be greatly affected by the size of the receive window and the latency of the link.
To enable parallel connections add the -P flag to the Iperf client parameters followed by the number of connections you want. Make sure to use a capital P, lowercase p will specify a different port number to connect on.
[Server] – iperf -s -i 1
[Client] – iperf -c 192.168.1.1 -t 30 -P 10
UDP Mode
Testing with UDP packets requires the -u flag on both the client and server. The cool thing about UDP mode is that you don’t have to use a server. Instead you can use the interface counters on your switches. You can also specify the destination address to be a multicast group, the default TTL for multicast is 1 (be careful). To set a different TTL use the -T option on the client.
If you want to test for jitter and packet loss then you should use UDP mode.
[Server] – iperf -s -i 1
[Client] – iperf -c 192.168.1.1 -t 30 -u
In UDP mode iperf defaults to 1Mb/s, you can tell it to use more bandwidth by using the -b flag followed by the number of bits/sec to send. For example, iperf -c 192.168.1.1 -u -b 100000000 would send at a rate of 100Mb/s.
Bidirectional testing
If you want to test throughput both to and from the server at the same time you can use the -d option to run a bidirectional test. This will send data to the server, and receive data from the server simultaneously.
[Server] – iperf -s -i 1
[Client] – iperf -c 192.168.1.1 -t 30 -d
Bandwidth limiting
If you need to test for packet loss or other problems at a specific rate of bandwidth you can use the -b flag to specify the maximum throughput in bits/second.
[Server] – iperf -s -i 1
[Client] – iperf -c 192.168.1.1 -t 30 -b 100000
Transfer 1GB of data then stop
Instead of running the test for a specific period of you can instruct Iperf to stop running after trasfering a certain amound of data. The example below will send 1GB (1024³) of data to the server and then stop
[Server] – iperf -s -i 1
[Client] – iperf -c 192.168.1.1 -n 1073741824
Stop the iPerf server
To kill the iperf server just press CTRL+C in your terminal and it will interrupt the process.
If you are running iPerf in daemon mode you’ll need to find the process ID first
ps -ef | grep iperf
root 16186 1 0 22:00 ? 00:00:00 iperf -s -D
Then kill it
kill 16186
Useful References
Energy Sciences Network Host Tuning Guide
Using Iperf – Guide by Jon Dugan
Taken From: http://samkear.com/networking/troubleshooting/iperf-commands-network-troubleshooting
No comments:
Post a Comment