---
title: Traffic Behavior Configuration Guide
slug: aidc/traffic-behavior-configuration-guide
description: QoS Configuration Guide
createdAt: 2025-11-12T12:13:54.099Z
---

## <font color="#1d50a2">Introduction</font>

QoS (Quality of Service) is a technique used to solve problems such as network latency and blocking. Complex traffic classifier in QoS can be achieved through traffic classifier in the Modular QoS Command-Line Interface (MQC), which consists of three elements, namely traffic classifier, traffic behavior and traffic policy. The traffic classifier is used to define a set of traffic matching rules for classifying packets; the traffic behavior is used to define the actions to be performed for a certain type of packet; the traffic policy is used to bind the specified traffic classifier to the traffic behavior to control the traffic.

## <font color="#1d50a2">Basic Concepts</font>

### <font color="#1d50a2">Flow Control</font>

The Flow Control function is based on ACL (Access Control List) and CAR (Committed Access Rate) policies to limit the speed of specific flows. The CAR policy is the basis for Flow Control. The user can define a CAR action that defines the speed at which the flow is limited.
This chapter focuses on the configuration of traffic behaviour and CAR actions. The configuration of ACL complex traffic classifier is described specifically in the ACL chapter.

### <font color="#1d50a2">Token Bucket Technology</font>

The token bucket technique is a common algorithm used in QoS. Based on the way token buckets process packets, two marking algorithms are defined in the RFC: sr\_tcm (single rate three color marker) and tr\_tcm (two rate three color marker). Where sr\_tcm denotes single rate two bucket, which is mainly concerned with bursting of packet size; tr\_tcm denotes two rate two bucket, which is mainly concerned with bursting of packet rate.
When using the token bucket, the following parameters are configured.

- <font color="#1d05a2">CIR\:</font> means the committed information rate, i.e. the average rate that is guaranteed to pass.
- <font color="#1d05a2">PIR\:</font> means peak information rate, i.e. the maximum allowable through rate.
- <font color="#1d05a2">CBS\:</font> means committed burst size, i.e. the amount of committed burst traffic that can pass instantaneously.
- <font color="#1d05a2">PBS\:</font> refers to peak burst size, i.e. the maximum burst of traffic allowed to pass instantaneously.
  CIR must be configured when using sr\_tcm mode, optionally CBS. If the user does not configure CBS, the system will automatically set the default value. CIR must be configured when using tr\_tcm mode, optionally CBS, PIR, PBS. if the user does not configure PIR, the switch will automatically set 1.2 times CIR. if the user does not configure CBS, PBS, the system will automatically set the default value.

## <font color="#1d50a2">Traffic Behavior Configuration</font>

### <font color="#1d50a2">Traffic Behavior Default Setting</font>

The default setting of Traffic Behavior is shown in the table below.

<font color="#1d05a2">Table 1 Traffic Behavior Default Setting</font>

| **Parameters**   | **Default value** |
| ---------------- | ----------------- |
| Traffic behavior | Not configured    |
| CAR action       | Not configured    |

### <font color="#1d50a2">Configure Traffic Behavior</font>

The key to configuring Traffic Behavior is the CAR template, which can define a rate limit policy; there are two types of CAR speed limit: BYTES, which refers to byte-based speed limit mode, and PACKETS, which refers to packet-based speed limit mode. If not specified, the default is BYTES mode.

- When BYTES mode is selected, the units of the above CIR and CBS parameters are bit/s. For example, if the user wants to set a speed limit of 4Mbit/s, configure cir=4000000bit/s.
- When PACKETS mode is selected, the units of the above CIR and CBS parameters are packet/s. For example, if the user wants to set a speed limit of 4M packet/s, configure cir=4000000packet/s. The conversion formula corresponding to the unit of bit/s is: CIR(bps)=CIR(pps)\*84\*8 (default packet length is 84Bytes).

:::hint{type="info"}
**NOTE:**
1G = 103 M, 1M = 103 K. The conversion factor is calculated uniformly at 1000.
:::

<font color="#1d05a2">Table 2 Configure Traffic Behavior</font>

| **Purpose**                                                                                             | **Commands**                                                                                                                                   | **Description**                              |
| ------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
| Enter global configuration view                                                                         | **configure terminal**                                                                                                                         | -                                            |
| Create traffic behavior and enter the traffic behavior view, or enter an existing traffic behavior view | **traffic behavior** *traffic-behavior-name*                                                                                                   | -                                            |
| Create CAR template                                                                                     | **car** \{**sr-tcm**\|**tr-tcm**} \[**meter-type** \{**bytes**\|**packets**}] **cir** *cir* \[**cbs** *cbs*] \[**pir** *pir*] \[**pbs** *pbs*] | cir is mandatory, pir, cbs, pbs are optional |

### <font color="#1d50a2">Configure Interface-Based Traffic Behavior</font>

<font color="#1d05a2">Table 3 Configure Interface-Based Traffic Behavior</font>

| **Purpose**                                                                                             | **Commands**                                                                                                                                   | **Description**                              |
| ------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
| Enter global configuration view                                                                         | **configure terminal**                                                                                                                         | -                                            |
| Create traffic behavior and enter the traffic behavior view, or enter an existing traffic behavior view | **traffic behavior** *traffic-behavior-name*                                                                                                   | -                                            |
| Create CAR template                                                                                     | **car** \{**sr-tcm**\|**tr-tcm**} \[**meter-type** \{**bytes**\|**packets**}] **cir** *cir* \[**cbs** *cbs*] \[**pir** *pir*] \[**pbs** *pbs*] | cir is mandatory, pir, cbs, pbs are optional |
| Exit traffic behavior view                                                                              | **exit**                                                                                                                                       | -                                            |
| Enter interface configuration view                                                                      | **interface ethernet** *interface-name*                                                                                                        | -                                            |
| Bind traffic behavior                                                                                   | **traffic-behavior** *traffic-behavior-name*                                                                                                   | -                                            |

### <font color="#1d50a2">Configure ACL-Based Complex Traffic Behavior</font>

<font color="#1d05a2">Table 4 Configure ACL-Based Complex Traffic Behavior</font>

| **Purpose**                                  | **Commands**                                                                    | **Description**                                                              |
| -------------------------------------------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| Enter global configuration view              | **configure terminal**                                                          | -                                                                            |
| Create Layer 3 ACL table                     | **access-list** *table\_name* **flow\_control** \{**ingress**\|**egress**}      | -                                                                            |
| Configure rate limit rule for specific flows | **rule** *rule-id rule\_options* **traffic-behavior** *traffic\_behavior\_name* | *rule-id:* Rule sequence number (Range: 1–500)*rule\_options*: match fields  |

## <font color="#1d50a2">Display and Maintenance</font>

The following command allows you to view the configured traffic behavior.

<font color="#1d05a2">Table 5 Traffic Behavior Display and Maintenance</font>

| **Purpose**                         | **Commands**                                         | **Description** |
| ----------------------------------- | ---------------------------------------------------- | --------------- |
| Display configured traffic behavior | **show traffic behavior** \[*traffic-behavior-name*] | -               |

## <font color="#1d50a2">Typical Configuration Example</font>

### <font color="#1d50a2">Flow Control Configuration Example</font>

1. Networking Requirements
   As shown in the diagram below, Department A and Department B are connected to the Switch via Ethernet 0 and 1. There are a number of hosts under each department that access the network via the switch and the router. It is known that all hosts under department A have their IP in the 10.0.0.0/24 network segment and all hosts under department B have their IP in the 20.0.0.0/24 network segment. There is only data traffic in the network, so there is no need to prioritize the services, but the network bandwidth is limited and the overall bandwidth limit for access to department A and department B is required to achieve a speed limit for users on different network segments.

- Department A bandwidth is limited to 800 Mbps, up to a maximum of 1000 Mbit/s.
- Department B bandwidth is limited to 500Mbps, up to a maximum of 800Mbit/s.

2. Topology

::Image[]{src="https://app.archbee.com/api/optimize/zl-MD6bX0o2Ab3p8w66u1/aKOZjuhkVT0kTgh0DtimZ-20251201-054938.png" size="60" width="329" height="401" position="center" caption="Figure 7 Flow Control " showCaption="true"}

3. Procedure

\#Configure each interface IP to enable users to access the network through the Switch. (skipped)

\#Configure traffic behavior

```plaintext
sonic# configure terminal
sonic(config)# traffic behavior test1
sonic(config-traffic-behavior-test1)# car tr-tcm cir 800000000 pir 1000000000
sonic(config-traffic-behavior-test1)# ex
sonic(config)# traffic behavior test2
sonic(config-traffic-behavior-test2)# car tr-tcm cir 500000000 pir 8000000000
sonic(config-traffic-behavior-test2)# ex
```

\#Create flow\_control ACL rule.

```plaintext
sonic(config)# access-list flow_control TABLE_1 ingress
sonic(config-flow_control-acl-TABLE_1)# rule 200 source-ip 10.0.0.0/24 in-ports 0/0 traffic-behavior test1
sonic(config-flow_control-acl-TABLE_1)# rule 201 source-ip 20.0.0.0/24 in-ports 0/1 traffic-behavior test2
```

4. Verify the configuration.

- Check the created policer and ACL rules.

```plaintext
sonic# show traffic behavior
Name    Type    Mode          CIR    CBS
------  ------  ------  ---------  -----
test1   BYTES   TR_TCM  800000000  64000
test2   BYTES   TR_TCM  500000000  64000
sonic# show acl rule
Table    Rule      Priority    Action                      Match
-------  --------  ----------  --------------------------  -------------------
TABLE_1  rule_201  201         SET_POLICER: POLICER|test2  IN_PORTS: Ethernet1
                                                          SRC_IP: 20.0.0.0/24
TABLE_1  rule_200  200         SET_POLICER: POLICER|test1  IN_PORTS: Ethernet0
                                                          SRC_IP: 10.0.0.0/24
```

- Send traffic to verify.
  Departments A and B are sending data traffic to the Switch using 1500Mbps and 1000Mbps respectively. The RX rate of Ethernet0 is about 800Mbps and the TX rate of Ethernet2 is about 500Mbps, and both have some packets dropped, indicating that the speed limit is successful.

