Configuring WRED and ECN (Explicit congestion notification)

Table of Contents

Configuring WRED and ECN

Threshold Limits

Testing

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.

Explicit congestion notification (ECN) enables traffic congestion control between two ECN-enabled devices. When the switch detects the congestion, the ECN field is set in the IP header of a packet before forwarding it. If the receiver device receives the packets with ECN marked, it sends the congestion notification packets (CNP) to the sender device to reduce the transmit packet rate. The CNP packets continue to be sent to the sender until the congestion is released.

ECN uses the WRED thresholds being applied to an egress queue.

When ECN is enabled, process the packets based on the following rules:

  • When the average queue length is below the minimum threshold, no packet is marked.
  • When the average queue length is between minimum threshold and maximum threshold, one of the following scenarios can occur:
    • If the IP packet has ECT(0) or ECT(1) codepoints, change the ECT and EC bits to 1 based on drop probability and forward the packet.
    • If the IP packet is received with CE codepoint 11, the packet is transmitted. No further marking is required.
    • If the IP packet is received with not-ECT codepoint 00, the packet is transmitted.
  • When the average queue length exceeds the maximum threshold, all the incoming IP packets with the ECT(0) and ECT(1) codepoints are marked.
NoteYou must enable ECN on all of the intermediate devices in the path between the sender and the receiver.

ECN supports the following:

  • IPv4 and IPv6 packets
  • Untagged, single-tagged, and double-tagged packets
  • The outer IP header of IP tunneled packets (but not the inner IP header)

ECN does not support the following:

  • IP packets with MPLS encapsulation
  • The inner IP header of IP tunneled packets (however, ECN works on the outer IP header)
  • Multicast, broadcast, and destination lookup fail (DLF) traffic
  • Non-IP traffic

Example model & SONiC version:

  • Aurora 830, Aurora 721, Aurora 621, Aurora 221
  • Netberg SONiC: sonic-broadcom-202311-n0

Restrictions:

  • Aurora 221 does not support PFC.
  • Broadcom supports only the Green WRED profile.
  • Broadcom supports a fixed range of maximum drop probability values [0~10, 25, 50, 75, 100] in hardware.
    • If the user configuration value ranges from 0 to 10, ASIC takes the same value as the hardware configuration.
    • If the user configuration value is 10 to 24, ASIC takes 10 as hardware configuration.
    • If the user configuration value is 25 to 49, ASIC takes 25 as hardware configuration.
    • If the user configuration value is 50 to 74, ASIC takes 50 as hardware configuration.
    • If the user configuration value is 75 to 99, ASIC takes 75 as hardware configuration.
    • If the user configuration value exceeds 100, ASIC takes 100 as hardware configuration.

Configuring WRED and ECN

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

Load the buffer configuration as described in the Buffer Settings piece.

It contains default WRED and ECN profiles with all necessary thresholds.

The results is a default profile, such as:

admin@sonic:~$ show ecn
Profile: AZURE_LOSSLESS
-----------------------  -------
ecn                      ecn_all
green_drop_probability   5
green_max_threshold      2097152
green_min_threshold      1048576
red_drop_probability     5
red_max_threshold        2097152
red_min_threshold        1048576
wred_green_enable        true
wred_red_enable          true
wred_yellow_enable       true
yellow_drop_probability  5
yellow_max_threshold     2097152
yellow_min_threshold     1048576
-----------------------  -------

The config_db schema:

"WRED_PROFILE": {
    "AZURE_LOSSLESS": {
        "ecn": "ecn_all", #Enable ECN marking for all colors.
        "green_drop_probability": "5",
        "green_max_threshold": "2097152",
        "green_min_threshold": "1048576",
        "red_drop_probability": "5",
        "red_max_threshold": "2097152",
        "red_min_threshold": "1048576",
        "wred_green_enable": "true",
        "wred_red_enable": "true",
        "wred_yellow_enable": "true",
        "yellow_drop_probability": "5",
        "yellow_max_threshold": "2097152",
        "yellow_min_threshold": "1048576"
    }
}

SONiC CLI sets ECN WRED parameters as follows:

Syntax:

config ecn [OPTIONS]

Options:

-profile <profile_name>         Profile name  [required]
-rmax <red threshold max>       Set red max threshold
-rmin <red threshold min>       Set red min threshold
-ymax <yellow threshold max>    Set yellow max threshold
-ymin <yellow threshold min>    Set yellow min threshold
-gmax <green threshold max>     Set green max threshold
-gmin <green threshold min>     Set green min threshold
-rdrop <red drop probability>   Set red drop probability
-ydrop <yellow drop probability> Set yellow drop probability
-gdrop <green drop probability> Set green drop probability

Example:

admin@sonic:~$ sudo config ecn -profile AZURE_LOSSLESS -gmax 2097152

Attach the WRED profile under a queue.

"QUEUE": {
    "Ethernet0|3": {
        "scheduler": "scheduler.1",
        "wred_profile": "AZURE_LOSSLESS"
    },
    "Ethernet0|4": {
        "scheduler": "scheduler.1",
        "wred_profile": "AZURE_LOSSLESS"
    },

Threshold Limits

Switch model

Maximum Threshold (bytes)

Aurora 221

Aurora 421

Aurora 621

Aurora 721

67,108,608

Aurora 830

266,338,050

Aurora 610

Aurora 710

Aurora 750

41,942,960

Aurora 810

92,274,512

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.

The switch runs the default ECN and WRED configuration.

Not ECN-Capable Transport

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

ECN-Capable Transport

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

admin@sonic:~$ show ecn
 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