When you want to test the speed of your Internet, there are a couple of helpful tools available.
Online Internet Speed check
Speedtest.net is the most widely known Internet Speed Test and tests the ISP speed between your browser and an automatically detected nearby server.
Cloudflare's Speed Test does a similar job, but shows more detailed information such as packet size, latency and loss.
Both speed test websites are launched in a browser on your device. This means: A bad device connection to the router (e.g. by using a weak WiFi signal) can interfere in the accuracy of the speed test!
To get more accurate results, we should run the speed test on the Internet router itself.
Note: For this article I'm using an AVM Fritz!Box router with OpenWRT installed. Check out this related article how to install OpenWRT on a AVM Fritzbox router.
LAN and WAN speed testing on OpenWRT router
Luckily OpenWRT routers allow to install additional tools and software. We can use the additional software and commands to launch real performance and network speed tests. And this is what this article is about.
Install iperf3 on OpenWRT
In the Linux world, the iperf command is a widely known command to measure the speed of the network. As OpenWRT is using a Linux system underneath, using the iperf command as idea is not that far fetched. And the iperf (and updated iperf3) packages can easily be installed!
To install iperf3 in the OpenWRT (LuCI) User Interface, navigate to System -> Software. Then search in the filter field for "iperf":
Note: If no packages show up under the "Available" tab, click on the "Update lists" button first.
If you feel comfortable on the command line, you can also SSH into your OpenWRT router and launch the following command (as root):
root@OpenWrt:~# opkg install iperf3
The iperf3 command is now available on your OpenWRT router.
Measuring LAN speed (LAN to Router)
Let's first test the speed of the internal LAN from a workstation to the OpenWRT router. You should use a workstation which is connected using a wired network connection.
To achieve this, we use the router as iperf3 server. SSH into your OpenWRT router (same credentials as logging into the User Interface) and launch the following command:
root@OpenWrt:~# iperf3 -s
-----------------------------------------------------------
Server listening on 5201 (test #1)
-----------------------------------------------------------
This starts a listener on TCP port 5201 on the OpenWRT router.
On your workstation, iperf3 is started in client mode. Install the iperf3 package:
- Debian / Ubuntu / Linux Mint: sudo apt install iperf3
- Fedora / Rocky Linux / Enterprise Linux: sudo dnf install iperf3
- macOS: brew install iperf3 (you need Homebrew)
- Windows: Download and install iperf3 from the iperf3 Download page
Then launch the following command on your workstation in a Terminal (or cmd.exe in Windows):
ck@mint ~ $ iperf3 -c 192.168.1.1
Connecting to host 192.168.1.1, port 5201
[ 5] local 192.168.1.15 port 49228 connected to 192.168.1.1 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 114 MBytes 953 Mbits/sec 0 445 KBytes
[ 5] 1.00-2.00 sec 112 MBytes 941 Mbits/sec 0 445 KBytes
[ 5] 2.00-3.00 sec 112 MBytes 938 Mbits/sec 0 445 KBytes
[ 5] 3.00-4.00 sec 111 MBytes 930 Mbits/sec 116 348 KBytes
[ 5] 4.00-5.00 sec 112 MBytes 943 Mbits/sec 0 372 KBytes
[ 5] 5.00-6.00 sec 112 MBytes 943 Mbits/sec 0 375 KBytes
[ 5] 6.00-7.00 sec 112 MBytes 941 Mbits/sec 0 378 KBytes
[ 5] 7.00-8.00 sec 87.3 MBytes 732 Mbits/sec 48 287 KBytes
[ 5] 8.00-9.00 sec 88.9 MBytes 746 Mbits/sec 22 287 KBytes
[ 5] 9.00-10.00 sec 87.6 MBytes 735 Mbits/sec 55 322 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 1.02 GBytes 880 Mbits/sec 241 sender
[ 5] 0.00-10.00 sec 1.02 GBytes 878 Mbits/sec receiver
iperf Done.
Note: The IP address 192.168.1.1 is obviously the OpenWRT router's IP address.
The output shows up on both client and server side and represents multiple connection and transfer tests. At the bottom a summary shows that a total of 1.02 GB were transferred and a bandwidth of 878 Mbit/s was reached on the receiver (OpenWRT router).
With [CTRL]+[C] you can stop the iperf3 server process on the OpenWRT router.
Measuring WAN speed (Router to Internet)
Time to measure the bandwidth of our Internet access, using an ISP (Internet Service Provider). We will use iperf3 on the OpenWRT router as client. This means we need an iperf3 server somewhere on the Internet. You can use an EC2 instance or a similar Cloud VM for this purpose.
The opposite communication (iperf3 Server on OpenWRT and Client running on the Internet) is of course also possible, but requires additional (incoming) firewall rule on the OpenWRT router for TCP 5201 or another port used by iperf3 (e.g. -p 4444).
On the Internet VM iperf3 is started in server mode, here listening on TCP port 4444:
root@internetvm:~# iptables -I INPUT 1 -p tcp --dport 4444 -j ACCEPT
root@internetvm:~# iperf3 -s -p 4444
-----------------------------------------------------------
Server listening on 4444 (test #1)
-----------------------------------------------------------
On the OpenWRT router, launch iperf3 as client, pointing to the IP address or DNS name of the server on the Internet VM:
oot@OpenWrt:~# iperf3 -c internetvm.example.com -p 4444
Connecting to host internetvm.example.com, port 4444
[ 5] local X.X.X.X port 34504 connected to Y.Y.Y.Y port 4444
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 95.5 MBytes 800 Mbits/sec 0 1.10 MBytes
[ 5] 1.00-2.00 sec 100 MBytes 842 Mbits/sec 0 1.54 MBytes
[ 5] 2.00-3.00 sec 103 MBytes 864 Mbits/sec 0 1.54 MBytes
[ 5] 3.00-4.00 sec 98.8 MBytes 828 Mbits/sec 0 1.54 MBytes
[ 5] 4.00-5.00 sec 97.8 MBytes 820 Mbits/sec 0 1.54 MBytes
[ 5] 5.00-6.00 sec 97.2 MBytes 816 Mbits/sec 0 1.54 MBytes
[ 5] 6.00-7.00 sec 98.6 MBytes 827 Mbits/sec 0 1.54 MBytes
[ 5] 7.00-8.00 sec 102 MBytes 860 Mbits/sec 0 1.54 MBytes
[ 5] 8.00-9.00 sec 99.2 MBytes 833 Mbits/sec 0 1.54 MBytes
[ 5] 9.00-10.00 sec 103 MBytes 865 Mbits/sec 0 1.54 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 997 MBytes 836 Mbits/sec 0 sender
[ 5] 0.00-10.01 sec 996 MBytes 835 Mbits/sec receiver
iperf Done.
The IP address shown (obfuscated) here as X.X.X.X represents your current public IP address, configured on your OpenWRT router. The Y.Y.Y.Y address is the target IP address, of your Internet VM.
From the output and result we can see an Internet speed of 835 Mbit/s between our Internet router and the destination server in the Internet.
Comparing online speed test vs. iperf3
The Cloudflare screenshot at the beginning showed a speed of ~510 Mbit/s, yet iperf3 achieved ~835 Mbit/s.
As mentioned before, the browser can interfere in such speed tests. For example having lots of browser tabs opened affects the RAM/Memory usage, which could interfere. Or if your workstation is connected using WiFi you will always have higher latency to your router than using a wired network connection.
To get the most accurate speed test results, use iperf3 on devices connected with a network cable.