July 7, 2008 · Networking · Email This Post

Sponsored Link
If you want to limit your download and upload speeds use one of the following tools

1) Wondershaper

2) Trickle

Wondershaper

An easy to use traffic shaping script that provides these improvements:

* Low latency for interactive traffic (and pings) at all times
* Allow websurfing at reasonable speeds while uploading / downloading
* Make sure uploads don't hurt downloads
* Make sure downloads don't hurt uploads

It does this by:

* Limiting upload speed slightly, to eliminate queues
* Limiting download speed, while allowing bursts, to eliminate queues
* Interactive traffic skips the queue
* ACKs and tiny packets skip the queue

Configuring the wondershaper requires you to accurately and precisely determine your consistent upload and download speeds.

Install wondershaper in Ubuntu

sudo aptitude install wondershaper

This will complete the installation.

Using wondershaper

use ifconfig to determine which of your networkcards is the one that is connected to your modem (and thus the internet).

ifconfig

the networkcard that has your normal ip adress is the one (not 192.168.x.x)

Go to a speedtesting website and determine your average upload and download speed. Use these speeds to setup limitations.

sudo wondershaper eth1 downspeed upspeed

Note:- Speed should be in KB

Example

sudo wondershaper eth0 10000 280

download a big and uncompressable file while pinging to a fast and stable server on the internet or to your modem and adjust your downspeed until you are satisfied and do the same with uploading a big and uncompressable file.

When you are ready you can make these connection settings permanent by

sudo gedit /etc/network/interfaces

add these lines under eth1 if eth1 is your internetconnection. Change eth1,upspeed and downspeed to your settings.

up /sbin/wondershaper eth1 downspeed upspeed

down /sbin/wondershaper clear eth1

Useful Tip

How do I go about putting my settings back to default for eth1?

sudo wondershaper clear eth1

Problem

When you try to run similar to the following command

wondershaper eth3 4500 333

You might see the following error

What is "flowid"?
Illegal "police"

Solution

This is a bug in iproute, not in wondershaper. Debian has already fixed the problem

Replacing iproute2 with this http://mirror.aarnet.edu.au/debian/pool/main/i/iproute/iproute_20071016-3_i386.deb solved the problem

trickle

Trickle is a voluntary, cooperative bandwidth shaper. it works entirely in userland and is very easy to use.The most simple application is to limit the bandwidth usage of programs.

Install trickle in ubuntu

sudo aptitude install trickle

Stand alone mode

Trickle is easiest to use in stand-alone mode. Simply run trickle with a download and/or upload limit and a program you want to limit. For example:

sudo trickle -d 20 -u 20 wget http://www.google.com/bigfile

Daemon mode

In daemon mode, trickle can limit a group of programs to a fixed limit of bandwidth. To start the daemon, run the trickled command:

sudo trickled -d 20 -u 20

This will start the trickle daemon that will limit the total bandwidth available to all programs run via trickle to 20 K/s both up and down. So if you run a single program via trickle, it can consume 20 K/s. Two programs can each consume 10 K/s, etc.

Sponsored Link

Incoming search terms:

Related posts

9 Comments to “Use bandwidth shapers (wondershaper or trickle) to limit internet connection speed”

  1. Vadim P. says:

    Apt links please!

    [Reply]

  2. aff says:

    Note:- Speed should be in KB

    That is, in kilobits.

    [Reply]

  3. jrjones says:

    if we have 512 downlink speed and 128 uplink speed subscribed from our ISP, and we hav more or less 150 nodes to cutter… what would be the appropriate shaping for downlink and uplink settings?

    [Reply]

  4. zipizap123 says:

    to use trickle there is no need to “sudo” it, you can simply:

    trickle -d 20 -u 20 wget http://bigfile

    [Reply]

  5. zipizap123 says:

    NOTE: trickle can only limit bandwidth of applications that are dinamically linked.

    As explained in linux.com [http://www.linux.com/archive/feed/61293]


    Any user on the system can run Trickle without needing administrative privileges. The software can handle only TCP stream connections, so it cannot shape traffic for network services that uses UDP stream connections, such as DNS (Bind) and TFTP. Actually, it cannot work with all network services that use TCP streams; because trickle uses the dynamic linker and loader, it can handle only network services that uses dynamic libraries (glibc) and not any programs that are statically linked. You can check whether a network service or command uses dynamic libraries with help of the ldd command, which prints shared library dependencies, so that you can see exactly what libraries are used with the specific command. For example to check whether FTP uses dynamic libraries:

    ~# ldd /usr/bin/ftp | grep libc.so
    libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7d42000)

    Since I get back a positive result, I can use shape FTP traffic on my system. If the ldd and grep combination returns no result, a command will not work with trickle.

    So in my case, trickle is not enough for Spotify which is running through Wine..

    [Reply]

  6. rider skn says:

    trickle does not perform its job perfectly. it is wondershaper that is good. i have a fast but limited data connection, so when i browse through videos, i loose my MBs very fast and they go waste… so i controlled my internet speed and now it is saving my money… thank you

    [Reply]

  7. Mike Roussin says:

    I have not been able to find a means of making bandwidth setting permanent on wlan0. wlan0 is not in my /etc/network/interfaces so if I append the two lines:

    up /sbin/wondershaper eth1 downspeed upspeed

    down /sbin/wondershaper clear eth1

    my ethernet bandwidth is limited but not my wlan0.
    wondershaper has worked marvelously on my desktops but not on my laptops. I plan to execute a shell script at start up up to set wondershaper up/down limits. Please reply if there is an easier way to make wlan0 limits permanent.

    Thanks,

    mroussin51

    [Reply]

    Mike Roussin Reply:

    To whom it concerns:

    My problem was following this guide without reading the readme file.

    This…

    up /sbin/wondershaper eth1 downspeed upspeed

    down /sbin/wondershaper clear eth1

    is wrong.

    it should be…

    up /usr/sbin/wondershaper eth1 downspeed upspeed

    down /usr/sbin/wondershaper clear eth1

    see the readme…

    /usr/share/doc/wondershaper/README.Debian.gz

    Spare yourself the trouble. Follow the readme not this webpage.

    regards,

    Mike Roussin

    [Reply]

  8. asep mulya says:

    I’d like to restrict the bandwidth of certain websites. For example:

    How can I make http://www.example.org load at no more than 10KB/s?

    [Reply]

Leave a Reply