next up previous
Next: References Up: Linux - Advanced Networking Previous: Example - 1 :

Example - 2 : CBQ with u32 classifier

Let us now consider a slightly more complicated scenario. Lets set up a CBQ for an ethernet device on testbed14 (129.237.125.149). Lets again assume that the average packet size is 1000, a cell value of 8 bytes and a maximum burst size of 20 bytes. Let us again have two types of classes, one for traffic to the machine 129.237.125.146 (testbed11) and the other for the traffic to machine 129.237.125.148 (testbed13). testbed11 requires a bandwidth of 3 Mbps and a priority of 3 while testbed13 requires a bandwidth of 7 Mbps and a priority of 7.

Now let us assume that the two classes in turn have two more classes each. The class setup for traffic to testbed11 is in turn classified into two classes, one with a priority of 1, a bandwidth of 2 Mbits and using port 6010 in testbed11, and the other with a priority of 2 and a bandwidth of 1 Mbit and using port 6011 on testbed11.

Similarly, the traffic to testbed13 is classified into two classes, one with a priority 1, a bandwidth of 2 Mbits and using port 6021 in testbed13, and the other with a priority of 2 and a bandwidth of 1 Mbit and using port 6031 on testbed13.

Also, let us assume that the testbed14 enforces the bandwidth sharing in a very strict sense. That is, none of the children are allowed to borrow unused bandwidth.

This example explains classification based on u32 classifiers. The set up is show in Figure 10.

Figure 10: Linux QoS Support - Example 2
\begin{figure}
\centerline{\psfig{file=figures/example2.eps,width=4.0in}}\end{figure}

To set up this environment in testbed14

# Attaching the Qdisc to the eth0 device.  The maximum available bandwidth is
# 10Mbit. 
tc qdisc add dev eth0 root handle 1: cbq bandwidth 10Mbit allot 1514 cell 8
avpkt 1000 mpu 64

# Adding the root class to the queuing discipline. The root has 10 Mbit
# completely. 
tc class add dev eth0 parent 1:0 classid 1:1 cbq bandwidth 10Mbit rate
10Mbit allot 1514 cell 8 weight 1Mbit prio 8 maxburst 20 avpkt 1000


# Traffic to testbed11. The priority is 3 and the allocation is 3 Mbit. Note
# that it is set to bounded because of the strict link sharing rules.
tc class add dev eth0 parent 1:1 classid 1:2 cbq bandwidth 10Mbit rate 3Mbit
allot 1514 cell 8 weight 300Kbit prio 3 maxburst 20 avpkt 1000 bounded

# Traffic to testbed13. The priority is 7 and the allocation is 7 Mbit.  Note
# that it is set to bounded because of the strict link sharing rules. 
tc class add dev eth0 parent 1:1 classid 1:3 cbq bandwidth 10Mbit rate 7Mbit
allot 1514 cell 8 weight 700Kbit prio 7 maxburst 20 avpkt 1000 bounded

# Attaching another CBQ to the traffic to testbed11. This is meant for further 
# classification. 
tc qdisc add dev eth0 parent 1:2 handle 2: cbq bandwidth 3Mbit allot 1514
cell 8 avpkt 1000 mpu 64

# Attaching another CBQ to the traffic to testbed13. This is meant for further 
# classification. 
tc qdisc add dev eth0 parent 1:3 handle 3: cbq bandwidth 7Mbit allot 1514
cell 8 avpkt 1000 mpu 64

# Setting up the classes for the traffic to testbed11 appropriately.
tc class add dev eth0 parent 2:0 classid 2:1 cbq bandwidth 3Mbit rate 3Mbit
allot 1514 cell 8 weight 300Kbit prio 3 maxburst 20 avpkt 1000
tc class add dev eth0 parent 2:1 classid 2:2 cbq bandwidth 3Mbit rate 2Mbit
allot 1514 cell 8 weight 200Kbit prio 1 maxburst 20 avpkt 1000
tc class add dev eth0 parent 2:1 classid 2:3 cbq bandwidth 3Mbit rate 1Mbit
allot 1514 cell 8 weight 100Kbit prio 2 maxburst 20 avpkt 1000

# Setting up the classes for the traffic to testbed13 appropriately.
tc class add dev eth0 parent 3:0 classid 3:1 cbq bandwidth 7Mbit rate 7Mbit
allot 1514 cell 8 weight 700Kbit prio 7 maxburst 20 avpkt 1000
tc class add dev eth0 parent 3:1 classid 3:2 cbq bandwidth 7Mbit rate 5Mbit
allot 1514 cell 8 weight 500Kbit prio 1 maxburst 20 avpkt 1000
tc class add dev eth0 parent 3:1 classid 3:3 cbq bandwidth 7Mbit rate 2Mbit
allot 1514 cell 8 weight 200Kbit prio 2 maxburst 20 avpkt 1000


# Installing a route classifier on device eth0.  
tc filter add dev eth0 parent 1:0 protocol ip prio 100 route

# Setting up the routes to testbed11 and testbed13 and the rules for this
# traffic. 
ip route add 129.237.125.146 via 129.237.125.149 flow 1:2
ip route add 129.237.125.148 via 129.237.125.149 flow 1:3

# Installing a u32 classifier for the traffic to testbed11
tc filter add dev eth0 parent 2:0 prio 3 protocol ip u32

# Creating  hash tables for classification of the packets to testbed11
tc filter add dev eth0 parent 2:0 prio 3 handle 1: u32 divisor 256
tc filter add dev eth0 parent 2:0 prio 3 handle 2: u32 divisor 256

# Configuring the 6th slot of the hash table 1 to select packets with
# destination set to testbed11 and the port set to 6010 (0x177a) and direct
# these to class 2:2 (which was just set up). 
tc filter add dev eth0 parent 2:0 prio 3 u32 ht 1:6: match ip dst
129.237.125.146 match tcp dst 0x177a 0xffff flowid 2:2

# Configuring the 6th slot of the hash table 2 to select packets with
# destination set to testbed11 and the port set to 6011 (0x177b) and direct
# these to class 2:3 (which was just set up). 
tc filter add dev eth0 parent 2:0 prio 3 u32 ht 2:6: match ip dst
129.237.125.146 match tcp dst 0x177b  0xffff flowid 2:3

# Lookup hash table and it it is not fragmented, use the protocol as the hash
# key. 
tc filter add dev eth0 parent 2:0 prio 3 handle ::1 u32 ht 800:: match ip
nofrag offset mask 0x0F00 shift 6 hashkey mask 0x00ff0000 at 8 link 1:
tc filter add dev eth0 parent 2:0 prio 3 handle ::1 u32 ht 800:: match ip
nofrag offset mask 0x0F00 shift 6 hashkey mask 0x00ff0000 at 8 link 2:

# Installing a u32 classfier for the traffic to testbed13
tc filter add dev eth0 parent 3:0 prio 7 protocol ip u32

# Creating  hash tables for classification of the packets to testbed13
tc filter add dev eth0 parent 3:0 prio 7 handle 3: u32 divisor 256
tc filter add dev eth0 parent 3:0 prio 7 handle 4: u32 divisor 256

# Configuring the 6th slot of the hash table 3 to select packets with
# destination set to testbed13 and the port set to 6021 (0x1785) and direct
# these to class 3:2 (which was just set up).
tc filter add dev eth0 parent 3:0 prio 7 u32 ht 3:6: match ip dst
129.237.125.148 match tcp dst 0x1785 0xffff flowid 3:2

# Configuring the 6th slot of the hash table 4 to select packets with
# destination set to testbed13 and the port set to 6031 (0x178f) and direct
# these to class 3:3 (which was just set up).
tc filter add dev eth0 parent 3:0 prio 7 u32 ht 4:6: match ip dst
129.237.125.148 match tcp dst 0x178f 0xffff flowid 3:3


# Lookup hash table and it it is not fragmented, use the protocol as the hash
# key. 
tc filter add dev eth0 parent 3:0 prio 7 handle ::1 u32 ht 800:: match ip
nofrag offset mask 0x0F00 shift 6 hashkey mask 0x00ff0000 at 8 link 3:
tc filter add dev eth0 parent 3:0 prio 7 handle ::1 u32 ht 800:: match ip
nofrag offset mask 0x0F00 shift 6 hashkey mask 0x00ff0000 at 8 link 4:


next up previous
Next: References Up: Linux - Advanced Networking Previous: Example - 1 :
Saravanan Radhakrishnan
1999-09-30