source: npl/internetserver/wshaper/rc.shaper @ 2154c77

Last change on this file since 2154c77 was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100755
File size: 3.5 KB
Line 
1#!/bin/bash
2#wshaper.htb - modified by DatuX for syn3
3
4# Wonder Shaper
5# please read the README before filling out these values
6#
7# Set the following values to somewhat less than your actual download
8# and uplink speed. In kilobits. Also set the device that is to be shaped.
9
10source /etc/wshaper.conf
11
12
13if [ "$1" = "status" ]
14then
15        tc -s qdisc ls dev $DEV
16        tc -s class ls dev $DEV
17        exit
18fi
19
20
21# clean existing down- and uplink qdiscs, hide errors
22tc qdisc del dev $DEV root    2> /dev/null > /dev/null
23tc qdisc del dev $DEV ingress 2> /dev/null > /dev/null
24
25if [ "$1" = "stop" ]
26then
27        exit
28fi
29
30
31###### uplink
32
33# install root HTB, point default traffic to 1:20:
34
35tc qdisc add dev $DEV root handle 1: htb default 20
36
37# shape everything at $UPLINK speed - this prevents huge queues in your
38# DSL modem which destroy latency:
39
40#geen burst zetten, berekend htb tegenwoordig automatisch
41tc class add dev $DEV parent 1: classid 1:1 htb rate ${UPLINK}kbit
42
43# high prio class 1:10:
44
45tc class add dev $DEV parent 1:1 classid 1:10 htb rate ${UPLINK}kbit \
46   burst 6k prio 1
47
48# bulk & default class 1:20 - gets slightly less traffic,
49# and a lower priority:
50
51tc class add dev $DEV parent 1:1 classid 1:20 htb rate $[9*$UPLINK/10]kbit \
52   burst 6k prio 2
53
54tc class add dev $DEV parent 1:1 classid 1:30 htb rate $[8*$UPLINK/10]kbit \
55   burst 6k prio 2
56
57# all get Stochastic Fairness:
58tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
59tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
60tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
61
62# TOS Minimum Delay (ssh, NOT scp) in 1:10:
63
64tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 \
65      match ip tos 0x10 0xff  flowid 1:10
66
67# ICMP (ip protocol 1) in the interactive class 1:10 so we
68# can do measurements & impress our friends:
69tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 \
70        match ip protocol 1 0xff flowid 1:10
71
72# To speed up downloads while an upload is going on, put ACK packets in
73# the interactive class:
74
75tc filter add dev $DEV parent 1: protocol ip prio 10 u32 \
76   match ip protocol 6 0xff \
77   match u8 0x05 0x0f at 0 \
78   match u16 0x0000 0xffc0 at 2 \
79   match u8 0x10 0xff at 33 \
80   flowid 1:10
81
82# rest is 'non-interactive' ie 'bulk' and ends up in 1:20
83
84# some traffic however suffers a worse fate
85for a in $NOPRIOPORTDST
86do
87        tc filter add dev $DEV parent 1: protocol ip prio 14 u32 \
88           match ip dport $a 0xffff flowid 1:30
89done
90
91for a in $NOPRIOPORTSRC
92do
93        tc filter add dev $DEV parent 1: protocol ip prio 15 u32 \
94           match ip sport $a 0xffff flowid 1:30
95done
96
97for a in $NOPRIOHOSTSRC
98do
99        tc filter add dev $DEV parent 1: protocol ip prio 16 u32 \
100           match ip src $a flowid 1:30
101done
102
103for a in $NOPRIOHOSTDST
104do
105        tc filter add dev $DEV parent 1: protocol ip prio 17 u32 \
106           match ip dst $a flowid 1:30
107done
108
109# rest is 'non-interactive' ie 'bulk' and ends up in 1:20
110
111tc filter add dev $DEV parent 1: protocol ip prio 18 u32 \
112   match ip dst 0.0.0.0/0 flowid 1:20
113
114
115########## downlink #############
116# slow downloads down to somewhat less than the real speed  to prevent
117# queuing at our ISP. Tune to see how high you can set it.
118# ISPs tend to have *huge* queues to make sure big downloads are fast
119#
120# attach ingress policer:
121
122#UIT, werkt slecht bij hogere snelheden en niet echt nodig
123
124#tc qdisc add dev $DEV handle ffff: ingress
125
126# filter *everything* to it (0.0.0.0/0), drop everything that's
127# coming in too fast:
128
129#tc filter add dev $DEV parent ffff: protocol ip prio 50 u32 match ip src \
130 #  0.0.0.0/0 police rate ${DOWNLINK}kbit drop flowid :1
131
132
Note: See TracBrowser for help on using the repository browser.