Foundation Topics
This chapter has three major sections. The chapter begins by examining the fields that can be marked by the classification and marking (C&M) tools. Next, the chapter covers the mechanics of the Cisco IOS Modular QoS CLI (MQC), which is used by all the IOS QoS tools that begin with the words “Class-Based.” Finally, the C&M tools are covered, with most of the content focused on the most important C&M tool, Class-Based Marking (CB Marking).
Fields That Can Be Marked for QoS Purposes
The IP header, LAN trunking headers, Frame Relay header, and ATM cell header all have at least one field that can be used to perform some form of QoS marking. This section lists and defines those fields, with the most significant coverage focused on the IP header IP Precedence (IPP) and Differentiated Services Code Point (DSCP) fields.
IP Precedence and DSCP Compared
The IP header is defined in RFC 791, including a 1-byte field called the Type of Service (ToS) byte. The ToS byte was intended to be used as a field to mark a packet for treatment with QoS tools. The ToS byte itself was further subdivided, with the high-order 3 bits defined as the IP Precedence (IPP) field. The complete list of values from the ToS byte’s original IPP 3-bit field, and the corresponding names, is provided in Table 3-2.
Table 3-2 IP Precedence Values and Names
Name |
Decimal Value |
Binary Value |
Routine |
Precedence 0 |
000 |
Priority |
Precedence 1 |
001 |
Immediate |
Precedence 2 |
010 |
Flash |
Precedence 3 |
011 |
Flash Override |
Precedence 4 |
100 |
Critic/Critical |
Precedence 5 |
101 |
Internetwork Control |
Precedence 6 |
110 |
Network Control |
Precedence 7 |
111 |
Bits 3 through 6 of the ToS byte included flag fields that were toggled on or off to imply a particular QoS service. The final bit (bit 7) was not defined in RFC 791. The flags were not used very often, so in effect, the ToS byte’s main purpose was to hold the 3-bit IPP field.
A series of RFCs collectively called Differentiated Services (DiffServ) came along later. DiffServ needed more than 3 bits to mark packets, so DiffServ standardized a redefinition of the ToS byte. The ToS byte itself was renamed the Differentiated Services (DS) field, and IPP was replaced with a 6-bit field (high-order bits 0–5) called the Differentiated Services Code Point (DSCP) field. Later, RFC 3168 defined the low-order 2 bits of the DS field for use with the QoS Explicit Congestion Notification (ECN) feature. Figure 3-1 shows the ToS byte’s format with the pre-DiffServ and post-DiffServ definition of the field.
Figure 3-1 IP ToS Byte and DS Field Compared
C&M tools often mark DSCP or IPP because the IP packet remains intact as it is forwarded throughout an IP network. The other possible marking fields reside inside Layer 2 headers, which means that the headers are discarded when forwarded by a Layer 3 process. Thus, the latter cannot be used to carry QoS markings beyond the current hop.
DSCP Settings and Terminology
Several DiffServ RFCs suggest a set of values to use in the DSCP field and an implied meaning for those settings. For example, RFC 3246 defines a DSCP of decimal 46, with a name Expedited Forwarding (EF). According to that RFC, packets marked as EF should be given queuing preference so that they experience minimal latency, but the packets should be policed to prevent them from taking over a link and preventing any other types of traffic from exiting an interface during periods when this high-priority traffic reaches or exceeds the interface bandwidth. These suggested settings, and the associated QoS behavior recommended when using each setting, are called Per-Hop Behaviors (PHB) by DiffServ. (The particular example listed in this paragraph is called the Expedited Forwarding PHB.)
Class Selector PHB and DSCP Values
IPP overlaps with the first 3 bits of the DSCP field because the DS field is simply a redefinition of the original ToS byte in the IP header. Because of this overlap, RFC 2475 defines a set of DSCP values and PHBs, called Class Selector (CS) PHBs that provide backward compatibility with IPP. A C&M feature can set a CS DSCP value, and if another router or switch just looks at the IPP field, the value will make sense from an IPP perspective. Table 3-3 lists the CS DSCP names and values, and the corresponding IPP values and names.
Table 3-3 Default and Class Selector DSCP Values
DSCP Class Selector Names |
Binary DSCP Values |
IPP Binary Values |
IPP Names |
Default/CS0* |
000000 |
000 |
Routine |
CS1 |
001000 |
001 |
Priority |
CS2 |
010000 |
010 |
Immediate |
CS3 |
011000 |
011 |
Flash |
CS4 |
100000 |
100 |
Flash Override |
CS5 |
101000 |
101 |
Critical |
CS6 |
110000 |
110 |
Internetwork Control |
CS7 |
111000 |
111 |
Network Control |
Besides defining eight DSCP values and their text names, the CS PHB also suggests a simple set of QoS actions that should be taken based on the CS values. The CS PHB simply states that packets with larger CS DSCPs should be given better queuing preference than packets with lower CS DSCPs.
Assured Forwarding PHB and DSCP Values
The Assured Forwarding (AF) PHB (RFC 2597) defines four classes for queuing purposes, along with three levels of drop probability inside each queue. To mark packets and distinguish into which of four queues a packet should be placed, along with one of three drop priorities inside each queue, the AF PHB defines 12 DSCP values and their meanings. The names of the AF DSCPs conform to the following format:
- AFxy
where x implies one of four queues (values 1 through 4) and y implies one of three drop priorities (values 1 through 3).
The AF PHB suggests that the higher the value of x in the DSCP name AFxy, the better the queuing treatment a packet should get. For example, packets with AF11 DSCPs should get worse queuing treatment than packets with AF23 DSCP values. Additionally, the AF PHB suggests that the higher the value of y in the DSCP name AFxy, the worse the drop treatment for those packets. (Treating a packet worse for drop purposes means that the packet has a higher probability of being dropped.) For example, packets with AF11 DSCPs should get better drop treatment than packets with AF23 DSCP values. Table 3-4 lists the names of the DSCP values, the queuing classes, and the implied drop likelihood.
Table 3-4 Assured Forwarding DSCP Values—Names, Binary Values, and Decimal Values
Queue Class |
Low Drop Probability |
Medium Drop Probability |
High Drop Probability |
Name/Decimal/Binary |
Name/Decimal/Binary |
Name/Decimal/Binary |
|
1 |
AF11/10/001010 |
AF12/12/001100 |
AF13/14/001110 |
2 |
AF21/18/010010 |
AF22/20/010100 |
AF23/22/010110 |
3 |
AF31/26/011010 |
AF32/28/011100 |
AF33/30/011110 |
4 |
AF41/34/100010 |
AF42/36/100100 |
AF43/38/100110 |
The text AF PHB names do not follow the “bigger-is-better” logic in all cases. For example, the name AF11 represents a decimal value of 10, and the name AF13 represents a decimal DSCP of 14. However, AF11 is “better” than AF13, because AF11 and AF13 are in the same queuing class, but AF11 has a lower probability of being dropped than AF13.
The binary version of the AF DSCP values shows the patterns of the values. The first 3 bits of the binary DSCP values designate the queuing class (bits 0 through 2 counting left to right), and the next 2 bits (bits 3 and 4) designate the drop preference. As a result, queuing tools that operate only on IPP can still react to the AF DSCP values, essentially making the AF DSCPs backward compatible with non-DiffServ nodes for queuing purposes.
Expedited Forwarding PHB and DSCP Values
RFC 2598 defines the Expedited Forwarding (EF) PHB, which was described briefly in the introduction to this section. This RFC defines a very simple pair of PHB actions:
- Queue EF packets so that they get scheduled quickly, to give them low latency.
- Police the EF packets so that they do not consume all bandwidth on the link or starve other queues.
The DSCP value defined for EF is named EF, with decimal value 46, binary value 101110.
Non-IP Header Marking Fields
As IP packets pass through an internetwork, the packet is encapsulated in a variety of other headers. In several cases, these other headers have QoS fields that can be used for classification and marking.
Ethernet LAN Class of Service
Ethernet supports a 3-bit QoS marking field, but the field only exists when the Ethernet header includes either an 802.1Q or ISL trunking header. IEEE 802.1Q defines its QoS field as the 3 most-significant bits of the 2-byte Tag Control field, calling the field the user-priority bits. ISL defines the 3 least-significant bits from the 1-byte User field, calling this field the Class of Service (CoS). Generally speaking, most people (and most IOS commands) refer to these fields as CoS, regardless of the type of trunking. Figure 3-2 shows the general location of the CoS field inside ISL and 802.1P headers.
Figure 3-2 LAN CoS Fields
WAN Marking Fields
Frame Relay and ATM support a single bit that can be set for QoS purposes, but these single bits are intended for a very strict use related to drop probability. Frames or cells with these bits set to 1 are considered to be better candidates to be dropped than frames or cells without the bit set to 1. Named the Frame Relay Discard Eligibility (DE) bit and the ATM Cell Loss Priority (CLP) bit, these bits can be set by a router, or by an ATM or Frame Relay switch. Router and switch drop features can then be configured to more aggressively drop frames and cells that have the DE or CLP bit set, respectively.
MPLS defines a 3-bit field called the MPLS Experimental (EXP) bit that is intended for general QoS marking. Often, C&M tools are used on the edge of MPLS networks to remap DSCP or IPP values to MPLS Experimental bit values to provide QoS inside the MPLS network.
Locations for Marking and Matching
Figure 3-3 shows a sample network, with notes about the locations of the QoS fields.
Figure 3-3 Sample Network Showing Non-IP Markable QoS Fields
In such a network, the IPP and DSCP inside the IP packet remain intact from end to end. However, some devices might not be able to look at the IPP or DSCP fields, and some might find it more convenient to look at some other header field. For example, an MPLS Label Switch Router (LSR) inside the MPLS cloud can be configured to make QoS decisions based on the 3-bit MPLS EXP field in the MPLS label, but unable to look at the encapsulated IP header and DSCP field. In such cases, QoS tools might need to be configured on edge devices to look at the DSCP and then mark a different field.
The non-IP header markable fields exist in only parts of the network. As a result, those fields can be used for classification or marking only on the appropriate interfaces. The rules for where these fields (CoS, DE, CLP, EXP) can be used are as follows:
- For classification: On ingress only, and only if the interface supports that particular header field
- For marking: On egress only, and only if the interface supports that particular header field
For example, if CB Marking were to be configured on R1’s fa0/0.1 802.1Q subinterface, it could classify incoming frames based on their CoS values, and mark outgoing frames with a CoS value. However, on ingress, it could not mark CoS, and on egress, it could not classify based on CoS. Similarly, on that same fa0/0.1 subinterface, CB Marking could neither classify nor mark based on a DE bit, CLP bit, or MPLS EXP bits, because these headers never exist on Ethernet interfaces.
Table 3-5 summarizes the QoS marking fields.
Table 3-5 Marking Field Summary
Field |
Location |
Length |
IP Precedence (IPP) |
IP header |
3 bits |
IP DSCP |
IP header |
6 bits |
DS field |
IP header |
1 byte |
ToS byte |
IP header |
1 byte |
CoS |
ISL and 802.1Q header |
3 bits |
Discard Eligible (DE) |
Frame Relay header |
1 bit |
Cell Loss Priority (CLP) |
A TM cell header |
1 bit |
MPLS Experimental |
MPLS header |
3 bits |
Cisco Modular QoS CLI
For many years and over many IOS releases, Cisco added QoS features and functions, each of which used its own separate set of configuration and exec commands. Eventually, the number of different QoS tools and different QoS commands got so large that QoS configuration became a big chore. Cisco created the Modular QoS CLI (MQC) to help resolve these problems, by defining a common set of configuration commands to configure many QoS features in a router or switch.
MQC is not a totally new CLI, different from IOS configuration mode, for configuring QoS. Rather, it is a method of categorizing IOS classification, marking, and related actions into logical groupings to unify the command-line interface. MQC defines a new set of configuration commands—commands that are typed in using the same IOS CLI, in configuration mode. However, after you understand MQC, you typically need to learn only one new command to know how to configure any additional MQC-based QoS tools. You can identify MQC-based tools by the name of the tool; they all begin with the phrase “Class-Based” (abbreviated CB for this discussion). These tools include CB Marking, CB Weighted Fair Queuing (CBWFQ), CB Policing, CB Shaping, and CB Header Compression.
Mechanics of MQC
MQC separates the classification function of a QoS tool from the action (PHB) that the QoS tool wants to perform. To do so, there are three major commands with MQC, with several subordinate commands:
- The class-map command defines the matching parameters for classifying packets into service classes.
- The PHB actions (marking, queuing, and so on) are configured under a policy-map command.
- The policy map is enabled on an interface by using a service-policy command.
Figure 3-4 shows the general flow of commands.
Figure 3-4 MQC Commands and Their Correlation
In Figure 3-4, the network’s QoS policy calls for treating packets in one of two categories, called QoS service classes. (The actual types of packets that are placed into each class are not shown, to keep the focus on the general flow of how the main commands work together.) Classifying packets into two classes calls for the use of two class-map commands. Each class-map command would be followed by a match subcommand, which defines the actual parameters that are compared to the frame/packet header contents to match packets for classification.
For each class, some QoS action (PHB) needs to be performed; this action is configured using the policy-map command. Under a single policy map, multiple classes can be referenced; in Figure 3-4, the two classes are myclass1 and myclass2. Inside the single policy called mypolicy, under each of the two classes myclass1 and myclass2, you can configure separate QoS actions. For example, you could apply different markings to packets in myclass1 and myclass2 at this point. Finally, when the service-policy command is applied to an interface, the QoS features are enabled either inbound or outbound on that interface.
The next section takes a much closer look at packet classification using class maps. Most of the discussion of policy maps will be included when specifically covering CB Marking configuration later in the chapter.
Classification Using Class Maps
MQC-based tools classify packets using the match subcommand inside an MQC class map. The following list details the rules surrounding how class maps work for matching and classifying packets:
- The match command has many options for matching packets, including QoS fields, ACLs, and MAC addresses.
- Class-map names are case sensitive.
- The match protocol command means that IOS uses Network-Based Application Recognition (NBAR) to perform that match.
- The match any command matches any packet—in other words, any and all packets.
Example 3-1 shows a simple CB Marking configuration, with comments focused on the classification configuration. Note that the names and logic match Figure 3-4.
Example 3-1 Basic CB Marking Example
! CEF is required for CB Marking. Without it, the class map and policy map ! configuration would be allowed, but the service-policy command would be rejected. ip cef ! The first class map matches all UDP/RTP packets with UDP ports between 16384 and ! 32767 (the 2nd number is added to the first to get the end of the range.) The ! second class map matches any and all packets. class-map match-all myclass1 match ip rtp 16384 16383 class-map match-all myclass2 match any ! The policy map calls each of the two class maps for matching. The set command ! implies that the PHB is marking, meaning that this is a CB Marking config. policy-map mypolicy class myclass1 set dscp EF class myclass2 set dscp default ! The policy map processes packets leaving interface fa0/0. interface Fastethernet0/0 service-policy output mypolicy
With Example 3-1, each packet leaving interface fa0/0 will match one of the two classes. Because the policy map uses a set dscp command in each class, and all packets happen to match either myclass1 or myclass2, each packet will leave the interface marked either with DSCP EF (decimal 46) or default (decimal 0). (If the matching logic was different and some packets match neither myclass1 nor myclass2, those packets would not be marked, and would retain their existing DSCP values.)
Using Multiple match Commands
In some cases, a class map might need to examine multiple items in a packet to decide whether the packet should be part of that class. Class maps can use multiple match commands, and even nest class maps inside other class maps, to achieve the desired combination of logic. The following list summarizes the key points regarding these more complex matching options:
- Up to four (CoS and IPP) or eight (DSCP) values can be listed on a single match cos, match precedence, or match dscp command, respectively. If any of the values are found in the packet, the statement is matched.
- If a class map has multiple match commands in it, the match-any or match-all (default) parameter on the class-map command defines whether a logical OR or a logical AND (default) is used between the match commands, respectively.
- The match class name command refers to another class map by name, nesting the named class map’s matching logic; the match class name command is considered to match if the referenced class map also results in a match.
Example 3-2 shows several examples of this more complicated matching logic, with notations inside the example of what must be true for a class map to match a packet.
Example 3-2 Complex Matching with Class Maps
! class-map example1 uses match-all logic (default), so this class map matches ! packets that are permitted by ACL 102, and that also have an IP precedence of 5. class-map match-all example1 match access-group 102 match precedence 5 ! class-map example2 uses match-any logic, so this class map matches packets that ! are permitted by ACL 102, or have DSCP AF21, or both. class-map match-any example2 match access-group 102 match dscp AF21 ! class-map example3 matches no packets, due to a common mistake—the two match ! commands use a logical AND between them due to the default match-all argument, ! meaning that a single packet must have DSCP 0 and DSCP 1, which is impossible. ! class-map example4 shows how to correctly match either DSCP 0 or 1. class-map match-all example3 match dscp 0 match dscp 1 ! class-map match-any example4 match dscp 0 1 ! class-map i-am-nesting refers to class-map i-am-nested through the match class ! i-am-nested command. The logic is explained after the example. class-map match-all i-am-nested match access-group 102 match precedence 5 ! class-map match-any i-am-nesting match class i-am-nested match cos 5
The trickiest part of Example 3-2 is how the class maps can be nested, as shown at the end. class-map i-am-nesting uses OR logic between its two match commands, meaning “I will match if the CoS is 5, or if class-map i-am-nested matches the packet, or both.” When combined with the match-all logic of the i-am-nested class map, the logic matches the following packets/frames:
- Packets that are permitted by ACL 102, AND marked with precedence 5
- or
- frames with CoS 5
Classification Using NBAR
NBAR classifies packets that are normally difficult to classify. For example, some applications use dynamic port numbers, so a statically configured match command, matching a particular UDP or TCP port number, simply could not classify the traffic. NBAR can look past the UDP and TCP header, and refer to the host name, URL, or MIME type in HTTP requests. (This deeper examination of the packet contents is sometimes called deep packet inspection.) NBAR can also look past the TCP and UDP headers to recognize application-specific information. For example, NBAR allows recognition of different Citrix application types, and allows searching for a portion of a URL string.
NBAR itself can be used for a couple of different purposes. Independent of QoS features, NBAR can be configured to keep counters of traffic types and traffic volume for each type. For QoS, NBAR can be used by CB Marking to match difficult-to-match packets. Whenever the MQC match protocol command is used, IOS is using NBAR to match the packets. Table 3-6 lists some of the more popular uses of the match protocol command and NBAR.
Table 3-6 Popular Fields Matchable by CB Marking Using NBAR
Field |
Comments |
RTP audio versus video |
RTP uses even-numbered UDP ports from 16,384 to 32,768. The odd-numbered port numbers are used by RTCP for call control traffic. NBAR allows matching the even-numbered ports only, for classification of voice payload into a different service class from that used for voice signaling. |
Citrix applications |
NBAR can recognize different types of published Citrix applications. |
Host name, URL string, MIME type |
NBAR can also match URL strings, including the host name and the MIME type, using regular expressions for matching logic. |
Peer-to-peer applications |
NBAR can find file-sharing applications like KaZaa, Morpheus, Grokster, and Gnutella. |
Classification and Marking Tools
The final major section of this chapter covers CB Marking, with a brief mention of a few other, less popular marking tools.
Class-Based Marking (CB Marking) Configuration
As with the other QoS tools whose names begin with the phrase “Class-Based,” you will use MQC commands to configure CB Marking. The following list highlights the key points regarding CB Marking configuration and logic:
- CB Marking requires CEF (enabled using the ip cef global command).
- Packets are classified based on the logic in MQC class maps.
- An MQC policy map refers to one or more class maps using the class class-map-name command; packets classified into that class are then marked.
- CB Marking is enabled for packets either entering or exiting an interface using the MQC service-policy in | out policy-map-name interface subcommand.
- A CB Marking policy map is processed sequentially; after a packet has matched a class, it is marked based on the set command(s) defined for that class.
- You can configure multiple set commands in one class to set multiple fields, for example, to set both DSCP and CoS.
- Packets that do not explicitly match a defined class are considered to have matched a special class called class-default.
- For any class inside the policy map for which there is no set command, packets in that class are not marked.
Table 3-7 lists the syntax of the CB Marking set command, showing the familiar fields that can be set by CB Marking. Table 3-8 lists the key show commands available for CB Marking.
Table 3-7 set Configuration Command Reference for CB Marking
Command |
Function |
set [ ip ] precedence ip-precedence-value |
Marks the value for IP Precedence for IPv4 and IPv6 packets if the ip parameter is omitted; sets only IPv4 packets if the ip parameter is included |
set [ ip ] dscp ip-dscp-value |
Marks the value for IP DSCP for IPv4 and IPv6 packets if the ip parameter is omitted; sets only IPv4 packets if the ip parameter is included |
set cos cos-value |
Marks the value for CoS |
set qos-group group-id |
Marks the group identifier for the QoS group |
set atm-clp |
Sets the ATM CLP bit |
set fr-de |
Sets the Frame Relay DE bit |
Table 3-8 EXEC Command Reference for CB Marking
Command |
Function |
show policy-map policy-map-name |
Lists configuration information about a policy map |
show policy-map interface-spec [input | output] [ class class-name ] |
Lists statistical information about the behavior of a policy map when enabled on an interface |
CB Marking Example
The first CB Marking example uses the network shown in Figure 3-5. Traffic was generated in the network to make the show commands more meaningful. Two G.711 voice calls were completed between R4 and R1 using Foreign Exchange Station (FXS) cards on these two routers, with Voice Activity Detection (VAD) disabled. Client1 performed an FTP get of a large file from Server1, and downloaded two large HTTP objects, named important.jpg and not-so.jpg. Finally, Client1 and Server1 held a Microsoft NetMeeting conference, using G.723 for the audio and H.263 for the video.
Figure 3-5 Sample Network for CB Marking Examples
The following criteria define the requirements for marking the various types of traffic for Example 3-3:
- VoIP payload is marked with DSCP EF.
- NetMeeting video traffic is marked with DSCP AF41.
- Any HTTP traffic whose URL contains the string “important” anywhere in the URL is marked with AF21.
- Any HTTP traffic whose URL contains the string “not-so” anywhere in the URL is marked with AF23.
- All other traffic is marked with DSCP Default (0).
Example 3-3 lists the annotated configuration, including the appropriate show commands.
Example 3-3 CB Marking Example 1, with show Command Output
ip cef ! Class map voip-rtp uses NBAR to match all RTP audio payload, but not the video ! or the signaling. class-map voip-rtp match protocol rtp audio ! Class map http-impo matches all packets related to downloading objects whose ! name contains the string "important," with any text around it. Similar logic ! is used for class-map http-not. class-map http-impo match protocol http url "*important*" ! class-map http-not match protocol http url "*not-so*" ! Class map NetMeet matches two RTP subtypes—one for G.723 audio (type 4) and ! one for H.263 video (type 34). Note the match-any logic so that if either is ! true, a match occurs for this class map. class-map match-any NetMeet match protocol rtp payload-type 4 match protocol rtp payload-type 34 ! policy-map laundry-list calls each of the class maps. Note that the order ! listed here is the order in which the class commands were added to the policy ! map. policy-map laundry-list class voip-rtp set ip dscp EF class NetMeet set ip dscp AF41 class http-impo set ip dscp AF21 class http-not set ip dscp AF23 class class-default set ip DSCP default ! Above, the command class class-default is only required if some nondefault action ! needs to be taken for packets that are not explicitly matched by another class. ! In this case, packets not matched by any other class fall into the class-default ! class, and are marked with DSCP Default (decimal 0). Without these two commands, ! packets in this class would remain unchanged. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!! ! Below, the policy map is enabled for input packets on fa0/0. interface Fastethernet 0/0 service-policy input laundry-list ! The command show policy-map laundry-list simply restates the configuration. R3# show policy-map laundry-list Policy Map laundry-list Class voip-rtp set ip dscp 46 Class NetMeet set ip dscp 34 Class http-impo set ip dscp 18 Class http-not set ip dscp 22 Class class-default set ip dscp 0 ! The command show policy-map interface lists statistics related to MQC features. ! Several stanzas of output were omitted for brevity. R3# show policy-map interface fastethernet 0/0 input Fastethernet0/0 Service-policy input: laundry-list Class-map: voip-rtp (match-all) 35268 packets, 2609832 bytes 5 minute offered rate 59000 bps, drop rate 0 bps Match: protocol rtp audio QoS Set ip dscp 46 Packets marked 35268 Class-map: NetMeet (match-any) 817 packets, 328768 bytes 5 minute offered rate 19000 bps, drop rate 0 bps Match: protocol rtp payload-type 4 protocol rtp payload-type 34 QoS Set ip dscp 34 Packets marked 817 ! omitting stanza of output for class http-impo ! omitting stanza of output for class http-not Class-map: class-default (match-all) 33216 packets, 43649458 bytes 5 minute offered rate 747000 bps, drop rate 0 bps Match: any QoS Set ip dscp 0 Packets marked 33301
Example 3-3 includes several different classification options using the match command, including the matching of Microsoft NetMeeting traffic. NetMeeting uses RTP for the video flows, and by default uses G.723 for audio and H.323 for video. To match both the audio and video for NetMeeting, a class map that matches either of the two RTP payload subtypes for G.723 and H.263 is needed. So, class map NetMeet uses match-any logic, and matches on RTP payload types 4 (G.723) and 34 (H.263). (For more background information on RTP payload types, refer to www.cisco.com/en/US/products/ps6616/products_white_paper09186a0080110040.shtml.)
The show policy-map interface command provides statistical information about the number of packets and bytes that have matched each class in the policy maps. The generic syntax is as follows:
show policy-map interface interface-name [vc [vpi/] vci] [dlci dlci] [input | output] [class class-name]
The end of Example 3-3 shows a sample of the command, which lists statistics for marking. If other MQC-based QoS features were configured, statistics for those features would also be displayed. As you can see from the generic command, the show policy-map interface command allows you to select just one interface, either input or output, and even select a single class inside a single policy map for display.
The load-interval interface subcommand can also be useful when looking at any QoS tool’s statistics. The load-interval command defines the time interval over which IOS measures packet and bit rates on an interface. With a lower load interval, the statistics change more quickly; with a larger load interval, the statistics change more slowly. The default setting is 5 minutes, and it can be lowered to 30 seconds.
Example 3-3 also shows a common oversight with QoS configuration. Note that the first class in policy-map laundry-list is class voip-rtp. Because that class map matches all RTP audio, it matches the Microsoft NetMeeting audio stream as well, so the NetMeeting audio is not matched by class NetMeet that follows. If the first two classes (voip-rtp and NetMeet) called in the policy map had been reversed, the NetMeeting audio would have been correctly matched in the NetMeet class, and all other audio would have been marked as part of the voip-rtp class.
CB Marking of CoS and DSCP
Example 3-4 shows how a router might be configured for CB Marking when an attached LAN switch is performing QoS based on CoS. In this case, R3 looks at frames coming in its fa0/0 interface, marking the DSCP values based on the incoming CoS settings. Additionally, R3 looks at the DSCP settings for packets exiting its fa0/0 interface toward the switch, setting the CoS values in the 802.1Q header. The actual values used on R3’s fa0/0 interface for classification and marking are as follows:
- Frames entering with CoS 5 will be marked with DSCP EF.
- Frames entering with CoS 1 will be marked with DSCP AF11.
- Frames entering with any other CoS will be marked DSCP 0.
- Packets exiting with DSCP EF will be marked with CoS 5.
- Packets exiting with DSCP AF11 will be marked with CoS 1.
- Packets exiting with any other DSCP will be marked with CoS 0.
Example 3-4 Marking DSCP Based on Incoming CoS, and Vice Versa
! The class maps each simply match a single CoS or DSCP value. class-map cos1 match cos 1 ! class-map cos5 match cos 5 ! class-map AF11 match dscp af11 ! class-map EF match dscp EF ! This policy map will map incoming CoS to a DSCP value policy-map map-cos-to-dscp class cos1 set DSCP af11 class cos5 set ip DSCP EF class class-default set ip dscp default ! This policy map will map incoming DSCP to outgoing CoS. Note that the DSCP ! value is not changed. policy-map map-dscp-to-cos class AF11 set cos 1 class EF set cos 5 class class-default set cos 0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! The policy maps are applied to an 802.1q subinterface. interface FastEthernet0/0.1 encapsulation dot1Q 102 service-policy input map-cos-to-dscp service-policy output map-dscp-to-cos ! interface FastEthernet0/0.2 encapsulation dot1Q 2 native
The QoS policy requires two policy maps in this example. Policy map map-cos-to-dscp matches CoS values for frames entering R3’s fa0/0.1 interface, and marks DSCP values, for packets flowing right to left in Figure 3-5. Therefore, the policy map is enabled on input of R3’s fa0/0.1 interface. Policy map map-dscp-to-cos matches DSCP values for packets exiting R3’s fa0/0.1 interface, and marks the corresponding CoS value. Therefore, the policy map was enabled on the output of R3’s fa0/0.1 interface. Neither policy map could be applied on the WAN interface, because only interfaces configured for 802.1Q accept service-policy commands that reference policy maps that either classify or mark based on CoS.
Note that you cannot enable a policy-map that refers to CoS on interface fa0/0.2 in this example. That subinterface is in the native VLAN, meaning that no 802.1Q header is used.
Network-Based Application Recognition
CB Marking can make use of NBAR’s powerful classification capabilities through the match protocol subcommand. Example 3-5 shows a configuration for CB Marking and NBAR in which the following requirements are met:
- Any HTTP traffic whose URL contains the string “important” anywhere in the URL is marked with AF21.
- Any HTTP traffic whose URL contains the string “not-so” anywhere in the URL is marked with DSCP default.
- All other traffic is marked with AF11.
Example 3-5 shows the configuration, along with a few NBAR-related show commands.
Example 3-5 CB Marking Based on URLs, Using NBAR for Classification
ip cef ! The "*" in the url string is a wildcard meaning "0 or more characters." class-map http-impo match protocol http url "*important*" class-map http-not match protocol http url "*not-so*" ! The policy map lists the three classes in order, setting the DSCP values. policy-map http class http-impo set dscp AF21 ! class http-not set dscp default ! class class-default set DSCP AF11 ! The ip nbar protocol discovery command may or may not be required—see the notes ! following this example. interface fastethernet 0/0 ip nbar protocol-discovery service-policy input http ! The show ip nbar command only displays statistics if the ip nbar ! protocol-discovery command is applied to an interface. These statistics are ! independent of those created by CB Marking. This example shows several of ! the large number of options on the command. R3# show ip nbar protocol-discovery interface fastethernet 0/0 stats packet-count top-n 5 FastEthernet0/0 Input Output Protocol Packet Count Packet Count ------------------------ ------------------------ ------------------------ http 721 428 eigrp 635 0 netbios 199 0 icmp 1 1 bgp 0 0 unknown 46058 63 Total 47614 492
Unlike most other IOS features, NBAR can be upgraded without changing to a later IOS version. Cisco uses a feature called Packet Description Language Modules (PDLM) to define new protocols that NBAR should match. When Cisco decides to add one or more new protocols to the list of protocols that NBAR should recognize, it creates and compiles a PDLM. You can then download the PDLM from Cisco, copy it into Flash memory, and add the ip nbar pdlm pdlm-name command to the configuration, where pdlm-name is the name of the PDLM file in Flash memory. NBAR can then classify based on the protocol information from the new PDLM.
CB Marking Design Choices
The intent of CB Marking is to simplify the work required of other QoS tools by marking packets of the same class with the same QoS marking. For other QoS tools to take advantage of those markings, packets should generally be marked as close to the ingress point of the packet as possible. However, the earliest possible point might not be a trusted device. For example, in Figure 3-5 (the figure upon which Examples 3-3 and 3-4 are based), Server1 could set its own DSCP and even CoS if its network interface card (NIC) supported trunking. However, trusting the server administrator might or might not be desirable. So, the following rule summarizes how to choose the best location to perform marking:
- Mark as close to the ingress edge of the network as possible, but not so close to the edge that the marking is made by an untrusted device.
Cisco QoS design guide documents make recommendations not only as to where to perform marking, but also as to which CoS, IPP, and DSCP values to set for certain types of traffic. Table 3-9 summarizes those recommendations.
Table 3-9 RFC-Recommended Values for Marking
Type of Traffic |
CoS |
IPP |
DSCP |
Voice payload |
5 |
5 |
EF |
Video payload |
4 |
4 |
AF41 |
Voice/video signaling |
3 |
3 |
CS3 |
Mission-critical data |
3 |
3 |
AF31, AF32, AF33 |
Transactional data |
2 |
2 |
AF21, AF22, AF23 |
Bulk data |
1 |
1 |
AF11, AF12, AF13 |
Best effort |
0 |
0 |
BE |
Scavenger (less than best effort) |
0 |
0 |
2, 4,6 |
Also note that Cisco recommends not to use more than four or five different service classes for data traffic. When you use more classes, the difference in behavior between the various classes tends to blur. For the same reason, do not give too many data service classes high-priority service.
Marking Using Policers
Traffic policers measure the traffic rate for data entering or exiting an interface, with the goal of determining whether a configured traffic contract has been exceeded. The contract has two components: a traffic rate, configured in bits/second, and a burst size, configured as a number of bytes. If the traffic is within the contract, all packets are considered to have conformed to the contract. However, if the rate or burst exceeds the contract, some packets are considered to have exceeded the contract. QoS actions can be taken on both categories of traffic.
The simplest form of policing enforces the traffic contract strictly by forwarding conforming packets and discarding packets that exceed the contract. However, both IOS policers allow a compromise action in which the policer marks down packets instead of dropping them. To mark down the packet, the policer re-marks a QoS field, typically IPP or DSCP, with a value that makes the packet more likely to be discarded downstream. For example, a policer could re-mark AF11 packets that exceed a contract with a new DSCP value of AF13, but not discard the packet. By doing so, the packet still passes through the router, but if the packet experiences congestion later in its travels, it is more likely to be discarded than it would have otherwise been. (Remember, DiffServ suggests that AF13 is more likely to be discarded than AF11 traffic.)
When marking requirements can be performed by using CB Marking, CB Marking should be used instead of either policer. However, if a requirement exists to mark packets based on whether they conform to a traffic contract, marking with policers must be used. Chapter 5, “Shaping, Policing, and Link Fragmentation,” covers CB policing, with an example of the syntax it uses for marking packets.
QoS Pre-Classification
With unencrypted, unencapsulated traffic, routers can match and mark QoS values, and perform ingress and egress actions based on markings, by inspecting the IP headers. However, what happens if the traffic is encrypted? If we encapsulate traffic inside a VPN tunnel, the original headers and packet contents are unavailable for inspection. The only thing we have to work with is the ToS byte of the original packet, which is automatically copied to the tunnel header (in IPsec transport mode, in tunnel mode, and in GRE tunnels) when the packet is encapsulated. But features like NBAR are broken when we are dealing with encapsulated traffic.
The issue that arises from this inherent behavior of tunnel encapsulation is the inability of a router to take egress QoS actions based on encrypted traffic. To mitigate this limitation, Cisco IOS includes a feature called QoS pre-classification. This feature can be enabled on VPN endpoint routers to permit the router to make egress QoS decisions based on the original traffic, before encapsulation, rather than just the encapsulating tunnel header. QoS pre-classification works by keeping the original, unencrypted traffic in memory until the egress QoS actions are taken.
You can enable QoS pre-classification in tunnel interface configuration mode, virtual-template configuration mode, or crypto map configuration mode by issuing the qos pre-classify command. You can view the effects of pre-classification using several show commands, which include show interface and show crypto-map.
Table 3-10 lists the modes in which you apply the qos pre-classify command.
Table 3-10 Where to Use the qos pre-classify Command
Configuration Command Under Which qos pre-classify Is Configured |
VPN Type |
interface tunnel |
GRE and IPIP |
interface virtual-template |
L2F and L2TP |
crypto map |
IPsec |
Policy Routing for Marking
Policy routing provides the capability to route a packet based on information in the packet besides the destination IP address. The policy routing configuration uses route maps to classify packets. The route-map clauses include set commands that define the route (based on setting a next-hop IP address or outgoing interface).
Policy routing can also mark the IPP field, or the entire ToS byte, using the set command in a route map. When you use policy routing for marking purposes, the following logic sequence is used:
- Packets are examined as they enter an interface.
- A route map is used to match subsets of the packets.
- Mark either the IPP or entire ToS byte using the set command.
- The traditional policy routing function of using the set command to define the route might also be configured, but it is not required.
Policy routing should be used to mark packets only in cases where CB Marking is not available, or when a router needs to both use policy routing and mark packets entering the same interface.
AutoQoS
AutoQoS is a macro that helps automate class-based quality of service (QoS) configuration. It creates and applies QoS configurations based on Cisco best-practice recommendations. Using AutoQoS provides the following benefits:
- Simpler QoS deployment.
- Less operator error, because most steps are automated.
- Cheaper QoS deployment because less staff time is involved in analyzing network traffic and determining QoS configuration.
- Faster QoS deployment because there are dramatically fewer commands to issue.
- Companies can implement QoS without needing an in-depth knowledge of QoS concepts.
There are two flavors—AutoQoS for VoIP and AutoQoS for the Enterprise—as discussed in the following sections.
AutoQoS for VoIP
AutoQoS for VoIP is supported on most Cisco switches and routers, and provides QoS configuration for voice and video applications. It is enabled on individual interfaces, but creates both global and interface configurations. When enabled on access ports, AutoQoS uses Cisco Discovery Protocol (CDP) to detect the presence or absence of a Cisco phone or softphone, and configures the interface QoS appropriately. When enabled on uplink or trunk ports, it trusts the COS or DSCP values received and sets up the interface QoS.
AutoQoS VoIP on Switches
AutoQoS assumes that switches will have two types of interfaces: user access and uplink. It also assumes that a user access interface might or might not have an IP phone connected to it. There is no need to enable QoS globally. After it is enabled for any interface, the command starts a macro that globally enables QoS, configures interface ingress and egress queues, configures class maps and policy maps, and applies the policy map to the interface.
AutoQoS is enabled for an access interface by the interface-level command auto qos voip {cisco-phone | cisco-softphone}. When you do this, the switch uses CDP to determine whether a Cisco phone or softphone is connected to the interface. If one is not found, the switch marks all traffic down to DSCP 0 and treats it as best effort. This is the default behavior for a normal trunk port. If a phone is found, the switch then trusts the QoS markings it receives. On the ingress interface, the following traffic is put into the priority, or expedite, queue:
- Voice and video control traffic
- Real-time video traffic
- Voice traffic
- Routing protocol traffic
- Spanning-tree BPDU traffic
All other traffic is placed in the normal ingress queue. On the egress side, voice is placed in the priority queue. The remaining traffic is distributed among the other queues, depending on the number and type of egress queues supported by that particular switch or switch module.
AutoQoS is enabled for an uplink port by the interface-level command auto qos voip trust. When this command is given, the switch trusts the COS values received on a Layer 2 port and the DSCP values received on a Layer 3 port.
The AutoQoS macro also creates quite a bit of global configuration in the switch. It generates too much to reproduce here, but the following list summarizes the configuration created:
- Globally enables QoS.
- Creates COS-to-DCSP mappings and DSCP-to-COS mappings. As the traffic enters the switch, the frame header containing the COS value is removed. The switch uses the COS value in the frame header to assign a DSCP value to the packet. If the packet exits a trunk port, the internal DSCP value is mapped back to a COS value.
- Enables priority or expedite ingress and egress queues.
- Creates mappings of COS values to ingress and egress queues and thresholds.
- Creates mappings of DSCP values to ingress and egress queues and thresholds.
- Creates class maps and policy maps to identify, prioritize, and police voice traffic. Applies those policy maps to the interface.
For best results, enable AutoQoS before configuring any other QoS on the switch. You can then go back and modify the default configuration if needed to fit your specific requirements.
AutoQoS VoIP on Routers
The designers of AutoQoS assumed that routers would be connecting to downstream switches or the WAN, rather than user access ports. Therefore, the VoIP QoS configuration is simpler. The command to enable it is auto qos voip [trust]. Make sure that the interface bandwidth is configured before giving this command. If you change it later, the QoS configuration will not change. When you issue the auto qos voip command on an individual data circuit, the configuration it creates differs depending on the bandwidth of the circuit itself. Compression and fragmentation are enabled on links of 768 kbps bandwidth and lower. They are not enabled on links faster than 768 kbps. The router additionally configures traffic shaping and applies an AutoQoS service policy regardless of the bandwidth.
When you issue the command on a serial interface with a bandwidth of 768 kbps or less, the router changes the interface encapsulation to PPP. It creates a PPP Multilink interface and enables Link Fragmentation and Interleave (LFI) on the interface. Serial interfaces with a configured bandwidth greater than 768 kbps keep their configured encapsulation, and the router merely applies an AutoQoS service policy to the interface.
If you use the trust keyword in the command, the router creates class maps that group traffic based on its DSCP values. It associates those class maps with a created policy map and assigns it to the interface. You would use this keyword when QoS markings are assigned by a trusted device.
If you do not use the trust keyword, the router creates access lists that match voice and video data and call control ports. It associates those access lists with class maps with a created policy map that marks the traffic appropriately. Any traffic not matching those access lists is marked with DSCP 0. You would use this command if the traffic either arrives at the router unmarked or arrives marked by an untrusted device.
Verifying AutoQoS VoIP
Displaying the running configuration shows all the mappings, class and policy maps, and interface configurations created by the AutoQoS VoIP macro. Use the following commands to get more specific information:
- show auto qos: Displays the interface AutoQoS commands
- show mls qos: Has several modifiers that display queuing and COS/DSCP mappings
- show policy-map interface: Verifies the actions of the policy map on each interface specified
AutoQoS for the Enterprise
AutoQoS for the Enterprise is supported on Cisco routers. The main difference between it and AutoQoS VoIP is that it automates the QoS configuration for VoIP plus other network applications, and is meant to be used for WAN links. It can be used for Frame Relay and ATM subinterfaces only if they are point-to-point links. It detects the types and amounts of network traffic and then creates policies based on that. As with AutoQoS for VoIP, you can modify those policies if you desire. There are two steps to configuring Enterprise AutoQoS. The first step discovers the traffic, and the second step provides the recommended QoS configuration.
Discovering Traffic for AutoQoS Enterprise
The command to enable traffic discovery is auto discovery qos [trust] and is issued at the interface, DLCI, or PVC configuration level. Make sure that Cisco Express Forwarding (CEF) is enabled, that the interface bandwidth is configured, and that no QoS configuration is on the interface before giving the command. Use the trust keyword if the traffic arrives at the router already marked, and if you trust those markings, because the AutoQoS policies will use those markings during the configuration stage.
Traffic discovery uses NBAR to learn the types and amounts of traffic on each interface where it is enabled. You should run it long enough for it to gather a representative sample of your traffic. The router will classify the traffic collected into one of ten classes. Table 3-11 shows the classes, the DSCP values that will be mapped to each if you use the trust option in the command, and sample types of traffic that NBAR will map to each. Note that the traffic type is not a complete list, but is meant to give you a good feel for each class.
Table 3-11 AutoQoS for the Enterprise Classes and DSCP Values
Class |
DSCP/PHB Value |
Traffic Types |
Routing |
CS6 |
EIGRP, OSPF |
VoIP |
EF (46) |
RTP Voice Media |
Interactive video |
AF41 |
RTP Video Media |
Streaming video |
CS4 |
Real Audio, Netshow |
Control |
CS3 |
RTCP, H323, SIP |
Transactional |
AF21 |
SAP, Citrix, Telnet, SSH |
Bulk |
AF11 |
FTP, SMTP, POP3, Exchange |
Scavenger |
CS1 |
Peer-to-peer applications |
Management |
CS2 |
SNMP, Syslog, DHCP, DNS |
Best effort |
All others |
All others |
Generating the AutoQoS Configuration
When the traffic discovery has collected enough information, the next step is to issue the auto qos command on the interface. This runs a macro that creates templates based on the traffic collected, creates class maps to classify that traffic, and creates a policy map to allocate bandwidth and mark the traffic. The router then automatically applies the policy map to the interface. In the case of a Frame Relay DLCI, the router applies the policy map to a Frame Relay map class, and then applies that class to the DLCI. You can optionally turn off NBAR traffic collection with the no auto discovery qos command.
Verifying AutoQoS for the Enterprise
As with AutoQoS VoIP, displaying the running configuration will show all the mappings, class and policy maps, and interface configurations created by the AutoQoS macro. Use the following commands to get more specific information:
- show auto discovery qos: Lists the types and amounts of traffic collected by NBAR
- show auto qos: Displays the class maps, policy maps, and interface configuration generated by the AutoQoS macro
- show policy-map interface: Displays each policy map and the actual effect it had on the interface traffic