wnd's weblog

Trickle, userspace bandwidth shaper

10 Jul 2007 10:11:09 software

Do you need to shape network traffic per application? Meet Trickle, a general purpose userspace bandwidth shaper.

I’m sitting at work, reading my email though my home computer, and listening to Nectarine. I’ve been listening Nectarine and Kohina exclusively for ages. For some reason, I’m suddenly totally fed up with these tunes. I start transferring some music (legally ripped from CDs I own, of course) from my home computer to my workstation at work, just to realize reading email has suddenly become very sluggish. That is something you get with an asymmetric xDSL-cable with no traffic shaping set.

I’ve used Wonder Shaper to set up intranet-global traffic shaping rules back home, but since my upstream limit varies from day to day, it’s not very practical. One day I can upload 80 KiB/s just fine, another day mere 50 KiB/s will bring my SSH-connections to near-halt. Obviously I should be shaping the traffic per process. This is where Trickle comes in picture.

In the most basic use case Trickle is trivial to use. To copy a file to remote host using scp, you can limit the upload speed to, say, 40 KiB/s:

trickle -u 40 scp bigfile host:

As I’m copying several files from my home computer while at work, I just issue the following command:

trickle -d 40 -t 0.1 ssh kikai \
	'tar -cf - audio/Christopher_Franke_-_Babylon_5' \
	| tar -xvvf -

Since compiling from the sources available on Trickle website at monkey.org didn’t work out too great, I grabbed the sources (and patches) from local Debian repository.

Edit: 23 Sep 2019

For single files, just use scp -l 320 ...

For rsync, use rsync --bwlimit

For ssh | tar, or even sshfs, use ssh ProxyCommand option and do rate limiting with pv.

Original link: http://monkey.org/~marius/pages/?page=trickle