Wondershaper

From SME Server
Revision as of 13:18, 15 November 2007 by RayMitchell (talk | contribs) (added HTBWondershaper script Howto)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

HTBWondershaper Traffic Shaping script

Description

The HTBWondershaper script implements traffic shaping by filtering outgoing traffic into classes and setting limits/priorities for these classes. Each class gets a lower and upper bandwidth limit. Each class also has a priority, and if the priority is lower, the traffic goes first.

Design Benefits

It uses HTB filter: this guarantees minimum bandwidth per class and divides surplus bandwidth evenly

It uses "iptables marks" to filter traffic into classes. This means you can use the rather simple iptables language to put specific traffic into TC classes rather than the complex non-documented TC stuff.

Nomenclature

Shaping: The process of delaying packets before they go out to make traffic confirm to a configured maximum rate. Shaping is performed on egress (outgoing traffic). Colloquially, dropping packets to slow traffic down is also often called Shaping.

Policing: Delaying or dropping packets in order to make traffic stay below a configured bandwidth. In Linux, policing can only drop a packet and not delay it - there is no 'ingress queue'.


Installation instructions

Log in to your sme server as root or as a user with root privileges and do

mkdir -p /opt/scripts/htbw
cd /opt/scripts/htbw
wget http://www.hanscees.com/sme7/HTBWondershaper

Edit the script to make basic changes for your broadband connection speed

pico -w /opt/scripts/htbw/HTBWondershaper

As a minimum adjust the variables DOWNLINK, CEIL, EXTDEV & LANDEV to suit yuour situation DOWNLINK should be your actual (not rated) download speed in Kb CEIL should be 75% of your actual (not rated) upstream bandwidth in Kb EXTDEV is your external internet device usually eth1 LANDEV is your local device usually eth0 Typical settings for a "real world" ADSL connection that is 2 or 3 km from a telephone exchange eg on line 99

DOWNLINK=4000

on line 103

CEIL=560

on line 108 & 109

EXTDEV=eth1
LANDEV=eth0

Save the changes & exit

Ctrl o
Ctrl x

Make make the script executable

cd /opt/scripts/htbw
chmod +x HTBWondershaper


Add the script to the start up sequence to load it at reboot

pico -w /etc/rc.d/rc.local

Add the following line to the end of the file (change location to suit where you actually put the script)

/opt/scripts/htbw/HTBWondershaper

Save & exit

Ctrl o
Ctrl x

Start the HTBWondershaper script

/opt/scripts/htbw/HTBWondershaper

Check the status of the script

/opt/scripts/htbw/HTBWondershaper status

Next time your server reboots check that the HTBWondershaper script runs during the startup process.


Removal instructions

To totally remove the script from your system and stop the script from running at startup time do the following.

To stop the script do

/opt/scripts/htbw/HTBWondershaper stop

Delete the script

rm /opt/scripts/htbw/HTBWondershaper

Remove the starup entry from /etc/rc.d/rc.local

pico -w /etc/rc.d/rc.local

Remove the following line from the file

/opt/scripts/htbw/HTBWondershaper

Save & exit

Ctrl o
Ctrl x


Additional configuration tips & information

The script is highly customisable. There is detailed information within the script, so please carefully read the script contents to see the extent of configuration possibilities. Please read the information at the authors website http://www.hanscees.com/sme7/wondershaperbeefedup.html

Also read information provided in the forum posts shown in the References section for additional configuration tips.


References

http://forums.contribs.org/index.php?topic=29546.0 http://forums.contribs.org/index.php?topic=29495.0 http://www.hanscees.com/sme7/wondershaperbeefedup.html http://www.hanscees.com/sme7/HTBWondershaper http://lartc.org/