I manage a Linux router that provides internet access to tenants in an apartment building. From time to time, a user will do something that will ruin the connection.
It can be Limewire, BitTorrent or just Skype… but the end result is a latency of more than 400ms!
Recently I came across a simple way to do this on Debian/Ubuntu.
apt-get install wondershaper
The usage is simple
wondershaper eth0 4600 490
This would limit you to 4600 kbits download and 490 kbits upload.
Before you limit your speed, make sure your connection is not being heavily used and ping google.com (and a few other servers). Get a good idea of your latency (Mine is 15ms at night, and 25ms during the day).
You should find out your actual speed; I suggest speedtest.net for testing. You should also do this across several days at different times!
Let’s say you find out that you have 5800 down and 600 up. If you ping google while you’re testing your connection you are going to notice that your latency goes up.
Since you probably want to avoid this, try different values for wondershaper until your latency is a low value even when you are using all avaible bandwidth. I find that 80% of your max speed is a good value to shoot for.
I find that I can use bittorrent on multiple computers and use speedtest.net and still have a latency of around 30ms limiting a 6000/600 connection to 5000/500.
If you come across any errors when running this script (Debian has this problem for me), just comment out the line causing the error. Everything will still work.