Understanding CoS Rewrite Rules
As packets enter or exit a network, edge switches might be required to alter the class-of-service (CoS) settings of the packets. This topic describes how to use rewrite rules to alter the CoS settings. It covers:
How Rewrite Rules Work
Rewrite rules set the value of the CoS bits within the packet’s header. Each rewrite rule reads the current forwarding class and loss priority associated with the packet, locates the chosen CoS value from a table, and writes this CoS value into the packet header. For rewrites to occur, rewrite rules must be explicitly assigned to an interface. Only tagged Layer 3 interfaces and tagged routed VLAN interfaces (RVIs) automatically rewrite packets by using the default IEEE 802.1p rewrite rule. Multiple rewrite rules of different types can be assigned to a single interface.
![]() | Note: On Juniper Networks EX8200 Ethernet Switches, tagged Layer 3 interfaces and tagged RVIs do not automatically rewrite packets using the default IEEE 802.1p rewrite rule. You must explicitly assign the IEEE 802.1p rewrite rule to these interfaces for rewrites to occur. Also, only one rewrite rule of each type can be assigned to any interface on an EX8200 switch. |
In effect, the rewrite rule performs the opposite function of the behavior aggregate (BA) classifier used when the packet enters the switch. As the packet leaves the switch, the final CoS action is generally the application of a rewrite rule.
You configure rewrite rules to alter CoS values in outgoing packets on the outbound interfaces of an edge switch to meet the policies of a targeted peer. This allows the downstream switch in a neighboring network to classify each packet into the appropriate service group.
![]() | Note: When an IP precedence rewrite rule is active, bits 3, 4, and 5 of the ToS byte are always reset to zero when code points are rewritten. |
Default Rewrite Rule
To enable a rewrite rule on an interface, you can either create your own rewrite rule and enable it on the interface or enable a default rewrite rule. See Defining CoS Rewrite Rules (CLI Procedure).
Table 1 shows the default rewrite-rule mappings. These are based on the default bit definitions of Differentiated Services code point (DSCP), IEEE 802.1p, and IP precedence values and the default forwarding classes.
When the CoS values of a packet match the forwarding-class and packet-loss-priority (PLP) values, the switch rewrites markings on the packet based on the rewrite table.
Table 1: Default Packet Header Rewrite Mappings
Map from Forwarding Class | PLP Value | Map to DSCP/IEEE 802.1p/IP Precedence Value |
|---|---|---|
expedited-forwarding | low | ef |
expedited-forwarding | high | ef |
assured-forwarding | low | af11 |
assured-forwarding | high | af12 (DSCP) |
best-effort | low | be |
best-effort | high | be |
network-control | low | nc1/cs6 |
network-control | high | nc2/cs7 |

