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
22 #The CBS is about 60 MTU sized packets
26 ############################################################
28 # install the ingress qdisc on the ingress interface
29 $TC qdisc add dev
$INDEV handle ffff
: ingress
30 ############################################################
33 $TC filter add dev
$INDEV parent ffff
: protocol ip prio
4 handle
1: u32 \
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
53 $TC filter add dev
$INDEV parent ffff
: protocol ip prio
4 u32 \
54 match ip tos
0x88 0xfc \
58 # if it exceeds the above but not the extra rate/burst below, it gets a
62 $TC filter add dev
$INDEV parent ffff
: protocol ip prio
5 u32 \
63 match ip tos
0x88 0xfc \
67 # if it exceeds the above but not the rule below, it gets a tcindex value
70 $TC filter add dev
$INDEV parent ffff
: protocol ip prio
6 u32 \
71 match ip tos
0x88 0xfc \
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 \
87 # if it exceeds the above but not the rule below, it gets a tcindex value
90 $TC filter add dev
$INDEV parent ffff
: protocol ip prio
6 u32 \
91 match ip tos
0x90 0xfc \
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 \
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
113 $TC filter add dev
$INDEV parent ffff
: protocol ip prio
7 u32 \
118 ######################## Egress side ########################
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 \
132 $TC class change
$EGDEV classid
1:2 dsmark mask
0x3 \
135 $TC class change
$EGDEV classid
1:3 dsmark mask
0x3 \
138 $TC class change
$EGDEV classid
1:3 dsmark mask
0x3 \
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 ----------"
164 echo "---- Class parameters Egress ----------"
166 echo "---- filter parameters Egress ----------"
167 $TC filter
ls $EGDEV parent
1:0
169 #deleting the ingress qdisc
170 #$TC qdisc del $INDEV ingress