Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

Configuring Basic Packet Flow Through the Junos OS CoS Process

date_range 25-Sep-24

Figure 1 and Figure 2 show the components of the Junos OS CoS features, illustrating the sequence in which they interact.

Figure 1: CoS Classifier, Queues, and SchedulerCoS Classifier, Queues, and Scheduler
Figure 2: Packet Flow Through CoS- Configurable ComponentsPacket Flow Through CoS- Configurable Components

The following configuration demonstrates the packet flow through the CoS process:

Define Classifiers

If you trust the CoS values in the packet headers, you can use behavior aggregate classification to map those values to a forwarding class and drop priority. For example:

content_copy zoom_out_map
[edit class-of-service]
classifiers { 
exp exp_classifier {
    forwarding-class data-queue {
        loss-priority high code-points 001;
        loss-priority low code-points 000;
    }
    forwarding-class nc-queue {
        loss-priority high code-points 111;
        loss-priority low code-points 110;
    }
    forwarding-class video-queue {
        loss-priority high code-points 011;
        loss-priority low code-points 010;
    }
    forwarding-class voice-queue {
        loss-priority high code-points 101;
        loss-priority low code-points 100;
    }
}

If you do not trust the CoS values in the packet headers, you can use the more complex multifield classification to map ingress traffic to a forwarding class and drop priority. For example:

content_copy zoom_out_map
[edit firewall]
family inet {
    filter classify {
        term sip {
            from {
                protocol [ udp tcp ];
                port 5060;
            }
            then {
                forwarding-class nc-queue;
                loss-priority low;
                accept;
            }
        }
    }
}

Apply Classifiers to Incoming Packets on Interfaces

You apply behavior aggregate classifiers to logical interfaces at the [edit class-of-service interfaces] hierarchy level. For example:

content_copy zoom_out_map
[edit class-of-service]
interfaces {  
    so-* {
        unit 0 {
            classifiers {
                exp exp_classifier;
            }
        }
    }
    t3-* {
        unit 0 {
            classifiers {
                exp exp_classifier;
            }
        }
    }
}

You apply multifield classifiers as input filters to logical interfaces at the [edit interfaces] hierarchy level. For example:

content_copy zoom_out_map
[edit interfaces]
fe-0/0/2 {
    unit 0 {
        family inet {
            filter {
                input classify;
            }
            address 10.12.0.13/30;
        }
    }
}

Define Policers to Limit Traffic and Control Congestion

If you need to rate-limit a traffic flow, either by discarding excess traffic (hard policing) or reassign excess traffic to a different forwarding class and/or loss priority (soft policing), define a policier and apply the policer to a firewall filter for that traffic flow. For example:

content_copy zoom_out_map
[edit firewall]
policer be-lp {
    if-exceeding {
        bandwidth-limit 10m;
        burst-size-limit 62500;
    }
    then loss-priority high;
}
family inet {
    filter be-lp {
        term t1 {
            from {
                protocol tcp;
                port 80;
            }
            then policer be-lp;
            then loss-priority low;
            then accept;
        }
    }
}

Define Drop Profiles

Use drop profiles to define the drop probabilities across the range of delay-buffer occupancy, supporting the random early detection (RED) process.

content_copy zoom_out_map
[edit class-of-service]
drop-profiles {
    be-red {
        fill-level 20 drop-probability 25;
        fill-level 30 drop-probability 50;
        fill-level 40 drop-probability 75;
        fill-level 50 drop-probability 100;
    }
}

Assign Each Forwarding Class to a Queue

To provide differentiated services to each forwarding class, assign each forwarding class to it’s own output queue. For example:

content_copy zoom_out_map
[edit class-of-service]
forwarding-classes {  
    queue 0 data-queue;
    queue 1 video-queue;
    queue 2 voice-queue;
    queue 3 nc-queue;
}

Define Schedulers

Define the scheduler characteristics for each forwarding class. For example:

content_copy zoom_out_map
[edit class-of-service]
schedulers {  # 
    data-scheduler {
        buffer-size percent 50;
        drop-profile-map loss-priority high protocol any drop-profile be-red;
        priority low;
        transmit-rate percent 50;
    }
    nc-scheduler {
        buffer-size percent 5;
        priority high;
        transmit-rate percent 5;
    }
    video-scheduler {
        buffer-size percent 25;
        priority strict-high;
        transmit-rate percent 25;
    }
    voice-scheduler {
        buffer-size percent 20;
        priority high;
        transmit-rate percent 20;
    }
}

Define Scheduler Maps

Use scheduler maps to map schedulers to forwarding classes. For example:

content_copy zoom_out_map
[edit class-of-service]
scheduler-maps {  
    sched1 {
        forwarding-class data-queue scheduler data-scheduler;
        forwarding-class nc-queue scheduler nc-scheduler;
        forwarding-class video-queue scheduler video-scheduler;
        forwarding-class voice-queue scheduler voice-scheduler;
    }
}

Define CoS Header Rewrite Rules

Use rewrite rules to redefine the CoS bit pattern of outgoing packets. For example:

content_copy zoom_out_map
[edit class-of-service]
rewrite-rules {
    inet-precedence inet-rewrite {
        forwarding-class data-queue {
            loss-priority high code-point 001;
            loss-priority low code-point 000;
        }
        forwarding-class nc-queue {
            loss-priority high code-point 111;
            loss-priority low code-point 110;
        }
        forwarding-class video-queue {
            loss-priority high code-point 101;
            loss-priority low code-point 100;
        }
        forwarding-class voice-queue {
            loss-priority high code-point 011;
            loss-priority low code-point 010;
        }
    }
}

Apply Scheduler Maps and Rewrite Rules to Egress Interfaces

content_copy zoom_out_map
[edit class-of-service]
interfaces {
    ge-* {
        scheduler-map sched1;
        unit * {
            rewrite-rules {
                inet-precedence inet-rewrite;
            }
        }
    }
}

Change History Table

Feature support is determined by the platform and release you are using. Use Feature Explorer to determine if a feature is supported on your platform.

Release
Description
21.2
Starting with Junos OS Release 21.2, Junos OS displays class of service configuration in alphabetical order regardless of configuration order.
footer-navigation