Class of Service · Topic 1 of 4

CoS Concepts, Processing and Header Fields

JN0-650 study page on Junos class of service: why CoS matters in Layer 2 and Layer 3 networks, the processing path, and 802.1p, DSCP and precedence fields.

  • 5 min
  • Includes a diagram
In a nutshell
  • CoS decides treatment under congestion; it does not create bandwidth.
  • Order: classify and police on ingress, queue, schedule and drop, shape and rewrite on egress.
  • 802.1p is 3 bits in the VLAN tag; IP precedence is 3 bits; DSCP is 6 bits; MPLS EXP is 3 bits.

What it is

A network treats all traffic equally unless you tell it otherwise. When a link is congested, voice and video suffer first, because they cannot tolerate delay, jitter or loss, while a file transfer simply slows down.

Class of service lets you separate traffic into classes, then give each class its own treatment. It does not create bandwidth. It decides who gets the bandwidth, and who is dropped first, when there is not enough.

Mixed trafficVoice, video, dataclassifyClassesEach has a queuescheduleLinkVoice first, data shares the rest

How it works

The CoS building blocks

BlockQuestion it answers
ClassifierWhich class is this packet in, and how important is it to keep?
Forwarding classWhich queue does it go to?
Packet loss priority (PLP)How likely is it to be dropped under congestion?
PolicerIs the traffic within its allowed rate?
SchedulerHow much bandwidth and what priority does each queue get?
Drop profileWhen should the queue start dropping packets?
ShaperHow fast may an interface or queue send?
Rewrite ruleWhat priority marking should the packet carry on leaving?

Processing on a Junos device

On ingress the classifier sets the forwarding class and PLP and a policer can limit the rate. The forwarding class chooses the queue. On egress the scheduler and drop profile serve the queue, then a shaper and a rewrite rule apply. The order of processing is the most tested idea in this chapter.

  1. On ingress, the packet is classified into a forwarding class and a loss priority. This is done by a behavior aggregate (BA) classifier reading a header field, or by a multifield (MF) classifier, which is a firewall filter.
  2. Ingress policers can limit the rate and change the PLP or discard.
  3. The forwarding class chooses the output queue.
  4. On egress, the scheduler serves the queues according to their priority and weight, and the drop profile decides which packets to drop as the queue fills.
  5. A shaper can limit the interface or queue rate.
  6. A rewrite rule sets the packet's priority bits for the next device.
IngressClassifier and policerforwarding classQueuescheduler and drop profileEgressShaper and rewrite rule
Exam tip

If a question asks where classification or policing happens, think ingress. Scheduling, shaping and rewrite are egress functions.

Layer 2 and Layer 3 CoS

CoS applies to frames at Layer 2 and to packets at Layer 3, and the field used depends on what the packet carries.

LayerFieldSizeValues
Layer 2IEEE 802.1p in the VLAN tag, also called PCP3 bits0 to 7
Layer 2Drop eligible indicator (DEI) in the VLAN tag1 bit0 or 1
Layer 3IP precedence3 bits0 to 7
Layer 3DSCP6 bits0 to 63
MPLSEXP bits (traffic class)3 bits0 to 7

IP precedence and DSCP both live in the IPv4 ToS byte, or the IPv6 traffic class byte. DSCP uses the first six bits, and the last two bits are used for explicit congestion notification. IP precedence is the first three of those same bits, so DSCP is backward compatible with precedence.

DSCP nameValueTypical use
Default (best effort)0General data
AF11 to AF43Class and drop precedenceAssured forwarding groups
EF46 (101110)Voice
CS6 and CS7 (network control)48 and 56Routing protocols and control

The assured forwarding code points are written AFxy, where x is the class from 1 to 4 and y is the drop precedence from 1 to 3. For example AF21 is class 2 with the lowest drop precedence.

Watch out

An 802.1p value exists only in a VLAN tagged frame. On an untagged access port there is no 802.1p field to classify on, so the device must classify using DSCP, a filter, or the port itself.

Trust boundary

Classification at the edge sets the markings, and the core devices trust them. A common design classifies and polices at the access layer, where devices are less trusted, and the core only schedules. Rewrite rules at the edge of a trust domain replace markings that the neighbor should not trust or that use a different scheme.

Access switchClassify, police, rewritetrusted markingsCoreSchedule onlytrusted markingsOther siteRewrite if needed

Default behavior

Junos devices apply default classifiers, forwarding classes and schedulers, so traffic is classified even with no CoS configuration. The exact defaults differ by platform and interface type, and the default forwarding classes on an EX or QFX switch include best-effort, expedited-forwarding, assured-forwarding and network-control, plus platform specific classes. Always check the defaults on your platform with the show class-of-service commands before you configure.

show class-of-service classifier
show class-of-service forwarding-class
show class-of-service interface ge-0/0/1

Common mistakes

Expecting CoS to add bandwidth. It only divides what exists.

Classifying on egress. Classification is an ingress function.

Looking for 802.1p on an untagged port. It requires a VLAN tag.

Confusing DSCP with IP precedence. DSCP is six bits and precedence is the first three.

Starting with schedulers. Without classification, all traffic ends in the default class.

What to remember for the exam

  • CoS decides treatment under congestion; it does not create bandwidth.
  • Order: classify and police on ingress, queue, schedule and drop, shape and rewrite on egress.
  • 802.1p is 3 bits in the VLAN tag; IP precedence is 3 bits; DSCP is 6 bits; MPLS EXP is 3 bits.
  • DSCP EF is 46 and is used for voice; AFxy has class x and drop precedence y.
  • Two kinds of classifier: BA (reads a header field) and MF (a firewall filter).
  • Rewrite rules set markings on egress, usually at a trust boundary.
  • Defaults vary by platform; verify with show class-of-service.

Check yourself

  • On which side of the device are classification and policing done?

    On ingress; scheduling, shaping and rewriting are done on egress.

  • How many bits does DSCP use, and which bits is IP precedence?

    DSCP uses 6 bits, and IP precedence is the first 3 of them.

  • Why can a classifier not use 802.1p on an untagged access port?

    The 802.1p field is part of the VLAN tag, which an untagged frame does not have.

Topic 1 of 4 in Class of Service

Test yourself on Class of Service

The full Juniper JNCIP-ENT JN0-650 question bank has 858 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.