After having switched to a new Internet Provider a few months ago, I was often disappointed by the bandwidth I got (or perceived). It’s not always easy to know if your connection is the problem, or is it Wi-Fi connectivity? Or the website you are trying to connect to, etc. So to get a better idea, I decided to create a simple setup to continuously monitor my connection, using two independent methods that I will describe below. Before digging into the details, here is how it currently looks like:
- RaspberryPi 3.
- Latest version of Raspbian.
- Direct Ethernet connection to the router.
To get a better idea of the bandwidth (I also measure upload and ping, but that is not the most important for me, and I’m not sure how robust the measurements are), I decided to implement two separate methods:
- The first one is using speedtest-cli, a Python project which allows you to measure you connection using servers from speedtest.net. It is very simple to use and the project seems to be pretty mature.
- For the second measurement, I wanted to use fast.com, a service provided by Netflix. I could not find a way to use it easily from the command line (and I could not find an easy way to get a driver for Selenium for either Firefox or Chromium), but I managed to get the measurements using
chromiumheadless mode, which is available on
raspbian, so no extra dependency is required!
Here is the current way measurements are performed:
- The script
speed.pyis triggered from a
watchcommand every 30 minutes (it runs in a detached
speedtest-climeasurement is triggered.
- Then we wait for 15 seconds.
fast.commeasurement is triggered.
- Results are persisted into a local sqlite3 database.
In parallel, the
app.py runs in another
screen to allow visualizing the results stored in the database. This is not mandatory, but it’s nice to see the bandwidth over time (the fluctuations reminds me of Bitcoin pricing…).
I have uploaded the scripts I’m using on GitHub so that it can be re-used or modified.
It should be noted that I now have more measurements and that both methods (speedtest and fast.com) yield similar results. Another interesting thing is that the bandwidth is usually higher than what I perceive in normal usage. I have currently two hypotheses:
- It could be that the provider is playing nice with servers used to measure bandwidth and artificially increases the bandwidth for those?
- My Wi-Fi setup might not be optimal, and I need to investigate if changing the channel or other settings would improve the situation.