#!/bin/bash # Derived from the WonderShaper (http://lartc.org/wondershaper) # Which is: # bert hubert # Copyright 2002 # Licensed under the GPL # Distributed under the terms of the GPL as it's derived from Wondershaper # which is GPL! DOWNLINK=512 UPLINK=128 DEV=eth1 # clean existing down- and uplink qdiscs, hide errors tc qdisc del dev $DEV root 2> /dev/null > /dev/null tc qdisc del dev $DEV ingress 2> /dev/null > /dev/null ###### uplink # install root CBQ tc qdisc add dev $DEV root handle 1: cbq avpkt 1000 bandwidth 10mbit # shape everything at $UPLINK speed - this prevents huge queues in your # DSL modem which destroy latency: # main class tc class add dev $DEV parent 1: classid 1:1 cbq rate ${UPLINK}kbit \ allot 1500 prio 5 bounded isolated # high prio class 1:10: tc class add dev $DEV parent 1:1 classid 1:5 cbq rate ${UPLINK}kbit \ allot 1600 prio 1 avpkt 1000 # bulk and default class 1:10 - normal stuff tc class add dev $DEV parent 1:1 classid 1:10 cbq rate $[9*$UPLINK/10]kbit \ allot 1600 prio 2 avpkt 1000 # # bulk and default class 1:15 - gets slightly less traffic, # and a lower priority: tc class add dev $DEV parent 1:1 classid 1:15 cbq rate $[5*$UPLINK/10]kbit \ allot 1600 prio 3 avpkt 1000 # both get Stochastic Fairness: tc qdisc add dev $DEV parent 1:5 handle 5: sfq perturb 10 tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10 tc qdisc add dev $DEV parent 1:15 handle 15: sfq perturb 10 # filters tc filter add dev $DEV parent 1:0 protocol ip prio 5 handle 5 fw classid 1:5 tc filter add dev $DEV parent 1:0 protocol ip prio 10 handle 10 fw classid 1:10 tc filter add dev $DEV parent 1:0 protocol ip prio 15 handle 15 fw classid 1:15