How does ECN work in IP and TCP, and why is it not used everywhere?
Show the answer
Say this first
Explicit Congestion Notification (RFC 3168) lets a router with active queue management mark a packet as congestion experienced instead of dropping it. ECN uses the two low bits of the old IP ToS byte. The receiver echoes the mark with the ECE flag; the sender reduces cwnd as if a loss had happened, without any retransmission, and confirms with CWR. It needs support at both ends and marking routers. Linux by default only accepts ECN when the peer asks for it and does not request it itself, and old middleboxes that mishandled the bits slowed deployment.
Go deeper
IP codepoints (2 bits after the 6-bit DSCP)
| Bits | Name | Meaning |
|---|---|---|
| 00 | Not-ECT | Sender does not support ECN |
| 10 | ECT(0) | ECN-capable transport |
| 01 | ECT(1) | ECN-capable transport, used by L4S |
| 11 | CE | Congestion experienced, set by a router |
TCP negotiation
- SYN with ECE and CWR set: "I support ECN".
- SYN-ACK with ECE set: "So do I".
- Data packets then carry ECT. A router marks CE; the receiver sets ECE on its ACKs until the sender replies with CWR.
Where it matters
- Data centers: DCTCP and RoCEv2 congestion control rely on ECN marking at low queue thresholds.
- L4S (RFC 9330 to 9332) uses ECT(1) for very low queueing delay.
- Linux:
net.ipv4.tcp_ecn=2by default (accept, do not initiate);1requests ECN on outgoing connections.
Network gotcha
QoS policies that rewrite the whole ToS byte instead of only DSCP wipe ECN bits. Remarking DSCP should leave the two ECN bits alone.
They will ask next
What is the difference between ECE and CWR?
ECE goes from receiver to sender: "a packet you sent was marked". CWR goes from sender to receiver: "I have reduced my window, you can stop echoing". The receiver keeps setting ECE until it sees CWR.
Does a router mark every packet when the queue fills?
No. AQM such as RED or CoDel marks probabilistically or by delay before the queue is full. If the queue does overflow, packets are still dropped, ECN or not.
Traps
- Saying ECN uses DSCP bits. It uses the two bits after DSCP in the same byte.