The project objective is to monitor our ADSL and FTTP network connections to ensure Internet network services are reachable and we actually have Internet access. The current state of the network is stored in a database and is either 'up' or 'down'. This allows the various elements of our Home Control System (HCS) to make decisions based upon network status, such as sending SMS alerts or whether certain events are sent out to our Twitter account.
This project is closely linked to the work to monitor router status. If the modem/router is not connected then the network is simply assumed to be down.
The ultimate goal is to make an assessment of real network performance, which would then also logged in the database. This could be used to determine whether events such as security video uploads could be done.
The network monitoring is written as a separate process, since testing the network involves sending out an HTTP request and waiting for a response. This process can take some time and we don't want other Home Control System (HCS) functions delayed because of it. To provide some resilience to the process, it actually checks for the presence of three web pages on three different sites in turn. Only if all three are unreachable is the network deemed to be down. This approach is used as sites can be taken down for maintenance. The web pages requested are not actually web pages. We make requests for small graphics on some large and popular websites, that are known for their high response times and for serving high traffic volumes. The graphics chosen are very small, to minimise the data being sent to perform the tests.
The first request is an HTTP GET request to get a known, small content item on a popular and highly available web site. This request is given a 5 second timeout. If this request fails, a second request is sent out to another site with a 10 second timeout. If this also fails, a third request is made to another website with a 15 second timeout. If this fails, the network is assumed to be down. All failures are logged to provide an indication of any network delays.
There are fairly standard practices used to assess network performance and Java tools exist to do this already. We plan to re-use these as far as possible.
The first part of this project is implemented and live. Our Home Control System (HCS) is now monitoring the network status well and the resilience provided by checking three separate URLs has shown to be required. At the moment the 'ping' to check network availability is being done every 30 seconds.
The performance measurement part is currently being written but is a low priority activity for now.
The Java code is available on request.
- It is surprising just how often the first web site request times out. Whilst our ADSL network connection is quite fast the time delays in sending a request and getting a response can be significant, due to network congestion.
- This approach introduces a small delay in detecting network failure but in reality this is not an issue.
- In general our BT supplied ADSL connection is remarkably reliable and our 100Mbps FTTP even more so.