-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtc_borrowingwifi.bash
executable file
·111 lines (80 loc) · 2.55 KB
/
tc_borrowingwifi.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
#
# http://lartc.org/howto/lartc.qdisc.classful.html
# http://www.docum.org/docum.org/tests/cbq/classes.php
# http://lartc.org/howto/lartc.cookbook.ultimate-tc.html
#
TC=/sbin/tc
IF=wlxc04a001e7636 # Interface
DNLD=1.72mbit # DOWNLOAD Limit
LIM1=1mbit # for each class
LIM2=1mbit # for each class
CEIL=2mbit
start() {
#$TC qdisc add dev $IF root handle 1: htb default 30
#$TC class add dev $IF parent 1: classid 1:1 htb rate $DNLD burst 15k
$TC class add dev $IF parent 1:1 classid 1:10 htb rate $LIM1 burst 15k
$TC class add dev $IF parent 1:1 classid 1:20 htb rate $LIM2 ceil $CEIL burst 15k
$TC class add dev $IF parent 1:1 classid 1:30 htb rate 1kbit ceil $CEIL burst 15k
#$TC qdisc add dev $IF parent 1:10 handle 10: sfq perturb 10
#$TC qdisc add dev $IF parent 1:10 handle 10: fq_codel limit 300
#$TC qdisc add dev $IF parent 1:20 handle 20: sfq perturb 10
#$TC qdisc add dev $IF parent 1:20 handle 20: fq_codel limit 300
# $TC qdisc add dev $IF parent 1:30 handle 30: sfq perturb 10
U32="tc filter add dev $IF protocol ip parent 1:0 prio 1 u32"
# $U32 match ip dst 0.0.0.0/0 flowid 1:10
$U32 match ip sport 80 0xffff flowid 1:10
$U32 match ip dport 80 0xffff flowid 1:10
# $U32 match ip dst 0.0.0.0/0 flowid 1:20
$U32 match ip sport 8080 0xffff flowid 1:20
$U32 match ip dport 8080 0xffff flowid 1:20
show
}
stop() {
#$TC qdisc del dev $IF root
U32="tc filter del dev $IF protocol ip parent 1:0 prio 1 u32"
# $U32 match ip dst 0.0.0.0/0 flowid 1:10
$U32 match ip sport 80 0xffff flowid 1:10
$U32 match ip dport 80 0xffff flowid 1:10
# $U32 match ip dst 0.0.0.0/0 flowid 1:20
$U32 match ip sport 8080 0xffff flowid 1:20
$U32 match ip dport 8080 0xffff flowid 1:20
$TC class del dev $IF parent 1:1 classid 1:10 htb rate $LIM1 burst 15k
$TC class del dev $IF parent 1:1 classid 1:20 htb rate $LIM2 ceil $CEIL burst 15k
$TC class del dev $IF parent 1:1 classid 1:30 htb rate 1kbit ceil $CEIL burst 15k
}
restart() {
stop
sleep 1
start
}
show() {
$TC -s qdisc ls dev $IF
}
case "$1" in
start)
echo -n "Starting: "
start
echo "done"
;;
stop)
echo -n "Stopping: "
stop
echo "done"
;;
restart)
echo -n "Restarting: "
restart
echo "done"
;;
show)
echo "qdisc status for $IF:"
show
echo ""
;;
*)
pwd=$(pwd)
echo "Usage: $(/usr/bin/dirname $pwd)/tc_borrowing.bash {start|stop|restart|show}"
;;
esac
exit 0