# Classifying Traffic for Differentiated Services

In a differentiated services domain, traffic is classified into a behavior aggregate (BA), based on the type of diff-serv behavior for the traffic. At each node, traffic belonging to a particular BA is mapped to the corresponding per-hop behavior (PHB), which provides the scheduling behavior and drop probability required by the traffic.

MPLS uses the EXP bits in the shim header to support differentiated services. The JunosE Software supports both statically configured and signaled mapping between the EXP bits and the PHB of traffic.

In a signaled environment, you can configure on the ingress node the set of PHBs that a tunnel supports, and then the set of PHBs is signaled end to end.

To support differentiated services, MPLS employs two types of LSPs: E-LSPs and L-LSPs. The two types differ in how their PHB is determined. In the JunosE Software, the PHB is a combination of traffic class (also called per-hop scheduling class, or PSC) and drop precedence (color).

- E-LSPs (EXP-inferred-PSC LSP) can transport as many as eight BAs. For E-LSPs, the traffic’s PHB is learned from the MPLS shim header.
- L-LSPs (Label-only-inferred-PSC LSP) transport a single PSC. The PHB is determined from a combination of the packet’s label, which indicates the traffic class, and the EXP field of the shim header, which indicates the drop precedence.
  - Table 56 indicates how the PSC (column 1) is combined with the EXP field (column 2) to determine the PHB for incoming traffic on L-LSPs.

    Table 56: Incoming L-LSP PHB Determination

    PSC | + | EXP Field | = | PHB
    --- | --- | --- | --- | ---
    BE |  | 000 |  | BE
    CSn |  | 000 |  | CSn
    AFn |  | 001 |  | AFn1
    AFn |  | 010 |  | AFn2
    AFn |  | 011 |  | AFn3
    EF |  | 000 |  | EF

    For nonstandard PHBs (any that are not listed in Table 56), the JunosE Software uses mapping similar to AFn mapping; EXP 001 is mapped to color green, EXP 010 is mapped to yellow, and EXP 011 is mapped to red.

    Table 57 presents three examples that indicate how the PSC and the EXP field are combined to determine the PHB for traffic on incoming L-LSPs.

    Table 57: Examples of Incoming L-LSP PHB Determination

    PSC | + | EXP Field | = | PHB
    --- | --- | --- | --- | ---
    AF2 |  | 010 |  | AF22
    AF3 |  | 010 |  | AF32
    AF3 |  | 011 |  | AF33

  - For outgoing L-LSPs, the EXP is determined by the PHB. Table 58 indicates the PHB-to-EXP mapping for outgoing traffic on L-LSPs.

    Table 58: Outgoing L-LSP PHB Determination

    PHB | = | EXP Field
    --- | --- | ---
    BE |  | 000
    CSn |  | 000
    AFn1 |  | 001
    AFn2 |  | 010
    AFn3 |  | 011
    EF |  | 000

For nonstandard PHBs, the mapping is similar to AFn mapping. Red color maps to 011, yellow maps to 010, and green maps to 001.

Tasks to perform static configuration and signaled mapping between the EXP bits and the PHB of traffic include the following sets of tasks:

- Configuring Static EXP-to-PHB Mapping
- Signaled Mapping for RSVP-TE Tunnels
- Preference of per-VR Versus per-LSP Behavior

## Configuring Static EXP-to-PHB Mapping

You can configure static EXP-to-PHB mapping at the per-VR level, only for LSPs that do not have specific policies attached (by either per-LSP configured mapping or signaled mapping). The configured mapping applies regardless of label distribution protocol, BGP. LDP, or RSVP-TE.

The PHB of incoming packets is determined from the EXP bits by the match values set with the mpls match exp-bits command.

The EXP bits of outgoing packets are determined from the PHB by the mtach values set with the mpls match traffic-class command.

To configure static EXP-to-PHB mapping:

1. Set a combination of traffic class and color for incoming traffic that matches the specified EXP bits value in the shim header.
   host1(config)#mpls match exp-bits 1 set traffic-class bronze color red

   You can repeat the command to support the eight possible EXP bit values.

2. Set the EXP bits in the shim header of outgoing traffic that matches a particular combination of traffic class and color.
   host1(config)#mpls match traffic-class gold color green set exp-bits 7

   You can repeat the command to support up to 24 combinations: eight traffic classes supported on the router times three colors.

## Signaled Mapping for RSVP-TE Tunnels

For signaled mapping between EXP and PHB, policies apply the EXP bits matching and setting on a per-LSP basis rather than a per-VR basis. Signaled mapping applies only when RSVP-TE is the label distribution protocol.

When traffic is mapped onto the ingress router of the LSP, the EXP bits are set according to a policy attached to the LSP. The policy corresponds to the EXP-to-PHB mapping defined for the LSP. Typically, the policy sets the EXP bits differently according to classifier lists that match on internal class/color information or on a user packet class associated with a packet.

For transit routers and egress routers along the path of the LSP, the incoming EXP bits are matched to determine the traffic class and drop preference (color red, yellow, or green). This matching is accomplished by means of a policy corresponding to the signaled EXP-to-PHB mapping that is created and attached when the LSP is established.

EXP bits are not normally changed on transit routers, but when traffic is sent out of an LSP on a transit router, the bits can be changed by the policy. Normally, however, the net effect is that the EXP-bits remain the same through the mapping sequence of EXP bits to an internal traffic class/color combination back to EXP bits, unless the traffic class/color combination is also modified by other factors.

Because the policy (which maps the EXP bits to an internal traffic class/color combination and vice versa) attached to an LSP is created according to the PHB-ID–to–EXP mapping signaled by RSVP-TE, you must configure on each router a mapping association between PHB IDs and the internal traffic class/color combinations.

The JunosE Software automatically generates and attaches policies when tunnels are established.

Figure 65 shows the mapping associations between PHB IDs, EXP bits, and traffic class (TC)/color combination in an E-LSP case.

- Mapping association between PHB ID and EXP bits is configured on ingress routers using the tunnel mpls diff-serv phb-id command.
- Mapping association between PHB ID and traffic class/color combination is configured on all routers using the mpls diff-serv phb-id traffic-class command.
- Mapping association between EXP bits and traffic class/color combination is done automatically by the JunosE Software at the appropriate routers along the path.

  Figure 65: Associations Between PHB ID, EXP Bits, and Traffic Classes/Colors

Figure 66 shows the operations performed at ingress, transit, and egress systems during signaled mapping sessions.

Figure 66: Signaled Mapping

To define a policy rule that sets the EXP bits in packets to which the policy is applied:

- Issue the mark-exp command.
  host1(config-policy-list)#mark-exp 5 classifier-group claclEXP precedence 32

To create or modify an MPLS classifier control list to match on traffic class/color combination or EXP bits:

- Issue the mpls classifier-listcommand.
  host1(config)#mpls classifier-list be-green traffic-class best-effort color yellow

To map the specified PHB ID to the internal traffic class/color combination:

- Issue the mpls diff-serv phb-id traffic-class command.
  host1(config)#mpls diff-serv phb-id standard 45 traffic-class gold color green

To create or modify an MPLS policy:

- Issue the mpls policy-list command.
  host1(config)#mpls policy-list mpls-exp-setting

To enable collection of policy statistics for a tunnel or LSP. Collection is disabled by default.

- Issue the mpls policy-statistics command.
  host1#mpls policy-statistics boston2dc

Policy statistics are displayed when you issue the show mpls forwarding or show mpls tunnel command, if a policy is attached and policy statistics are enabled.

To specify the traffic class for which LSP-level queues are created and the scheduler profile to be used with the queues:

- Issue the mpls traffic-class command.
  host1(config)#mpls traffic-class af1 scheduler-profile af1-scheduler-profile

These classes originate from E-LSPs and L-LSPs (classes derived from the signaled PHB-ID) or regular LSPs (classes configured with the mpls traffic-class command)

To specify the PHB supported by a signaled tunnel:

- Issue the tunnel mpls diff-serv phb-id command.
  host1(config-if)#tunnel mpls diff-serv phb-id standard 35 exp-bits 5

For E-LSPs, you also use this command to map the PHB to the specified exp-bits bitValue. You can repeat the command for up to eight PHB mappings.

For L-LSPs, do not use the exp-bits keyword. If you repeat the command, the most recent command overwrites the previous command.

## Preference of per-VR Versus per-LSP Behavior

MPLS always prefers the per-LSP method of matching and setting EXP bits by means of applied policies over the per-VR method.

Per-VR matching of EXP bits is not performed on the LSP when an input policy (matching on incoming EXP bits) is attached to the ingress segment of the LSP.

Similarly, per-VR setting of EXP bits is not performed on the LSP when an output policy (setting the outgoing EXP bits) is attached to the egress segment of the LSP.