How to monitor your broadband connection and quality

As a Broadband Boffin I'm often asked about how best to monitor the quality of a connection.

I recommend a dual track approach:


  1. First check the connection from within your house, after all if you have issues here you need to know
  2. Secondly you can sign up for services that will check your connection remotely. I'll cover a free option that works for me.

I'll cover the external stuff first as it is simpler! For external monitoring use the Broadband Quality monitor from Think Broadband (you do not need to be a customer or pay for this service) http://www.thinkbroadband.com/ping/ Remember you modem needs to be on and respond to ICMP requests this is might be an option you have to enable.

Below is a short batch file I run on Windows 7 it does a few things first it looks are a couple of key internet sites and checks they are around, if not it will pull down the network log off your modem.

First off this batch file will not work with your ISP or your modem: You need to change it to fit your setup. You can also change the batch file to power cycle your modem, eg. with a relay control or RF plug on a Raspberry Pi or Wemo remote. This is the route if taken but I've posted the simple version here

The batch file below also sends out alerts to use during a restart and keeps log files based on date and even deletes empty logs that might be created if the modem reboots by itself. This is not a complete working system but a template you can fashion into something that works for you.

I used the pre-compiled version of curl for Windows of course you can write something similar for bash.


@ECHO OFF
SET /a i=0
:loop
cls
Time /T > Time.dat
set /P ftime= < Time.dat
set fDate=%date:~6%%date:~3,2%%date:~0,2%%ftime:~0,2%%ftime:~3,2%
echo %fDate% Testing Internet Connection...

REM This script checks for an active Internet connection by trying to access
REM five different web sites.  If all three checks fail, it will reset the cable
REM modem.

curl http://www.google.com/ > nul
IF %ERRORLEVEL%==0 GOTO done
echo Google failed.
curl http://www.bing.com/ > nul
IF %ERRORLEVEL%==0 GOTO done
echo Bing failed.
curl http://www.yahoo.com/ > nul
IF %ERRORLEVEL%==0 GOTO done
echo Yahoo! failed.

REM If we got here...  The Internet appears to be broken.
Time /T > Time.dat
set /P ftime= < Time.dat
set fDate=%date:~6%%date:~3,2%%date:~0,2%%ftime:~0,2%%ftime:~3,2%

echo %fDate% Copy Modem Log and stats.. >> internet-check.log
echo %fDate% Copy Modem Log and stats.. >> restart.log



curl "http://192.168.100.1/cgi-bin/VmRouterStatusEvLogCfgCgi" >> "%fDate%Network.html"
curl "http://192.168.100.1/cgi-bin/VmRouterStatusDownstreamCfgCgi"  >> "%fDate%Downstream.html"
curl "http://192.168.100.1/cgi-bin/VmRouterStatusUpstreamCfgCgi"  >> "%fDate%UpStream.html"
curl "http://192.168.100.1/cgi-bin/VmRouterStatusStatusCfgCgi"  >> "%fDate%Status.html"
curl "http://192.168.100.1/cgi-bin/VmRouterStatusOperationCfgCgi"  >> "%fDate%Ops.html"
echo %fDate% Restarting cable modem. >> internet-check.log
echo %fDate% Restarting cable modem. >> restart.log
rem curl http://activation.virginmedia.com/Activation/start.do --location >> restart.log
"C:\Program Files\Google\Chrome\Application\chrome.exe" http://activation.virginmedia.com/Activation/start.do
echo %fDate% Waiting for modem to restart..
echo %fDate% Waiting for modem to restart>> restart.log
echo %fDate% Waiting for modem to restart>> internet-check.log
msg /server:seth-pc seth "Detected the internet connection has failed, trying to restart the modem. This will take 2 minutes.."
msg /server:xxx-pc xxx "Detected the internet connection has failed, trying to restart the modem. This will take 2 minutes.."
msg /server:yyy-pc yyy "Detected the internet connection has failed, trying to restart the modem. This will take 2 minutes.."
curl http://www.google.com/ > nul
IF %ERRORLEVEL%==0 (
msg /server:zzz-pc zzz "Internet reconnected sucessfully; reboot was sucesfull"
msg /server:xxx-pc xxx"Internet reconnected sucessfully; reboot was sucesfull"
msg /server:yyy-pc ttt""Internet reconnected sucessfully; reboot was sucesfull"
)
else (
msg /server:zzz-pc zzz"Automated Reboot did not work still no internet switch the modem off count to 10 then switch it on again"
msg /server:xxx-pc xxx "Automated Reboot did not work still no internet switch the modem off count to 10 then switch it on again"
msg /server:yyy-pc yyy "Automated Reboot did not work still no internet switch the modem off count to 10 then switch it on again"
)
Time /T > Time.dat
set /P ftime= < Time.dat
set fDate=%date:~6%%date:~3,2%%date:~0,2%%ftime:~0,2%%ftime:~3,2%
echo %fDate% Delete empty Log and stats.. >> internet-check.log
echo %fDate% Delete empty Log and stats.. >> restart.log
forfiles /c "cmd /c if @fsize==0  del @file"
GOTO LOOP
rem exit 1
:done
Time /T > Time.dat
set /P ftime= < Time.dat
set fDate=%date:~6%%date:~3,2%%date:~0,2%%ftime:~0,2%%ftime:~3,2%
echo %fDate% Internet Conected, waiting 30s to retest connection...
echo %fDate% Internet connected>> internet-check.log
ping -n 30 127.0.0.1>NUL
rem exit 0
GOTO LOOP
IF %i%==10 GOTO END
echo This is iteration %i%.
SET /a i=%i%+1
GOTO LOOP
:end
echo That’s it!