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.2)
10 # The colors are defined using the Diffserv Fields
11 #path to various utilities;
12 #change to reflect yours.
14 IPROUTE=/root/DS-6-beta/iproute2-990530-dsing
17 IPCHAINS=/root/DS-6-beta/ipchains-1.3.9/ipchains
22 # the PIR is what is in excess of the CIR
26 #The CBS is about 60 MTU sized packets
29 #the EBS is about 20 max sized packets
33 # The meters: Note that we have shared meters in this case as identified
34 # by the index parameter
35 meter1=" police index 1 rate $CIR1 burst $CBS1 "
36 meter1a=" police index 2 rate $PIR1 burst $EBS1 "
37 meter2=" police index 3 rate $CIR2 burst $CBS1 "
38 meter2a=" police index 4 rate $PIR2 burst $EBS1 "
39 meter3=" police index 5 rate $CIR2 burst $CBS2 "
40 meter3a=" police index 6 rate $PIR2 burst $EBS2 "
41 meter4=" police index 7 rate $CIR1 burst $CBS2 "
43 ############################################################
45 # install the ingress qdisc on the ingress interface
46 $TC qdisc add dev $INDEV handle ffff: ingress
47 ############################################################
49 # All packets are marked with a tcindex value which is used on the egress
50 # tcindex 1 maps to AF41, 2->AF42, 3->AF43, 4->BE
52 # *********************** AF41 ***************************
53 #AF41 (DSCP 0x22) from is passed on with a tcindex value 1
54 #if it doesnt exceed its CIR/CBS + PIR/EBS
57 $TC filter add dev $INDEV parent ffff: protocol ip prio 1 u32 \
58 match ip tos 0x88 0xfc \
61 $TC filter add dev $INDEV parent ffff: protocol ip prio 2 u32 \
62 match ip tos 0x88 0xfc \
66 # if it exceeds the above but not the extra rate/burst below, it gets a
70 $TC filter add dev $INDEV parent ffff: protocol ip prio 3 u32 \
71 match ip tos 0x88 0xfc \
74 $TC filter add dev $INDEV parent ffff: protocol ip prio 4 u32 \
75 match ip tos 0x88 0xfc \
79 # if it exceeds the above but not the rule below, it gets a tcindex value
82 $TC filter add dev $INDEV parent ffff: protocol ip prio 5 u32 \
83 match ip tos 0x88 0xfc \
86 $TC filter add dev $INDEV parent ffff: protocol ip prio 6 u32 \
87 match ip tos 0x88 0xfc \
91 # *********************** AF42 ***************************
92 #AF42 (DSCP 0x24) from is passed on with a tcindex value 2
93 #if it doesnt exceed its CIR/CBS + PIR/EBS
94 #policer 2 is used. Note that this is shared with the AF41
97 $TC filter add dev $INDEV parent ffff: protocol ip prio 8 u32 \
98 match ip tos 0x90 0xfc \
101 $TC filter add dev $INDEV parent ffff: protocol ip prio 9 u32 \
102 match ip tos 0x90 0xfc \
106 # if it exceeds the above but not the rule below, it gets a tcindex value
109 $TC filter add dev $INDEV parent ffff: protocol ip prio 10 u32 \
110 match ip tos 0x90 0xfc \
113 $TC filter add dev $INDEV parent ffff: protocol ip prio 11 u32 \
114 match ip tos 0x90 0xfc \
119 # *********************** AF43 ***************************
121 #AF43 (DSCP 0x26) from is passed on with a tcindex value 3
122 #if it doesnt exceed its CIR/CBS + PIR/EBS
123 #policer 3 is used. Note that this is shared with the AF41 and AF42
125 $TC filter add dev $INDEV parent ffff: protocol ip prio 13 u32 \
126 match ip tos 0x98 0xfc \
129 $TC filter add dev $INDEV parent ffff: protocol ip prio 14 u32 \
130 match ip tos 0x98 0xfc \
134 ## *********************** BE ***************************
136 ## Anything else (not from the AF4*) gets discarded if it
137 ## exceeds 1Mbps and by default goes to BE if it doesnt
138 ## Note that the BE class is also used by the AF4* in the worst
141 $TC filter add dev $INDEV parent ffff: protocol ip prio 16 u32 \
146 ######################## Egress side ########################
150 $TC qdisc add $EGDEV handle 1:0 root dsmark indices 64
152 # values of the DSCP to change depending on the class
153 #note that the ECN bits are masked out
155 #AF41 (0x88 is 0x22 shifted to the right by two bits)
157 $TC class change $EGDEV classid 1:1 dsmark mask 0x3 \
160 $TC class change $EGDEV classid 1:2 dsmark mask 0x3 \
163 $TC class change $EGDEV classid 1:3 dsmark mask 0x3 \
166 $TC class change $EGDEV classid 1:3 dsmark mask 0x3 \
172 $TC filter add $EGDEV parent 1:0 protocol ip prio 1 \
173 handle 1 tcindex classid 1:1
174 $TC filter add $EGDEV parent 1:0 protocol ip prio 1 \
175 handle 2 tcindex classid 1:2
176 $TC filter add $EGDEV parent 1:0 protocol ip prio 1 \
177 handle 3 tcindex classid 1:3
178 $TC filter add $EGDEV parent 1:0 protocol ip prio 1 \
179 handle 4 tcindex classid 1:4
183 echo "---- qdisc parameters Ingress ----------"
184 $TC qdisc ls dev $INDEV
185 echo "---- Class parameters Ingress ----------"
186 $TC class ls dev $INDEV
187 echo "---- filter parameters Ingress ----------"
188 $TC filter ls dev $INDEV parent ffff:
190 echo "---- qdisc parameters Egress ----------"
192 echo "---- Class parameters Egress ----------"
194 echo "---- filter parameters Egress ----------"
195 $TC filter ls $EGDEV parent 1:0
197 #deleting the ingress qdisc
198 #$TC qdisc del $INDEV ingress