How the IP ECN bits and the TCP ECN bits interact
You may have noticed that both the IPv4 and TCP headers feature fields talking about ECN.
Here’s the IPv4 header.
Here’s the TCP header.
These interact in a very strange way, but it makes sense once you understand it.
1. Two IPv4 hosts negotiate that they support ECN by setting the ECT bit in the DSCP header. They also negotiate ECN support at the TCP layer by setting the TCP ECE and CWR flags with the Syn packet.
2. When a router along the path is experiencing congestion AND is configured for ECN in it’s QoS policy it will mark the IP header as CE (congestion encountered).
3. When the TCP host receives this he sets the TCP ECE flag in the ack back to the original sender. This is what tells them that the path they took is congested.
4. Then the original sender lowers his congestion window and sets the TCP CWR flag on his next packet to the host. This let’s the receiver know that the window was reduced AND that they can stop setting the ECE flag because we got it.