The project objective is to monitor my ADSL modem/router to check Internet network connectivity and to record synchronisation speeds. The data is logged in a database and used by our Home Control System (HCS) to make decisons on whether it should use network services.
The code is written in Java and is run as a separate process, since testing the router involves sending out an authenticated HTTP request (to access the admin interface) and processing the response. This process could take some time if the router is unreachable and we don't want other Home Control System (HCS) functions delayed because of it. It also isolates the main Home Control System (HCS) functions from any unreliabilities in this feature such as the router locking up. The response is the HTML status page on the router and this is parsed to look for key fields and data. The main ones used are:
- The router status - either 'Connected', 'Negotiating' or 'Connecting'.
- The router 'UpStream' synchronisation speed.
- The router 'DownStream' synchronisation speed.
Another reason to write this as a separate process is that it is dependent upon the make and model of router you use (and the software version). We have written two versions, one for each of the modems/routers we use.
The second part of this project is to monitor what devices are connected to the router over Ethernet and wi-fi. This allows us to check for security breaches and to monitor whether devices have been left on (e.g. our laser printer). It can also be used to provide indicative occupancy of our home, since personal devices such as iPhones infer that the device owner is at home. Testing has also revealed that we can monitor how much time the children are spending on the Nintendo Wii console.
The first part of this project is implemented and live. Our Home Control System (HCS) is now monitoring the router status. When using a Netgear router, we've discovered that if becomes unreliable if you hit the admin screens at regular intervals like this. One option to resolve this is to use the SNMP protocol. We are reading up on this now.
The part to detect connected devices is now also written. I've not left this running as I'm resolving a few issues with the way this service works.
One thing to note: Some routers only allow a single login to the admin interface, e.g. Netgear routers. If our router monitor is running on our Netgear router, it is not possible to login using a web browser.
The Java code is available on request.