From: "Luciana Esteves Neves Hilario" Date: Fri, 14 Jul 2006 20:56:56 +0000 Subject: [LARTC] I need help with tc filters!!!!! Message-Id: <004e01c6a788$0be29f70$e10f14c8@setiba> MIME-Version: 1 Content-Type: multipart/mixed; boundary="----=_NextPart_000_004A_01C6A76E.E547B1C0" List-Id: To: lartc@vger.kernel.org This is a multi-part message in MIME format. ------=_NextPart_000_004A_01C6A76E.E547B1C0 Content-Type: multipart/alternative; boundary="----=_NextPart_001_004B_01C6A76E.E547B1C0" ------=_NextPart_001_004B_01C6A76E.E547B1C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Everybody! I need help! I'm doing a tc script with tc filters that have match = the Type of Service field in the IP header. This is the script I am = using to setup the filters. tc filter add dev $DEV parent 1: protocol ip prio $PRIO_CONTROL u32 = match ip protocol 6 0xff \ match u32 00190000 00ff0000 at 0 flowid 1:10 tc filter add dev $DEV protocol ip parent 1: prio $PRIO_VIDEO u32 match = ip protocol 17 0xff \ match u32 001b0000 00ff0000 at 0 \ police rate ${VIDEO_LEVEL_0_BW}kbit buffer ${VIDEO_BUFFER}k drop flowid = 1:13 tc filter add dev $DEV protocol ip parent 1: prio $PRIO_VIDEO u32 match = ip protocol 17 0xff \ match u32 000b0000 00ff0000 at 0 \ police rate ${VIDEO_LEVEL_1_BW}kbit buffer ${VIDEO_BUFFER}k drop flowid = 1:14 tc filter add dev $DEV protocol ip parent 1: prio $PRIO_VIDEO u32 match = ip protocol 17 0xff \ match u32 00130000 00ff0000 at 0 \ police rate ${VIDEO_LEVEL_2_BW}kbit buffer ${VIDEO_BUFFER}k drop flowid = 1:15 tc filter add dev $DEV protocol ip parent 1: prio $PRIO_VIDEO u32 match = ip protocol 17 0xff \ match u32 00030000 00ff0000 at 0 \ police rate ${VIDEO_LEVEL_3_BW}kbit buffer ${VIDEO_BUFFER}k drop flowid = 1:16 Please, if someone could help me, I will be so glad! The role script is = the file attached Thanks a lot Luciana ------=_NextPart_001_004B_01C6A76E.E547B1C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi Everybody!
 
    I need help! I'm = doing a tc=20 script with tc filters that have match the Type of Service field in the = IP=20 header. This is the script I am using to setup the filters.
 

tc filter add dev $DEV parent 1: protocol ip prio $PRIO_CONTROL u32 match ip=20 protocol 6 0xff \

match u32 00190000 00ff0000 at 0 flowid 1:10

 

tc filter add dev $DEV protocol ip parent 1: prio=20 $PRIO_VIDEO u32 match ip protocol 17 0xff = \

match u32 001b0000 00ff0000 at 0 \

police rate ${VIDEO_LEVEL_0_BW}kbit buffer = ${VIDEO_BUFFER}k=20 drop flowid 1:13

 

tc filter add dev $DEV protocol ip parent 1: prio=20 $PRIO_VIDEO u32 match ip protocol 17 0xff = \

match u32 000b0000 00ff0000 at 0 \

police rate ${VIDEO_LEVEL_1_BW}kbit buffer = ${VIDEO_BUFFER}k=20 drop flowid 1:14

 

tc filter add dev $DEV protocol ip parent 1: prio=20 $PRIO_VIDEO u32 match ip protocol 17 0xff = \

match u32 00130000 00ff0000 at 0 \

police rate ${VIDEO_LEVEL_2_BW}kbit buffer = ${VIDEO_BUFFER}k=20 drop flowid 1:15

 

tc filter add dev $DEV protocol ip parent 1: prio=20 $PRIO_VIDEO u32 match ip protocol 17 0xff = \

match u32 00030000 00ff0000 at 0 \

police rate ${VIDEO_LEVEL_3_BW}kbit buffer = ${VIDEO_BUFFER}k=20 drop flowid 1:16

 

Please, if someone could help me, I will be so = glad! The=20 role script is the file attached

Thanks a lot

Luciana

------=_NextPart_001_004B_01C6A76E.E547B1C0-- ------=_NextPart_000_004A_01C6A76E.E547B1C0 Content-Type: application/octet-stream; name="router_qos_script.sh" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="router_qos_script.sh" #!/bin/sh=0A= #=0A= # 1st parameter MAX_CLIENTS=0A= # 2nd parameter BASE_PORT=0A= =0A= =0A= DEV=3Deth1=0A= # Bandwidth values (in kbits)=0A= BANDWIDTH=3D3500=0A= =0A= # The following must sum $BANDWIDTH or less=0A= VIDEO_BW=3D3000=0A= CONTROL_BW=3D300=0A= =0A= VIDEO_LEVEL_0_BW=3D1000=0A= VIDEO_LEVEL_1_BW=3D800=0A= VIDEO_LEVEL_2_BW=3D700=0A= VIDEO_LEVEL_3_BW=3D500=0A= =0A= #Buffer length in k=0A= VIDEO_BUFFER=3D15000=0A= =0A= # Priorities to get the remaining bandwidth=0A= # 0 is max (can be repeated)=0A= PRIO_CONTROL=3D0=0A= PRIO_VIDEO=3D1=0A= PRIO_OTHER=3D3=0A= =0A= INSMOD=3D/sbin/insmod=0A= =0A= # Load kernel modules=0A= grep -q ^sch_htb /proc/modules || $INSMOD /lib/modules/`uname = -r`/sch_htb.o=0A= grep -q ^sch_sfq /proc/modules || $INSMOD /lib/modules/`uname = -r`/sch_sfq.o=0A= grep -q ^cls_u32 /proc/modules || $INSMOD /lib/modules/`uname = -r`/cls_u32.o=0A= =0A= echo "Vai comecar o script"=0A= =0A= # Clean existing qdiscs (redirects error output to /dev/null)=0A= tc qdisc del dev $DEV root 2> /dev/null=0A= tc qdisc del dev $DEV ingress 2> /dev/null=0A= =0A= echo "Passou pelo del" =0A= =0A= # Creates root qdisc with HTB policy. Default class for packets is 12 = (less prio)=0A= tc qdisc add dev $DEV root handle 1: htb default 12=0A= =0A= echo "Passou pelo cria qdisc root" =0A= =0A= # Creates a root class hanging from the root qdisc=0A= # This allows other sub-classes of this one to borrow the remaining = bandwidth=0A= # If we prescind of this one and hang subclasses directly from the root = qdisc=0A= # then the remaining bandwidth is lost (!)=0A= tc class add dev $DEV parent 1: classid 1:1 htb rate ${BANDWIDTH}kbit = ceil ${BANDWIDTH}kbit=0A= =0A= echo "Passou pela primeira classe" =0A= =0A= # Now creates 3 classes: (1:10 =3D max prio)=0A= # 1:10 for Control packets=0A= # 1:11 for Video packets=0A= # 1:12 for other packets=0A= tc class add dev $DEV parent 1:1 classid 1:10 htb rate ${CONTROL_BW}kbit = ceil ${BANDWIDTH}kbit prio $PRIO_CONTROL=0A= tc class add dev $DEV parent 1:1 classid 1:11 htb rate ${VIDEO_BW}kbit = ceil ${BANDWIDTH}kbit prio $PRIO_VIDEO=0A= tc class add dev $DEV parent 1:1 classid 1:12 htb rate $(($BANDWIDTH - = $VIDEO_BW - CONTROL_BW))kbit ceil ${BANDWIDTH}kbit prio $PRIO_OTHER=0A= =0A= echo "Passou por todas as classes" =0A= =0A= # Creates four sub-classes for V=EDdeo (level 0 (1:13), level 1 (1:14), = level 2 (1:15) and level 3 (1:16))=0A= tc class add dev $DEV parent 1:11 classid 1:13 htb rate = ${VIDEO_LEVEL_0_BW}kbit ceil ${BANDWIDTH}kbit prio $PRIO_VIDEO=0A= tc class add dev $DEV parent 1:11 classid 1:14 htb rate = ${VIDEO_LEVEL_1_BW}kbit ceil ${BANDWIDTH}kbit prio $PRIO_VIDEO=0A= tc class add dev $DEV parent 1:11 classid 1:15 htb rate = ${VIDEO_LEVEL_2_BW}kbit ceil ${BANDWIDTH}kbit prio $PRIO_VIDEO=0A= tc class add dev $DEV parent 1:11 classid 1:16 htb rate = ${VIDEO_LEVEL_3_BW}kbit ceil ${BANDWIDTH}kbit prio $PRIO_VIDEO=0A= =0A= echo "Passou pelas subclasses" =0A= =0A= # Now creates qdiscs to handle the packets of each class=0A= # Since all of them must treat equally concurrent connections we use sqf = everywhere=0A= =0A= tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10=0A= tc qdisc add dev $DEV parent 1:12 handle 12: sfq perturb 10=0A= tc qdisc add dev $DEV parent 1:13 handle 13: sfq perturb 10=0A= tc qdisc add dev $DEV parent 1:14 handle 14: sfq perturb 10=0A= tc qdisc add dev $DEV parent 1:15 handle 15: sfq perturb 10=0A= tc qdisc add dev $DEV parent 1:16 handle 16: sfq perturb 10=0A= =0A= echo "Vai comecar os match" =0A= =0A= # Filters=0A= =0A= #tem que especificar primeiro se =E9 um pacote transferido por tcp ou = udp (no caso de pacotes de controle =E9 usado tcp)=0A= #depois, a partir do vig=E9simo byte, que =E9 o campo de op=E7=F5es do = cabe=E7alho ip, deve-se ler os bytes mostrados=0A= #depois disso, passar o fluxo para a classe de pacotes de controle=0A= tc filter add dev $DEV parent 1: \=0A= protocol ip prio $PRIO_CONTROL \=0A= u32 match ip protocol 6 0xff \=0A= match u32 00190000 00ff0000 at 0 \=0A= flowid 1:10=0A= =0A= echo "Passou pelo 1 match" =0A= =0A= #tem que especificar primeiro se =E9 um pacote transferido por tcp ou = udp (no caso de pacotes de v=EDdeo =E9 usado udp)=0A= #depois, a partir do vig=E9simo primeiro byte, que =E9 o campo de = op=E7=F5es do cabe=E7alho ip, deve-se ler os bytes mostrados=0A= #depois disso, passar o fluxo para a classe de pacotes de controle=0A= tc filter add dev $DEV protocol ip parent 1: prio $PRIO_VIDEO u32 \=0A= match ip protocol 17 0xff \=0A= match u32 001b0000 00ff0000 at 0 \=0A= police rate ${VIDEO_LEVEL_0_BW}kbit buffer ${VIDEO_BUFFER}k drop \=0A= flowid 1:13=0A= =0A= echo "Passou pelo 2 match" =0A= =0A= tc filter add dev $DEV protocol ip parent 1: prio $PRIO_VIDEO u32 \=0A= match ip protocol 17 0xff \=0A= match u32 000b0000 00ff0000 at 0 \=0A= police rate ${VIDEO_LEVEL_1_BW}kbit buffer ${VIDEO_BUFFER}k drop \=0A= flowid 1:14=0A= =0A= echo "Passou pelo 3 match" =0A= =0A= tc filter add dev $DEV protocol ip parent 1: prio $PRIO_VIDEO u32 \=0A= match ip protocol 17 0xff \=0A= match u32 00130000 00ff0000 at 0 \=0A= police rate ${VIDEO_LEVEL_2_BW}kbit buffer ${VIDEO_BUFFER}k drop \=0A= flowid 1:15=0A= =0A= echo "Passou pelo 4 match" =0A= =0A= tc filter add dev $DEV protocol ip parent 1: prio $PRIO_VIDEO u32 \=0A= match ip protocol 17 0xff \=0A= match u32 00030000 00ff0000 at 0 \=0A= police rate ${VIDEO_LEVEL_3_BW}kbit buffer ${VIDEO_BUFFER}k drop \=0A= flowid 1:16=0A= =0A= echo "Passou pelo 5 match" =0A= ------=_NextPart_000_004A_01C6A76E.E547B1C0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ LARTC mailing list LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc ------=_NextPart_000_004A_01C6A76E.E547B1C0--