Mobile internet rate limiting

Why would you want to limit the rate of mobile internet?

Broadband internet service providers offer dongles with a given data bandwidth included as part of the price plan. The plan may be for 1,3,5,7 or 15Gb per month with different charging levels, or a given price per gigabyte. For example, Vodafone offer 1 gigabyte for £15, which can be used with unlimited time.

When you are paying for internet based on price per unit of data, it is in your interest to use the data economically. But how do you keep control of costs? £15 may buy you access to view 2500 web pages at 400k/page (including pictures), but if you accidentally stumble accross pages which are 20Mb, or your computer starts an update, your 1Gb allowance can soon be finished. By using a bursting rate limiter, this can be avoided. In fact, by limiting the underlying rate to 5k, it will take at least 55 hours of constant use, to exhaust your 1Gb allowance.

Won’t the rate limiting invariably reduce the performance to make it unusable, or little better than dial-up?

For large downloads, yes. For small web pages and email downloads, no.

You can set a rate limiter with a burst capability. In our example, we can set a burst capability of one megabyte, with a rate of 5K/sec. So long as your average rate of use is no more than 5K/sec, and each page is much less than 1Mb, you will experience full speed. Only when your average rate of use exceeds 5K/sec, your speed will be limited to dial-up. Normally, this will not be the case.

Won’t that give poor performance on Youtube etc?

If you are intending to watch on-line movies, this rate limiting won’t be for you. On-line movies swallow a lot of data quickly. You best go for a large data package with your provider, and keep an eye on your data use.

Installing mobile internet rate limiting

This is assuming you use a dongle or mobile phone connected to a USB or serial port, and that you connect via PPP. The rate limiting will apply for all PPP based connections (eg mobile broadband, ISDN or ordinary modem). You will need a linux distro with traffic control (tc) installed. Ubuntu and most others have this by default. I will be assuming you use Ubuntu. All you need to do is drop this simple script into /etc/ppp/ip-up.d/ and the same script into /etc/ppp/ip-down.d/ . The script will recognise which directory it is in, and behave accordingly, to start or stop the rate limit.

Assuming you use Ubuntu,
Download the script to your desktop. Open your terminal then type

sudo cp Desktop/1ingress_police /etc/ppp/ip-up.d/
sudo cp Desktop/1ingress_police /etc/ppp/ip-down.d/
sudo chmod 755 /etc/ppp/ip-up.d/1ingress_police /etc/ppp/ip-down.d/1ingress_police

Once the scripts are in place, the ingress and egress speed will follow the limits set. To set the system back, simply delete 1ingress_police from /etc/ppp/ip-up.d/ and /etc/ppp/ip-down.d/ . You may, of course, change the rates set by editing the script in /etc/ppp/ip-up.d/1ingress_police .

The techies amongst you will see that we are using what is commonly regarded as a “fierce” option to rate control traffic, and that is discarding packets which have already been sent. True, packets which would otherwise be useful are dropped in over-bandwidth conditions, and if the user will want to continue a download, packets will need to be re-sent. If you have a practical method to overcome what will under normal circumstances be (hopefully) irregular occurrence of packet loss, let me know!
We are hoping, and assuming, the sender will have sensible rate control mechanisms, which is what umtimately preserves the user’s bandwidth. I presume badly behaving hosts (in terms of having poor rate throttling) form only a very small proportion of internet hosts. In the vast majority of instances, the rate control mechanism should be effective.

<<Back