Saturday, January 31, 2015

Quality of Service (QoS) in HP ProCurve Switches (K.15.xxx)

First off, a basic review of QoS. When congestion occurs in a network, packets will be delayed or dropped. Loosely speaking, QoS is a policy that decides which traffic will be forwarded ahead of other traffic.

QoS is done by the prioritization of frames (or packets) at an egress port in a switch or router. This prioritization is based on the value of the CoS (also known as 802.1p) field in the VLAN tag of an Ethernet frame (layer 2), or the DSCP field in an IP header (layer 3). Within a switch or router, it's the CoS value that decides which priority queue a packet will be assigned to at an egress port. The DSCP value in the IP header is carried from one switch (or router) to another to indicate which level of priority a packet should have, but once a packet arrives in a switch (or router), its DSCP value will be translated to a corresponding CoS value based on which that packet is assigned to an egress queue.

Question: since DSCP is translated to CoS, and CoS is used to determine which egress queue a packet is assigned to, why bother with DSCP at all? Answer: CoS is carried in a VLAN tag and may be lost when a packet is sent out of an untagged port or when a packet is routed, while DSCP (which is carried in an IP header) can be preserved across a network. Note: even though DSCP can be preserved across a network, at some point administrators may choose to re-mark the DSCP to a different value to suit their QoS policy.

The CoS field is 3 bits long, allowing for 8 CoS values (from 0 to 7). However, in order of low to high priority, these values are: 1, 2, 0, 3, 4, 5, 6, 7. CoS value of 0 is used for the normal, i.e. best effort traffic.

The DSCP field is 6 bits long, allowing for 64 DSCP values (from 0 to 63). A number of these values are grouped into PHBs (per-hop behavior) as follows:

EF (Expedited Forwarding): 46 decimal

VA (Voice Admit): 44 decimal

AF (Assured Forwarding):
Class 1: AF11 (10 decimal), AF12 (12 decimal), AF13 (14 decimal)
Class 2: AF21 (18 decimal), AF22 (20 decimal), AF23 (22 decimal)
Class 3: AF31 (26 decimal), AF32 (28 decimal), AF33 (30 decimal)
Class 4: AF41 (34 decimal), AF42 (36 decimal), AF43 (38 decimal)

CS (Class Selector):
CS0: 0 decimal CS1: 8 decimal CS2: 16 decimal CS3: 24 decimal
CS4: 32 decimal CS5: 40 decimal CS6: 48 decimal CS7: 56 decimal

Obviously, there is no 1-to-1 mapping between DSCP and CoS. Instead, multiple DSCP values will be mapped to one single CoS value.

Now, let's look at how QoS is done in HP ProCurve switches.

QoS implementation involves the following steps: selecting the traffic, marking the traffic, and applying the QoS policy.

Selected traffic can be marked with DSCP (Layer 3) or 802.1p priority, also known as CoS values (Layer 2). Before a DSCP value can be used to mark the selected traffic, it has to be mapped to a CoS value. DSCP values corresponding to pre-defined PHBs (EF, VA, AF and CS) are pre-mapped, while other DSCP values can be mapped to CoS values in a customized manner. To see if a specific DSCP value has been mapped or not, issue the command: “show qos dscp-map”. The output will look like this:


The display above shows that DSCP 34 and 36 have been mapped to a CoS value of 6, while the “No-override” in the third column for DSCP 35 confirms that there is no mapping from DSCP 35 to any CoS value in the switch. To map DSCP 35 to CoS value of 5, use the command:

HP-5406zl(config)# qos dscp-map 35 priority 5

Then run “show qos dscp-map” again and the output will look like this:


This confirms that DSCP 35 has been mapped to CoS (i.e. 802.1p priority) 5. Now we can use DSCP 35 to mark selected traffic in this switch. If we try to mark selected traffic with DSCP 35 before mapping it to a CoS value, an error message “DSCP Policy 35 not configured” will appear.

Important: the DSCP-to-CoS mapping as shown above has to be enabled by issuing the command:

qos type-of-service diff-services

To verify if diff-serv is enabled, use the command “show qos type-of-service”.

There are 2 ways to implement QoS: globally-configured QoS and classifier-based QoS. Classifier-based QoS provides more flexibility in terms of traffic selection and policy application.

Global QoS configuration:

- Traffic can be selected based on in the order of precedence: TCP/UDP applications, IP address, DSCP values, L3 protocol, VLAN ID, and ingress interface.
- QoS policy is applied globally across the switch.

Examples:

HP-5406zl(config)# qos tcp-port 2299 priority 6
HP-5406zl(config)# qos udp-port range 1001 1005 dscp 35

The first command selects all TCP packets with TCP port of 2299 and marks these packets with 802.1p priority (CoS) of 6. The second command selects all UDP packets with UDP ports ranging from 1001 to 1005, and marks these packets with DSCP codepoint of 35. For verification use the command “show qos tcp-udp-port-priority

The 2 examples above show how to select (and mark) traffic based on TCP/UDP ports. Below are examples on how to select (and mark) traffic based on other criteria:

Based on the IP address of the packets (either source or destination address):
HP-5406zl(config)# qos device-priority 192.168.4.2/24 priority 5
HP-5406zl(config)# qos device-priority 192.168.4.2/24 dscp 30
For verification, use the command “show qos device-priority

Based on the existing DSCP value of the packets:
HP-5406zl(config)# qos type-of-service diff-services 35 dscp 25
The command above selects packets with DSCP 35 and re-marks DSCP to 25.

Based on the L3 protocol (IP, IPX, ARP, AppleTalk, SNA, or NetBEUI):
HP-5406zl(config)# qos protocol arp priority 4
For verification, use the command “show qos protocol”.

Based on VLAN ID:
HP-5406zl(config)# vlan 2 qos priority 5
HP-5406zl(config)# vlan 3 qos dscp 48
For verification use the command “show qos vlan-priority

Based on the ingress interface:
HP-5406zl(config)# interface a5-a7 qos priority 6
HP-5406zl(config)# interface a1 qos dscp 46
For verification use the command “show qos port-priority

Classifier-based QoS configuration:

- Traffic is selected into one or more classes by using the “match” and “ignore” commands.
- A QoS policy is created, which specifies the actions to be performed on a traffic class.
- The policy is then applied to inbound traffic on a port or a VLAN interface.

Creating a class:

HP-5406zl(config)# class ipv4 Windward
HP-5406zl(config-class)# match tcp 192.168.4.0/24 eq 9801 host 192.168.1.3
HP-5406zl(config-class)# exit

In the example above, a class named Windward was created for all TCP traffic with source belonging to subnet 192.168.4.0/24, TCP port 9801, and destination address 192.168.1.3. For verification, use the command “show class config”. The “match” command accepts a wide range of protocols (tcp, udp, ip, igmp, esp, ospf, pim, and so on). Under each protocol we can specify source/destination IP addresses, TCP/UDP ports, DSCP, VLAN, etc.

Creating a policy for a traffic class:

HP-5406zl(config)# policy qos Alpharetta
HP-5406zl(policy-qos)# class ipv4 Windward action dscp 32
HP-5406zl(policy-qos)# class ipv4 Westside action priority 4
HP-5406zl(policy-qos)# exit

In the example above, packets that match class Windward will be marked with DSCP 32, and packets matching class Westside will be marked with CoS value of 4. For verification use the command “show policy config”. The “action” command also accepts the options “ip-precedence” and “rate-limit”.

Applying a policy to the inbound traffic on a port or VLAN interface:

Only one policy can be applied per interface.

HP-5406zl(config)# interface a1 service-policy Alpharetta in
HP-5406zl(config)# vlan 2 service-policy Alpharetta in

Queuing and QoS Monitoring at Egress Ports:

At the egress port, frames/packets are put into priority queues according to their CoS values. By default there are 8 queues, but this number can be changed by the command “qos queue-config 4-queues” or “qos queue-config 2-queues”. The switch will have to be rebooted for these commands to take effect.

DSCP values can be carried to the next switch in the IP header. CoS values can only be carried to the next switch in the VLAN tag. If the traffic leaves the switch on an untagged port, then CoS values will not be included. Again, DSCP and CoS values in frames/packets can be modified in the next switch.

To view how queues are configured at egress ports, run the command “show qos queue-config”. The output will look like below. Note that CoS 0 corresponds to Queue 3, which is the default best-effort queue.


To view how port bandwidth is distributed among priority queues, issue the command “show bandwidth output ”. For example the command “show bandwidth output a1” will have the output as follows:


Above is the default bandwidth distribution among 8 queues. To change the guaranteed minimum bandwidth for Queue 3 to 20% and Queue 8 to 30% and the rest remain the same as default, use the command:

HP-5406zl(config)# interface a1 bandwidth-min output 2 3 20 10 10 10 15 30

When running the command “show bandwidth output a1” again, the output will look like this:


To monitor queues at an egress port (port A1 in the example below), use the commands:

HP-5406zl(config)# qos watch-queue a1
HP-5406zl(config)# show interface queues a1

The output will look like below. When the amount of outbound traffic on port A1 exceeds its capacity, dropped packets will start to appear in low priority queues.