WRED and ECN

As the output queue fills, weighted random early detection (WRED) drop profiles define the drop probability of packets of different packet loss probabilities (PLPs). During periods of congestion, as the output queue fills, the switch drops incoming packets as determined by a drop profile until the output queue becomes less congested. Depending on the drop probabilities, a drop profile can drop many packets long before the buffer becomes full or drop only a few packets even if the buffer is almost full.

Example model & SONiC version:

* Aurora 615/715
* Netberg SONiC: sonic-202012-nb-inno-211121

Configuring WRED

Netberg SONiC comes with pre-configured templates that a user can fine-tune to requirements.

Method 1

Initial configuration comes from executing this command:

admin@sonic:~$ sudo config qos reload
 Running command: /usr/local/bin/sonic-cfggen  -d --write-to-db -t /usr/share/sonic/device/x86_64-netberg_aurora_715-r0/aurora-715/buffers.json.j2,
 config-db -t /usr/share/sonic/device/x86_64-netberg_aurora_715-r0/aurora-715/qos.json.j2,config-db -y /etc/sonic/sonic_version.yml

The results is a default profile with some settings, such as:

admin@sonic:~$ ecnconfig -l
 Profile: AZURE_LOSSLESS
 -----------------  -----
 red_min_threshold  50000
 -----------------  -----

The ecnconfig CLI utility sets ECN WRED parameters as follows:

admin@sonic:~$ ecnconfig -h
 usage: ecnconfig [-h] [-l] [-p PROFILE] [-gmin GREEN_MIN] [-gmax GREEN_MAX]
 [-ymin YELLOW_MIN] [-ymax YELLOW_MAX] [-rmin RED_MIN]
 [-rmax RED_MAX] [-gdrop GREEN_DROP_PROB]
 [-ydrop YELLOW_DROP_PROB] [-rdrop RED_DROP_PROB] [-v] [-vv]
 [-q QUEUE] [-f FILENAME]
 [{on,off}]

Example:

admin@sonic:~$ sudo ecnconfig -p AZURE_LOSSLESS -gmax 2097152
admin@sonic:~$ sudo ecnconfig -p AZURE_LOSSLESS -gmin 1048576
admin@sonic:~$ sudo ecnconfig -p AZURE_LOSSLESS -gdrop 5
admin@sonic:~$ sudo ecnconfig -p AZURE_LOSSLESS -ymax 1048576
admin@sonic:~$ sudo ecnconfig -p AZURE_LOSSLESS -ymin 1048576
admin@sonic:~$ sudo ecnconfig -p AZURE_LOSSLESS -ydrop 5
admin@sonic:~$ sudo ecnconfig -p AZURE_LOSSLESS -rmax 1048576
admin@sonic:~$ sudo ecnconfig -p AZURE_LOSSLESS -rmin 1048576
admin@sonic:~$ sudo ecnconfig -p AZURE_LOSSLESS -rdrop 5
admin@sonic:~$ ecnconfig -l
 Profile: AZURE_LOSSLESS
 -----------------------  -------
 red_min_threshold        1048576
 green_max_threshold      2097152
 green_min_threshold      1048576
 green_drop_probability         5
 yellow_max_threshold     1048576
 yellow_min_threshold     1048576
 yellow_drop_probability        5
 red_max_threshold        1048576
 red_drop_probability           5
 -----------------------  -------

This will use default queues, buffer profiles, and buffer pools.

Method 2

Modify the statements in the /etc/sonic/config_db.json file.

Configure WRED profile.

"WRED_PROFILE": {
 "AZURE_LOSSLESS": {
 "green_drop_probability": "5",
 "green_max_threshold": "2097152",
 "green_min_threshold": "1048576",
 "red_drop_probability": "5",
 "red_max_threshold": "1048576",
 "red_min_threshold": "1048576",
 "yellow_drop_probability": "5",
 "yellow_max_threshold": "1048576",
 "yellow_min_threshold": "1048576"
 }
 },

Attach the WRED profile under a queue.

"QUEUE": {
 "Ethernet4,Ethernet22,Ethernet23|3" : {
 "wred_profile"  :   "[WRED_PROFILE|AZURE_LOSSLESS]"
 }

Configure a buffer pool with a size relative to the minimum or maximum thresholds in the WRED profile.

Data taken from the default values in sonic-202012-nb-inno-211121

"BUFFER_POOL": {
 "ingress_lossless_pool": {
 "mode": "dynamic",
 "size": "34056960",
 "type": "ingress",
 "xoff": "4185600"
 },
 "lossy_pool": {
 "mode": "dynamic",
 "size": "14595840",
 "type": "egress",
 "xoff": "0"
 }

Configure a buffer profile that references the buffer pool.

"BUFFER_PROFILE": {
 "egress_lossless_profile": {
 "pool": "[BUFFER_POOL|ingress_lossless_pool]",
 "size": "0",
 "static_th": "23001600"
 },
 "egress_lossy_profile": {
 "dynamic_th": "2",
 "pool": "[BUFFER_POOL|lossy_pool]",
 "size": "1518"
 },
 "ingress_lossless_profile": {
 "dynamic_th": "1",
 "pool": "[BUFFER_POOL|ingress_lossless_pool]",
 "size": "1518",
 "xoff": "38816",
 "xon_offset": "13440"
 },
 "ingress_lossy_profile": {
 "pool": "[BUFFER_POOL|lossy_pool]",
 "size": "0",
 "static_th": "23001600"
 },
 "pg_lossless_100000_40m_profile": {
 "dynamic_th": "1",
 "pool": "[BUFFER_POOL|ingress_lossless_pool]",
 "size": "1518",
 "xoff": "38816",
 "xon": "0",
 "xon_offset": "13440"
 }
 },

Associate the buffer pool with the queue.

"BUFFER_QUEUE": {
 "Ethernet0,Ethernet100,Ethernet104,Ethernet108,Ethernet112,Ethernet116,Ethernet12,Ethernet120,Ethernet124,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet4,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet8,Ethernet80,Ethernet84,Ethernet88,Ethernet92,Ethernet96|0-2": {
 "profile": "[BUFFER_PROFILE|egress_lossy_profile]"
 },
 "Ethernet0,Ethernet100,Ethernet104,Ethernet108,Ethernet112,Ethernet116,Ethernet12,Ethernet120,Ethernet124,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet4,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet8,Ethernet80,Ethernet84,Ethernet88,Ethernet92,Ethernet96|3-4": {
 "profile": "[BUFFER_PROFILE|egress_lossless_profile]"
 },
 "Ethernet0,Ethernet100,Ethernet104,Ethernet108,Ethernet112,Ethernet116,Ethernet12,Ethernet120,Ethernet124,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet4,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet8,Ethernet80,Ethernet84,Ethernet88,Ethernet92,Ethernet96|5-7": {
 "profile": "[BUFFER_PROFILE|egress_lossy_profile]"
 }
 },

Configuring Explicit Congestion Notification

Explicit congestion notification (ECN) enables end-to-end congestion notification between two endpoints on TCP/IP based networks. The two endpoints are an ECN-enabled sender and an ECN-enabled receiver. ECN must be enabled on both endpoints and on all the intermediate devices between the endpoints for ECN to work properly.

Modify the statements in the /etc/sonic/config_db.json file.

"WRED_PROFILE": {
 "AZURE_LOSSLESS": {
 "green_drop_probability": "5",
 "green_max_threshold": "2097152",
 "green_min_threshold": "1048576",
 "red_drop_probability": "5",
 "red_max_threshold": "1048576",
 "red_min_threshold": "1048576",
 "yellow_drop_probability": "5",
 "yellow_max_threshold": "1048576",
 "yellow_min_threshold": "1048576"
 "ecn": "ecn_all",
 }
 },

Testing

Both endpoints must have EN enabled. In Linux, please have a look at https://sysctl-explorer.net/net/ipv4/tcp_ecn/

If not – the traffic is Not ECN-Capable.

Not ECN-Capable

Once ECN is on, no matter the switch settings, the user can see ECN-Capable packets.

ECN-Capable

Setting some thresholds to 0 brings ECN-Echo and ECN-cwr flags.

root@sonic:/home/admin# ecnconfig -l
 Profile: AZURE_LOSSLESS
 -----------------------  -------
 red_max_threshold        2097152
 red_drop_probability     5
 yellow_max_threshold     2097152
 ecn                      ecn_all
 green_min_threshold      0
 red_min_threshold        0
 wred_yellow_enable       true
 yellow_min_threshold     0
 green_max_threshold      2097152
 green_drop_probability   5
 wred_green_enable        true
 yellow_drop_probability  5
 wred_red_enable          true
 -----------------------  -------

ECN-Echo and ECN-cwr flags

Once congestion is experienced, it will bring Congestion Experienced marks.

Congestion Experienced

NEWS

Latest news