d912f4dcaf1aa8f1bbab77435736b10354a34fd1
3 # please read the README before filling out these values
5 # Set the following values to somewhat less than your actual download
6 # and uplink speed. In kilobits. Also set the device that is to be shaped.
8 MODULES
='sch_ingress sch_sfq sch_htb cls_u32'
13 # low priority OUTGOING traffic - you can leave this blank if you want
14 # low priority source netmasks
17 # low priority destination netmasks
20 # low priority source ports
23 # low priority destination ports
26 if [ "$1" = "status" ]
28 tc
-s qdisc
ls dev
$DEV
29 tc
-s class
ls dev
$DEV
34 # clean existing down- and uplink qdiscs, hide errors
35 tc qdisc del dev
$DEV root
2> /dev
/null
> /dev
/null
36 tc qdisc del dev
$DEV ingress
2> /dev
/null
> /dev
/null
40 for i
in $MODULES ; do
46 for i
in $MODULES ; do
52 # install root HTB, point default traffic to 1:20:
54 tc qdisc add dev
$DEV root handle
1: htb default
20
56 # shape everything at $UPLINK speed - this prevents huge queues in your
57 # DSL modem which destroy latency:
59 tc class add dev
$DEV parent
1: classid
1:1 htb rate
${UPLINK}kbit burst
6k
61 # high prio class 1:10:
63 tc class add dev
$DEV parent
1:1 classid
1:10 htb rate
${UPLINK}kbit \
66 # bulk & default class 1:20 - gets slightly less traffic,
67 # and a lower priority:
69 tc class add dev
$DEV parent
1:1 classid
1:20 htb rate $
((9*$UPLINK/10))kbit \
72 tc class add dev
$DEV parent
1:1 classid
1:30 htb rate $
((8*$UPLINK/10))kbit \
75 # all get Stochastic Fairness:
76 tc qdisc add dev
$DEV parent
1:10 handle
10: sfq perturb
10
77 tc qdisc add dev
$DEV parent
1:20 handle
20: sfq perturb
10
78 tc qdisc add dev
$DEV parent
1:30 handle
30: sfq perturb
10
80 # TOS Minimum Delay (ssh, NOT scp) in 1:10:
82 tc filter add dev
$DEV parent
1:0 protocol ip prio
10 u32 \
83 match ip tos
0x10 0xff flowid
1:10
85 # ICMP (ip protocol 1) in the interactive class 1:10 so we
86 # can do measurements & impress our friends:
87 tc filter add dev
$DEV parent
1:0 protocol ip prio
10 u32 \
88 match ip protocol
1 0xff flowid
1:10
90 # To speed up downloads while an upload is going on, put ACK packets in
91 # the interactive class:
93 tc filter add dev
$DEV parent
1: protocol ip prio
10 u32 \
94 match ip protocol
6 0xff \
95 match u8
0x05 0x0f at 0 \
96 match u16
0x0000 0xffc0 at 2 \
97 match u8
0x10 0xff at 33 \
100 # rest is 'non-interactive' ie 'bulk' and ends up in 1:20
102 # some traffic however suffers a worse fate
103 for a
in $NOPRIOPORTDST
105 tc filter add dev
$DEV parent
1: protocol ip prio
14 u32 \
106 match ip dport
$a 0xffff flowid
1:30
109 for a
in $NOPRIOPORTSRC
111 tc filter add dev
$DEV parent
1: protocol ip prio
15 u32 \
112 match ip sport
$a 0xffff flowid
1:30
115 for a
in $NOPRIOHOSTSRC
117 tc filter add dev
$DEV parent
1: protocol ip prio
16 u32 \
118 match ip src
$a flowid
1:30
121 for a
in $NOPRIOHOSTDST
123 tc filter add dev
$DEV parent
1: protocol ip prio
17 u32 \
124 match ip dst
$a flowid
1:30
127 # rest is 'non-interactive' ie 'bulk' and ends up in 1:20
129 tc filter add dev
$DEV parent
1: protocol ip prio
18 u32 \
130 match ip dst
0.0.0.0/0 flowid
1:20
133 ########## downlink #############
134 # slow downloads down to somewhat less than the real speed to prevent
135 # queuing at our ISP. Tune to see how high you can set it.
136 # ISPs tend to have *huge* queues to make sure big downloads are fast
138 # attach ingress policer:
140 tc qdisc add dev
$DEV handle ffff
: ingress
142 # filter *everything* to it (0.0.0.0/0), drop everything that's
143 # coming in too fast:
145 tc filter add dev
$DEV parent ffff
: protocol ip prio
50 u32 match ip src \
146 0.0.0.0/0 police rate
${DOWNLINK}kbit burst
10k drop flowid
:1