Simple Words

On Juniper JunOS Class-of-service...

Something I've always had trouble with, is wrapping my head around class-of-service on Juniper devices.
It's never helped that almost all the EX examples are overly complicated, and or assume you are running some manner of L3 interface on the device.
In our environments, almost every single one our EX switches are exactly that - just switches. So we typically need to classify on ingress and set dscp or 802.1p values based on what's connected to what port.

Something in my head clicked today and I realized that it's so simple... I just have to remember:
Classify on -INGRESS-, mark on -EGRESS-
Classification assigns traffic to a forwarding class, and mark on egress based on which forwarding class you just put traffic into.

So incredibly simplified, mark everything entering ge-0/0/1 with 802.1p priority 5 as it exits ge-0/0/0:

ex2200# show class-of-service
interfaces {
    /* Mark everything on egress appropriately per the custom re-write rule */
    ge-0/0/0 {
        unit 0 {
            rewrite-rules {
                ieee-802.1 EF-TO-PCP-5;
            }
        }
    }
    /* Classify everything on ingress as EF, and put it into the EF switch queue(s) */
    ge-0/0/1 {
        unit 0 {
            forwarding-class expedited-forwarding;
        }
    }
}
rewrite-rules {
    /* Mark packets in the EF queues as priority 5 */
    ieee-802.1 EF-TO-PCP-5 {
        forwarding-class expedited-forwarding {
            loss-priority low code-point 101;
            loss-priority high code-point 101;
        }
    }
}

Random sidetracked moment of the day;
Punching at random words from Android autocomplete entries and reading the resulting phrases.

Actual examples:
Can ping it is not the intended recipient of this tag has a lot of planning and the mayonnaise jar Svideo tuner

Know when to expect from the lab and a gateway of Once again for all your favorite music is my first post a link on my phone number for you guys sell it

How'd the office and the other hand that's probably why you should know about the future of this message has been in business

I feel like I'm reading Huawei manuals again.