Sometimes it’s useful to limit the bandwidth used by some of your programs, perhaps you want to limit your Browser or FTP client, and they dont’ have a native way to limit the input and/or output bandwidth they are using, there is a small application that can solve this problem for you: Trickle
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.
It allows you to limit the bandwidth consumption of a program without requiring all kinds of kernel patches, firewall configurations or root access to the machine on which you wish to use it. Trickle can run in collaborative and stand alone mode. In collaborative mode, trickle can limit the bandwidth used by a bunch of programs at the same time. In stand alone mode, trickle simply limits the program you specify.
Trickle it’s available on Debian and Ubuntu, so to install it you can use the standard package manager:
sudo aptitude install trickle
The easiest way to use Trickle it’s in the standalone mode, you use it with a single command, in this method the syntax it’s :
trickle -d Download_Bandwidth -u Upload_Bandwidth command
Example 1 : Limit the download bandwidth at 20Kbps for wget
trickle -d 20 wget http://linuxaria.com
Example 2 : Limit to 200kpbs the download bandwidth for a system update via aptitude:
trickle -d 200 aptitude upgrade
Example 3: Start Firefox limiting its upload badwidth to 10 KB/s, and download to 20 KB/s.
trickle -u 10 -d 20 firefox
Running trickle as a daemon collaborative-mode
To start trickle in daemon mode and limit all the bandwidth, use the command trickled with the following syntax:
sudo trickled -d Download_Bandwidth -u Upload_Bandwidth
Example 1; start the daemon, and limit upload and download at 100KB
trickled -d 100 -u 100
This will start the trickle daemon that will limit the total bandwidth available to all programs run via trickle to 100 KB/s both up and down. So if you run a single program via trickle, it can consume 100 KB/s. Two programs can each consume 50 KB/s, etc.
Trickle Configuration file
Trickle’s configuration file is located at /etc/trickled.conf. It contains two values by default, which are commented out.
An example of configuration could be:
[ssh] Priority = 1 Time-Smoothing = 0.1 Length-Smoothing = 1 [www] Priority = 2 Time-Smoothing = 5 Length-Smoothing = 10 [ftp] Priority = 8
Priority numbers let you set one service to have a higher priority relative to another. Services with a low number will get more bandwidth than services with higher numbers. By using priorities, you can connect to a services such as SSH remotely even if your network bandwidth is maxed out.
The smoothing time determines with what intervals trickle will try to let the application transcieve data. Smaller values will result in a more continuous (smooth) session, while larger values may produce bursts in the sending and receiving data. Smaller values (0.1 – 1 s) are ideal for interactive applications while slightly larger values (1 – 10 s) are better for applications that need bulk transfer.
The smoothing length is a fallback of the smoothing time. If trickle cannot meet the requested smoothing time, it will instead fall back on sending length KB of data. The default value is 10 KB.
Trickle doesn’t work with setuid programs
The reason for this is that setuid programs ignore the LD_PRELOAD functionality for security reasons. Trickle requires this functionality to do its shaping. (It also doesn’t work with statically linked programs for the same reason.)
Trickle only works with programs that use the socket interface for transmitting and receiving data
Also, it only works with TCP connections, not with UDP connections.
- Linux game: Garry’s Mod
- Check how much do you type with WhatPulse on Linux
- Zorin OS Contest Results
- Linux Terminal: speedtest_cli checks your real bandwidth speed.
- Counting and listing hard links on Linux
Find me on Google+