Cisco IOS XR QoS: Class-Map, Policy-Map and Shaping Examples - 夜莺博客

Cisco IOS XR QoS: Class-Map, Policy-Map and Shaping Examples

Cisco IOS XR implements QoS through the Modular QoS CLI (MQC), the same class-map / policy-map model used on IOS but with XR-specific syntax such as end-class-map, commit-based configuration and per-class shaping on ASR 9000 routers. This article walks through a complete IOS XR QoS configuration: defining traffic classes, building a policy-map with shaping and policing actions, attaching it to an interface, and verifying with show commands - based on the official Cisco ASR 9000 Modular QoS configuration guide.

The MQC Building Blocks on IOS XR

MQC has three stages: class-map selects traffic (match on precedence, DSCP, ACL, CoS, EXP...), policy-map defines what happens to each class (set, police, shape, queue), and service-policy attaches the policy to an interface in the input or output direction. On XR every configuration change must be committed with commit.

Defining a Class-Map

RP/0/RSP0/CPU0:router(config)# class-map class1
RP/0/RSP0/CPU0:router(config-cmap)# match precedence 3
RP/0/RSP0/CPU0:router(config-cmap)# end-class-map
RP/0/RSP0/CPU0:router(config)# commit

Without a match type keyword the class-map defaults to match-any; use class-map match-all when every condition must match.

Building a Policy-Map with Shaping

Shape the priority class at 30 percent and the default class at 20 percent of the interface rate:

RP/0/RSP0/CPU0:router(config)# policy-map policy1
RP/0/RSP0/CPU0:router(config-pmap)# class class1
RP/0/RSP0/CPU0:router(config-pmap-c)# shape average percent 30
RP/0/RSP0/CPU0:router(config-pmap-c)# exit
RP/0/RSP0/CPU0:router(config-pmap)# class class-default
RP/0/RSP0/CPU0:router(config-pmap-c)# shape average percent 20
RP/0/RSP0/CPU0:router(config-pmap-c)# end-policy-map
RP/0/RSP0/CPU0:router(config)# commit

Class order matters: XR programs classes into TCAM in the order they appear in the policy-map and applies the first matching class, so put more specific matches first.

Policing and Marking Actions

Police limits the rate and can mark conform/exceed traffic differently, while set rewrites fields. The example below polices class c1 at 10 Mbps peak 20 Mbps and remarks DSCP per action:

policy-map p1
 class c1
  set dscp af11
  set cos 5
  police rate 10 mbps peak-rate 20 mbps
   conform-action set dscp af12
   conform-action set cos 6
   exceed-action set dscp af13
   exceed-action set cos 4
 end-policy-map

Attaching the Policy to an Interface

RP/0/RSP0/CPU0:router(config)# interface TenGigE0/0/0/0
RP/0/RSP0/CPU0:router(config-if)# service-policy output policy1
RP/0/RSP0/CPU0:router(config-if)# commit

Verification Commands

show policy-map interface TenGigE0/0/0/0
show running-config policy-map policy1
show qos interface TenGigE0/0/0/0

Related Guides on This Site

QoS problems often show up as drops first - see IOS XR input drops and NP counters, plus IOS XR BGP configuration and XR RPL route policies to complete your router baseline.

原文链接:https://www.cisco.com/c/en/us/td/docs/routers/asr9000/software/711x/qos/configuration/guide/b-qos-cg-asr9k-711x/modular-qos-overview.html