1#! /bin/sh -x 2# 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) 9# 10# The colors are defined using the Diffserv Fields 11#path to various utilities; 12#change to reflect yours. 13# 14IPROUTE=/root/DS-6-beta/iproute2-990530-dsing 15TC=$IPROUTE/tc/tc 16IP=$IPROUTE/ip/ip 17IPCHAINS=/root/DS-6-beta/ipchains-1.3.9/ipchains 18INDEV=eth2 19EGDEV="dev eth1" 20CIR1=1000kbit 21CIR2=500kbit 22# the PIR is what is in excess of the CIR 23PIR1=1000kbit 24PIR2=500kbit 25 26#The CBS is about 60 MTU sized packets 27CBS1=90k 28CBS2=90k 29#the EBS is about 20 max sized packets 30EBS1=30k 31EBS2=30k 32 33# The meters: Note that we have shared meters in this case as identified 34# by the index parameter 35meter1=" police index 1 rate $CIR1 burst $CBS1 " 36meter1a=" police index 2 rate $PIR1 burst $EBS1 " 37meter2=" police index 3 rate $CIR2 burst $CBS1 " 38meter2a=" police index 4 rate $PIR2 burst $EBS1 " 39meter3=" police index 5 rate $CIR2 burst $CBS2 " 40meter3a=" police index 6 rate $PIR2 burst $EBS2 " 41meter4=" police index 7 rate $CIR1 burst $CBS2 " 42 43############################################################ 44# 45# install the ingress qdisc on the ingress interface 46$TC qdisc add dev $INDEV handle ffff: ingress 47############################################################ 48# 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 51# 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 55#policer 1 is used. 56# 57$TC filter add dev $INDEV parent ffff: protocol ip prio 1 u32 \ 58match ip tos 0x88 0xfc \ 59$meter1 \ 60continue flowid :1 61$TC filter add dev $INDEV parent ffff: protocol ip prio 2 u32 \ 62match ip tos 0x88 0xfc \ 63$meter1a \ 64continue flowid :1 65# 66# if it exceeds the above but not the extra rate/burst below, it gets a 67# tcindex value of 2 68# policer 2 is used 69# 70$TC filter add dev $INDEV parent ffff: protocol ip prio 3 u32 \ 71match ip tos 0x88 0xfc \ 72$meter2 \ 73continue flowid :2 74$TC filter add dev $INDEV parent ffff: protocol ip prio 4 u32 \ 75match ip tos 0x88 0xfc \ 76$meter2a \ 77continue flowid :2 78# 79# if it exceeds the above but not the rule below, it gets a tcindex value 80# of 3 (policer 3) 81# 82$TC filter add dev $INDEV parent ffff: protocol ip prio 5 u32 \ 83match ip tos 0x88 0xfc \ 84$meter3 \ 85continue flowid :3 86$TC filter add dev $INDEV parent ffff: protocol ip prio 6 u32 \ 87match ip tos 0x88 0xfc \ 88$meter3a \ 89drop flowid :3 90# 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 95# 96# 97$TC filter add dev $INDEV parent ffff: protocol ip prio 8 u32 \ 98match ip tos 0x90 0xfc \ 99$meter2 \ 100continue flowid :2 101$TC filter add dev $INDEV parent ffff: protocol ip prio 9 u32 \ 102match ip tos 0x90 0xfc \ 103$meter2a \ 104continue flowid :2 105# 106# if it exceeds the above but not the rule below, it gets a tcindex value 107# of 3 (policer 3) 108# 109$TC filter add dev $INDEV parent ffff: protocol ip prio 10 u32 \ 110match ip tos 0x90 0xfc \ 111$meter3 \ 112continue flowid :3 113$TC filter add dev $INDEV parent ffff: protocol ip prio 11 u32 \ 114match ip tos 0x90 0xfc \ 115$meter3a \ 116drop flowid :3 117 118# 119# *********************** AF43 *************************** 120# 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 124# 125$TC filter add dev $INDEV parent ffff: protocol ip prio 13 u32 \ 126match ip tos 0x98 0xfc \ 127$meter3 \ 128continue flowid :3 129$TC filter add dev $INDEV parent ffff: protocol ip prio 14 u32 \ 130match ip tos 0x98 0xfc \ 131$meter3a \ 132drop flowid :3 133# 134## *********************** BE *************************** 135## 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 139## case 140## 141$TC filter add dev $INDEV parent ffff: protocol ip prio 16 u32 \ 142match ip src 0/0\ 143$meter4 \ 144drop flowid :4 145 146######################## Egress side ######################## 147 148# attach a dsmarker 149# 150$TC qdisc add $EGDEV handle 1:0 root dsmark indices 64 151# 152# values of the DSCP to change depending on the class 153#note that the ECN bits are masked out 154# 155#AF41 (0x88 is 0x22 shifted to the right by two bits) 156# 157$TC class change $EGDEV classid 1:1 dsmark mask 0x3 \ 158 value 0x88 159#AF42 160$TC class change $EGDEV classid 1:2 dsmark mask 0x3 \ 161 value 0x90 162#AF43 163$TC class change $EGDEV classid 1:3 dsmark mask 0x3 \ 164 value 0x98 165#BE 166$TC class change $EGDEV classid 1:3 dsmark mask 0x3 \ 167 value 0x0 168# 169# 170# The class mapping 171# 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 180# 181 182# 183echo "---- qdisc parameters Ingress ----------" 184$TC qdisc ls dev $INDEV 185echo "---- Class parameters Ingress ----------" 186$TC class ls dev $INDEV 187echo "---- filter parameters Ingress ----------" 188$TC filter ls dev $INDEV parent ffff: 189 190echo "---- qdisc parameters Egress ----------" 191$TC qdisc ls $EGDEV 192echo "---- Class parameters Egress ----------" 193$TC class ls $EGDEV 194echo "---- filter parameters Egress ----------" 195$TC filter ls $EGDEV parent 1:0 196# 197#deleting the ingress qdisc 198#$TC qdisc del $INDEV ingress 199