Most readers have heard likely heard of services like speedtest.net, fast.com, or speed.cloudflare.com used to test internet speed also known as network bandwidth. The downsides of services like these is that they reply on your internet connection and more often than not a web browser. If we flip both these and are looking for a way to speed test a local connection without replying on third party services like the Internet or someone else’s servers, this is where something like Iperf comes into play.
In this blog post we will explore background, what is Iperf, how to install, and everything from basic to more advanced usage.
What is throughput?
You can think of throughput as the maximum practical bandwidth between the two servers.
What Is Iperf?
The Iperf utility, is a tool that is used to run speed tests locally without the need to an internet connection. This requires two servers one in client mode and the other in server mode. This allows you to test the throughput between the two networked computers to its limits.
What’s the difference between Iperf, Iperf2, and Iperf3?
The package named Iperf in most Linux package managers is typically iperf2 and was created as a successor to the original software released under that name.
My understanding is that iperf3 was created during a lull in development of Iperf2. Although afterwords development was then resumed of iperf2. Causing there to be two versions which are both of which are actively maintained.
Note: If you use one for the server you will be required to use the same for the client device.
How To Install
On most Linux systems the package should be available via your Linux distributions package manager.
Basic Usage
For both versions of Iperf the basic operation is the same you use the -s flag for server mode and -c for client mode. In the example below I run tests on localhost showing some rather fun numbers.
Iperf Server
For server mode, you append the -s flag to your preferred version of iperf.
In this example, the following command was used:
iperf3 -s
Client Mode
For client mode you will run the command followed by the -c flag and the host or IP you want to connect to
In this example, the we show the client connecting to localhost:
iperf3 -c localhost
Advanced Flags
Here are some flags I cherry-picked from the man pages for both applications, that I feel your most someone else would be most likely to use.
Iperf2
For the full list of Iperf2 commands check out the man page.
-e, –enhanced use enhanced reporting giving more tcp/udp and traffic information
–hide-ips hide ip addresses and host names within outputs
-o, –output <filename> output the report or error message to this specified file
-p, –port # client/server port to listen/send on and to connect
–sum-only output sum only reports
-u, –udp use UDP rather than TCP
-B, –bind <host>[:<port>][%<dev>] bind to <host>, ip addr (including multicast address) and optional port and device
-C, Enables compatibility mode
Server Specific:
-p, –port #[-#] server port(s) to listen on/connect to
-1, –singleclient run one server at a time
-t, –time # time in seconds to listen for new connections as well as to receive traffic (default not set)
-B, –bind <ip>[%<dev>] bind to multicast address and optional device
-U, –single_udp run in single threaded UDP mode
-D, –daemon run the server as a daemon
Client Specific:
-c, –client <host> run in client mode, connecting to <host>
-d, –dualtest Do a bidirectional test simultaneously (multiple sockets)
–full-duplex run full duplex test using the same socket
-r, –tradeoff Do a full-duplex test individually
-B, –bind [<ip> | <ip:port>] bind ip (and optional port) from which to source traffic
-L, –listenport # port to receive full-duplex tests back on
-P, –parallel # number of parallel client threads to run
-X, –peer-detect performs server version detection and version exchange
Iperf3
For the full list of Iperf3commands checkout the man page.
-p, –port # server port to listen on/connect to
-B, –bind <host> bind to the interface associated with the address <host>
-J, –json output in JSON format
–logfile f sends output to a log file
-d, –debug emit debugging output
Server Specific
-s, –server run in server mode
-D, –daemon runs the server as a daemon
-I, –pidfile file write PID file
-1, –one-off handle one client connection then exit
Client Specific
-c, –client <host> run in client mode, connecting to <host>
-u, –udp use UDP rather than TCP
-t, –time # time in seconds to transmit for (default 10 secs)
–cport <port> bind to a specific client port (TCP and UDP, default: ephemeral port)
-P, –parallel # number of parallel client threads to run
–bidir run in bidirectional mode.
-4, –version4 only use IPv4
-6, –version6 only use IPv6
Conclusion
If you’re looking to run speed tests between two hosts the tool to use is Iperf. Iperf uses a client-server model meaning one host needs to be running in server and the other in client mode. Both the client and server are part of the same package, so there is no need to worry about needing to install different packages. In this blog post we will cover background, what is Iperf, how to install it, and move on to everything from basic to more advanced flags.
Looking For More
Done reading, and looking for another network testing tool, then check these posts out?
Embracing a lifelong passion for technology since childhood, CJ delved into the intricate workings of systems, captivated by the desire to understand the unknown. This innate curiosity led to his discovery of Linux, a revelation that resonated deeply. With more than 7 years of on the job experience, he’s honed his technical skills as a Geek and Senior Linux Systems Administrator.
Leave a Reply