Good evening Hive community!
It's my first post in POB and I hope to follow all the guidelines, please let me know if something is out place, thanks!
Today I wanted to talk about a software that I have been using quite a lot lately at my workplace, we are currently upgrading the whole network infrastructure and we use this software for various tests before migrating the old network to the new one.
I previously had a clue on how to use it and its functionality but during the last weeks I have learned quite a lot about it, I don't want to say I mastered it 😅, but now I have a proper working understanding of the software and I wanted to share with you a quick guide on how to use it.
The software is called iperf3 and here is the official definition from their website:
iPerf3 is a tool for active measurements of the maximum achievable bandwidth on IP networks. It supports tuning of various parameters related to timing, buffers and protocols (TCP, UDP, SCTP with IPv4 and IPv6). For each test it reports the bandwidth, loss, and other parameters.
What can we use it for?
The main usage as the definition says it's to test the maximum bandwidth over links in a network, in our case we used it in conjunction with Wireshark to also verify various other info like:
checking for the right QoS marking to be applied (using Wireshark to sniff and analyse the traffic flowing over the link)
making sure the expected behaviour of the QoS configurations was achieved (for example certain traffic may have only 10-15% of bandwidth allowed of the max throughput of a link which could be a 1G port so with the correct configuration applied we would expect to see a maximum of 100-150 Mbps traffic flowing))
checking other info as drops and traffic exceeded for different protocols over different ports (TCP/UDP) as well as QoS behaviour for different types of traffic
It's quite a simple software that can do really a lot to help if you are testing in a new or existing network.
For this test my setup will be on a LAN environment (my own home router) and two devices attached to it, my own PC and a mac book pro. One device will act as the server (receiving traffic) and the other will act as the client (sending traffic).
The server is passively listening for traffic over a certain port and the client is the device that actively starts the test and defines extra modifiers to tweak it, more on that later!
What we need:
- iperf3 downloaded on both devices (it's a very tiny folder with only 2 files usually, a .dll file and iperf3 - download link at the top of the post)
- the IP addresses of the two devices (or at least of the device that will act as a server)
- the TCP or UDP port over which we want to send the traffic (facultative, this is a good modifier to add to the test if you are testing to gather different info like I explained above on what we used the software for in our case at work)
Let's start the Test
To start the test we will need to run iperf3 on one device as a Server (receiving device) this will be the device to which we are sending traffic to! To start the software as a server we will need to open a terminal (preferably with admin rights) and go inside the folder that contains the iperf3 file.
Device 1 - Windows PC - Server side
To enter in the terminal we can search CMD in windows then right click and "Run as an administrator"...
...and now we are in the terminal as admin.
Navigate to the right folder where iperf3 is located:
To run the server we need to run the following command (in this case iperf3 will listen to the default port):
If we want to specify a specific port we need to add the -p modifier (in this example I'll use port 8080):
iperf3 -s -p 8080
As you can see from the picture above first I run the command without specifying the port, then I interrupted the server with Ctrl + C and run it again but this time specifying port 8080.
Now this device is listening for incoming traffic over port 8080 and we can move over to the second device, a mac book pro in our case, which we'll use as our client and will push traffic to test the bandwidth.
Device 2 - mac book pro - Client side
To open the terminal on the mac is pretty much similar to Windows, just search in the search bar for Terminal and hit enter, this will open a terminal and then you can navigate to the right folder where you have downloaded iperf3 (if you want to have admin rights you can type sudo su and input your password).
My PC's IP address is 192.168.1.65 (the server side), it's good practice to check for connectivity with a ping test before starting the testing.
Now here is where things get a bit more complicated, here is where we specify different modifiers for changing the behaviour of the test, I will try to list the most important and their relative behaviour, also is worth mentioning that those commands are exactly the same on any OS (Windows, Mac, Linux) so once you learned how to use this software you will be able to use it on any system.
iperf3 - To run the software on Windows and Linux (used at the start of the command) ./iperf3 - To run the software on Mac OSX (used at the start of the command) -u - If you want to run the test in UDP mode (by default the test will be in TCP mode so in order to do a TCP test simply omit the -u modifier) -s - Run the software as a server -c (-c x.x.x.x) - Connect to x.x.x.x (IP address of the server to which we are trying to push traffic to, used in client mode) -l - length (100, 400, 750, 1200, etc) -b - bandwidth (1M ,5M, 10M, 100M, 1G, etc) -t - time (in seconds)
This are not all the commands, but only the most important and usually used, you can find the list of all the modifiers in the links I provided at the start of the post.
So a basic usage of the software in client mode would be:
- TCP test
iperf -c x.x.x.x -b <speed> -l <length> -t <time> -p <port> (windows, linux) ./iperf -c x.x.x.x -b <speed> -l <length> -t <time> -p <port> (mac osx) x.x.x.x = ip address of the server <speed> = 1 (if we omit the M it's 1kbps I think) 1M, 10M, 100M, 1G = 100, 200, 400, 750, 900, 1200, etc = in seconds 10, 60, 600, 3000, etc = the server's listening port
- UDP test
iperf -u -c x.x.x.x -b <speed> -l <length> -t <time> -p <port> (windows, linux) ./iperf -u -c x.x.x.x -b <speed> -l <length> -t <time> -p <port> (mac osx) x.x.x.x = ip address of the server <speed> = 1 (if we omit the M it's 1kbps I think) 1M, 10M, 100M, 1G = 100, 200, 400, 750, 900, 1200, etc = in seconds 10, 60, 600, 3000, etc = the server's listening port
In our example we will need to connect to my Windows PC that is listening over port 8080, the IP address of the machine is 192.168.1.65 (verified above). I will start with a simple test and gradually will add options and we'll see the test results change accordingly.
First test, default settings (10 sec default):
./iperf3 -c 192.168.1.65 -p 8080
Client side (sending traffic and actively starting the test):
Server side (receiving traffic and passively listening for traffic):
As you can see from the test we are sending aroung 50-60 Mbps and receiving the same amount, no big loss here, everything looks cool.
Next test, I will add some modifiers like bandwidth and length, and maybe will make it run for 30 sec this time:
./iperf3 -c 192.168.1.65 -b 10M -l 400 -t 30 -p 8080
You can see the test now is pushing 10Mbps and on the other side my Windows PC is receiving 10M, no packet loss we can say.
Now let's try to run the test in UDP and because of the nature of UDP the test itself will be able to tell us if there is packet loss or not:
./iperf3 -u -c 192.168.1.65 -b 50M -l 400 -t 30 -p 8080
Here you can see the stats from the sending and receiving devices and you can notice there is a new stat that previously with a TCP test we did not have, datagrams lost, and we can see there has been some packet loss and we can also see on the terminal screen some datagrams that arrived at the wrong order. (that is just the last part of the test, the whole terminal would have been way too long as there have been quite a lot of packets out of order as you can see, also we had loads of those messages because of the -l 400 modifier, at the next text I will omit it and you will see a little difference in the result)
Let's try a similar UDP test this time that goes just a little bit above my maximum bandwidth (around 70-80Mbps), because this test is done on my local network and the traffic is flowing through my router I believe that will be my maximum throughput, I might be wrong, but we will try to make the same test after with a different setup (I will remove the router and connect the two devices directly to each other with an ethernet cable, then I will set those two devices on the same subnet with a static IP configuration, because the router won't be there anymore with the limit of 70-80Mbps I should expect to see my maximum throughput to increase to the maximum seed of my network cards (hopefully 1G)
./iperf3 -u -c 192.168.1.65 -b 100M -t 30 -p 8080
And as expected you can see we are dropping a lot of packets here, even more than expected honestly.
The server is the device that receives the traffic, it's the one listening and ready to receive the incoming traffic.
The client is the device that sends the traffic and hence can define additional options for the test such as bandwidth, length, speed, etc etc.
Once we are done with the test one way, we can always do the same test in the other direction, when testing a network it's always good practice to test both ways! If the traffic can flow one way this is no way a warranty that it will also flow through in the other direction! As a matter of fact when I was setting up the test I noticed that from the PC sending traffic to the mac I was good, but the other way around the traffic was blocked! I had to temporarily disable my Window firewall in order to receive traffic from iperf3 for the sake of this test.
This pretty much sums up the main usage for the software 😀
Now, as I mentioned previously I will try to do the same test but this time directly from one pc to the other without any router in the middle, the mac book bro unfortunately could not read the adapter so for this test I will use another machine I have with Linux installed.
For this test I quickly disconnected the devices from the wifi, connected with a cable to each other, assigned to a dumb subnet and pinged one to each other to ensure connectivity).
PC IP address : 10.10.10.20 (Black terminal with green characters)
Linux IP address : 10.10.10.30 (Black terminal with white characters)
Here's the successful ping test, we are ready to start iperf3!
For this bunch of tests I will use the Linux as the server:
./iperf3 -s -p 8080
The Linux now is listening, so let's push some traffic from my PC (Let's start with 50M where previously we started experiencing drops, let's see if we won't drop any packet as expected):
And as expected there are no significant drops because now our 70Mbps limit is gone, let's push first 100M, 500M and then 1G and see if all the packets will flow through (We expect to see 500M flow with no issue and maybe a bit of drops with 1G)!
For all of the following tests I will use the UDP option to show you the packet drop rate directly from the test (in the office we use to check stuff also directly on the switchports and obviously not all the traffic in a network is UDP so you probably understand that this test can be tweaked on occasion depending on what you need on the moment, simple but brilliant little tool with a big range of options and usability) but anyway let's run the last bunch of tests!
So as we can see from this little testing session that we had together the results of the test confirms what we have been saying in this post!
My connection is a normal 70-80Mbps and that is the limit applied by the router and when we push traffic above that limit we start experiencing packet loss, below that number we are ok, above we drop significantly.
Once we get rid of the router in the middle (and the 70-80Mbps limit with it) we can push up to 1G of traffic between the two devices without any significant packet loss.
This is pretty much all for today!
Bear in mind that this is not 100% of the things you can do with this software, there are many more commands and options we can use that I did not mention in this article, like the -cport modifier to define from what port we want the source to send and the -B modifier used when we want to bind a certain device (by IP address) to the -cport source port, It's a command we used a couple of times in the office for certain more specific tests but I did not find any proper usage to explain it today here so I decided to skip it!
Feel free to comment and ask any question, I'll be happy to answer!
Also I think it's worth to mention that this is my first tutorial and article here and if you want to give me an advice or a critique please feel free to do so! Will be highly appreciated! Thanks.
Happy testing! 😀
I tried to leave the sources where needed and I hope to have respected everyone's work in doing so!
Thanks to the iperf3 developers, this software is a brilliant tool!
iperf3 Contact Page