The sys admin's daily grind – Trickle
Blown Away
If your data traffic suffers from congestion at times, don't worry. Now you can shoot down programs that are heavy on traffic to free up the inflow and outflow.
I am over 40 years old and am starting to mellow in my old age. No, I'm only joking; certain phenomena still drive me up the wall. For example, when I am using SSH on a server to edit a configuration file and the bandwidth is so pathetic that the landing zone is a matter of luck when you try to position the cursor – that really makes me mad.
I know, I know, today even a line to a Black Forest village has enough bandwidth for an SSH connection, if you have exclusive access. Because hell, as Sartre already knew, is other people: In my case, it's the HTTP connections that are pushing my poor little SSH to the edge. I could turn to Mosh [1], but that helps with shaky connections rather than crowded lines. My remedy for traffic jams goes by the name of trickle [2] [3].
This traffic-shaping tool uses LD_PRELOAD
to redirect some standard library calls, such as socket()
and therefore only works with dynamically linked binaries. However, that practically includes all programs that the typical user deploys to eat up bandwidth. In the simplest case, I might even be one of these users myself; then, I can practice self-restraint when calling traffic-producing programs. To this end, I can start Firefox, for example, with:
trickle -u 32 -d 256 firefox
This command limits the upload speed (-u
) to 100KBps and the download speed (-d
) to 300KBps. Beware: These are actually kilobytes, not bits. I can also reduce speed in one direction only, if I am not worried about the other direction. Figure 1 shows the successful application of a download limit to 2Mbps.
Late Throttle
Trickle's boons naturally only occur to me when the download is already running and the SSH session hangs. Luckily, trickle has a daemon mode. Therefore, I launch trickle when I boot the machine with
trickled -u 32 -d 256
Of course, the values must be adapted to match the available bandwidth. When launched, the trickle daemon searches for /etc/trickled.conf
, which can look like Listing 1. It assigns certain protocols a priority and does some tweaking.
Listing 1
trickled.conf
The values that follow Time-Smoothing
and Length-Smoothing
determine how great the fluctuations can be over a certain interval. The smaller the value, the greater the benefits are for interactive protocols such as SSH. With larger values, sometimes a major outlier is permissible in both upward and downward directions. Trickle has some disadvantages compared with real traffic shaping, but it's fine for home use – maybe I really am getting soft.
Infos
- "Charly's Column: Mosh" by Charly Kühnast. Linux Magazine, November 2013, pg. 46: http://www.linuxpromagazine.com/Issues/2013/156/Charly-s-Column-Mosh
- Trickle: http://monkey.org/~marius/pages/?page=trickle
- "Traffic shaping with Trickle" by Oliver Frommel. Linux Magazine, January 2006, pg. 70: http://www.linux-magazine.com/Issues/2006/62/Traffic-shaping-with-Trickle
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.