Howto: Limit upload/download speeds and optimize/improve internet connection speed and responsiveness in Ubuntu Linux!

Do you need to limit an applications upload/download speed? Or give priority to certain applications? I will introduce you to two different traffic shaping applications that you can install from the repository.

What does Wondershaper do?

wondershaper is a traffic shaping script that provides low latency, prioritizes bulk transfers below normal web traffic, prioritizes interactive shells above normal web traffic, and attempts to prevent upload and download traffic from affecting each other’s ack
packets. Put simply, the wondershaper makes your internet connection more "responsive"

More info:

* Maintain low latency for interfactive traffic at all times

This means that downloading or uploading files should not disturb SSH or even telnet. These are the most important things, even 200ms latency is sluggish to work over.

* Allow 'surfing' at reasonable speeds while up or downloading

Even though http is 'bulk' traffic, other traffic should not drown it out too much.

* Make sure uploads don't harm downloads, and the other way around

This is a much observed phenomenon where upstream traffic simply destroys download speed. It turns out that all this is possible, at the cost of a tiny bit of bandwidth. The reason that uploads, downloads and ssh hurt each other is the presence of large queues in many domestic access devices like cable or DSL modems.

Howto use Wondershaper:
Install wondershaper via searching synaptic or click here to install with 1 click
Open a Terminal via Applications->Accessories->Terminal
First figure out how much bandwidth you want to cap it to in kilobits
Of course you should calculate the above settings to what you prefer to shape
Now once you have the download/upload amounts in kilobits lets shape our traffic:
wondershaper wlan0 1536 128
Replace wlan0 with your interface, 1536 with your downlink speed, and 128 with your uplink speed.

Check the status of wondershaper:
sudo wondershaper ifacename

Howto disable shaping on specified interface:
sudo wondershaper clear ifacename


Now I
will introduce you to Trickle:
Click Here to install trickle
Trickle is a lightweight traffic limiter for applications like wget, firefox, and any other user space internet application.

Trickle is handy for limiting single applications upload and download speeds, what it does is starts the application in a speed limited sandbox.

In short

trickle is a portable lightweight userspace bandwidth shaper. It can run in collaborative mode (together with trickled) or in stand alone mode.

trickle works by taking advantage of the unix loader preloading. Essentially it provides, to the application, a new version of the functionality that is required to send and receive data through sockets. It then limits traffic based on delaying the sending and receiving of data over a socket. trickle runs entirely in userspace and does not require root privileges.


Here are a few examples:

wget example that limits the download speed to 30 KB/s
trickle -d 30 wget http://somerandomdownloadsite.com/filetodownload

Pidgin example that limits the upload/download speed of filetransfers
trickle -u 30 -d 30 pidgin

Firefox Example that limits download/upload browsing speed as well as file transfer speed:
trickle -d 30 -u 30 firefox

As you see above the -d operator means download speed and 30 is the KB/s that is specified and can be changed to whatever you choose, the -u operator is the upload speed in KB/s

References:
Trickle Developer site
Wondershaper Dev site

Clicky Web Analytics