Listing 3. tc Script to Set Up a Core Router
#!/bin/sh
# Create root DiffServ qdisc, attach to proper
# network interface
tc qdisc add dev eth3 handle 1:0 root dsmark\
indices 64 set_tc_index
tc filter add dev eth3 parent 1:0 protocol ip\
prio 1 tcindex mask 0xfc shift 2
# Create class-based queuing discipline to hold
# the two classes
tc qdisc add dev eth3 parent 1:0 handle 2:0 cbq\
bandwidth 10MB cell 8 avpkt 1000 mpu 64
# Create EF class, create queuing discpline for
# EF, create filters
tc class add dev eth3 parent 2:0 classid 2:1 cbq\
bandwidth 10Mbit rate 8Mbit avpkt 40000 prio 1\
bounded isolated allot 1514 weight 1 maxburst 30
tc qdisc add dev eth3 parent 2:1 tbf rate 8Mbit\
burst 2Mbit limit 10Mbit
tc filter add dev eth3 parent 2:0 protocol ip\
prio 1 handle 0x2e tcindex classid 2:1 pass_on
# Create BE class, create queuing discipline for
# BE, create filters
tc class add dev eth3 parent 2:0 classid 2:2 cbq\
bandwidth 10Mbit rate 2Mbit avpkt 1000 prio 7\
allot 1514 weight 1 maxburst 21 borrow split 2:0\
defmap 0xffff
tc qdisc add dev eth3 parent 2:2 red limit 50KB\
min 10KB max 30KB burst 20 avpkt 1000\<\n>
bandwidth 2Mbit\ probability 0.4
tc filter add dev eth3 parent 2:0\
protocol ip prio 2 handle 0 tcindex mask 0\
classid 2:2 pass_on
Copyright © 1994 - 2019 Linux Journal. All rights reserved.