Limit download and upload speed on Linux
I tend to do a lot of things in a terminal that take up my bandwidth. Unfortunately I don’t currently have a lot of bandwidth to spare and it can really hurt to watch apt take 99% of my bandwidth during a large update. Along comes trickle to help manage bandwidth usage.
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.
Trickle is available from the Debian repositories, or visit the trickle page to download.
$ aptitude install trickle
Once you have trickle installed usage is pretty straight forward. The options are as follows.
Usage: trickle [-hvVs] [-d <rate>] [-u <rate>] [-w <length>] [-t <seconds>]
[-l <length>] [-n <path>] command …
-h Help (this)
-v Increase verbosity level
-V Print trickle version
-s Run trickle in standalone mode independent of trickled
-d <rate> Set maximum cumulative download rate to <rate> KB/s
-u <rate> Set maximum cumulative upload rate to <rate> KB/s
-w <length> Set window length to <length> KB
-t <seconds> Set default smoothing time to <seconds> s
-l <length> Set default smoothing length to <length> KB
-n <path> Use trickled socket name <path>
-L <ms> Set latency to <ms> milliseconds
-P <path> Preload the specified .so instead of the default one
An example of how to limit an aptitude distribution upgrade to 25kb/s.
$ trickle -s -d 25 aptitude dist-upgrade


•