Congestion Avoidance – WRED
Last updated
Last updated
What happens when there are more packets than the queue length? By default, all these packets are dropped, a process that is called “Tail Drop”. Unfortunately, we will never know what we dropped, maybe packets of an important flow.
Random Early Detection is a fancy word for randomly dropping packets in a queue so we can avoid congestions and not perform Tail Drop. RED takes advantage of the congestion mechanism of TCP, therefor it is only suitable for this kind of traffic. When RED drops a packet, the source will not receive a confirmation for it and will reduce the window size, therefore slowing down the transmission rate. Another advantage of RED is that it avoids Global Synchronization. If all traffic that is over the limit is dropped, then all sources slow down, and then they all begin to send, overwhelming again the link. By randomly dropping traffic, not all sources are affected of a drop at the same time.
Since RED drops the packets randomly, the sources that send more packets are more likely to be affected by those that send fewer packets
RED drops packets based on the Drop Probability. When the average Queue Depth is above the minimum threshold (MIN-TH), RED starts dropping packets. The rate of the packet drop increases linearly as the average queue size increases until it reaches maximum threshold (MAX-TH). At this point, the drop probability is limited to the value known as Mark Probability Denominator. If the average queue size continues to grow until it reaches the Queue Limit, then all the packets are dropped. If the Mark Probability Denominator = X, then 1 out of every X packets is dropped.
To calculate the average Queue Depth, the router uses the following formula:
n is a called the exponential weight factor, and can be configured:
WRED can selectively discard lower priority traffic when the interface begins to be congested. To enable WRED on an interface, use:
You can’t configure interface-level WRED when CBWFQ is used on the same interface. By default, WRED uses IP Precedence values but it can be configured to use the DSCP values
To verify WRED configuration, use:
Flow-Based WRED maintains a count of the number of active flows that exist on an output interface and calculates a number of buffers available for each flow. An Average Queue Size is calculated as:
Flows with a Queue Size that is less than the Average Queue Size will not experience Drops. Flows with a Queue Size greater than the Average Queue Size will start to experience Drops and the MAX-TH is recalculated as
This will actually bring the MAX-TH closer to the MIN-TH making the Drop Probability to increase quicker.
To enable Flow-Based RED, use:
You can set the number of flows to use and a scaling-factor that is used to calculate if the flow is adaptive or not.
WRED can also be set using the MQC, inside the class of a policy, but with similar configuration commands: To enable WRED for a class, use:
It will enable IP-Precedence based WRED which can be configured with:
You can switch to a DSCP based WRED with:
The Exponential Weight Factor can be configured with
You can verify the configuration using the command:
Instead of dropping the packets, ECN marks them in a way similar to the Discard Eligible bit for Frame Relay. The difference is that this marking is done at Layer 3, inside the ToS Byte.
In the IP ToS byte, the first 6 bits are used for DSCP, and the last 2 bits are used for Explicit Congestion Notification. The first bit is called ECT (ECN-capable Transport) and the second bit is called CE (Congestion Experienced). ECN bits are set by the sender to indicate to the router if the endpoints of the connection (sender and receiver) are ECN capable
0
0
The endpoints are not ECN capable
1
0
The endpoints are ECN capable but no congestion is experienced
0
1
-
1
1
The endpoints are ECN capable and congestion is being experienced
If the number of packets in the queue is below the minimum threshold, then packets are transmitted, just like in normal WRED. If the number of packets in the queue exceeds the maximum threshold, then packets are dropped, again, just like in normal WRED.
The difference appears when the number of packets is between the minimum and the maximum threshold. If the endpoints are not ECN-capable (00), the traffic will be dropped according to the probability, just like in normal WRED. If the endpoints are ECN-capable but no congestion is experienced (10 or 01), then if the packet should be dropped based on the probability, it will be marked with (11) and will be transmitted instead. If a congestion is being experienced (11), then the packet is transmitted because it is already marked as such.
The packets that are marked can be dropped at another point in the network if congestion also happens there, or may be forwarded to the next hop.
To enable ECN, use this command when configuring the class inside a policy: