Junos Class of Service: Classifiers and Schedulers - 夜莺博客

Junos Class of Service: Classifiers and Schedulers

Junos Class of Service is modular, and that modularity is both its strength and the reason first configurations rarely behave as expected. A classifier marks traffic into forwarding classes, a forwarding class maps to a queue, a scheduler assigns resources and priority to that queue, and a drop profile decides which packets are discarded when the queue fills. Miss one link in that chain and the traffic classifies cleanly while receiving no differentiated treatment at all. This article builds a complete, verifiable CoS configuration and explains which statement enables which behaviour.

The chain, in order

  1. Classifier — reads a field (DSCP, IP precedence, 802.1p) and assigns a forwarding class and loss priority.
  2. Forwarding class to queue — maps the class onto one of the hardware queues.
  3. Scheduler — defines transmit rate, buffer size and priority for that queue.
  4. Drop profile — RED parameters applied to a queue by loss priority.
  5. Application — the scheduler map and classifier attached to an interface, and CoS applied outbound.

The critical detail at the end of that list: a drop profile is not active merely because it exists. It becomes active when a scheduler references it with drop-profile-map. A defined-but-unreferenced profile is the most common CoS misconfiguration in the field.

A working configuration

Classifier and forwarding classes

set class-of-service classifiers dscp BA-DSCP import default
set class-of-service classifiers dscp BA-DSCP forwarding-class expedited-forwarding loss-priority low code-points ef
set class-of-service classifiers dscp BA-DSCP forwarding-class assured-forwarding loss-priority low code-points af21
set class-of-service classifiers dscp BA-DSCP forwarding-class assured-forwarding loss-priority high code-points af23

set class-of-service forwarding-classes class expedited-forwarding queue-num 5
set class-of-service forwarding-classes class assured-forwarding queue-num 3
set class-of-service forwarding-classes class best-effort queue-num 0
set class-of-service forwarding-classes class network-control queue-num 7

Drop profiles

set class-of-service drop-profiles af-normal interpolate fill-level 60 drop-probability 0
set class-of-service drop-profiles af-normal interpolate fill-level 85 drop-probability 20
set class-of-service drop-profiles af-normal interpolate fill-level 100 drop-probability 100

set class-of-service drop-profiles af-with-PLP interpolate fill-level 40 drop-probability 0
set class-of-service drop-profiles af-with-PLP interpolate fill-level 70 drop-probability 40
set class-of-service drop-profiles af-with-PLP interpolate fill-level 100 drop-probability 100

The two profiles differ in when they start dropping, which is what makes loss priority meaningful: high-loss-priority traffic in the assured forwarding class begins being discarded earlier, protecting the low-loss-priority traffic sharing the same queue.

Schedulers

set class-of-service schedulers ef-scheduler transmit-rate percent 20
set class-of-service schedulers ef-scheduler buffer-size percent 10
set class-of-service schedulers ef-scheduler priority strict-high

set class-of-service schedulers af-scheduler transmit-rate percent 45
set class-of-service schedulers af-scheduler buffer-size percent 45
set class-of-service schedulers af-scheduler priority high
set class-of-service schedulers af-scheduler drop-profile-map loss-priority low protocol any drop-profile af-normal
set class-of-service schedulers af-scheduler drop-profile-map loss-priority high protocol any drop-profile af-with-PLP

set class-of-service schedulers be-scheduler transmit-rate remainder 35
set class-of-service schedulers be-scheduler buffer-size percent 40
set class-of-service schedulers be-scheduler priority low

set class-of-service schedulers nc-scheduler transmit-rate percent 5
set class-of-service schedulers nc-scheduler buffer-size percent 5
set class-of-service schedulers nc-scheduler priority high

Using transmit-rate remainder for best effort is deliberate: once voice and assured forwarding have taken their share, everything left over is available to bulk traffic, so the network is not artificially idle. Strict-high priority on voice gives it absolute preference, which is the right choice on a link where voice quality matters — but it also means a misbehaving voice source can starve everything else, so use it narrowly.

Scheduler map and interface application

set class-of-service scheduler-maps WAN-MAP forwarding-class expedited-forwarding scheduler ef-scheduler
set class-of-service scheduler-maps WAN-MAP forwarding-class assured-forwarding scheduler af-scheduler
set class-of-service scheduler-maps WAN-MAP forwarding-class best-effort scheduler be-scheduler
set class-of-service scheduler-maps WAN-MAP forwarding-class network-control scheduler nc-scheduler

set class-of-service interfaces ge-0/0/0 unit 0 scheduler-map WAN-MAP
set class-of-service interfaces ge-0/0/0 unit 0 classifiers dscp BA-DSCP

Verification

show class-of-service interface ge-0/0/0
show class-of-service classifier name BA-DSCP
show class-of-service scheduler-map WAN-MAP
show interfaces ge-0/0/0 extensive | match "CoS|Queue"
show interfaces queue ge-0/0/0

show interfaces queue is the decisive view: it shows per-queue transmitted packets, bytes, and drop counters. If the voice queue is not the queue you expected, the classifier or the forwarding-class-to-queue mapping is wrong — the scheduler cannot help traffic that never reached its queue. show class-of-service interface confirms which classifier and scheduler map are actually attached, which catches the case where the configuration exists but applies to a different unit than the one forwarding traffic.

Where CoS interacts with everything else

Shaping and queueing only matter where there is congestion, so establish that the bottleneck exists before building an elaborate configuration. Marking decisions are usually made at the edge, and the trust boundary — which device is allowed to set DSCP and which devices rewrite it — is a design question that belongs in the same document as this configuration. Where the Queuing design spans platforms, comparing the Juniper approach with a scheduler-map-free implementation is instructive, as in our QoS trust boundary: DSCP vs CoS.

For a comparison of QoS configuration on another platform, and the trust boundary that classifies traffic in the first place, see Arista EOS QoS configuration and Junos OSPF areas and interfaces.

原文链接:https://www.juniper.net/documentation/us/en/software/junos/cos-security-devices/topics/example/cos-scheduler-security-configuring.html