Weighted Random Early Detection (WRED)
Whereas queuing provides congestion management, mechanisms such as WRED provide congestion avoidance. Specifically, WRED can prevent an output queue from ever filling to capacity, which would result in packet loss for all incoming packets. This section examines the need for and the configuration of WRED on Cisco routers.
How TCP Handles Drops
Recall from your early studies of networking technology how Transport Control Protocol (TCP) windowing functions. A sender sends a single segment, and if the sender receives a successful acknowledgment from the receiver, it then sends two segments (that is, a “windows size” of 2). If those two segments were acknowledged successfully, the sender sends four segments, and so on, increasing the window size exponentially.
However, if one of the segments is dropped, the TCP flow goes into TCP slow start, where the window size is reduced to 1. The TCP flow then exponentially increases its window size until the window size reaches half of the window size when congestion originally occurred. At that point, the TCP flow’s window size increases linearly.
TCP slow start is relevant to QoS, because when an interface’s output queue is full, all newly arriving packets are discarded (that is, “tail dropped”), and all of those TCP flows simultaneously go into TCP slow start.
Note that the process of multiple TCP flows simultaneously entering TCP slow start is called global synchronization or TCP synchronization. When TCP synchronization occurs, the link’s bandwidth is underutilized, resulting in wasted bandwidth.
The purpose of Random Early Detection (RED) is to prevent TCP synchronization by randomly discarding packets as an interface’s output queue begins to fill. How aggressively RED discards packets depends on the current queue depth.
The following three parameters influence when a newly arriving packet is discarded:
Mark Probability Denominator (MPD)
The minimum threshold specifies the number of packets in a queue before the queue considers discarding packets. The probability of discard increases until the queue depth reaches the maximum threshold. After a queue depth exceeds the maximum threshold, all other packets that attempt to enter the queue are discarded.
However, the probability of packet discard when the queue depth equals the maximum threshold is 1/(MPD). For example, if the mark probability denominator were set to 10, when the queue depth reached the maximum threshold, the probability of discard would be 1/10 (that is, a 10 percent chance of discard).
The minimum threshold, maximum threshold, and MPD comprise the RED profile. The following figure shows the three distinct ranges in a RED profile: no drop, random drop, and full drop.
RED is most useful on router interfaces where congestion is likely. For example, a WAN interface might be a good candidate for RED.
Cisco does not support RED, but fortunately it supports something better: Weighted Random Early Detection (WRED). Unlike RED, WRED has a profile for each priority marking. For example, a packet with an IP Precedence value of 0 might have a minimum threshold of 20 packets, whereas a packet with an IP Precedence of 1 might have a minimum threshold of 25 packets. In this example, packets with an IP Precedence of 0 would start to be discarded before packets with an IP Precedence of 1.
Although WRED can be configured from interface-configuration mode or from virtual-circuit-configuration mode, these Quick Reference Sheets focus on an MQC-based WRED configuration. To enable WRED and to specify the marking that WRED pays attention to (that is, IP Precedence or DSCP), issue the following policy-map-class configuration-mode command:
Router(config-pmap-c)#random-detect [dscp-based | prec-based]
If neither dscp-based nor prec-based is specified, WRED defaults to prec-based. After WRED is configured, the IOS assigns default minimum threshold, maximum threshold, and MPD values. However, you can alter those default parameters with the following commands:
Router(config-pmap-c)#random-detect precedence precedence_value minimum-threshold maximum-threshold mark-probability-denominator
(Used for prec-based WRED)
Router(config-pmap-c)#random-detect dscp dscp_value minimum-threshold maximum-threshold mark-probability-denominator
(Used for dscp-based WRED)
To reinforce this syntax, consider the following example, where the goal is to configure WRED for the WREDTEST class-map. After the class-map’s queue depth reaches 25 packets, a DSCP value of AF13 might be discarded. Packets that are marked with a DSCP value of AF12 should not be discarded until the queue depth reaches 30 packets, and finally, packets that are marked with a DSCP value of AF11 should have no chance of discard until the queue depth reaches 35 packets. If the queue depth exceeds 100 packets, there should be a 100 percent chance of discard for these three DSCP values. However, when the queue depth is exactly 100 packets, the chance of discard for these various packet types should be 25 percent. Also, CB-WRED requires that CB-WFQ be configured for the interface. So, as an additional requirement, you make 25 percent of the interface’s bandwidth available to the WREDTEST class of traffic.
Router(config-pmap)#class WREDTEST Router(config-pmap-c)#bandwidth percent 25 Router(config-pmap-c)#random-detect dscp-based Router(config-pmap-c)#random-detect dscp af13 25 100 4 Router(config-pmap-c)#random-detect dscp af12 30 100 4 Router(config-pmap-c)#random-detect dscp af11 35 100 4
Examine the solution, and notice that the MPD is 4. This value was chosen to meet the requirement of a 25 percent chance of discard when the queue depth equals the maximum threshold (that is, 1/4 = .25). Also, notice that a DSCP value of AF13 is dropped before a DSCP value of AF12, which is dropped before a DSCP value of AF11. This approach is consistent with the definition of the per-hop behaviors (PHBs), because the last digit in the Assured Forwarding (AF) DSCP name indicates its drop preference. For example, a value of AF13 would drop before a value of AF12.
To view the minimum threshold, maximum threshold, and MPD settings for the various IP Precedence or DSCP values, you can issue the show policy-map interface interface-identifier command.
WRED discards packets, and that is one way for the router to indicate congestion. However, routers can now indicate a congestion condition by signaling, using an approach called Explicit Congestion Notification (ECN).
ECN uses the 2 last bits in the ToS byte to indicate whether a device is ECN capable, and if so, whether congestion is being experienced.
Cisco routers can use ECN as an extension to WRED and mark packets that exceed a specified value, instead of dropping the packets. If the queue depth is at or below the WRED minimum threshold, the packets are sent normally, just as with WRED. Also, if the queue depth is above the WRED maximum threshold, all packets are dropped, just as with WRED.
But if the queue depth is currently in the range from the minimum threshold through the maximum threshold, one of the following things can happen:
If both endpoints are ECN capable, the ECT and CE bits are set to a 1 and sent to the destination, indicating that the transmission rate should be reduced.
If neither endpoints supports ECN, the normal WRED behavior occurs.
A packet with its ECN and CE bits marked can reach a destination router that already has a full queue. In such an instance, the notification is dropped.
Use the following command to enable ECN:
Note that although WRED also can be configured in interface-configuration mode, ECN must be configured through MQC. Because ECN is configured by the three-step MQC process, the same verification and troubleshooting commands apply. Specifically, you can use the show policy-map and show policy-map interface interface-identifier commands to verify the ECN configuration.