Class of Service · Topic 4 of 4
Shaping, Rewrite Rules and Verifying CoS
JN0-650 study page on Junos CoS shaping, rewrite rules for 802.1p and DSCP, a full end-to-end configuration, and commands to monitor and troubleshoot CoS.
- 5 min
- Shaping buffers and delays; policing drops or marks.
- Interface shaping uses
shaping-rate; hierarchical shaping on some platforms uses traffic control profiles. - Rewrite rules map class and PLP to a code point, on egress.
What it is
Shaping limits the rate at which an interface or queue sends traffic, and it buffers the excess instead of dropping it. It is used when the next device or the service contract allows less than the physical link speed.
Rewrite rules change the priority marking of a packet on egress, so the next device sees the markings you want it to trust.
How it works
Shaping
| Policing | Shaping | |
|---|---|---|
| Excess traffic | Dropped or marked | Buffered and delayed |
| Adds delay | No | Yes |
| Typical place | Ingress | Egress |
| Effect on bursts | Cuts them | Smooths them |
On an interface the shaping rate sets the maximum output rate. This is common when a service provider hands off a 1 Gbps port but sells 200 Mbps.
set class-of-service interfaces ge-0/0/1 shaping-rate 200m
You can also shape a single queue inside a scheduler:
set class-of-service schedulers SCH-DATA shaping-rate 100m
On some QFX and ELS platforms the interface level shaping and hierarchical scheduling are configured with traffic control profiles and forwarding class sets, which group queues and give the group a rate. Check the platform's syntax before configuring.
Shaping adds delay because packets wait in the buffer. Do not apply a tight shaper to a queue carrying voice unless the rate is well above the voice load.
Rewrite rules
A rewrite rule maps a forwarding class and a loss priority to a code point. It is the reverse of classification, and is applied to an interface on egress.
set class-of-service rewrite-rules dscp RW-DSCP forwarding-class VOICE loss-priority low code-point 101110
set class-of-service rewrite-rules dscp RW-DSCP forwarding-class best-effort loss-priority low code-point 000000
set class-of-service interfaces ge-0/0/1 unit 0 rewrite-rules dscp RW-DSCP
The rewrite types match the classifier types: dscp, dscp-ipv6, inet-precedence, ieee-802.1 and exp. An ieee-802.1 rewrite marks the 802.1p bits and applies to frames that leave with a VLAN tag. A dscp rewrite marks only IP packets.
set class-of-service rewrite-rules ieee-802.1 RW-8021P forwarding-class VOICE loss-priority low code-point 101
set class-of-service interfaces ge-0/0/1 unit 0 rewrite-rules ieee-802.1 RW-8021P
Use a rewrite rule at the trust boundary: when traffic leaves one domain for another, or when the neighbor uses a different marking scheme, for example translating DSCP in the network to 802.1p on a tagged link.
| Classifier | Rewrite rule |
|---|---|
| Ingress | Egress |
| Code point to class and PLP | Class and PLP to code point |
If a question describes marking packets for the next hop device, it is a rewrite rule. If it describes sorting arriving packets into classes, it is a classifier.
A complete example
set class-of-service forwarding-classes class VOICE queue-num 5
set class-of-service classifiers dscp CLS forwarding-class VOICE loss-priority low code-points 101110
set class-of-service schedulers SCH-VOICE transmit-rate percent 30
set class-of-service schedulers SCH-VOICE priority strict-high
set class-of-service scheduler-maps SMAP forwarding-class VOICE scheduler SCH-VOICE
set class-of-service rewrite-rules dscp RW forwarding-class VOICE loss-priority low code-point 101110
set class-of-service interfaces xe-0/0/1 unit 0 classifiers dscp CLS
set class-of-service interfaces xe-0/0/1 scheduler-map SMAP
set class-of-service interfaces xe-0/0/1 unit 0 rewrite-rules dscp RW
Every piece must be both defined and applied to the interface. A scheduler map that is defined but not applied has no effect.
Monitoring and troubleshooting
| Command | What it shows |
|---|---|
show class-of-service interface name | Classifier, rewrite rule and scheduler map on the interface |
show class-of-service classifier | The code point to class mappings |
show class-of-service forwarding-class | Class to queue mapping |
show class-of-service scheduler-map | Scheduler settings per class |
show class-of-service rewrite-rule | Rewrite tables |
show interfaces queue name | Packets and drops per queue |
show class-of-service code-point-aliases | The code point names |
| Symptom | Likely cause |
|---|---|
| Everything in the default queue | Classifier not applied, or the code points do not match |
| Voice delayed under load | Voice queue is not strict-high, or shaping is too tight |
| Low priority queue gets nothing | A strict-high queue consumes the link |
| Next device ignores the markings | No rewrite rule on egress, or a different scheme is used there |
| Rewrite has no effect on a tagged port | The wrong rewrite type: dscp does not mark 802.1p |
| Policy applies to wrong direction | Classifiers and filters are ingress, scheduler, shaper and rewrite are egress |
Follow the order of processing when troubleshooting: check the classifier and the class, then the queue counters, then the scheduler, and last the rewrite on egress.
Common mistakes
Defining a rewrite rule but not applying it. Nothing is marked.
Using a dscp rewrite on a Layer 2 only link and expecting 802.1p. That needs an ieee-802.1 rewrite.
Shaping when policing was meant. One buffers, the other drops.
Checking only configuration. Use show interfaces queue to see real traffic.
Applying egress features on ingress. Schedulers and rewrite rules act on egress.
What to remember for the exam
- Shaping buffers and delays; policing drops or marks.
- Interface shaping uses
shaping-rate; hierarchical shaping on some platforms uses traffic control profiles. - Rewrite rules map class and PLP to a code point, on egress.
- Rewrite types:
dscp,dscp-ipv6,inet-precedence,ieee-802.1,exp. - Each CoS element must be defined and applied to the interface.
- Verify with
show class-of-service interfaceandshow interfaces queue.
Check yourself
What is the difference between shaping and policing?
Shaping buffers excess traffic and delays it, while policing drops or marks it.
Which direction does a rewrite rule act in?
Egress, setting the code point from the forwarding class and loss priority.
Where do you see whether traffic actually reaches the expected queue?
In
show interfaces queue, which shows per queue packets and drops.
Topic 4 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.