Ok, so I'm not the only one who's using speedtest.net to measure the internet speed, right? You can run the test against a huge amount of servers distributed globally directly from your browser, or with the help of Android or iOS applications. But did you knew that you can do it from the terminal, too? I find it to be very useful in some cases, so let's play a little bit with it.

There are a bunch of cloud providers out there, with computing regions (data centers) scattered across the world. If you would like to test the network speed to one of those endpoints, there are multiple ways to measure the latency, throughput etc. by setting up probably a client-server tool, like iperf. This is exactly what I'm not going to do. :)

In fact, I will do it the other way around: I will set up a VM and measure the network performance between that specific VM and the speedtest.net servers deployed in different countries, thanks to local service providers. I'm using OCI VM.Standard.2.1 shape, which provides 1 Gbps network bandwidth as you will see from the tests I'm running.

This is very convenient, having the chance to measure the latency to different geographic locations and service providers it would be very difficult to achieve in any other way. Of course, these measurements will not be what you would see in real life, but it should be pretty close. At least, you can make an idea about the latencies measured to different geographic locations.

You will start by installing the speedtest cli tool, following the official documentation. I was using Ubuntu, so in my case, the installation was straightforward, just copy and paste the commands below.

sudo apt-get install gnupg1 apt-transport-https dirmngr
export INSTALL_KEY=379CE192D401AB61
export DEB_DISTRO=$(lsb_release -sc)
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $INSTALL_KEY
echo "deb https://ookla.bintray.com/debian ${DEB_DISTRO} main" | sudo tee  /etc/apt/sources.list.d/speedtest.list
sudo apt-get update
sudo apt-get install speedtest

That's it. You can just type speedtest in your terminal and after few seconds you will get the Latency, Download and Upload speed, Packet Loss displayed on your screen. You receive also an URL if you want to share the results or just see the same results in your browser, prettier :).

ubuntu@speedtest-vm:~$ speedtest

   Speedtest by Ookla

     Server: Vodafone DE - Frankfurt (id = 1746)
        ISP: Oracle Public Cloud
    Latency:     1.75 ms   (0.14 ms jitter)
   Download:   505.00 Mbps (data used: 618.3 MB)
     Upload:   495.35 Mbps (data used: 704.5 MB)
Packet Loss:     0.0%
 Result URL: https://www.speedtest.net/result/c/2bde0595-d752-4999-80db-e8f4d7440762

Have you noticed how speedtest is using a Service Provider (server) which has determined on its own? I'm using a VM hosted in Frankfurt, so it doesn't come as a big surprise that Vodafone DE is being used. Ok, but how can I use this to measure the speed towards other destinations? We will achieve this by specifying the exact server we want to use for our measurements

Speedtest.net has more than 9000 servers in its network, all of them can be found using this link. As they say, "their strength is in their hosted servers" and we can leverage this. Searching after Romanian ones we can see there are many service providers who are providing such a server.

Grab the server ID, we will use it to launch the measurements towards that specific server, by using -s followed by the <SERVER ID>. Run the test several times, you will see small variations but the tests are pretty relevant, especially when we look at latency.

I'm not looking to compare service providers, so what I'm going to do is to check the latency towards different geographic regions from the same Romanian using the same carrier.

ubuntu@speedtest-vm:~$ speedtest -s 11502 -P 4

   Speedtest by Ookla

     Server: RCS & RDS - Iasi (id = 11502)
        ISP: Oracle Public Cloud
    Latency:    33.38 ms   (0.09 ms jitter)
   Download: 520.5625 Mbps (data used: 882.7 MB)
     Upload: 495.3730 Mbps (data used: 587.1 MB)
Packet Loss:     0.0%
   Speedtest by Ookla

     Server: RCS & RDS - Oradea (id = 11501)
        ISP: Oracle Public Cloud
    Latency:    21.46 ms   (0.02 ms jitter)
   Download: 511.2425 Mbps (data used: 521.1 MB)
     Upload: 499.6363 Mbps (data used: 651.9 MB)
Packet Loss:     0.0%
 Result URL: https://www.speedtest.net/result/c/38d108ef-b9f9-4633-9db0-89c319c4f61c
ubuntu@speedtest-vm:~$ speedtest -s 11500 -P 4
ubuntu@speedtest-vm:~$ speedtest -s 11494 -P 4

   Speedtest by Ookla

     Server: RCS & RDS - Bucharest (id = 11494)
        ISP: Oracle Public Cloud
    Latency:    32.25 ms   (0.08 ms jitter)
   Download: 504.7814 Mbps (data used: 688.1 MB)
     Upload: 500.3939 Mbps (data used: 475.6 MB)
Packet Loss: Not available.
 Result URL: https://www.speedtest.net/result/c/197b4100-36ee-46d4-badd-5e4e3486b127

There are so many things that can influence these results when you measure it the other way around. It's up to you to figure out if it's useful - or not. You might find that the end-users might experience completely different values, but nevertheless, it's a very quick way of measuring the network speed from your cloud provider's IaaS and leverage speedtest.net directly from cli.