Monday, 19 November 2012

Improving My ADSL2+ Connection Speed

I used a Netgear DG843GT Modem/Router that I purchased on eBay for £12 delivered. It had a faulty swollen power supply capacitor on the Broadcom modem chip area of the printed circuit board, this I replaced, it was a 1000uF at 6.3V electrolytic capacitor. I flashed the modem/router with DGTeam Firmware Mirror. I didn't like the new firmware's logos at the top of the DG843GT Web interface so I just blocked this frame in my browser to remove it from view :).
This firmware allows you to reduce the noise margin via the routers web interface and command line. I first logged the modems varying ADSL2+ snr over a period of about a week from a Raspberry Pi using a shell script (shown below) to Xively. See the Xively tutorial for more information. The Xively data format is detailed here. The reason I wanted to record the data was to get a feel for the actual noise conditions on my telephone line over a period of time and to see what I was going to be up against.

The Xively internet of everything concept takes a bit of understanding , I'm not sure I fully understand it yet. My attempt to describe it here is that a feed is a location on Xively for your device to record its many data channels also known as datastreams. These channels can be various outputs from sensors on the device or data gleaned from the device itself. In this case I'm screen scraping the Modem/Router's browser based status page to get the SNR and Download speed values. I'm doing this using a few shell scripts running that loop every 5 minutes on a Raspberry PI a low power Linux device that runs 24-7.

To do this yourself you need to signup with Xively to create your own account and password. After this you then create a feed for your DG843GT with two channels one called SNR (Signal to Noise Ratio) measured in dB (decibels) and the other is speed the download speed measured in kbps (kilo Bits Per Second).

As part of the account set up process a Product ID , Product Secret , Serial Number and Activation Code is created as is a Feed ID ,
Feed URL in the form :-
https://xively.com/feeds/***Feed_Number***
and an API endpoint URL of the form :-
https://api.xively.com/v2/feeds/***Feed_Number***
An auto-generated device key for your ***Feed Number*** is also created to allow secure uploading of the readings from your remote device.

The script RouterCall.sh uses a command wget to automatically log in to the DG834GT Modem/Router and download the stattbl.htm page. This page is then scraped using various cut commands to get the value into variables within the script which are then packaged up into a data.json file that is uploaded to Xively by running the cosm.sh script. The cosm script has the feed details and associated security key along with the reference to the data.json data file.
The annotations on the screenshot images are as follows #1 is the API endpoint #2 is the device key for the feed number.

Screenshot of the Device Feed

The following image is of the cosm script and shows #1 the API feed endpoint URL and  #2 is the device key for the feed , this shows hopefully how they are linked.


cosm,sh


Note the area of the graph below showing off scale and a flat line is where I was playing around with the Router. From the graph below one can see that before the noise margin reduction it was around 10dB, and you can see the reduction at night time due to interference from MW radio stations etc reducing the noise margin. You can also see where I reduce the noise margin down to the target 6dB, this is where my download speed increased from 5Mbps up to 7.4Mbps, what a result :).

The connection has been rock solid for over a week with no line re-sync and a very low crc much in line with what I experienced with the higher noise margin and a lower speed.



Shell Script RouterCall.sh
# This script uses another script cosm.sh to send data to the Cosm Website
# Note you have to create an account yourself and use this id for your script
#!/bin/sh
while [ true ]
do
# Create my data files
touch noise.txt speed.txt data.txt
# Get content of Stats Page from Router
wget --http-user=admin --http-passwd='********' http://192.168.1.1/stattbl.htm
# Get data into files
cat stattbl.htm | grep kbps | cut -d\> -f3 | cut -dk -f1 | head -1 > speed.txt
cat stattbl.htm | grep db | cut -d\> -f3 | cut -d\< -f1 | cut -dk -f1 | tail -2 | head -1 > noise.txt
# Load Variable list with contents of speed.txt
noise=`cat noise.txt`
speed=`cat speed.txt`
# Send data to Cosm by creating a json file containing the data
echo -e {\"version\":\"1.0.0\",\"datastreams\": [\{\"id\":\"ADSL\",\"current_value\":\"$noise\"\},\{\"id\":\"speed\",\"current_value\":\"$speed\"\}]\} > data.json
# Run other Shell script
cosm.sh
# Remove the created files to renew them next time
rm noise.txt data.txt speed.txt data.json stattbl.htm
# Wait for 5 minutes before looping again
sleep 300
done

Shell Script cosm.sh
# Script to send Data to your Cosm feed page
#!/bin/sh
curl --request PUT --data-binary @data.json --header "X-ApiKey: ***********You use your Key Here************" --verbose http://api.cosm.com/v2/feeds/***Your Feed Number Here*******

Update: I have managed a consistent 8.227Mbps by reducing the noise margin to around 3dB, it is also a rock solid connection and is much better than my old Zyxel P-660HW T1 V2 at around 4Mbps, it also used to restart for no reason even when it was brand new.

Further Update: I have now managed a consistent 9.139Mbps by further reducing the noise margin to around 2.4dB, it is still a solid connection. It was up at 9.9Mbps but this was not stable so it was reduced. These changes were made in the summer when static and atmospheric noise is at its highest on the frequencies used by ADSL2 so fingers crossed that it stays this way :).

Even Further Update
My broadband started playing up around the 1st of April 2014 and it took BT Openreach about 2 weeks to fix it, I am still trying to get a refund. I was effectively without broadband during this time due to excessive noise on my telephone line, it was very crackly like static on a radio. I did however use a 3G USB Dongle for my broadband over this time. My SNR logging came to the rescue as I could see exactly when it happened and what was occurring on the line. See my image of the the SNR below.

My system is now back but it is now only running around 3Mbps which is pretty rubbish. My line still has to go through a learning process so the equipment at the telephone exchange can eventually see the line is no longer noisy and so should allow higher speeds hopefully. 


 Even Further Further Update

After over a full month of mediocre/sometimes non existent broadband I have finally got the speed I think I should. I contacted them on two separate occasions saying I had been capped since the fault at 3Mbps even after BT saying the cap had been removed. I told them I had the evidence for the cap not being removed when even after a router reset the speed was always 3Mbps +- a few kbps. This morning I was contacted by BT to say the cap had not indeed been removed but that it was now and could I restart the router. This I did, the speed immediately went to 10Mbps download and 1Mbps upload, thanks goodness, fingers crossed that it stays this way. Images of the broadband speed and SNR are shown below.





New Router Installed
My old Netgear DG834GT started to disconnect at random, so I purchased a Billion 7800DXL modem router to replace it. This was installed and no tweaking of the SNR was necessary, I am getting a reliable 9.2Mbps download and 1.0Mbps upload so a good result. The added benefit of this is that this router has dual band wifi and 1Gbit ethernet ports so file transfers to and from my NAS which is also 1Gbit on the home network is pretty rapid.

References Used: With grateful thanks


Making a datalogger for a Kamstrup electricity / gas meter with Raspberry Pi!


Duncan Jauncey's Blog



File resolv.conf changed on reboot

The file /etc/resolv.conf was being reset and losing the correct nameserver on my Raspberry Pi after a reboot. The unfriendly way of fixing ...