MPLS Tutorial header image

MPLS Tutorial

≡ Menu

Some TC scripts and other appendices

Appendix D

TC script for filter 1

#!/bin/bash

# This script will set-up an example DS tree

#only set ENABLE_MPLS_IP to true if you installed the DSMPLS+IP patch

#ENABLE_MPLS_IP=false

ENABLE_MPLS_IP=true

IFACES=”eth1 eth2 eth3″

TC=/usr/local/bin/tc

if test $# -gt 0

then

case $1 in

s|-s)

if test $# -gt 1

then

if test $# -gt 2

then

case $3 in

BE)

echo BE statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 3 “red 4:”

;;

EF)

echo EF statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 2 “pfifo 3:”

;;

OR)

echo OR statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 2 “pfifo 9:”

;;

AF1)

echo AF1 statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 8 “gred 5:”

;;

AF2)

echo AF2 statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 8 “gred 6:”

;;

AF3)

echo AF3 statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 8 “gred 7:”

;;

*)

echo BE statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 3 “red 4:”

echo EF statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 2 “pfifo 3:”

echo OR statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 2 “pfifo 9:”

echo AF1 statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 8 “gred 5:”

echo AF2 statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 8 “gred 6:”

echo AF3 statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 8 “gred 7:”

esac

else

echo “***”$2″***”

$TC -s qdisc ls dev $2

fi;

else

for i in $IFACES; do echo “***”$i”***”

$TC -s qdisc ls dev $i 2>/dev/null; done

fi;;

d|-d)

if test $# -gt 1

then

$TC qdisc del root dev $2 >/dev/null 2>/dev/null

else

for i in $IFACES; do

$TC qdisc del root dev $i >/dev/null 2>/dev/null

done

fi;;

h|-h|–help|-help)

echo $0

echo “-sshow statistics”

echo “-s interfaceshow statistics of interface”

echo “-s interface <PHB>show PHB statistics on interface”

echo “-ddelete filters and qdiscs”

echo “install qdiscs and filers”

echo “<phb> = BE | EF | OR | AF1 | AF2 | AF3 | *”

exit

esac

else

if [ $ENABLE_MPLS_IP = true ]

then

echo $0 running in MPLS + IP mode

echo Make sure the kernel is patched with dsmpls+ip.patch

else

echo $0 running in MPLS only mode

fi

for i in $IFACES; do

echo

echo Configuring interface $i

# DSMARK Qdisc added

if [ $ENABLE_MPLS_IP = true ]

then

$TC qdisc add dev $i root handle 1:0 dsmark indices 64 default_index 0x161 set_tc_index

else

$TC qdisc add dev $i root handle 1:0 dsmark indices 64 default_index 0x161

fi

#Main DSMARK classifier (converts TOS to DSCP)

$TC filter add dev $i parent 1:0 protocol all prio 1 tcindex mask 0xfc shift 2 pass_on

##### Set up of the proper qdisc on $i

# HTB qdisc is used in order to support EF, AF and BE classes

# Main HTB qdisc

$TC qdisc add dev $i parent 1:0 handle 2:0 htb

#Main HTB class (to enable borrowing) ******(60 Mbps link)*****

$TC class add dev $i parent 2:0 classid 2:1 htb rate 60Mbit ceil 60Mbit

#Main HTB classifier

$TC filter add dev $i parent 2:0 protocol all prio 1 tcindex mask 0xf0 shift 4 pass_on

## Definition of the HTB leaf classes to support AF, EF and BE

echo “AF1: (60Mbps)”

## AF Class 1 specific setup (latency 900ms)

$TC class add dev $i parent 2:1 classid 2:10 htb rate 8Mbit ceil 20Mbit

$TC filter add dev $i parent 2:0 prio 1 handle 1 tcindex classid 2:10

$TC qdisc add dev $i handle 5:0 parent 2:10 gred setup DPs 3 default 2 grio

# — AF Class 1 DP 1—

$TC filter add dev $i parent 1:0 prio 1 handle 0x0a tcindex classid 1:111

$TC qdisc change dev $i parent 2:10 gred limit 7.2MB min 300KB max 900KB burst 500 \

avpkt 1000 bandwidth 60Mbit DP 1 probability 0.01 prio 1

# — AF Class 1 DP 2—

$TC filter add dev $i parent 1:0 prio 1 handle 0x0c tcindex classid 1:112

$TC qdisc change dev $i parent 2:10 gred limit 7.2MB min 300KB max 900KB burst 500 \

avpkt 1000 bandwidth 60Mbit DP 2 probability 0.02 prio 2

# — AF Class 1 DP 3—

$TC filter add dev $i parent 1:0 prio 1 handle 0x0e tcindex classid 1:113

$TC qdisc change dev $i parent 2:10 gred limit 7.2MB min 300KB max 900KB burst 500 \

avpkt 1000 bandwidth 60Mbit DP 3 probability 0.03 prio 3

## AF Class 2 specific setup (latency 600ms)

echo “AF2: (60Mbps)”

$TC class add dev $i parent 2:1 classid 2:20 htb rate 8Mbit ceil 40Mbit

$TC filter add dev $i parent 2:0 prio 1 handle 2 tcindex classid 2:20

$TC qdisc add dev $i handle 6:0 parent 2:20 gred setup DPs 3 default 2 grio

# — AF Class 2 DP 1—

$TC filter add dev $i parent 1:0 prio 1 handle 0x12 tcindex classid 1:121

$TC qdisc change dev $i parent 2:20 gred limit 4.8MB min 200KB max 600KB burst 350 \

avpkt 1000 bandwidth 60Mbit DP 1 probability 0.02 prio 1

# — AF Class 2 DP 2—

$TC filter add dev $i parent 1:0 prio 1 handle 0x14 tcindex classid 1:122

$TC qdisc change dev $i parent 2:20 gred limit 4.8MB min 200KB max 600KB burst 350 \

avpkt 1000 bandwidth 60Mbit DP 2 probability 0.04 prio 2

# — AF Class 2 DP 3—

$TC filter add dev $i parent 1:0 prio 1 handle 0x16 tcindex classid 1:123

$TC qdisc change dev $i parent 2:20 gred limit 4.8MB min 200KB max 600KB burst 350 \

avpkt 1000 bandwidth 60Mbit DP 3 probability 0.06 prio 3

## AF Class 3 specific setup (latency 400ms)

echo “AF3: (60Mbps)”

$TC class add dev $i parent 2:1 classid 2:30 htb rate 8Mbit ceil 40Mbit

$TC filter add dev $i parent 2:0 prio 1 handle 3 tcindex classid 2:30

$TC qdisc add dev $i handle 7:0 parent 2:30 gred setup DPs 3 default 2 grio

# — AF Class 3 DP 1—

$TC filter add dev $i parent 1:0 prio 1 handle 0x1a tcindex classid 1:131

$TC qdisc change dev $i parent 2:30 gred limit 3.2MB min 130KB max 400KB burst 250 \

avpkt 1000 bandwidth 60Mbit DP 1 probability 0.03 prio 1

# — AF Class 3 DP 2—

$TC filter add dev $i parent 1:0 prio 1 handle 0x1c tcindex classid 1:132

$TC qdisc change dev $i parent 2:30 gred limit 3.2MB min 130KB max 400KB burst 250 \

avpkt 1000 bandwidth 60Mbit DP 2 probability 0.05 prio 2

# — AF Class 3 DP 3—

$TC filter add dev $i parent 1:0 prio 1 handle 0x1e tcindex classid 1:133

$TC qdisc change dev $i parent 2:30 gred limit 3.2MB min 130KB max 400KB burst 250 \

avpkt 1000 bandwidth 60Mbit DP 3 probability 0.07 prio 3

## EF class specific setup

echo “EF: (60Mbps)”

$TC class add dev $i parent 2:1 classid 2:50 htb rate 8Mbit ceil 8Mbit

$TC qdisc add dev $i handle 3:0 parent 2:50 pfifo limit 10

$TC filter add dev $i parent 1:0 prio 1 handle 0x2e tcindex classid 1:151

$TC filter add dev $i parent 2:0 prio 1 handle 5 tcindex classid 2:50

## BE class specific setup

echo “BE: rate 20 ceil 30 (60Mbps)”

$TC class add dev $i parent 2:1 classid 2:60 htb rate 20Mbit ceil 30Mbit

$TC qdisc add dev $i parent 2:60 handle 4:0 red limit 4.8MB min 200KB max 600KB burst 350 \

avpkt 1000 bandwidth 100Mbit probability 0.4

#$TC filter add dev $i parent 1:0 prio 1 handle 0x0 tcindex classid 1:161

#Not needed coz we have set the default to be 0x161

$TC filter add dev $i parent 2:0 prio 1 handle 6 tcindex classid 2:60

## OSPF – RSVP Pipe class specific setup

#echo OSPF \& RSVP queue

#$TC class add dev $i parent 2:0 classid 2:7 cbq bandwidth 100Mbit rate 1Mbit \

#avpkt 1000 prio 1 bounded allot 1514 weight 1Mbit maxburst 10 defmap 0

#$TC qdisc add dev $i handle 9:0 parent 2:7 pfifo limit 10

#$TC filter add dev $i parent 1:0 prio 1 handle 0x30 tcindex classid 1:171

#$TC filter add dev $i parent 2:0 prio 1 handle 7 tcindex classid 2:7

done

fi


Appendix E

TC script for the proposed filter

#!/bin/bash

# This script will set-up an example DS tree

#only set ENABLE_MPLS_IP to true if you installed the DSMPLS+IP patch

#ENABLE_MPLS_IP=false

ENABLE_MPLS_IP=true

IFACES=”eth2″

TC=/usr/local/bin/tc

if test $# -gt 0

then

case $1 in

s|-s)

if test $# -gt 1

then

if test $# -gt 2

then

case $3 in

BE)

echo BE statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 3 “red 4:”

;;

EF)

echo EF statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 2 “pfifo 3:”

;;

OR)

echo OR statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 2 “pfifo 9:”

;;

AF1)

echo AF1 statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 8 “gred 5:”

;;

AF2)

echo AF2 statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 8 “gred 6:”

;;

AF3)

echo AF3 statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 8 “gred 7:”

;;

*)

echo BE statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 3 “red 4:”

echo EF statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 2 “pfifo 3:”

echo OR statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 2 “pfifo 9:”

echo AF1 statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 8 “gred 5:”

echo AF2 statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 8 “gred 6:”

echo AF3 statistics on interface $2

$TC -s qdisc ls dev $2 | grep -A 8 “gred 7:”

esac

else

echo “***”$2″***”

$TC -s qdisc ls dev $2

fi;

else

for i in $IFACES; do echo “***”$i”***”

$TC -s qdisc ls dev $i 2>/dev/null; done

fi;;

d|-d)

if test $# -gt 1

then

$TC qdisc del root dev $2 >/dev/null 2>/dev/null

else

for i in $IFACES; do

$TC qdisc del root dev $i >/dev/null 2>/dev/null

done

fi;;

h|-h|–help|-help)

echo $0

echo “-sshow statistics”

echo “-s interfaceshow statistics of interface”

echo “-s interface <PHB>show PHB statistics on interface”

echo “-ddelete filters and qdiscs”

echo “install qdiscs and filers”

echo “<phb> = BE | EF | OR | AF1 | AF2 | AF3 | *”

exit

esac

else

if [ $ENABLE_MPLS_IP = true ]

then

echo $0 running in MPLS + IP mode

echo Make sure the kernel is patched with dsmpls+ip.patch

else

echo $0 running in MPLS only mode

fi

for i in $IFACES; do

echo

echo Configuring interface $i

# DSMARK Qdisc added

if [ $ENABLE_MPLS_IP = true ]

then

$TC qdisc add dev $i root handle 1:0 dsmark indices 64 default_index 0x161 set_tc_index

else

$TC qdisc add dev $i root handle 1:0 dsmark indices 64 default_index 0x161

fi

#Main DSMARK classifier (converts TOS to DSCP)

$TC filter add dev $i parent 1:0 protocol all prio 1 tcindex mask 0xfc shift 2 pass_on

#PRIO qdisc 2:0

$TC qdisc add dev $i parent 1:0 handle 2:0 prio

#Main PRIO classifier

$TC filter add dev $i parent 2:0 protocol all prio 1 tcindex mask 0xf0 shift 4 pass_on

#for AF classes HTB defined

$TC qdisc add dev $i parent 2:2 handle 3:0 htb

#AF packets beinf forwarded to classid 2:2

$TC filter add dev $i parent 2:0 prio 1 handle 1 tcindex classid 2:2

$TC filter add dev $i parent 1:0 prio 1 handle 0x0a tcindex classid 1:111

$TC filter add dev $i parent 1:0 prio 1 handle 0x0c tcindex classid 1:112

$TC filter add dev $i parent 2:0 prio 1 handle 2 tcindex classid 2:2

$TC filter add dev $i parent 1:0 prio 1 handle 0x12 tcindex classid 1:121

$TC filter add dev $i parent 1:0 prio 1 handle 0x14 tcindex classid 1:122

$TC filter add dev $i parent 2:0 prio 1 handle 3 tcindex classid 2:2

$TC filter add dev $i parent 1:0 prio 1 handle 0x1a tcindex classid 1:131

$TC filter add dev $i parent 1:0 prio 1 handle 0x1c tcindex classid 1:132

#For EF traffic

$TC qdisc add dev $i parent 2:1 tbf rate 9Mbit burst 10kB limit 16kB

$TC filter add dev $i parent 1:0 prio 1 handle 0x2e tcindex classid 1:151

$TC filter add dev $i parent 2:0 prio 1 handle 5 tcindex classid 2:1

#For BE traffic

$TC qdisc add dev $i parent 2:3 red limit 600KB min 150KB max 450KB burst 200 \

avpkt 1000 bandwidth 100Mbit probability 0.01

#$TC filter add dev $i parent 1:0 prio 1 handle 0x0 tcindex classid 1:161

$TC filter add dev $i parent 2:0 prio 1 handle 6 tcindex classid 2:3

#Now the AF traffic is collectively handed to HTB

#HTB class for borrowing

$TC class add dev $i parent 3:0 classid 3:1 htb rate 24Mbit ceil 24Mbit

#HTB classifer

$TC filter add dev $i parent 3:0 protocol all prio 1 tcindex mask 0xf0 shift 4 pass_on

#Adding classes for AF1x class

$TC class add dev $i parent 3:1 classid 3:10 htb rate 8Mbit ceil 24Mbit

$TC filter add dev $i parent 3:0 prio 1 handle 1 tcindex classid 3:10

$TC qdisc add dev $i handle 5:0 parent 3:10 gred setup DPs 3 default 2 grio

# — AF Class 1 DP 1—

$TC qdisc change dev $i parent 3:10 gred limit 7.2MB min 300KB max 900KB burst 500 \

avpkt 1000 bandwidth 60Mbit DP 1 probability 0.01 prio 1

# — AF Class 1 DP 2—

$TC qdisc change dev $i parent 3:10 gred limit 7.2MB min 300KB max 900KB burst 500 \

avpkt 1000 bandwidth 60Mbit DP 2 probability 0.03 prio 2

#Adding classes for AF2x class

$TC class add dev $i parent 3:1 classid 3:20 htb rate 8Mbit ceil 24Mbit

$TC filter add dev $i parent 3:0 prio 1 handle 2 tcindex classid 3:20

$TC qdisc add dev $i handle 6:0 parent 3:20 gred setup DPs 3 default 2 grio

# — AF Class 2 DP 1—

$TC qdisc change dev $i parent 3:20 gred limit 4.8MB min 200KB max 600KB burst 350 \

avpkt 1000 bandwidth 60Mbit DP 1 probability 0.01 prio 1

# — AF Class 2 DP 2—

$TC qdisc change dev $i parent 3:20 gred limit 4.8MB min 200KB max 600KB burst 350 \

avpkt 1000 bandwidth 60Mbit DP 2 probability 0.03 prio 2

#Adding classes for AF3x class

$TC class add dev $i parent 3:1 classid 3:30 htb rate 8Mbit ceil 24Mbit

$TC filter add dev $i parent 3:0 prio 1 handle 3 tcindex classid 3:30

$TC qdisc add dev $i handle 7:0 parent 3:30 gred setup DPs 3 default 2 grio

# — AF Class 2 DP 1—

$TC qdisc change dev $i parent 3:30 gred limit 3.2MB min 150KB max 400KB burst 200 \

avpkt 1000 bandwidth 60Mbit DP 1 probability 0.01 prio 1

# — AF Class 2 DP 2—

$TC qdisc change dev $i parent 3:30 gred limit 3.2MB min 150KB max 400KB burst 200 \

avpkt 1000 bandwidth 60Mbit DP 2 probability 0.03 prio 2

done

fi


Appendix F

MPLS-TEST-MIB DEFINITIONS ::= BEGIN

IMPORTS

experimental FROM RFC1155-SMI

MODULE-IDENTITY, OBJECT-TYPE, INTEGERFROM SNMPv2-SMI;

mplsTest MODULE-IDENTITY

LAST-UPDATED “200411290000Z”

ORGANIZATION “IIT BOMBAY”

CONTACT-INFO

“Communication Lab”

DESCRIPTION

“MPLS test MIB”

REVISION”200411290000Z”

DESCRIPTION

“MPLS test MIB”

::= { experimental 572}

mpls OBJECT IDENTIFIER ::= {experimental 140 }

mplsOutPackets OBJECT-TYPE

SYNTAXINTEGER

MAX-ACCESSread-only

STATUScurrent

DESCRIPTION

“Returns the number of MPLS packets going out through an interface”

::= { mpls 1}

mplsOutBytes OBJECT-TYPE

SYNTAXINTEGER

MAX-ACCESSread-only

STATUScurrent

DESCRIPTION

“Returns the number of MPLS bytes exiting through an interface”

::= { mpls 2 }

mplsInPackets OBJECT-TYPE

SYNTAXINTEGER

MAX-ACCESSread-only

STATUScurrent

DESCRIPTION

“Returns the number of MPLS packets entering through an interface”

::={mpls 3}

mplsInBytes OBJECT-TYPE

SYNTAXINTEGER

MAX-ACCESSread-only

STATUScurrent

DESCRIPTION

“Returns the number of MPLS bytes entering through an interface”

::= { mpls 4 }

END

 

Appendix B

OSPF sample configuration file on GateD:

# Disable RIP

rip no;

# Enable OSPF;

# use password authentication.

ospf yes {

backbone {

authtype simple ;

interface 10.107.23.26 {

authkey “It’sREAL” ;

} ;

} ;

} ;


Appendix C

Sample ntp configuration file for server

# Prohibit general access to this service.

# Permit all access over the loopback interface.This could

# be tightened as well, but to do so would effect some of

# the administrative functions.

Restrict 127.0.0.1

# — CLIENT NETWORK ——-

# Permit systems on this network to synchronize with this

# time service.Do not permit those systems to modify the

# configuration of this service.Also, do not use those

# systems as peers for synchronization.

restrict 10.107.23.22 mask 255.255.255.252 notrust nomodify notrap

# — GENERAL CONFIGURATION —

#

# Undisciplined Local Clock. This is a fake driver intended for backup

# and when no outside source of synchronized time is available. The

# default stratum is usually 3, but in this case we elect to use stratum

# 0. Since the server line does not have the prefer keyword, this driver

# is never used for synchronization, unless no other other

# synchronization source is available. In case the local host is

# controlled by some external source, such as an external oscillator or

# another protocol, the prefer keyword would cause the local host to

# disregard all other synchronization sources, unless the kernel

# modifications are in use and declare an unsynchronized condition.

#

server127.127.1.0# local clock

fudge127.127.1.0 stratum 10

#

# Drift file.Put this in a directory which the daemon can write to.

# No symbolic links allowed, either, since the daemon updates the file

# by creating a temporary in the same directory and then rename()’ing

# it to the file.

#

driftfile /etc/ntp/drift

broadcastdelay0.008

# Authentication delay.If you use, or plan to use someday, the

# authentication facility you should make the programs in the auth_stuff

# directory and figure out what this number should be on your machine.

#

authenticate no

#

# Keys file.If you want to diddle your server at run time, make a

# keys file (mode 600 for sure) and define the key number to be

# used for making requests.

#

# PLEASE DO NOT USE THE DEFAULT VALUES HERE. Pick your own, or remote

# systems might be able to reset your clock at will. Note also that

# ntpd is started with a -A flag, disabling authentication, that

# will have to be removed as well.

#

keys/etc/ntp/keys

 

css.php