# 随机早期检测

**随机早期检测**（Random early detection，RED）是一种用于网络路由器的[主动队列管理](https://www.edgepedia.org/zh/active-queue-management)（AQM）算法，它在缓冲区满之前以概率方式丢弃或标记到达的数据包，以此向发送方发出初现拥塞的信号。该算法由当时在[劳伦斯伯克利国家实验室](https://www.edgepedia.org/zh/lawrence-berkeley-national-laboratory)（Lawrence Berkeley National Laboratory）的计算机科学家萨莉·弗洛伊德（Sally Floyd）和同样当时在该实验室的[范·雅各布森](https://www.edgepedia.org/zh/van-jacobson)（Van Jacobson）设计，于1993年8月发表在《IEEE/ACM网络汇刊》（*IEEE/ACM Transactions on Networking*）上<sup>[1](https://cir.nii.ac.jp/crid/1362262945132557824)</sup>。1998年的互联网性能建议RFC 2309将RED描述为推荐的队列管理机制，并呼吁广泛部署<sup>[2](https://datatracker.ietf.org/doc/html/rfc2309)</sup>。

| 关键事实 | 详情 |
|---|---|
| 起源 | 萨莉·弗洛伊德与范·雅各布森，“用于拥塞避免的随机早期检测网关”，《IEEE/ACM网络汇刊》1(4):397–413，1993年8月<sup>[1](https://cir.nii.ac.jp/crid/1362262945132557824)</sup> |
| 拥塞信号 | 在队列溢出之前，基于运行平均队列长度而非瞬时占用率，以概率方式丢弃数据包（或进行ECN标记）<sup>[3](https://www.rfc-editor.org/rfc/rfc2884.html)</sup> |
| 核心参数 | 最小阈值（minth）、最大阈值（maxth）和最大丢弃概率maxp；丢弃概率在两阈值之间从0线性升至maxp，超过maxth时所有数据包均被丢弃<sup>[2](https://datatracker.ietf.org/doc/html/rfc2309)</sup> |
| 解决的问题 | 尾部丢弃的排斥行为和满队列问题，这些问题导致TCP流的全局同步和吞吐量损失<sup>[2](https://datatracker.ietf.org/doc/html/rfc2309)</sup> |
| 标准化 | RFC 2309（1998年）建议部署；RFC 7567（2015年）继续推荐AQM，但不再默认推荐RED或任何特定算法<sup>[2](https://datatracker.ietf.org/doc/html/rfc2309)</sup><sup> • </sup><sup>[4](https://datatracker.ietf.org/doc/rfc7567/)</sup> |
| 部署状况 | 在适当的参数配置下RED是有效的，但动态预测该参数集被证明是困难的；RED未被默认启用，其在当今互联网中的使用有限<sup>[4](https://datatracker.ietf.org/doc/rfc7567/)</sup> |
| 实现 | Linux `tc red`排队规则；Cisco IOS XE加权RED（WRED）<sup>[5](https://man7.org/linux/man-pages/man8/tc-red.8.html)</sup><sup> • </sup><sup>[6](https://www.cisco.com/c/en/us/td/docs/routers/ios-xe/quality-of-service/quality-of-service/m_qos-conavd-oview-0.html)</sup> |

## 动机：尾部丢弃的缺点

路由器中的传统队列规则是尾部丢弃：接受数据包直到队列达到最大长度，然后丢弃每个新到达的数据包，直到空间释放。RFC 2309指出了两个缺点<sup>[2](https://datatracker.ietf.org/doc/html/rfc2309)</sup>。

**排斥。** 尾部丢弃可能允许单个连接或少数流垄断队列空间，阻止其他连接获得空间，这通常是同步或时序效应的结果<sup>[2](https://datatracker.ietf.org/doc/html/rfc2309)</sup>。

**满队列。** 由于尾部丢弃仅在缓冲区已满时才发出拥塞信号，队列会长时间保持满或接近满的状态。随后到达的突发流量会导致多个数据包同时被丢弃，这可能触发全局同步：许多TCP主机同时降低传输速率，随后是持续的低链路利用率时期<sup>[2](https://datatracker.ietf.org/doc/html/rfc2309)</sup><sup> • </sup><sup>[6](https://www.cisco.com/c/en/us/td/docs/routers/ios-xe/quality-of-service/quality-of-service/m_qos-conavd-oview-0.html)</sup>。RFC 2309主张，队列限制应根据路由器必须吸收的突发流量来设定，而非稳态队列，并且保持通常较小的队列可以提高吞吐量并降低延迟<sup>[2](https://datatracker.ietf.org/doc/html/rfc2309)</sup>。

主动队列管理是前瞻性的替代方案：在缓冲区溢出之前丢弃数据包，使响应式终端系统在严重拥塞之前退让。RFC 2309列出了对响应式流的预期好处：路由器中丢弃的数据包更少、交互式服务延迟更低、避免排斥<sup>[2](https://datatracker.ietf.org/doc/html/rfc2309)</sup>。

## 算法工作原理

RED由两部分组成：平均队列长度的估计和每个到达数据包的丢弃决策<sup>[2](https://datatracker.ietf.org/doc/html/rfc2309)</sup>。

**平均队列长度。** RED响应的是时间平均队列长度，而非瞬时长度，使用指数加权移动平均（EWMA）计算，可在转发路径或后台进行<sup>[2](https://datatracker.ietf.org/doc/html/rfc2309)</sup>。如果队列在近期大部分时间为空，RED不会倾向于丢弃数据包；如果队列近期相对较满，表明持续拥塞，则到达的数据包更可能被丢弃<sup>[2](https://datatracker.ietf.org/doc/html/rfc2309)</sup>。取平均还避免了对突发流量的偏见，因为单次突发本身不会提高平均值<sup>[3](https://www.rfc-editor.org/rfc/rfc2884.html)</sup>。

**丢弃决策。** 两个阈值支配着决策。低于最小阈值（minth）时不丢弃任何数据包；高于最大阈值（maxth）时每个到达的数据包都被丢弃。在两者之间，随着平均队列长度从minth增长到maxth，每个到达的数据包以从0线性变化到maxp的概率被丢弃<sup>[2](https://datatracker.ietf.org/doc/html/rfc2309)</sup>。Linux实现将这些暴露为`tc red`排队规则的`min`、`max`和`probability`参数，以及`limit`、`avpkt`、`burst`、`ecn`标志和用于自适应RED的`adaptive`标志<sup>[5](https://man7.org/linux/man-pages/man8/tc-red.8.html)</sup>。

由于丢弃是随机分布在各个流之间的，特定流丢失数据包的概率大约与该流的带宽份额成正比：使用相对更多带宽的发送方会受到更多丢弃的惩罚<sup>[3](https://www.rfc-editor.org/rfc/rfc2884.html)</sup>。随机性还打破了导致排斥的同步过程<sup>[2](https://datatracker.ietf.org/doc/html/rfc2309)</sup>。

**ECN标记。** 当平均队列长度超过阈值时，RED路由器可以使用显式拥塞通知来标记数据包而非丢弃它；RFC 2884描述了这种IP中的ECN组合，其中拥塞指示无丢失地到达端点<sup>[3](https://www.rfc-editor.org/rfc/rfc2884.html)</sup>。

## 参数敏感性与部署历史

RFC 2309的结论是，现有的经验证据表明AQM带来了显著的性能优势，RED应被广泛部署<sup>[2](https://datatracker.ietf.org/doc/html/rfc2309)</sup>。部署未能达到该建议。2015年发布以取代RFC 2309的RFC 7567指出，RED在给定合适的参数配置时运行良好，但以动态方式确定这样的配置被证明具有挑战性；因此RED默认未开启，在当今互联网上的部署有限。该备忘录继续推荐部署AQM，但不再默认推荐RED或任何其他特定算法<sup>[4](https://datatracker.ietf.org/doc/rfc7567/)</sup>。

RFC 7928——AQM特征描述指南——将参数敏感性列为RED部署的最大障碍之一：为部署调整RED参数以获得可接受的收益是困难的，波动的拥塞水平和网络条件增加了复杂性，错误的参数值导致性能不佳<sup>[7](https://www.rfc-editor.org/info/rfc7928/)</sup>。后来的分析得出了类似的结论，指出RED对拥塞响应缓慢且参数调优困难，这使得当不同应用使用不同数据速率时算法工作不正确<sup>[8](https://www.nature.com/articles/s41598-022-17528-x)</sup>。对耦合TCP/RED系统的控制论研究指出，RED的若干调优参数紧密耦合，必须仔细选择，且RED的基本版本未能成功地将路由器队列稳定在目标长度<sup>[9](https://www.sciencedirect.com/science/article/abs/pii/S0045790608000803)</sup>。

## 变体

参数调优问题催生了一系列自适应衍生算法。**自适应RED**（Adaptive RED）由萨莉·弗洛伊德、拉马克里希纳·古马迪（Ramakrishna Gummadi）和[斯科特·申克](https://www.edgepedia.org/zh/scott-shenker)（Scott Shenker）于2001年提出，随时间调整maxp以使平均队列接近目标值，在Linux中通过`adaptive`标志可用<sup>[10](https://priv3.icsi.berkeley.edu/floyd/red.html)</sup><sup> • </sup><sup>[5](https://man7.org/linux/man-pages/man8/tc-red.8.html)</sup>。ns模拟器的“温和”修改将丢弃概率从maxp扩展到1，随着平均队列从maxthresh增长到两倍maxthresh<sup>[10](https://priv3.icsi.berkeley.edu/floyd/red.html)</sup>。后来的研究提案包括具有三个阈值的GRED、具有动态调整的maxp和从线性稳定性条件选择的权重的自调优RED，以及AGRED等进一步改进<sup>[8](https://www.nature.com/articles/s41598-022-17528-x)</sup><sup> • </sup><sup>[11](https://onlinelibrary.wiley.com/doi/10.1155/2011/872347)</sup><sup> • </sup><sup>[12](https://link.springer.com/article/10.1007/s44227-025-00056-1)</sup>。

在厂商实现中，Cisco的**加权RED**（WRED）将RED算法与IP优先级功能相结合，使路由器的丢弃决策可以因流量类别而异；Cisco将RED描述为高速中转网络的最佳选择<sup>[6](https://www.cisco.com/c/en/us/td/docs/routers/ios-xe/quality-of-service/quality-of-service/m_qos-conavd-oview-0.html)</sup>。

## RED与后来的AQM算法

RED是基于队列长度的AQM的典型例子。IETF的AQM工作中后来的方案，特别是[CoDel](https://www.edgepedia.org/zh/codel)和PIE，是基于排队延迟的：它们作用于数据包在队列中花费的时间而非队列长度<sup>[13](https://www.potaroo.net/ietf/all-ids/draft-ietf-aqm-eval-guidelines-02.pdf)</sup>。PIE（增强型比例积分控制器）旨在将RED的易于实现性与CoDel风格的延迟控制相结合：与RED一样，它在拥塞开始时随机丢弃数据包，但其拥塞检测基于排队延迟及其趋势，而非队列长度<sup>[14](https://courses.cs.duke.edu/compsci514/current/readings/pie.pdf)</sup>。RFC 8289——CoDel规范——指出了RED设计中一个进一步的测量微妙之处：如原始RED中那样在数据包到达时监测的队列长度对长度被观察的方式和时间敏感，因为高速入站链路上的突发流量可能在一个往返时间过去之前就消散了<sup>[15](https://www.rfc-editor.org/rfc/rfc8289.html)</sup>。

RED仍然是一个广为人知的参照点：RFC 7141在其关于拥塞通知的讨论中始终将其作为具体示例，正是因为它是一个广为人知且已部署的AQM算法<sup>[16](https://www.rfc-editor.org/rfc/rfc7141.html)</sup>。

## References

1. [S. Floyd and V. Jacobson (1993). Random Early Detection Gateways for Congestion Avoidance. IEEE/ACM Transactions on Networking 1(4):397–413.](https://cir.nii.ac.jp/crid/1362262945132557824)
2. [B. Braden et al. (April 1998). RFC 2309: Recommendations on Queue Management and Congestion Avoidance in the Internet.](https://datatracker.ietf.org/doc/html/rfc2309)
3. [K. Ramakrishnan, S. Floyd, D. Black (July 2000). RFC 2884: The ECN Reaction to Congestion in IP Networks.](https://www.rfc-editor.org/rfc/rfc2884.html)
4. [F. Baker, G. Fairhurst (July 2015). RFC 7567: IETF Recommendations Regarding Active Queue Management.](https://datatracker.ietf.org/doc/rfc7567/)
5. [tc-red(8) Linux manual page, iproute2.](https://man7.org/linux/man-pages/man8/tc-red.8.html)
6. [Cisco IOS XE Quality of Service Configuration Guide: Congestion Avoidance Overview.](https://www.cisco.com/c/en/us/td/docs/routers/ios-xe/quality-of-service/quality-of-service/m_qos-conavd-oview-0.html)
7. [N. Kuhn et al. (July 2016). RFC 7928: Characterization Guidelines for Active Queue Management (AQM).](https://www.rfc-editor.org/info/rfc7928/)
8. [Improving RED algorithm congestion control by using the Markov decision process. Scientific Reports (2022).](https://www.nature.com/articles/s41598-022-17528-x)
9. [Dynamic queue level control of TCP/RED systems in AQM routers. Computers & Electrical Engineering (2008).](https://www.sciencedirect.com/science/article/abs/pii/S0045790608000803)
10. [S. Floyd, R. Gummadi, S. Shenker (2001). Adaptive RED: An Algorithm for Increasing the Robustness of RED's Active Queue Management; RED references page.](https://priv3.icsi.berkeley.edu/floyd/red.html)
11. [D. Chen (2011). Self-Tuning Random Early Detection Algorithm to Improve Performance of Network Transmission. Mathematical Problems in Engineering.](https://onlinelibrary.wiley.com/doi/10.1155/2011/872347)
12. [Performance Analysis of Diverse Active Queue Management Algorithms. International Journal of Networked and Distributed Computing (2025).](https://link.springer.com/article/10.1007/s44227-025-00056-1)
13. [N. Kuhn et al. (2015). draft-ietf-aqm-eval-guidelines: Evaluation Guidelines for AQM.](https://www.potaroo.net/ietf/all-ids/draft-ietf-aqm-eval-guidelines-02.pdf)
14. [R. Pan et al. PIE: A Lightweight Control Scheme to Address the Bufferbloat Problem.](https://courses.cs.duke.edu/compsci514/current/readings/pie.pdf)
15. [Kathie Nichols, Van Jacobson (January 2018). RFC 8289: Controlled Delay Active Queue Management.](https://www.rfc-editor.org/rfc/rfc8289.html)
16. [B. Briscoe, A. Manner (May 2014). RFC 7141: Byte and Packet Congestion Notification.](https://www.rfc-editor.org/rfc/rfc7141.html)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 网络与安全 › Networking fundamentals and architecture › Internet protocol suite

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/random-early-detection

English original: https://www.edgepedia.org/random-early-detection
