Is there any way to limit my Internet connection to a per program basis?
My Linux connection is REALLY free.
I live in Brazil, so where I live I can only have 1 Mbit/s. Yes I know it's sad, but it's not the point.
Everytime I'm updating my Ubuntu 9.04 or downloading something, it does eat all my bandwidth. Like, while update-manager is downloading the packages, I can see by netspeed applet in my panel that the incoming traffic goes to 110 kB/s. And then, my Emesene suddenly goes disconnected, and I can't navigate.
As you can imagine, I can't use my Internet connection again until the packages are all downloaded or I cancel the update in the middle.
As I said, same thing happens when I'm dowloading something, but less intrusive and immediate.
The question is: is there any way to limit that APT/downloads traffic to some way I can still use my other Internet services, or to reserve some bandwidth for common navigation tasks (like we have on Windows, but I forgot this thing's name, it's like "something packages".
You can configure apt to restrict its download speed by setting a configuration file in /etc/apt/apt.conf.d/, as detailed in this post
Specifically, create a file:
/etc/apt/apt.conf.d/76download
that contains the text:
Acquire { Queue-mode "access"; http { Dl-Limit "65"; }; };
where "65" is the speed in kb/s
For other applications with no auto bandwidth control option, you can use trickle
Example for APT with upload rate of 20 KB/s and download rate of 50 KB/s (you need sudo trickle):
sudo trickle -u 20 -d 50 aptitude dist-upgrade
Example for wget with download rate of 30 KB/s:
trickle -d 30 wget http://...
From trickle's man page:
trickle is a userspace bandwidth manager. Currently, trickle supports the shaping of any SOCK_STREAM (see socket(2)) connection established via the socket(2) interface. Furthermore, trickle will not work with statically linked executables, nor with setuid(2) executables. trickle is highly configurable; download and upload rates can be set separately, or in an aggregate fashion.