Configuring QoS
Summary: Networking › Switching › Edge › Synapse
Overview of QoS
Typically, networks operate on a best-effort delivery basis, which means that all traffic has equal priority and an equal chance of being delivered in a timely manner. When congestion occurs, all traffic has an equal chance of being dropped. When you configure the QoS feature, you can select specific network traffic, prioritize it according to its relative importance, and use congestion-management and congestion-avoidance techniques to provide preferential treatment. Implementing QoS in your network makes network performance more predictable and bandwidth utilization more effective. The QoS implementation is based on the Differentiated Services (Diff-Serv) architecture, an emerging standard from the Internet Engineering Task Force (IETF). This architecture specifies that each packet is classified upon entry into the network. The following Figure shows the model of the QoS.
Classification
Classification is the process of distinguishing one kind of traffic from another by examining the fields in the packet. Classification is enabled only if QoS is globally enabled on the switch. By default, QoS is globally disabled, so no classification occurs. During classification, the switch performs a lookup and assigns a QoS label to the packet. The QoS label identifies all QoS actions to be performed on the packet and from which queue the packet is sent. The QoS label is based on the DSCP or the CoS value in the packet and decides the queueing and scheduling actions to perform on the packet. The label is mapped according to the trust setting and the packet type. Trust CoS:
- QoS with CoS label.
- For tagged packets, the CoS uses the CoS information in the tag.
- For packets without tags, the CoS adopts the default CoS value of the port.
Trust DSCP:
- For non-IP packets, the QoS is labeled with CoS; for packets with tags, CoS uses the CoS information in the tag; for packets without tags, the CoS uses the default CoS of the port.
- For IP packets, QoS has a DHCP label; select the DSCP value of the packet.
No trust:
- QoS with CoS label
- CoS adopts the default CoS value of the port.
Policing(Ingress) The ingress policer meters the given flow and classifies as either in-profile or out-of-profile. Out-of-profile packets may be discarded or have their QOS attributes remarked.
Marking
After a packet is classified and has a DSCP-based or CoS-based QoS label assigned to it, the marking process can begin. For packets with CoS labels:
- Use the configured CoS-to-DSCP mapping relationship to generate DSCP values for packets.
- Select the egress queue for the packet through the CoS-to-Queue mapping relationship.
For packets with DSCP labels
- Modify the DSCP value of the packet through the DSCP-to-DSCP mapping relationship.
- Generate a new CoS value for the packet through the DSCP-to-CoS mapping relationship.
- Select the egress queue for the packet through the DSCP-to-Queue mapping relationship.
Queuing and scheduling
Generally, there are 8 queues for QoS exit, which map the 0-7 priority relationship of CoS. The packet enters the corresponding egress queue according to the final marked CoS and CoS-to-Queue relationship. For the priority of packet processing in the egress queue, there are the following algorithms:
- WRR:The weight scheduling algorithm processes the packets in each queue in turn. The weight configuration can be used to change the number of queue packets processed in each cycle. The larger the weight, the higher the queue priority.
- SP:Strict scheduling algorithm, traverse queue 7 to queue 0 in each loop, when the initial processing of the packets in the high-priority queue ends, continue to process the low-priority queue.
- SP+WRR:The combination of WRR and SP, the global WRR mode, supports a specific queue configured as SP mode, and the queue configured as SP mode is a high-priority queue, which is processed first.
Policing(Egress) The egress policer meters the given flow and classifies as either in-profile or out-of-profile. Out-of-profile packets may be discarded.
Configuring
- Enabling QoS Globally
SWITCH(config)#mls qos enable
SWITCH(config)#no mls qos
Enabling QoS Globally. Default is disabled.
SWITCH(config)#mls qos algorithm {sp | wrr}
Configuring the queue scheduling algorithm, support two modes: wrr and sp.
SWITCH(config)#mls qos weight <0-7> <0-32>
Configure the queue weight. The queue weight is only valid for wrr mode. The default weight of all queues is 1. When in wrr mode, configure the queue weight to 0, the queue will schedule in sp mode.
SWITCH(config-if)#mls qos trust {cos | dscp}
SWITCH(config-if)#no mls qos trust
Configure the port trust mode, the default is not trust mode. When in no trust mode, the CoS field and DHCP field of the packet will be modified according to the default CoS of the port. When in trust cos mode, the same as the no trust mode for untagged packets, and for tagged packets, use the own CoS of the packet. When configuring trust dscp mode, for ip packets, select the packet with DSCP, and for non-ip packets, the same as trust cos mode.
SWITCH(config-if)#mls qos cos <0-7>
SWITCH(config-if)#no mls qos cos
Configure the default CoS of the port. The default CoS takes effect for the ingress packets without tags. The default port cos is 0.
SWITCH(config)#mls qos cos-dscp <0-63> <0-63> <0-63> <0-63> <0-63> <0-63> <0-63> <0-63>
SWITCH(config)#no mls qos cos-dscp
Configure CoS-to-DSCP mapping. Default CoS-to-DSCP mapping: 0-0, 1-8, 2-16, 3-24, 4-32, 5-40, 6-48, 7-56.
SWITCH(config)#mls qos cos-queue <0-7> <0-7>
SWITCH(config)#no mls qos cos-queue <0-7>
Configure CoS-to-Queue mapping. Default CoS-to-Queue mapping: 0-0, 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7.
Note
When the configured port is no trust, trust cos or trust dscp and the port is not ip: the cos-dscp configuration takes effect, modify the packet dscp according to the mapping relationship, and the cos-queue configuration takes effect, modify the packet export queue according to the mapping relationship.
- Configuring DSCP-to-CoS Mapping
SWITCH(config)#mls qos dscp-cos <0-63> to <0-7>
SWITCH(config)#no mls qos dscp-cos
Configure DSCP-to-CoS mapping. Default DSCP-to-CoS mapping: <0-7>-0, <8-15>-1, <16-23>-2, <24-31>-3, <32-39>-4, <40-47>- 5, <48-55>-6, <56-63>-7.
SWITCH(config)#mls qos dscp-mutation <0-63> to <0-63>
SWITCH(config)#no mls qos dscp-mutation
Configure DSCP-to-DSCP mapping.
SWITCH(config)#mls qos dscp-queue <0-63> <0-7>
SWITCH(config)#no mls qos dscp-queue <0-63>
Configure DSCP-to-Queue mapping. Default DSCP-to-Queue mapping: <0-7>-0, <8-15>-1, <16-23>-2, <24-31>-3, <32-39>-4, <40-47>- 5, <48-55>-6, <56-63>-7.
Note
When configuring the port as trust dscp and ip packets: the dscp-cos configuration takes effect, modify the packet dscp according to the mapping relationship, and the dscp-queue configuration takes effect, and modify the packet egress queue according to the mapping relationship. When a colleague configures dscp-dscp at the same time, first perform dscp-dscp conversion, and then perform dscp-cos mapping as a result.
- Creating Class-map
SWITCH(config)#class-map CNAME
SWITCH(config-cmap)#
SWITCH(config)#no class-map CNAME
Create class-map. After creating a class-map, automatically enter the class-map mode.
SWITCH(config-cmap)# match access-group ACLNAME
SWITCH(config-cmap)#no match access-group ACLNAME
Configure to match ACL entries for class-map.
SWITCH(config-cmap)#match ip-dscp <0-63>
SWITCH(config-cmap)#no match ip-dscp
Configure to match the DHCP field in the IP packet, up to 64 different DHCP values can be configured.
SWITCH(config-cmap)#match cos <0-7>
SWITCH(config-cmap)#no match cos
Configure to match the CoS field in the packet, up to 8 different CoS values can be configured.
SWITCH(config-cmap)#match ethertype ETYPE
SWITCH(config-cmap)#no match ethertype
Configure to match the ethernet protocol type field of the packets.
SWITCH(config-cmap)#match {vlan <1-4094> | vlan-range <1-4094> to <1-4094>}
SWITCH(config-cmap)#no match {vlan | vlan-range}
Configure to match vlan field in the packet, support range configuration.
SWITCH(config-cmap)#match layer4 {tcp | udp} {source-port | destination-port} VALUE
SWITCH(config-cmap)#no match layer4 {tcp | udp} {source-port | destination-port} VALUE
Configure to match Layer 4 port fields of TCP and UDP packets.
SWITCH(config-cmap)#match vlan-range <1-4094> to <1-4094> ethertype ETYPE
SWITCH(config-cmap)#no match vlan-range
Configure to match vlan and etype fields in the packets.
SWITCH(config)#policy-map PNAME
SWITCH(config-pmap)#
SWITCH(config)#no policy-map PNAME
Configure policy-map
SWITCH(config-pmap)# class CNAME
SWITCH(config-pmap-c)#
SWITCH(config-pmap)#no class CNAME
Attach class-map to policy-map. A policy-map can attach up to 8 class-maps.
SWITCH(config-pmap-c)#set cos <0-7>
SWITCH(config-pmap-c)#no set cos
Configure policy action: modify the cos field of packets.
SWITCH(config-pmap-c)#set ip-dscp <0-63>
SWITCH(config-pmap-c)#no set ip-dscp
Configure policy action: modify the ip-dscp field of packets.
SWITCH(config-pmap-c)#set vlan <1-4094>
SWITCH(config-pmap-c)#no set vlan
Configure policy action: modify packet vlan.
SWITCH(config-pmap-c)#nest vlan <1-4094>
SWITCH(config-pmap-c)#no nest vlan
Configure policy action: add external tags to matching packets.
SWITCH(config-pmap-c)#police cir <32-1000000> cbs <4-31250> exceed-action drop
SWITCH(config-pmap-c)#no police
Configure policy action: rate-limit. Cir is the speed limit water line, in kbps. Cbs is burst capacity, unit Kbyte.
Note
The value of cir is determinable. For example, if the speed limit is 1M, then the value of cir is 1024, but the value of cbs is taken from the empirical value. When the cbs value is set large, the flow peak is higher, and the speed limit is stable, but the average speed may be higher than the speed limit value; when the cbs value is set small, the flow peak is lower, the speed limit fluctuates greatly, and the average speed may be lower than the speed limit value. It is recommended that the cbs configuration take 4 times the value of cir.
- Applying Policy-map on the Interface
SWITCH(config-if)#service-policy input PNAME
SWITCH(config-if)#no service-policy input PNAME
Apply the policy-map on the interface. Only one policy-map can be applied to an interface.
SWITCH(config-if)#rate-limit input <64-1000000> <32-16384>
SWITCH(config-if)#no rate-limit input
Configure port ingress rate limit. The first parameter is limit level, in kbps. The second parameter is burst level, in Kbyte.
SWITCH(config-if)#rate-limit output <64-1000000> <32-16384>
SWITCH(config-if)#no rate-limit output
Configure port egress rate limit. The first parameter is limit value, in kbps. The second parameter is burst value, in Kbyte.
Note
The limit value is determinable. For example, if the speed limit is 1M, then the limit value is 1024, but the burst value is taken from the experience value. When the burst value is large, the flow peak is higher, and the speed limit is stable, but the average rate may be higher than the speed limit value; when the burst value is small, the flow peak is lower, the speed limit fluctuates greatly, and the average rate may be lower than the speed limit value. . It is recommended that the burst configuration be 4 times the limit value.
Examples
Example 1: This example shows how to Configure ingress and egress rate-limit on the interface. Step 1: Configuring Ingress rate-limit on interface gigabitEthernet0/1.
SWITCH(config-if)#rate-limit input 1024 4096
Step 2: Configuring Egress rate-limit on interface gigabitEthernet0/1.
SWITCH(config-if)#rate-limit output 1024 4096
Example 2: This example shows how to configure flow-based rate-limit. Step 1: Enable QoS globally.
SWITCH(config)#mls qos enable
Step 2:Create ACL rule.
SWITCH(config)#ip-access-list 1 permit 192.168.64.1
Step 3:Create class-map, policy-map, attach ACL to the class-map, attach class-map to the policy-map, and configure the policy-map action.
SWITCH(config)#class-map c1
SWITCH(config-cmap)#match access-group 1
SWITCH(config-cmap)#exit
SWITCH(config)#policy-map p1
SWITCH(config-pmap)#class c1
SWITCH(config-pmap-c)#police cir 1024 cbs 4096 exceed-action drop
Step 4: Apply policy-map to the interface.
SWITCH(config)#interface gigabitEthernet0/1
SWITCH(config-if)#service-policy input p1
Example 3: This example shows how to configure port-based QoS service, to Implement preferential forwarding of specific port packets. Step 1: Enable QoS globally.
SWITCH(config)#mls qos enable
Step 2: Configure interface gigabitEthernet0/1 and gigabitEthernet0/2 trust cos. Set gigabitEthernet0/1 default CoS to 0. Set gigabitEthernet0/2 default CoS to 2.
SWITCH(config)#interface gigabitEthernet0/1
SWITCH(config-if)#mls qos trust cos
SWITCH(config-if)#mls qos cos 0
SWITCH(config-if)#exit
SWITCH(config)#interface gigabitEthernet0/2
SWITCH(config-if)#mls qos trust cos
SWITCH(config-if)#mls qos cos 2
Step 3: Configure CoS-to-Queue mapping.
SWITCH(config)#mls qos cos-queue 0 0
SWITCH(config)#mls qos cos-queue 2 2
Step 4: Configure scheduling algorithm wrr.
SWITCH(config)#mls qos algorithm wrr
Step 5: Configuring queue 2 weight 0.
SWITCH(config)#mls qos weight 2 0
Display Information
- Display Scheduling Algorithm and Weight Information
SWITCH#show mls qos algorithm
Mls qos algorithm is WRR. Queue-id 0 1 2 3 4 5 6 7 Weight 1 1 1 1 1 1 1 1
SWITCH#show mls qos cos-maps
—————————-
Cos Dscp Queue
—————————- 0 0 0 1 8 1 2 16 2 3 24 3 4 32 4 5 40 5 6 48 6 7 56 7
- Display DSCP-to-CoS, DSCP-to-DSCP and DSCP-to-Queue Mapping Information
SWITCH#show mls qos dscp-maps
——————————————
Dscp Cos Mutation Queue
—————————————— 0 0 0 0 1 0 1 0 2 0 2 0 3 0 3 0 4 0 4 0 5 0 5 0 6 0 6 0 7 0 7 0 8 1 8 1 9 1 9 1 10 1 10 1 11 1 11 1 12 1 12 1 13 1 13 1 14 1 14 1 15 1 15 1
- Display QoS Configuration on the Interfaces
SWITCH#show mls qos interfaces
——————————-
Interface Trust mode Cos
——————————- GiE0/1 Not 0 GiE0/2 Not 0 GiE0/3 Not 0 GiE0/4 Not 0 GiE0/5 Not 0 GiE0/6 Not 0 GiE0/7 Not 0 GiE0/8 Not 0
- Display Class-map Configuration
SWITCH#show class-map
CLASS-MAP-NAME: c1 Match Cos: 3
SWITCH#show policy-map
POLICY-MAP-NAME: p1 State: detached CLASS-MAP-NAME: c1 Match Cos: 3 Police: Mode: SrTCM cir (1024 Kbps) cbs (4096 KBytes) exceed-action (drop)
SWITCH#show rate-limit
——————————————————-
Interface In limit In burst Out limit Out burst
——————————————————- GiE0/1 — — — — GiE0/2 — — — — GiE0/3 1024 4096 — — GiE0/4 — — — — GiE0/5 — — — — GiE0/6 — — — — GiE0/7 — — — — GiE0/8 — — — — GiE0/9 — — — — GiE0/10 — – 1024 4096

