Htb Match

The following scenario shows how to configure different matches in a HTB qdisc.

../../../../../../_images/topology1.svg

Test HTB Matches

Description

This scenario tests different matches in HTB qdisc.

Scenario

Step 1: Set the following configuration in DUT0:

set interfaces ethernet eth0 address 10.0.0.2/24
set interfaces ethernet eth0 traffic control out QDISC
set traffic control QDISC type htb bandwidth 100
set traffic control QDISC type htb class 1 bandwidth percentage 100
set traffic control QDISC type htb class 2 bandwidth percentage 100
set traffic control QDISC type htb match 1 class 1
set traffic control QDISC type htb default-class 2
set traffic policy POL rule 1 set mark 99
set interfaces ethernet eth0 traffic policy local-out POL

Step 2: Set the following configuration in DUT1:

set interfaces ethernet eth0 address 10.0.0.1/24

Step 3: Ping IP address 10.0.0.1 from DUT0:

admin@DUT0$ ping 10.0.0.1 count 1 size 56 timeout 1
Show output
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.444 ms

--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.444/0.444/0.444/0.000 ms

Step 4: Set the following configuration in DUT0:

set traffic control QDISC type htb match 1 ether protocol arp

Step 5: Send arp ping from DUT0 to IP address 10.0.0.1:

admin@DUT0$ arping 10.0.0.1 interface eth0 timeout 5 count 1
Show output
ARPING 10.0.0.1 from 10.0.0.2 eth0
Unicast reply from 10.0.0.1 [DE:AD:BE:EF:6C:20]  0.827ms
Sent 1 probes (1 broadcast(s))
Received 1 response(s)

Step 6: Run command traffic control show at DUT0 and check if output matches the following regular expressions:

1:0\s+[1-9][0-9]*\s+[1-9][0-9]*\s+0
Show output
Traffic control for interface 'eth0' - 'egress' mode

------------------------------------------------------------------------------------
ID   traffic control        type         parent  bytes sent  pkts sent  pkts dropped
------------------------------------------------------------------------------------
1:0  QDISC            htb                root           282          3             0
1:1  QDISC            class 1            1:0             42          1             0
1:2  QDISC            class 2 (default)  1:0            240          2             0
2:0  -                fq_codel           1:1             42          1             0
3:0  -                fq_codel           1:2            240          2             0

Step 7: Set the following configuration in DUT0:

del traffic control QDISC type htb match 1 ether protocol arp

Step 8: Set the following configuration in DUT0:

set traffic control QDISC type htb match 1 ether destination DE:AD:BE:EF:6C:20

Step 9: Send arp ping from DUT0 to IP address 10.0.0.1:

admin@DUT0$ arping 10.0.0.1 interface eth0 timeout 5 count 1
Show output
ARPING 10.0.0.1 from 10.0.0.2 eth0
Unicast reply from 10.0.0.1 [DE:AD:BE:EF:6C:20]  0.744ms
Sent 1 probes (1 broadcast(s))
Received 1 response(s)

Step 10: Run command traffic control show at DUT0 and check if output matches the following regular expressions:

1:0\s+[1-9][0-9]*\s+[1-9][0-9]*\s+0
Show output
Traffic control for interface 'eth0' - 'egress' mode

------------------------------------------------------------------------------------
ID   traffic control        type         parent  bytes sent  pkts sent  pkts dropped
------------------------------------------------------------------------------------
1:0  QDISC            htb                root            42          1             0
1:1  QDISC            class 1            1:0              0          0             0
1:2  QDISC            class 2 (default)  1:0             42          1             0
2:0  -                fq_codel           1:1              0          0             0
3:0  -                fq_codel           1:2             42          1             0

Step 11: Set the following configuration in DUT0:

del traffic control QDISC type htb match 1 ether destination DE:AD:BE:EF:6C:20

Step 12: Set the following configuration in DUT0:

set traffic control QDISC type htb match 1 ip protocol tcp

Step 13: Initiate a tcp connection from DUT0 to DUT1 and try to send some messages between both endpoints

admin@DUT1$ monitor test connection server 4040 tcp
admin@DUT0$ monitor test connection client 10.0.0.1 4040 tcp

Step 14: Run command traffic control show at DUT0 and check if output matches the following regular expressions:

1:0\s+[1-9][0-9]*\s+[1-9][0-9]*\s+0
Show output
Traffic control for interface 'eth0' - 'egress' mode

------------------------------------------------------------------------------------
ID   traffic control        type         parent  bytes sent  pkts sent  pkts dropped
------------------------------------------------------------------------------------
1:0  QDISC            htb                root           464          7             0
1:1  QDISC            class 1            1:0            422          6             0
1:2  QDISC            class 2 (default)  1:0             42          1             0
2:0  -                fq_codel           1:1            422          6             0
3:0  -                fq_codel           1:2             42          1             0

Step 15: Set the following configuration in DUT0:

del traffic control QDISC type htb match 1 ip protocol tcp

Step 16: Set the following configuration in DUT0:

set traffic control QDISC type htb match 1 ip destination address 10.0.0.1

Step 17: Initiate a tcp connection from DUT0 to DUT1 and try to send some messages between both endpoints

admin@DUT1$ monitor test connection server 4040 tcp
admin@DUT0$ monitor test connection client 10.0.0.1 4040 tcp

Step 18: Run command traffic control show at DUT0 and check if output matches the following regular expressions:

1:0\s+[1-9][0-9]*\s+[1-9][0-9]*\s+0
Show output
Traffic control for interface 'eth0' - 'egress' mode

------------------------------------------------------------------------------------
ID   traffic control        type         parent  bytes sent  pkts sent  pkts dropped
------------------------------------------------------------------------------------
1:0  QDISC            htb                root           422          6             0
1:1  QDISC            class 1            1:0            422          6             0
1:2  QDISC            class 2 (default)  1:0              0          0             0
2:0  -                fq_codel           1:1            422          6             0
3:0  -                fq_codel           1:2              0          0             0

Step 19: Set the following configuration in DUT0:

del traffic control QDISC type htb match 1 ip destination address 10.0.0.1

Step 20: Set the following configuration in DUT0:

set traffic control QDISC type htb match 1 ip source address 10.0.0.2

Step 21: Initiate a tcp connection from DUT0 to DUT1 and try to send some messages between both endpoints

admin@DUT1$ monitor test connection server 4040 tcp
admin@DUT0$ monitor test connection client 10.0.0.1 4040 tcp

Step 22: Run command traffic control show at DUT0 and check if output matches the following regular expressions:

1:0\s+[1-9][0-9]*\s+[1-9][0-9]*\s+0
Show output
Traffic control for interface 'eth0' - 'egress' mode

------------------------------------------------------------------------------------
ID   traffic control        type         parent  bytes sent  pkts sent  pkts dropped
------------------------------------------------------------------------------------
1:0  QDISC            htb                root           422          6             0
1:1  QDISC            class 1            1:0            422          6             0
1:2  QDISC            class 2 (default)  1:0              0          0             0
2:0  -                fq_codel           1:1            422          6             0
3:0  -                fq_codel           1:2              0          0             0

Step 23: Set the following configuration in DUT0:

del traffic control QDISC type htb match 1 ip source address 10.0.0.2

Step 24: Set the following configuration in DUT0:

set traffic control QDISC type htb match 1 ip destination port 8080

Step 25: Initiate a tcp connection from DUT0 to DUT1 and try to send some messages between both endpoints

admin@DUT1$ monitor test connection server 8080 tcp
admin@DUT0$ monitor test connection client 10.0.0.1 8080 tcp source-port 7643

Step 26: Run command traffic control show at DUT0 and check if output matches the following regular expressions:

1:0\s+[1-9][0-9]*\s+[1-9][0-9]*\s+0
Show output
Traffic control for interface 'eth0' - 'egress' mode

------------------------------------------------------------------------------------
ID   traffic control        type         parent  bytes sent  pkts sent  pkts dropped
------------------------------------------------------------------------------------
1:0  QDISC            htb                root           422          6             0
1:1  QDISC            class 1            1:0            422          6             0
1:2  QDISC            class 2 (default)  1:0              0          0             0
2:0  -                fq_codel           1:1            422          6             0
3:0  -                fq_codel           1:2              0          0             0

Step 27: Set the following configuration in DUT0:

del traffic control QDISC type htb match 1 ip destination port 8080

Step 28: Set the following configuration in DUT0:

set traffic control QDISC type htb match 1 ip source port 7643

Step 29: Initiate a tcp connection from DUT0 to DUT1 and try to send some messages between both endpoints

admin@DUT1$ monitor test connection server 8080 tcp
admin@DUT0$ monitor test connection client 10.0.0.1 8080 tcp

Step 30: Run command traffic control show at DUT0 and check if output matches the following regular expressions:

1:0\s+[1-9][0-9]*\s+[1-9][0-9]*\s+0
Show output
Traffic control for interface 'eth0' - 'egress' mode

------------------------------------------------------------------------------------
ID   traffic control        type         parent  bytes sent  pkts sent  pkts dropped
------------------------------------------------------------------------------------
1:0  QDISC            htb                root           422          6             0
1:1  QDISC            class 1            1:0              0          0             0
1:2  QDISC            class 2 (default)  1:0            422          6             0
2:0  -                fq_codel           1:1              0          0             0
3:0  -                fq_codel           1:2            422          6             0

Step 31: Set the following configuration in DUT0:

del traffic control QDISC type htb match 1 ip source port 7643

Step 32: Set the following configuration in DUT0:

set traffic control QDISC type htb match 1 ip protocol tcp

Step 33: Initiate a tcp connection from DUT0 to DUT1 and try to send some messages between both endpoints

admin@DUT1$ monitor test connection server 7070 tcp
admin@DUT0$ monitor test connection client 10.0.0.1 7070 tcp

Step 34: Run command traffic control show at DUT0 and check if output matches the following regular expressions:

1:0\s+[1-9][0-9]*\s+[1-9][0-9]*\s+0
Show output
Traffic control for interface 'eth0' - 'egress' mode

------------------------------------------------------------------------------------
ID   traffic control        type         parent  bytes sent  pkts sent  pkts dropped
------------------------------------------------------------------------------------
1:0  QDISC            htb                root           422          6             0
1:1  QDISC            class 1            1:0            422          6             0
1:2  QDISC            class 2 (default)  1:0              0          0             0
2:0  -                fq_codel           1:1            422          6             0
3:0  -                fq_codel           1:2              0          0             0

Step 35: Set the following configuration in DUT0:

del traffic control QDISC type htb match 1 ip protocol tcp

Step 36: Set the following configuration in DUT0:

set traffic control QDISC type htb match 1 ip protocol tcp

Step 37: Initiate a tcp connection from DUT0 to DUT1 and try to send some messages between both endpoints

admin@DUT1$ monitor test connection server 9090 tcp
admin@DUT0$ monitor test connection client 10.0.0.1 9090 tcp

Step 38: Run command traffic control show at DUT0 and check if output matches the following regular expressions:

1:0\s+[1-9][0-9]*\s+[1-9][0-9]*\s+0
Show output
Traffic control for interface 'eth0' - 'egress' mode

------------------------------------------------------------------------------------
ID   traffic control        type         parent  bytes sent  pkts sent  pkts dropped
------------------------------------------------------------------------------------
1:0  QDISC            htb                root           422          6             0
1:1  QDISC            class 1            1:0            422          6             0
1:2  QDISC            class 2 (default)  1:0              0          0             0
2:0  -                fq_codel           1:1            422          6             0
3:0  -                fq_codel           1:2              0          0             0

Step 39: Set the following configuration in DUT0:

del traffic control QDISC type htb match 1 ip protocol tcp