Skip to content
Ask AI

Classification and Scheduling

Table 1 Class Map View

CommandPurpose
**show class-map ** [class_map_name]Display class map configuration.

[Command] **show class-map ** [class_map_name]

[Purpose] Display class map configuration.

[Parameters]

ParameterDescription
class_map_nameClass map name.

[View] Privileged User View

[Use Cases]

sonic# show class-map

Table 2 Class Map Config

CommandPurpose
class-map class_map_nameCreate a class map, and enter Class Map Configuration View.
match cos cos_valueSpecify the COS value.

[Command] class-map class_map_name

[Purpose] Create a class map, and enter Class Map Configuration View

[Parameters]

ParameterDescription
class_map_nameClass map name.

[View] Global Configuration View

[Notes] Run command no class-map class_map_name to delete the class map.

[Use Cases]

sonic# configure terminal
leaf-138(config)# class-map cmap_4
leaf-138(config-cmap-cmap_4)# match cos 4
leaf-138(config-cmap-cmap_4)# show this
!
class-map cmap_4
match cos 4
leaf-138(config-cmap-cmap_4)#
leaf-138(config-cmap-cmap_4)# match cos 3 4
leaf-138(config-cmap-cmap_4)# show this
!
class-map cmap_4
match cos 3 4

[Command] match cos cos_value

[Purpose] Specify the COS value.

[Parameters]

ParameterDescription
cos_valueThe range is from 0 to7. When specifying more than one, use spaces to separate them.

[View] Class Map Configuration View

[Notes] COS 0~7 corresponds to queues 0~7 one-to-one. Modifying the map of COS to queues is not supported yet.

[Use Cases]

sonic# configure terminal
sonic(config)# class-map test_1000
sonic(config-cmap-test_1000)# match cos 2 3 4 5

Table 3 Diffserv Map View

CommandPurpose
**show diffserv-map ** [type {ip-dscp default|diffserv_map_name |8021p diffserv_map_name}]Display diffserv map configuration.

[Command] **show diffserv-map ** [type {ip-dscp default|diffserv_map_name |8021p diffserv_map_name}]

[Purpose] Display diffserv map configuration.

[Parameters]

ParameterDescription
diffserv_map_nameDiffserv map name.

[View] Privileged User View

[Notes] default is the default diffserv map (ip-dscp type).

[Use Cases]

sonic# show diffserv-map
Diffserv Map default:
Type ip-dscp
from 30 to 3
from 42 to 5
from 43 to 5
from 60 to 7
from 61 to 7
from 62 to 7
from 63 to 7
from 53 to 6
from 52 to 6
from 23 to 2
from 24 to 3
from 25 to 3
from 26 to 3
from 27 to 3
from 20 to 2
from 21 to 2
from 22 to 2
from 49 to 6
from 46 to 5
from 47 to 5
from 44 to 5
from 45 to 5
from 28 to 3
from 29 to 3
from 40 to 5
from 41 to 5
from 1 to 0
from 0 to 0
from 3 to 0
from 2 to 0
from 5 to 0
from 4 to 0
from 7 to 0
from 6 to 0
from 9 to 1
from 8 to 1
from 18 to 2
from 39 to 4
from 38 to 4
from 59 to 7
from 32 to 4
from 14 to 1
from 11 to 1
from 10 to 1
from 13 to 1
from 12 to 1
from 15 to 1
from 58 to 7
from 17 to 2
from 16 to 2
from 19 to 2
from 54 to 6
from 31 to 3
from 56 to 7
from 51 to 6
from 36 to 4
from 35 to 4
from 34 to 4
from 33 to 4
from 55 to 6
from 37 to 4
from 48 to 6
from 57 to 7
from 50 to 6

Table 4 Diffserv Map Config

CommandPurpose
diffserv-map type {ip-dscp|8021p} diffserv_map_nameCreate a diffserv map, and enter Diffserv Map Configuration View.
default {cos_value|copy}Configure COS mapping in bulk.
ip-dscp dscp_value cos cos_valueSet DSCP to COS mapping.
8021p dot1p_value cos cos_valueSet DOT1P to COS mapping.

[Command] diffserv-maptype {ip-dscp|8021p} diffserv_map_name

[Purpose] Create a diffserv map, and enter Diffserv Map Configuration View

[Parameters]

ParameterDescription
diffserv_map_nameDiffserv map name.

[View] Global Configuration View

[Notes] There are DSCP mappings and DOT1P mappings.

[Use Cases]

sonic# configure terminal
sonic(config)# diffserv-map type ip-dscp testdiff1
sonic(config-diffservmap-testdiff1)# exit
sonic(config)#diffserv-map type 8021p testdiff2
sonic(config-diffservmap-testdiff2)#

[Command] default {cos_value|copy}

[Purpose] Configure COS mapping in bulk.

[Parameters]

ParameterDescription
cos_valueThe range is from 0 to7.

[View] Diffserv Map Configuration View

[Notes] COS 0~7 corresponds to queues 0~7 one-to-one. Modifying the map of COS to queues is not supported yet.; default cos_value indicates that all traffic will be mapped to the specified COS value. default copy indicates to use the default DSCP mapping(only for DSCP to COS mapping). Run command no default to delete this mapping configuration.

[Use Cases]

sonic(config)# diffserv-map type 8021p test1
sonic(config-diffservmap-test1)# default 0
sonic(config-diffservmap-test1)# do show diffserv-map
Diffserv Map test1:
Type 8021p
from 0 to 0
from 1 to 0
from 2 to 0
from 3 to 0
from 4 to 0
from 5 to 0
from 6 to 0
from 7 to 0

[Command] ip-dscp dscp_value cos cos_value

[Purpose] Set DSCP to COS mapping.

[Parameters]

ParameterDescription
dscp_valueThe range is from 0 to 63.
cos_valueThe range is from 0 to 7.

[View] DSCP Diffserv Map Configuration View

[Notes] COS 0~7 corresponds to queues 0~7 one-to-one. Modifying the map of COS to queues is not supported yet.; Run command no ip-dscp dscp_value cos cos_value to delete DSCP to COS mapping.

[Use Cases]

sonic(config)# diffserv-map type ip-dscp testdiff1
sonic(config-diffservmap-testdiff1)# ip-dscp 0 cos 2
sonic(config-diffservmap-testdiff1)# ip-dscp 1 cos 4

[Command] 8021p dot1p_value cos cos_value

[Purpose] Set DOT1P to COS mapping.

[Parameters]

ParameterDescription
dot1p_valueThe range is from 0 to 7.
cos_valueThe range is from 0 to 7.

[View] DOT1P Diffserv Map Configuration View

[Notes] COS 0~7 corresponds to queues 0~7 one-to-one. Modifying the map of COS to queues is not supported yet.; Run command no 8021p dot1p_value cos cos_value to delete DOT1P to COS mapping.

[Use Cases]

sonic(config)# diffserv-map type 8021p testdiff2
sonic(config-diffservmap-testdiff2)# 8021p 0 cos 2
sonic(config-diffservmap-testdiff2)# 8021p 1 cos 4

Table 5 Policy Map View

CommandPurpose
**show policy-map ** [policy_map_name]Display policy map configuration.
show interface policy-mapDisplay the relationship between interfaces and policy-maps.

[Command] **show policy-map ** [policy_map_name]

[Purpose] Display policy map configuration.

[Parameters]

ParameterDescription
policy_map_namePolicy map name.

[View] Privileged User View

[Use Cases]

sonic# show policy-map
!
policy-map test
!
policy-map test11
!
policy-map test_pfc
class cmap_4
priority-group-buffer pg_lossless_1
!

[Command] show interface policy-map

[Purpose] Display the relationship between interfaces and policy-maps.

[View] Privileged User View

[Use Cases]

sonic# show interface policy-map
Port service policy
------ ----------------
0/0 roce_lossless
0/4 test
0/8 roce_lossless
0/12 roce_lossless
0/16 roce_lossless
0/20 roce_lossless
0/24 roce_lossless
0/28 roce_lossless
0/32 roce_lossless
0/36 roce_lossless
0/40 roce_lossless
0/44 roce_lossless
0/48 roce_lossless
……

Table 6 Policy Map Config

CommandPurpose
policy-map policy_map_nameCreate a policy map, and enter Traffic Policy Configuration View.
set cos {dscp|8021p} diffserv diffserv_map_nameSet DSCP or DOT1P to COS mapping.
port-shape target-bit-rate burst-sizeAdd a speed limit policy for ports.
queue-sheduler priority queue queue-idAdd strict queue scheduling policies.
queue-scheduler queue-limit percent queue-wight queue queue-idAdd DWRR queue scheduling policies.
class {class_map_name|class-default}Specify the COS value of the policy, and enter Policy Map-Class Map Configuration View.
queue-shape target-bit-rate burst-sizeAdd a speed limit policy for queues.
wred {wred_profile_name|default_drop|default_ecn}Bind WRED profile to the class map.
priority-group-buffer buffer_profile_nameBind a custom PG buffer profile (Ingress).
queue-buffer buffer_profile_nameBind a custom Queue Buffer Profile (Egress).
bandwidth rate-bps [burst-size]Set minimum guaranteed bandwidth.
service-policy policy_map_nameApply the policy to the interface.

[Command] policy-map policy_map_name

[Purpose] Create a policy map, and enter Traffic Policy Configuration View.

[Parameters]

ParameterDescription
policy_map_namePolicy map name.

[View] Global Configuration View

[Notes] Run command no policy-map policy_map_name to delete the policy map.

[Use Cases]

sonic# configure terminal
sonic(config)# policy-map test1
sonic(config-pmap-test1)#

[Command] set cos {dscp|8021p} diffserv diffserv_map_name

[Purpose] Set DSCP or DOT1P to COS mapping.

[Parameters]

ParameterDescription
diffserv_map_nameDiffserv map name.

[View] Traffic Policy Configuration View

[Notes] COS 0~7 corresponds to queues 0~7 one-to-one. Modifying the map of COS to queues is not supported yet. Run command no set cos {dscp|8021p} diffserv diffserv_map_name to delete the mapping.

[Use Cases]

sonic(config-pmap-test1)# set cos dscp diffserv testdiff1

[Command] port-shape target-bit-rate burst-size

[Purpose] Add a speed limit policy for ports.

[Parameters]

ParameterDescription
target-bit-rateSpecify the target rate in Bps, the value range of CX308P-48Y-N-V2, CX532P-N-V2 and CX732Q-N-V2 model equipment is from 320000 to line rate, and the value range of other equipment is from 64000 to line rate.
burst-sizeSpecify the burst size in bytes, and the range is from 1000 to 3145728.

[View] Traffic Policy Configuration View

[Notes] The port shaping policy should be configured on the egress interface of the traffic. Run command no port-shape to delete the speed limit policy.

[Use Cases]

Limit the speed of the interface to 2Gbps.
sonic(config)# policy-map pmap1
sonic(config-pmap-pmap1)# port-shape 250000000 128000
sonic(config-pmap-pmap1)# interface ethernet 0/76
sonic(config-if-0/76)# service-policy pmap1

[Command] queue-scheduler priority queue queue-id

[Purpose] Add strict queue scheduling policies.

[Parameters]

ParameterDescription
queue-idQueue ID, the range is [0,7]

[View] Traffic Policy Configuration View

[Notes] Run command no queue-scheduler priority queue queue-id to delete strict queue scheduling policies.

[Use Cases]

sonic(config-pmap-test1)# queue-scheduler priority queue 2
sonic(config-pmap-test1)# queue-scheduler priority queue 3

[Command] queue-scheduler queue-limit percent queue-wight queue queue-id

[Purpose] Add DWRR queue scheduling policies.

[Parameters]

ParameterDescription
queue-wightQueue weight, the range is [1,100]
queue-idQueue ID, the range is [0,7]

[View] Traffic Policy Configuration View

[Notes] Run command no queue-scheduler queue-limit percent queue-wight queue queue-id to delete DWRR queue scheduling policies.

[Use Cases]

sonic(config-pmap-test1)# queue-scheduler priority queue 2
sonic(config-pmap-test1)# queue-scheduler priority queue 3
sonic(config-pmap-test1)# queue-scheduler queue-limit percent 20 queue 4
sonic(config-pmap-test1)# queue-scheduler queue-limit percent 20 queue 5

[Command] class {class_map_name|class-default}

[Purpose] Specify the COS value of the policy, and enter Policy Map-Class Map Configuration View.

[Parameters]

ParameterDescription
class_map_nameClass map name.

[View] Traffic Policy Configuration View

[Notes] When configuring queue limit/WRED/Queue Buffer/PG Buffer policy, you need to specify the matching COS value first. COS 0~7 corresponds to queues 0~7 one-to-one. Modifying the map of COS to queues is not supported yet.; class-default is the default class map of the system, which will match any other unclassified packets. Run command no class {class_map_name|class-default} to unbind the class map from the policy.

[Use Cases]

sonic(config)# policy-map roce_lossless
sonic(config-pmap-roce_lossless)# class roce_lossless_class_map
sonic(config-pmap-c)#

[Command] queue-shape target-bit-rate burst-size

[Purpose] Add a speed limit policy for queues.

[Parameters]

ParameterDescription
target-bit-rateSpecify the target rate in Bps, and the value range of CX308P-48Y-N-V2, CX532P-N-V2 and CX732Q-N-V2 model equipment is from 320000 to line rate, and the value range of other equipment is from 64000 to line rate.
burst-sizeSpecify the burst size in bytes, and the range is from 1000 to 3145728.

[View] Policy Map-Class Map Configuration View

[Notes] Before running this command, please bind an existing class map to specify the queue to be matched for the policy. Run command no queue-shape to delete the speed limit policy.

[Use Cases]

sonic(config)# class-map classtest
sonic(conifg-cmap-classtest)# exit
sonic(config)# polic-map test1
sonic(config-pmap-test1)# class classtest
sonic(config-pmap-c)# queue-shape 1200000 128000

[Command] wred {wred_profile_name|default_drop|default_ecn}

[Purpose] Bind WRED profile to the class map.

[Parameters]

ParameterDescription
wred_profile_nameProfile name.

[View] Policy Map-Class Map Configuration View

[Notes] Before running this command, please bind an existing class map to specify the queue to be matched for the policy. Two default WRED templates, default_drop and default_ecn, are built in ‘-N’ model switches, which users can bind directly, and not in ‘-N-V2’. Run command no wred wred_profile_name to unbind the WRED profile.

[Use Cases]

sonic(config)# class-map classtest
sonic(conifg-cmap-classtest)# exit
sonic(config)# polic-map test1
sonic(config-pmap-test1)# class classtest
sonic(config-pmap-c)# wred wred_profile

[Command] priority-group-buffer buffer_profile_name

[Purpose] Bind a custom PG buffer profile (Ingress).

[Parameters]

ParameterDescription
buffer_profile_nameProfile name.

[View] Policy Map-Class Map Configuration View

[Notes] Use this command to bind a PG buffer profile when configuring a custom PFC. Before running this command, please bind an existing class map to specify the queue to be matched for the policy. Run command no priority-group-buffer buffer_profile_name to unbind the PG buffer profile.

[Use Cases]

sonic(config)# buffer-profile pg_lossless_100000_100m_profile
sonic(config-buffer-profile-pg_lossless_100000_100m_profile)# mode lossless dynamic 1 size 1518 xoff 46496 xon-offset 13440
sonic(config-buffer-profile-pg_lossless_100000_100m_profile)# exit
sonic(config)# polic-map test1
sonic(config-pmap-test1)# class cmap_4
sonic(config-pmap-c)# priority-group-buffer pg_lossless_100000_100m_profile

[Command] queue-buffer buffer_profile_name

[Purpose] Bind a custom Queue Buffer Profile (Egress).

[Parameters]

ParameterDescription
buffer_profile_nameProfile name.

[View] Policy Map-Class Map Configuration View

[Notes] Before running this command, please bind an existing class map to specify the queue to be matched for the policy. It is generally not recommended to modify the interface egress queue buffer manually, so please be careful. Setting unreasonable parameters may cause loss of packets while forwarding traffic on the interface. Run command no queue-buffer buffer_profile_name to unbind the queue buffer profile.

[Use Cases]

sonic(config)# class-map classtest
sonic(conifg-cmap-classtest)# exit
sonic(config)# polic-map test1
sonic(config-pmap-test1)# class classtest
sonic(config-pmap-c)# queue-buffer buffer_profile

[Command] bandwidth rate-Bps [burst-size]

[Purpose] Set minimum guaranteed bandwidth.

[Parameters]

ParameterDescription
rate-BpsBandwidth value, unit bytes/s,  the value range of CX308P-48Y-N-V2, CX532P-N-V2 and CX732Q-N-V2 model equipment is from 320000 to line rate, and the value range of other equipment is from 64000 to line rate.
burst-sizeBurst value, unit byte, range [64000,3145728]

[View] Policy Map-Class Map Configuration View

[Notes] Before running this command, please bind an existing class map to specify the queue to be matched for the policy. Run command no bandwidth to delete Bandwidth Configuration.

[Use Cases]

sonic(config)# class-map classtest
sonic(conifg-cmap-classtest)# exit
sonic(config)# polic-map test1
sonic(config-pmap-test1)# class classtest
sonic(config-pmap-c)# bandwidth 64000

[Command] service-policy policy_map_name

[Purpose] Apply the policy to the interface.

[Parameters]

ParameterDescription
policy_map_namePolicy map name.

[View]

Physical Interface Configuration View

[Notes] When the policy has been applied to an interface, please unbind the interface from the policy before modifying the policy configuration. Run command no service-policy policy_map_name to unbind the policy.

[Use Cases]

sonic(config)# interface ethernet 0/0
sonic(config-if-0/0)# service-policy test1

Table 7 Queue View

CommandPurpose
**show counters queue ** [interface_name]Display queue counters.
clear counters queueClear queue counters.

[Command] **show counters queue ** [interface_name]

[Purpose] Display queue counters.

[Parameters]

ParameterDescription
interface_nameInterface name (eg.0/1)

[View] Privileged User View

[Use Cases]

sonic# show counters queue 0/0
The poll time of QUEUES COUNTERS is 2000.0 ms, update time of queue rates is 4000.0 ms
Port TxQ Counter/pkts Counter/bytes Drop/pkts Drop/bytes CounterRate/pkts CounterRate/bytes DropRate/pkts DropRate/bytes Occupancy/bytes SharedOccupancy/bytes
--------- ----- -------------- --------------- ----------- ------------ ------------------ ------------------- --------------- ---------------- ----------------- -----------------------
0/0 UC0 0 0 0 0 0.00/s 0.00 B/s 0.00/s 0.00 B/s 0 0
0/0 UC1 0 0 0 0 0.00/s 0.00 B/s 0.00/s 0.00 B/s 0 0
0/0 UC2 0 0 0 0 0.00/s 0.00 B/s 0.00/s 0.00 B/s 0 0
0/0 UC3 0 0 0 0 0.00/s 0.00 B/s 0.00/s 0.00 B/s 0 0
0/0 UC4 0 0 0 0 0.00/s 0.00 B/s 0.00/s 0.00 B/s 0 0
0/0 UC5 0 0 0 0 0.00/s 0.00 B/s 0.00/s 0.00 B/s 0 0
0/0 UC6 0 0 0 0 0.00/s 0.00 B/s 0.00/s 0.00 B/s 0 0
0/0 UC7 0 0 0 0 0.00/s 0.00 B/s 0.00/s 0.00 B/s 0 0

[Command] clear counters queue

[Purpose] Clear queue counters.

[View] Privileged User View

[Use Cases]

sonic# clear counters queue