Site icon Karneliuk

Tools 3. Checking your connectivity bandwidth with Speedtest

Hello my friend,

Continuing our discussion about the network troubleshooting tools we can’t pass by one of the most popular and widely used, which is named SpeedTest.


1
2
3
4
5
No part of this blogpost could be reproduced, stored in a
retrieval system, or transmitted in any form or by any
means, electronic, mechanical or photocopying, recording,
or otherwise, for commercial purposes without the
prior permission of the author.

Can automation help with performance troubleshooting?

Doing the collection and initial analysis of the information during the troubleshooting could be quite a time-consuming task. On the other hand, the troubleshooting of the live outages should be as quick as possible to minimise the downtime of the affected services. That’s where the automation can help you.

In our network automation training we explain how to use existing open-source tools and create your own with Ansible, Bash and Python. Leveraging them and all possible interfaces (CLI, NETCONF, RESTCONF, gNMI) we teach you how to effectively build, operate and troubleshoot your network.

Start your automation training today.

Brief description

From the name of the tool, SpeedTest, it is obvious that the main goal is to measure the “speed”. In fact, it measures the following parameters:

All these measurements are done against the SpeedTest server, which is chosen based on your geographical location (the server closer to you is preferable) and the server load. Those servers are hosted in various networks across the globe. The whole solution is developed and supported by Ookla.

It is possible to manually choose the test server out of list, if you have specific needs (e.g., you want to measure speed to a different country).

The very important consideration here is that the Speedtest results are NOT absolute. Instead, they just show you connectivity to a specific server in a specific point in time. There are various components contributing to the end results:

Therefore, if you suspect that you have problems with the speed Internet connectivity, we advise to do several tests to several servers to have more data.

Usage

Let’s take a look how to use Speedtest.

#1. Installation

The installation of the official Speedtest CLI is described in the official documentation at quite a good level of details. In our lab we are using CentOS; hence, we use CentOS path for installation, which consist of two major steps:

Here is the sample installation process for your reference:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
$ wget https://bintray.com/ookla/rhel/rpm -O bintray-ookla-rhel.repo
--2020-12-28 08:37:08--  https://bintray.com/ookla/rhel/rpm
Resolving bintray.com (bintray.com)... 108.168.194.93
Connecting to bintray.com (bintray.com)|108.168.194.93|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/plain]
Saving to: ‘bintray-ookla-rhel.repo’

bintray-ookla-rhel.repo                            [ <=>                                                                                                ]     172  --.-KB/s    in 0s      

2020-12-28 08:37:08 (123 MB/s) - ‘bintray-ookla-rhel.repo’ saved [172]

[aaa@nnat ~]$ sudo mv bintray-ookla-rhel.repo /etc/yum.repos.d/
[sudo] password for aaa:
[aaa@nnat ~]$ sudo yum install speedtest
bintray--ookla-rhel                                                                                                                                        2.5 kB/s | 1.4 kB     00:00    
Dependencies resolved.
===========================================================================================================================================================================================
 Package                                 Architecture                         Version                                              Repository                                         Size
===========================================================================================================================================================================================
Installing:
 speedtest                               x86_64                               1.0.0.2_1.5ae238b-1                                  bintray--ookla-rhel                               910 k

Transaction Summary
===========================================================================================================================================================================================
Install  1 Package

Total download size: 910 k
Installed size: 2.2 M
Is this ok [y/N]: y
Downloading Packages:
ookla-speedtest-1.0.0-x86_64-linux.rpm                                                                                                                     857 kB/s | 910 kB     00:01    
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                      853 kB/s | 910 kB     00:01    
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                   1/1
  Installing       : speedtest-1.0.0.2_1.5ae238b-1.x86_64                                                                                                                              1/1
  Running scriptlet: speedtest-1.0.0.2_1.5ae238b-1.x86_64                                                                                                                              1/1
  Verifying        : speedtest-1.0.0.2_1.5ae238b-1.x86_64                                                                                                                              1/1
Installed products updated.

Installed:
  speedtest-1.0.0.2_1.5ae238b-1.x86_64                                                                                                                                                    

Complete!

Once installed, you can check that it is installed indeed and what is the version:


1
2
3
4
5
$ speedtest -V
Speedtest by Ookla 1.0.0.2 (5ae238b) Linux/x86_64-linux-musl 4.18.0-240.1.1.el8_3.x86_64 x86_64

The official command line client for testing the speed and performance
of your internet connection.

#2. Simple tests

To run the test you just need to type speedtest in CLI without further parameter. However, before you run your first test after installation, you will be asked to accept the End User License Agreement:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
$ speedtest
==============================================================================

You may only use this Speedtest software and information generated
from it for personal, non-commercial use, through a command line
interface on a personal computer. Your use of this software is subject
to the End User License Agreement, Terms of Use and Privacy Policy at
these URLs:

    https://www.speedtest.net/about/eula
    https://www.speedtest.net/about/terms
    https://www.speedtest.net/about/privacy

==============================================================================

Do you accept the license? [type YES to accept]: YES
License acceptance recorded. Continuing.

==============================================================================

Ookla collects certain data through Speedtest that may be considered
personally identifiable, such as your IP address, unique device
identifiers or location. Ookla believes it has a legitimate interest
to share this data with internet providers, hardware manufacturers and
industry regulators to help them understand and create a better and
faster internet. For further information including how the data may be
shared, where the data may be transferred and Ookla's contact details,
please see our Privacy Policy at:

       http://www.speedtest.net/privacy

==============================================================================

Do you accept the license? [type YES to accept]: YES
License acceptance recorded. Continuing.


   Speedtest by Ookla

     Server: Mauritius Telecom Ltd - London (id = 17418)
        ISP: BT
    Latency:    21.97 ms   (13.06 ms jitter)
   Download:    11.31 Mbps (data used: 10.2 MB)                              
     Upload:     0.91 Mbps (data used: 1.7 MB)                              
Packet Loss:     0.0%
 Result URL: https://www.speedtest.net/result/c/e7fecd74-d235-4258-80cd-9e18aab3dbe1

In the end of the snippet you see the results of the test:

The second and further tests doesn’t require you accepting EULA anymore. It is also quite possible that the next test will be run against different server:


1
2
3
4
5
6
7
8
9
10
11
$ speedtest

   Speedtest by Ookla

     Server: Inovedia Outsourcing - London (id = 37471)
        ISP: BT
    Latency:    21.95 ms   (18.28 ms jitter)
   Download:     9.54 Mbps (data used: 12.2 MB)                              
     Upload:     0.95 Mbps (data used: 1.4 MB)                              
Packet Loss: Not available.
 Result URL: https://www.speedtest.net/result/c/c8ef3047-7ee6-4431-8902-ec982c80e80c

As you can see, two consecutive measurements were performed against different servers and show different speeds.

#3. Advanced tests

The Speedtest by Ookla gives you a few parameters, which you can specify, which may influence the results of the measurement or the representation of the results. You can see them in the inline help:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
$ speedtest --help
Speedtest by Ookla is the official command line client for testing the speed and performance of your internet connection.

Version: speedtest 1.0.0.2

Usage: speedtest [<options>]
  -h, --help                        Print usage information
  -V, --version                     Print version number
  -L, --servers                     List nearest servers
  -s, --server-id=#                 Specify a server from the server list using its id
  -I, --interface=ARG               Attempt to bind to the specified interface when connecting to servers
  -i, --ip=ARG                      Attempt to bind to the specified IP address when connecting to servers
  -o, --host=ARG                    Specify a server, from the server list, using its host's fully qualified domain name
  -p, --progress=yes|no             Enable or disable progress bar (Note: only available for 'human-readable'
                                    or 'json' and defaults to yes when interactive)
  -P, --precision=#                 Number of decimals to use (0-8, default=2)
  -f, --format=ARG                  Output format (see below for valid formats)
  -u, --unit[=ARG]                  Output unit for displaying speeds (Note: this is only applicable
                                    for ‘human-readable’ output format and the default unit is Mbps)
  -a                                Shortcut for [-u auto-decimal-bits]
  -A                                Shortcut for [-u auto-decimal-bytes]
  -b                                Shortcut for [-u auto-binary-bits]
  -B                                Shortcut for [-u auto-binary-bytes]
      --selection-details           Show server selection details
      --ca-certificate=ARG          CA Certificate bundle path
  -v                                Logging verbosity. Specify multiple times for higher verbosity
      --output-header               Show output header for CSV and TSV formats

 Valid output formats: human-readable (default), csv, tsv, json, jsonl, json-pretty

 Machine readable formats (csv, tsv, json, jsonl, json-pretty) use bytes as the unit of measure with max precision

 Valid units for [-u] flag:
   Decimal prefix, bits per second:  bps, kbps, Mbps, Gbps
   Decimal prefix, bytes per second: B/s, kB/s, MB/s, GB/s
   Binary prefix, bits per second:   kibps, Mibps, Gibps
   Binary prefix, bytes per second:  kiB/s, MiB/s, GiB/s
   Auto-scaled prefix: auto-binary-bits, auto-binary-bytes, auto-decimal-bits, auto-decimal-bytes

If you want to run the test against a specific server, you can list what are your options:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ speedtest -L
Closest servers:

    ID  Name                           Location             Country
==============================================================================
 37471  Inovedia Outsourcing           London               United Kingdom
 11445  Structured Communications      London               United Kingdom
 26922  toob Ltd                       London               United Kingdom
 30690  Community Fibre Limited        London               United Kingdom
  6032  fdcservers.net                 London               Great Britain
  7352  Redraw Internet                London               Great Britain
 30904  GMCHosting LLC                 London               United Kingdom
 17418  Mauritius Telecom Ltd          London               GB
 30376  UK Dedicated Servers           London               United Kingdom
 11123  Spitfire Network Services      London               United Kingdom

Ookla claims that they have more than 13 thousands of test servers worldwide, which is quite good. However, you would see in the list only the closest to you. To run the test against any of the listed, you pick up its ID and run the speedtest with the key -s:


1
2
3
4
5
6
7
8
9
10
11
$ speedtest -s 11123

   Speedtest by Ookla

     Server: Spitfire Network Services - London (id = 11123)
        ISP: BT
    Latency:    23.32 ms   (0.95 ms jitter)
   Download:    11.16 Mbps (data used: 19.6 MB)                              
     Upload:     0.87 Mbps (data used: 1.4 MB)                              
Packet Loss:     0.0%
 Result URL: https://www.speedtest.net/result/c/bffccd86-845c-4abd-904a-6d0764334259

Depending on your business type (say if you are a streaming or gaming platform), you might be interested in having ideas, how are you services available in different part of the world. The trick here is to get list of servers from other countries. Unfortunately, the Speedtest CLI doesn’t provide a possibility for you to list that. It is possible to find unofficial dump of the server IDs in the internet, but there is no guarantee they are working. So the best advise (if you have such a possibility) is to ask some you friends in the destination country to run speedtest -L and give you a list of servers they see :-). Here is a list of servers how does they look like from New York:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
FriendInNewYork$ speedtest -L
Closest servers:

    ID  Name                           Location             Country
==============================================================================
  5029  AT&T                           New York, NY         United States
 13098  Pilot                          New York, NY         United States
 16976  Spectrum                       New York, NY         United States
 10546  Sprint                         New York, NY         United States
 16888  Natural Wireless               New York, NY         US
 16686  CCleaner                       New York, NY         United States
 24374  GTT.net                        New York, NY         United States
 21313  Data Room                      New York, NY         United States
  6030  fdcservers.net                 New York, NY         United States
 21016  Starry, Inc.                   New York, NY         United States

Once you have the ID, you can run the speedtest over the globe:


1
2
3
4
5
6
7
8
9
10
11
$ speedtest -s 21016

   Speedtest by Ookla

     Server: Starry, Inc. - New York, NY (id = 21016)
        ISP: BT
    Latency:    90.24 ms   (1.24 ms jitter)
   Download:     8.31 Mbps (data used: 14.8 MB)                              
     Upload:     0.81 Mbps (data used: 1.3 MB)                              
Packet Loss:     0.0%
 Result URL: https://www.speedtest.net/result/c/555174dc-bda7-4a87-841a-f43f62ebb8cc

If your host has multiple IP addresses (e.g. if you have multiple interfaces or just have secondary IP addresses), you can specify which source IP you use to test the speed. It is generally pointless if your host is located behind the NAT, but could be useful if your IP addresses are public, especially if they are from different public ranges. You would do that as:


1
2
3
4
5
6
7
8
9
10
11
$ speedtest -i 10.0.2.6

   Speedtest by Ookla

     Server: GMCHosting LLC - London (id = 30904)
        ISP: BT
    Latency:    22.56 ms   (0.98 ms jitter)
   Download:    10.12 Mbps (data used: 19.2 MB)                              
     Upload:     0.87 Mbps (data used: 1.5 MB)                              
Packet Loss:     0.0%
 Result URL: https://www.speedtest.net/result/c/d1eb795c-cbec-4418-9902-db263fcd8957

#4. Changing the output format

The standard output is human readable, which is good for manual troubleshooting, but is not good for automated workflows, because you would need to parse the text. To solve that the Speedtest CLI allows you changing the output format to CSV or JSON:


1
2
3
4
5
6
$ speedtest -f csv
"Mauritius Telecom Ltd - London","17418","21.585","4.213","0","1401882","113009","9503140","1601620","https://www.speedtest.net/result/c/b9bcd7db-475f-461b-ae50-0e5cd3d4ec0c"


$ speedtest -f json
{"type":"result","timestamp":"2020-12-28T15:21:52Z","ping":{"jitter":3.569,"latency":21.946999999999999},"download":{"bandwidth":1150832,"bytes":10311268,"elapsed":8809},"upload":{"bandwidth":116023,"bytes":1449140,"elapsed":15014},"isp":"BT","interface":{"internalIp":"10.0.2.6","name":"enp0s3","macAddr":"08:00:27:F7:42:60","isVpn":false,"externalIp":"5.80.15.152"},"server":{"id":37471,"name":"Inovedia Outsourcing","location":"London","country":"United Kingdom","host":"speedtest.inovedia.com","port":8080,"ip":"154.51.158.15"},"result":{"id":"3a90fee2-ee31-42e5-b7c2-ddd0a764b95b","url":"https://www.speedtest.net/result/c/3a90fee2-ee31-42e5-b7c2-ddd0a764b95b"}}

The JSON output contains even more details, which you can use for your troubleshooting. Moreover, you can save it in file or just call test from the Ansible or Python script.

Learn more about Asible, Python, JSON for the network configuration and troubleshooting in our Network Automation Training.

#5. Ideas for automation

As said, the JSON output is perfect for automation and, therefore, you can create some Python script, which will test the connectivity and mail the results to you.

Take me to the examples

Lessons learned

Previously the Speedtest CLI was distributed as Python software. You still can download and use it from the PyPI or the Git repo. However, Ookla recommends to use the official one distributed via package managers as explained earlier in this blogpost.

Conclusion

Having data about the internet connectivity at your home, office, or data centre is an important part of both general operation of your service and troubleshooting if something doesn’t work correctly. Speedtest allows to collect you such data. In addition, it is free of charge for users; therefore, it is one of the most popular tools for such tasks. Take care and good bye.

Support us





P.S.

If you have further questions or you need help with your networks, I’m happy to assist you, just send me message. Also don’t forget to share the article on your social media, if you like it.

BR,

Anton Karneliuk

Exit mobile version