Use bandwidth shapers (wondershaper or trickle) to limit internet connection speed
Posted by admin on July 7th, 2008
Email This Post
1) Wondershaper
2) Trickle
Wondershaper
An easy to use traffic shaping script that provides these improvements:
* Low latency for interactive traffic (and pings) at all times
* Allow websurfing at reasonable speeds while uploading / downloading
* Make sure uploads don’t hurt downloads
* Make sure downloads don’t hurt uploads
It does this by:
* Limiting upload speed slightly, to eliminate queues
* Limiting download speed, while allowing bursts, to eliminate queues
* Interactive traffic skips the queue
* ACKs and tiny packets skip the queue
Configuring the wondershaper requires you to accurately and precisely determine your consistent upload and download speeds.
Install wondershaper in Ubuntu
sudo aptitude install wondershaper
This will complete the installation.
Using wondershaper
use ifconfig to determine which of your networkcards is the one that is connected to your modem (and thus the internet).
ifconfig
the networkcard that has your normal ip adress is the one (not 192.168.x.x)
Go to a speedtesting website and determine your average upload and download speed. Use these speeds to setup limitations.
sudo wondershaper eth1 downspeed upspeed
Note:- Speed should be in KB
Example
sudo wondershaper eth0 10000 280
download a big and uncompressable file while pinging to a fast and stable server on the internet or to your modem and adjust your downspeed until you are satisfied and do the same with uploading a big and uncompressable file.
When you are ready you can make these connection settings permanent by
sudo gedit /etc/network/interfaces
add these lines under eth1 if eth1 is your internetconnection. Change eth1,upspeed and downspeed to your settings.
up /sbin/wondershaper eth1 downspeed upspeed
down /sbin/wondershaper clear eth1
Useful Tip
How do I go about putting my settings back to default for eth1?
sudo wondershaper clear eth1
Problem
When you try to run similar to the following command
wondershaper eth3 4500 333
You might see the following error
What is “flowid”?
Illegal “police”
Solution
This is a bug in iproute, not in wondershaper. Debian has already fixed the problem
Replacing iproute2 with this http://mirror.aarnet.edu.au/debian/pool/main/i/iproute/iproute_20071016-3_i386.deb solved the problem
trickle
Trickle is a voluntary, cooperative bandwidth shaper. it works entirely in userland and is very easy to use.The most simple application is to limit the bandwidth usage of programs.
Install trickle in ubuntu
sudo aptitude install trickle
Stand alone mode
Trickle is easiest to use in stand-alone mode. Simply run trickle with a download and/or upload limit and a program you want to limit. For example:
sudo trickle -d 20 -u 20 wget http://www.google.com/bigfile
Daemon mode
In daemon mode, trickle can limit a group of programs to a fixed limit of bandwidth. To start the daemon, run the trickled command:
sudo trickled -d 20 -u 20
This will start the trickle daemon that will limit the total bandwidth available to all programs run via trickle to 20 K/s both up and down. So if you run a single program via trickle, it can consume 20 K/s. Two programs can each consume 10 K/s, etc.
If you want to be notified the next time we write something please subscribe to our RSS feed.Thanks for Visiting!


July 8th, 2008 at 3:09 pm
Apt links please!