ttshaper.sh

NAME
SYNOPSIS
DESCRIPTION
OPERATION AND SETUP
RATES
FILES
BUGS
AUTHOR
SEE ALSO

NAME

ttshaper − An easy way to set up HTB (+ IMQ) shaping

SYNOPSIS

ttshaper.sh start|stop|restart|status|test [config_file]

DESCRIPTION

Tom’s traffic shaper written in Python. The shell script is a wrapper with better logging, usable in init sequences. Uses a config file. By default, it is /etc/network/ttshaper.conf. The default file comes with commented definitions. ttshaper.sh starts, stops, restarts, or shows status or checks the config file. It works by running the ttshaper.py script that actually does the work. ttshaper.sh script logs when appropriate (start, stop, restart) to logfile, by default /var/log/ttshaper.log. The status and test options log the output to stdout. The output may be quite long. The script aborts on any error.

Needs python 2.3 or higher, tc, iptables, ifconfig commands. Needs HTB, SFQ and optionally IMQ enabled in kernel. IMQ is in a separate patch.

OPERATION AND SETUP

ttshaper currently supports only HTB (+ IMQ optional) setup. This is one of useful setups. This brings you:

HTB:

guarranteed rate, ceil rate, priority

IMQ:

bandwidth is shared among multiple devices

This script:

per IP range speeds - upper/lower, download/upload

download and upload limited below physical capacity

NAT supported for private networks

free (unshaped) traffic definable

easy setup

It uses one interface to the Internet (usually eth{x}, optionally with NAT, referred to as UpDev) and one or many interfaces to customers. These are usually other eth{y} device(s). There may be only one such device, referred to as DownDev. If there are more customer devices, they are then grouped under an imq device, which is the DownDev.

The main entity is a Customer, who has an IP range, speeds (rate = min, ceil = max) per direction (up, down) and priorities per direction (lower number means higher priority). The last parameter defines if the customer is NAT’ed.

RATES

Each down_min (minimal download rate from Internet) is divided so that in sum they match the TotalDown value.

Each up_min (minimal upload rate to Internet) is divided so that in sum they matc the TotalUp value. For NAT’ed addresses, the min and max speed are determined globally and both have the same value. This value is the sum of up_min’s for all NAT’s divided with the same factor as other up_min’s. Desired and alloted rates are shown in the log. Real rates through classes can be seen using nusage(1).

With too high or too low computed rates you may have to change the R2Q parameter in the config. See dmesg(1) after ttshaper start.

FILES

/usr/local/sbin/ttshaper.sh

init shell script, resonable logging

/usr/local/sbin/ttshaper.py

actual worker

/etc/network/ttshaper.conf

default config...

/var/log/ttshaper.log

log...

BUGS

Classes are only at one level. Each class is furthermore bound to an IP range. Config file check is not strict enough.

Tell about me other bugs.

AUTHOR

Tom Olexa <olexat@post.cz>

SEE ALSO

tc(8), tc-htb(8), tc-sfq(8), iptables(8), dmesg(1), python(1), nusage(1), pydoc ttshaper