How to limit upload/download speed in ubuntu

June 15, 2011

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.

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.

wondershaper is a universe/net package described as a Easy to use traffic shaping script. At just 76KB, it can be installed very quickly, using

apt-get install wondershaper

and if you ever want to remove it, you can simply run

apt-get remove wondershaper

.
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

apt-get 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: