Classify Traffic Using DSCP on Junos Routers
The most common way to look at the IP packet header when classifying traffic for use with a CoS implementation is to interpret the header “type of service” bits as the Differentiated Services Code Point (DSCP). This field has 8 bits, the first 6 of which are important to CoS. Although you can look at traffic other ways, especially at the frame level, DSCP is the most popular and powerful choice for CoS these days.
The DSCP’s 6 bits identify two important pieces of the CoS puzzle: the forwarding class and the packet loss priority. The combination of these pieces makes up what is called the per-hop behavior (PHB), which basically describes what happens to packets for any particular hop in its path.
Here are the five classes of traffic:
Best effort (be): Best effort forwarding is the base forwarding for all traffic. Basically, the router does its best to forward the traffic. If congestion develops on the router (its buffers are full, for example), this traffic is likely to be dropped.
Expedited forwarding (ef): Expedited forwarding is essentially first-class travel for packets in the router. The router provides priority services for this traffic, and it ensures that packets in this forwarding class are the last to be delayed or dropped during times of congestion.
As packets come in, if the total bandwidth doesn’t exceed the allocated bandwidth for this class, the traffic is considered in-profile, and the packet is forwarded normally. If the total bandwidth exceeds the allocation, the traffic is considered out-of-profile.
The router will basically do whatever it can to forward the traffic using available bandwidth from the other classes. If there is no available bandwidth, packets can be dropped, though they’ll be the last packets subjected to this horrid fate.
Expedited forwarding is what you use for mission-critical traffic that can’t be dropped or have excess jitter or delay (think voice traffic).
Assured forwarding (af): Assured forwarding is pretty similar to expedited forwarding. Assured forwarding is kind of like passengers flying business class (that is, they get lots of perks, but not quite the first-class treatment).
As packets come in, they’re either in-profile or out-of-profile (just like ef packets). Packets that are in-profile are forwarded normally. The difference is that whereas ef packets are automatically queued up for forwarding if they’re out-of-profile, af packets can be subjected to a random early detection (RED) drop profile. Packets in the af class can be assigned a drop precedence (using the PLP bit), and they’re randomly dropped to ease congestion.
Assured forwarding is used for applications that need better than best-effort forwarding but aren’t quite mission-critical (typically applications such as PeopleSoft, SAP, or Oracle).
Network control (nc): Network control traffic includes packets like routing protocol hello messages or keepalives. Packets in this class are forwarded with lower priority, meaning they’re more subject to delay. However, these packets are less likely to be discarded. Because the loss of these packets can cause network-wide events (like routing adjacencies flapping), delaying delivery is much better than dropping the packet completely.
Class selector (cs): CS values enable backward compatibility with the older IP Precedence scheme. The Class Selector codepoints are of the form xxx000. The first three bits are the IP precedence bits. Each IP precedence value can be mapped into a DiffServ class. If a packet is received from a non–DiffServ-aware router that used IP precedence markings, the DiffServ router can still understand the encoding as a Class Selector codepoint.
Each of these forwarding classes has at least one PLP associated with it. The combination of forwarding class and PLP is identified by the bit pattern in the DSCP. So when you want to either match on or assign one a particular PHB (that is, you want to specify how a packet is to be handled), you need to specify the specific bit pattern.