1、ECN with IP
ECN使用IPv4或者IPv6首部DiffServ字段的最低两个bits,编码后产生4个值:
- 00 : Non ECN-Capable Transport, Non-ECT
- 10 : ECN Capable Transport, ECT(0)
- 01 : ECN Capable Transport, ECT(1)
- 11 : Congestion Encountered, CE
2、ECN with TCP
ECN使用TCP首部的两个flags:
- ECN-Echo(ECE):反馈网络拥塞,i.e. 通知发送方减少发送量
- Congestion Window Reduced(CWR):确认网络拥塞反馈(ECE)已收到
3、交互过程
3.1、协商
An ECT codepoint is set in packets transmitted by the sender to indicate that ECN is supported by the transport entities for these packets.
发送方发送带有ECT标志的报文。
3.2、检测&标记
An ECN-capable router detects impending congestion and detects that an ECT codepoint is set in the packet it is about to drop. Instead of dropping the packet, the router chooses to set the CE codepoint in the IP header and forwards the packet.
支持ECN的路由器检测到网络拥塞,并且本来要丢弃的报文中携带了ECT标志。路由器这时会设置CE标志,并继续转发报文。
3.3、反馈
The receiver receives the packet with the CE codepoint set, and sets the ECN-Echo flag in its next TCP ACK sent to the sender.
接收端收到带有CE标志的报文后,在后续发送给发送端的ACK报文中携带ECE标志。
3.4、降速
The sender receives the TCP ACK with ECN-Echo set, and reacts to the congestion as if a packet had been dropped.
发送端接收到携带ECE标志的ACK报文后,执行降速,来解决网络拥塞。
3.5、确认
The sender sets the CWR flag in the TCP header of the next packet sent to the receiver to acknowledge its receipt of and reaction to the ECN-Echo flag.
发送端为了确认ECE标志,会在后续发送报文中携带CWR标志。