Busybox: Upgrade to 1.21.1 (stable). lsof active.
[tomato.git] / release / src / router / iproute2 / examples / diffserv / Edge31-ca-u32
blob25e6c0b1039993029e8e2e6f1ea8d5c2d9596e17
1 #! /bin/sh -x
3 # sample script on using the ingress capabilities using u32 classifier
4 # This script tags tcindex based on metering on the ingress
5 # interface the result is used for fast classification and re-marking
6 # on the egress interface
7 # This is an example of a color aware mode marker with PIR configured
8 # based on draft-wahjak-mcm-00.txt (section 3.1)
10 # The colors are defined using the Diffserv Fields
11 #path to various utilities;
12 #change to reflect yours.
14 IPROUTE=/usr/src/iproute2-current
15 TC=$IPROUTE/tc/tc
16 IP=$IPROUTE/ip/ip
17 INDEV=eth0
18 EGDEV="dev eth1"
19 CIR1=1500kbit
20 CIR2=1000kbit
22 #The CBS is about 60 MTU sized packets
23 CBS1=90k
24 CBS2=90k
26 ############################################################
28 # install the ingress qdisc on the ingress interface
29 $TC qdisc add dev $INDEV handle ffff: ingress
30 ############################################################
32 # Create u32 filters
33 $TC filter add dev $INDEV parent ffff: protocol ip prio 4 handle 1: u32 \
34 divisor 1
35 ############################################################
37 # The meters: Note that we have shared meters in this case as identified
38 # by the index parameter
39 meter1=" police index 1 rate $CIR1 burst $CBS1 "
40 meter2=" police index 2 rate $CIR2 burst $CBS1 "
41 meter3=" police index 3 rate $CIR2 burst $CBS2 "
42 meter4=" police index 4 rate $CIR1 burst $CBS2 "
43 meter5=" police index 5 rate $CIR1 burst $CBS2 "
45 # All packets are marked with a tcindex value which is used on the egress
46 # tcindex 1 maps to AF41, 2->AF42, 3->AF43, 4->BE
48 # *********************** AF41 ***************************
49 #AF41 (DSCP 0x22) is passed on with a tcindex value 1
50 #if it doesnt exceed its CIR/CBS
51 #policer 1 is used.
53 $TC filter add dev $INDEV parent ffff: protocol ip prio 4 u32 \
54 match ip tos 0x88 0xfc \
55 $meter1 \
56 continue flowid :1
58 # if it exceeds the above but not the extra rate/burst below, it gets a
59 # tcindex value of 2
60 # policer 2 is used
62 $TC filter add dev $INDEV parent ffff: protocol ip prio 5 u32 \
63 match ip tos 0x88 0xfc \
64 $meter2 \
65 continue flowid :2
67 # if it exceeds the above but not the rule below, it gets a tcindex value
68 # of 3 (policer 3)
70 $TC filter add dev $INDEV parent ffff: protocol ip prio 6 u32 \
71 match ip tos 0x88 0xfc \
72 $meter3 \
73 drop flowid :3
76 # *********************** AF42 ***************************
77 #AF42 (DSCP 0x24) from is passed on with a tcindex value 2
78 #if it doesnt exceed its CIR/CBS
79 #policer 2 is used. Note that this is shared with the AF41
82 $TC filter add dev $INDEV parent ffff: protocol ip prio 5 u32 \
83 match ip tos 0x90 0xfc \
84 $meter2 \
85 continue flowid :2
87 # if it exceeds the above but not the rule below, it gets a tcindex value
88 # of 3 (policer 3)
90 $TC filter add dev $INDEV parent ffff: protocol ip prio 6 u32 \
91 match ip tos 0x90 0xfc \
92 $meter3 \
93 drop flowid :3
95 # *********************** AF43 ***************************
97 #AF43 (DSCP 0x26) from is passed on with a tcindex value 3
98 #if it doesnt exceed its CIR/CBS
99 #policer 3 is used. Note that this is shared with the AF41 and AF42
101 $TC filter add dev $INDEV parent ffff: protocol ip prio 6 u32 \
102 match ip tos 0x98 0xfc \
103 $meter3 \
104 drop flowid :3
106 # *********************** BE ***************************
108 # Anything else (not from the AF4*) gets discarded if it
109 # exceeds 1Mbps and by default goes to BE if it doesnt
110 # Note that the BE class is also used by the AF4* in the worst
111 # case
113 $TC filter add dev $INDEV parent ffff: protocol ip prio 7 u32 \
114 match ip src 0/0\
115 $meter4 \
116 drop flowid :4
118 ######################## Egress side ########################
120 # attach a dsmarker
122 $TC qdisc add $EGDEV handle 1:0 root dsmark indices 64
124 # values of the DSCP to change depending on the class
125 #note that the ECN bits are masked out
127 #AF41 (0x88 is 0x22 shifted to the right by two bits)
129 $TC class change $EGDEV classid 1:1 dsmark mask 0x3 \
130 value 0x88
131 #AF42
132 $TC class change $EGDEV classid 1:2 dsmark mask 0x3 \
133 value 0x90
134 #AF43
135 $TC class change $EGDEV classid 1:3 dsmark mask 0x3 \
136 value 0x98
138 $TC class change $EGDEV classid 1:3 dsmark mask 0x3 \
139 value 0x0
142 # The class mapping
144 $TC filter add $EGDEV parent 1:0 protocol ip prio 1 \
145 handle 1 tcindex classid 1:1
146 $TC filter add $EGDEV parent 1:0 protocol ip prio 1 \
147 handle 2 tcindex classid 1:2
148 $TC filter add $EGDEV parent 1:0 protocol ip prio 1 \
149 handle 3 tcindex classid 1:3
150 $TC filter add $EGDEV parent 1:0 protocol ip prio 1 \
151 handle 4 tcindex classid 1:4
155 echo "---- qdisc parameters Ingress ----------"
156 $TC qdisc ls dev $INDEV
157 echo "---- Class parameters Ingress ----------"
158 $TC class ls dev $INDEV
159 echo "---- filter parameters Ingress ----------"
160 $TC filter ls dev $INDEV parent ffff:
162 echo "---- qdisc parameters Egress ----------"
163 $TC qdisc ls $EGDEV
164 echo "---- Class parameters Egress ----------"
165 $TC class ls $EGDEV
166 echo "---- filter parameters Egress ----------"
167 $TC filter ls $EGDEV parent 1:0
169 #deleting the ingress qdisc
170 #$TC qdisc del $INDEV ingress