RED(8)
๐ RED(8) โ the red page, but make it a vibe ๐
okay bestie, gather round, because today we're talking about red โ Random Early Detection โ and no, it's not the color, it's a queueing discipline and it's honestly kind of iconic. ๐
โจ NAME โจ
red โ Random Early Detection ๐
๐ฆ SYNOPSIS ๐ฆ
tc qdisc ... red limit bytes [ min bytes ] [ max bytes ] avpkt bytes [
burst packets ] [ ecn ] [ harddrop ] [ nodrop ] [ bandwidth rate ] [
probability chance ] [ adaptive ] [ qevent early_drop block index ] [
qevent mark block index ]
๐ธ DESCRIPTION ๐ธ
so. Random Early Detection is a classless qdisc, and the way it manages its queue size is, like, smart. ๐
Regular queues are giving "no thoughts, head empty" โ they just drop packets from the tail once they're full, which is lowkey not the optimal behaviour. RED also does tail drop, but it does it in a way more gradual, slow-burn, character-development-arc kind of way. ๐ง
Here's the tea: once the queue hits a certain average length, the packets getting enqueued have a configurable chance of being marked (and marking might mean dropped). That chance increases linearly up to a point called the max average queue length โ even though the queue itself might still get bigger. The audacity, honestly. ๐ญ
This has a whole host of benefits over plain simple taildrop, and it's not processor intensive. It prevents synchronous retransmits after a burst in traffic โ which would otherwise cause further retransmits, etc. etc. cascade of chaos, we don't do that here. ๐
The goal? A small queue size. Which is good for interactivity, while not disturbing TCP/IP traffic with too many sudden drops after a burst of traffic. Balance. Main character energy. ๐
And depending on if ECN is configured, marking either means dropping, or purely marking a packet as overlimit. โจ
๐ ALGORITHM ๐
The average queue size is what determines the marking probability, periodt. It's calculated using an Exponential Weighted Moving Average, which can be more or less sensitive to bursts โ depending on how you set it up.
- When the average queue size is below
minbytes, no packet will ever be marked. Zero. None. Not happening. ๐ซ - When it exceeds
min, the probability of marking climbs linearly up toprobability, until the average queue size hitsmaxbytes. ๐ - Because
probabilityis normally not set to 100%, the queue size might conceivably rise abovemaxbytes โ so thelimitparameter is provided to set a hard maximum for the size of the queue. ๐
๐ PARAMETERS ๐
minโ Average queue size at which marking becomes a possibility. Defaults tomax /3. ๐ฑmaxโ At this average queue size, the marking probability is maximal. Should be at least twiceminto prevent synchronous retransmits, and higher for a lowmin. Defaults tolimit /4. ๐ฅprobabilityโ Maximum probability for marking, specified as a floating point number from0.0to1.0. Suggested values are0.01or0.02(that's 1% or 2%, respectively). Default:0.02. ๐ฒlimitโ Hard limit on the real (not average!) queue size, in bytes. Further packets get dropped. Should be set higher thanmax+burst. It is advised to set this a few times higher thanmax. โ ๏ธburstโ Used for determining how fast the average queue size is influenced by the real queue size. Larger values make the calculation more sluggish, allowing longer bursts of traffic before marking starts. Real life experiments support the following guideline:(min+min+max)/(3*avpkt). ๐avpktโ Specified in bytes. Used together withburstto determine the time constant for average queue size calculations.1000is a good value. ๐bandwidthโ This rate is used for calculating the average queue size after some idle time. Should be set to the bandwidth of your interface. > ๐จ It does not mean that RED will shape for you! Optional. Default:10Mbit.ecnโ As mentioned before, RED can either 'mark' or 'drop'. Explicit Congestion Notification allows RED to notify remote hosts that their rate exceeds the amount of bandwidth available. Non-ECN capable hosts can only be notified by dropping a packet. If this parameter is specified, packets which indicate that their hosts honor ECN will only be marked and not dropped โ unless the queue size hitslimitbytes. Recommended. ๐harddropโ If the average flow queue size is abovemaxbytes, this parameter forces a drop instead of an ECN marking. ๐nodropโ With this parameter, traffic that should be marked, but is not ECN-capable, is enqueued. Without the parameter, it is early-dropped. ๐adaptiveโ (Added in linux-3.3) Sets RED in adaptive mode, as described inhttp://icir.org/floyd/papers/adaptiveRed.pdf. The goal of Adaptive RED is to makeprobabilitya dynamic value between 1% and 50%, to reach the target average queue:(max - min) / 2. ๐ฆ
โญ QEVENTS โญ
See tc (8) for some general notes about qevents. The RED qdisc supports the following qevents:
early_dropโ The associated block is executed when packets are early-dropped. This includes non-ECT packets in ECN mode. ๐ญmarkโ The associated block is executed when packets are marked in ECN mode. โจ
๐ EXAMPLE ๐
# tc qdisc add dev eth0 parent 1:1 handle 10: red
limit 400000 min 30000 max 90000 avpkt 1000
burst 55 ecn adaptive bandwidth 10Mbit
๐ SEE ALSO ๐
๐ SOURCES ๐
- Floyd, S., and Jacobson, V., Random Early Detection gateways for Congestion Avoidance.
http://www.aciri.org/floyd/papers/red/red.html - Some changes to the algorithm by Alexey N. Kuznetsov.
- Adaptive RED :
http://icir.org/floyd/papers/adaptiveRed.pdf
๐ซถ AUTHORS ๐ซถ
Alexey N. Kuznetsov, <kuznet@ms2.inr.ac.ru>, Alexey Makarenko <makar@phoenix.kharkov.ua>, J Hadi Salim <hadi@nortelnetworks.com>, Eric Dumazet <eric.dumazet@gmail.com>. This manpage maintained by bert hubert <ahu@ds9a.nl>
and that's the whole page bestie, no crumbs left ๐ โ this one shipped with iproute2, dated 13 December 2001, and it's still eating to this day. slay. ๐ โจ
๐ฆ where this page comes from
- arch rolling: iproute2 7.2.0-1
- arch rolling: iproute2 7.3.0-1 ยท GPL-2.0-or-later
- nixpkgs unstable: iproute2 7.2.0
- ubuntu stonking: iproute2 7.2.0-1ubuntu1 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms