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 | |
---|
10 | source /etc/wshaper.conf |
---|
11 | |
---|
12 | |
---|
13 | if [ "$1" = "status" ] |
---|
14 | then |
---|
15 | tc -s qdisc ls dev $DEV |
---|
16 | tc -s class ls dev $DEV |
---|
17 | exit |
---|
18 | fi |
---|
19 | |
---|
20 | |
---|
21 | # clean existing down- and uplink qdiscs, hide errors |
---|
22 | tc qdisc del dev $DEV root 2> /dev/null > /dev/null |
---|
23 | tc qdisc del dev $DEV ingress 2> /dev/null > /dev/null |
---|
24 | |
---|
25 | if [ "$1" = "stop" ] |
---|
26 | then |
---|
27 | exit |
---|
28 | fi |
---|
29 | |
---|
30 | |
---|
31 | ###### uplink |
---|
32 | |
---|
33 | # install root HTB, point default traffic to 1:20: |
---|
34 | |
---|
35 | tc 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 |
---|
41 | tc class add dev $DEV parent 1: classid 1:1 htb rate ${UPLINK}kbit |
---|
42 | |
---|
43 | # high prio class 1:10: |
---|
44 | |
---|
45 | tc 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 | |
---|
51 | tc class add dev $DEV parent 1:1 classid 1:20 htb rate $[9*$UPLINK/10]kbit \ |
---|
52 | burst 6k prio 2 |
---|
53 | |
---|
54 | tc 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: |
---|
58 | tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10 |
---|
59 | tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10 |
---|
60 | tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10 |
---|
61 | |
---|
62 | # TOS Minimum Delay (ssh, NOT scp) in 1:10: |
---|
63 | |
---|
64 | tc 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: |
---|
69 | tc 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 | |
---|
75 | tc 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 |
---|
85 | for a in $NOPRIOPORTDST |
---|
86 | do |
---|
87 | tc filter add dev $DEV parent 1: protocol ip prio 14 u32 \ |
---|
88 | match ip dport $a 0xffff flowid 1:30 |
---|
89 | done |
---|
90 | |
---|
91 | for a in $NOPRIOPORTSRC |
---|
92 | do |
---|
93 | tc filter add dev $DEV parent 1: protocol ip prio 15 u32 \ |
---|
94 | match ip sport $a 0xffff flowid 1:30 |
---|
95 | done |
---|
96 | |
---|
97 | for a in $NOPRIOHOSTSRC |
---|
98 | do |
---|
99 | tc filter add dev $DEV parent 1: protocol ip prio 16 u32 \ |
---|
100 | match ip src $a flowid 1:30 |
---|
101 | done |
---|
102 | |
---|
103 | for a in $NOPRIOHOSTDST |
---|
104 | do |
---|
105 | tc filter add dev $DEV parent 1: protocol ip prio 17 u32 \ |
---|
106 | match ip dst $a flowid 1:30 |
---|
107 | done |
---|
108 | |
---|
109 | # rest is 'non-interactive' ie 'bulk' and ends up in 1:20 |
---|
110 | |
---|
111 | tc 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 | |
---|