This article goes from:http://blog.sina.com.cn/s/blog_7fc4c23d0101fa0z.htmlThe current TCP implementation treats the intermediate network between TCP-side nodes as an opaque "black box." The TCP packet enters and exits the box. Sometimes the bag that goes into the box is lost. Because today's numbers and light media are less likely to appear than super-high errors, TCP designers assume that packet loss is largely due to router congestion
TCP Support for ECN
When the ECN domain of an IP packet is set to 11 o'clock by the router, the receiving side, not the sender, is notified that there is congestion on the path. The ECN uses the TCP header to tell the sending network that it is experiencing congestion, and informs the receiving side that the sending segment has received a congestion notification from the receiving end, which has lowered the send rate.
Figure 2
TCP Support for ECN uses pre-defined reserved bits in TCP. The ECN defines two new flags, 2 as shown:
- The ECE:ECN response flag is used in the TCP3 handshake to indicate that a TCP side is an ECN-capable, and that an ECN that indicates the IP header of the received TCP packet is set to 11. Please refer to RFC793 for more information.
- CWR: The Congestion window reduction flag is sent to the host setting to indicate that it has received a TCP packet that sets the ECE flag. The Congestion window is an internal variable maintained by TCP that is used to manage the sending window size.
When two TCP ports that support ECN are TCP connected, they exchange syn,syn-ack and ACK packets. For the TCP side that supports ECN, the ECE and CWR flags for the SYN package are set. Syn-ack only sets the ECE flag.
A TCP host that supports ECN sends TCP packets with an IP header of 10 or 01 on a TCP connection that supports ECN. ECN-enabled routers set the IP header's ECN domain at 11 when they experience congestion. When a TCP receiver sends a response to a TCP packet that is received to set the ECN bit to 11, it sets the ECE in the TCP header and also makes the same setting in the next ACK.
When the sending host receives an ACK with the ECE flag set, it begins to reduce the sending window, running the slow boot process and congestion avoidance algorithm as if it senses packet loss. In the next packet, the sender sets the CWR flag. When a package that receives a new set of CWR flags is received, the recipient stops setting the ECE flag in the next ACK.
ECN examples
Figure 3
Figure 3 shows an example of a TCP connection between the TCP-side nodes that support ECN, an ECN-enabled router that is experiencing congestion.
In this example, TCP side A sends data to TCP side B. TCP Side A sends 5 packets at once. Package 2 sets the ECN bit of the IP header to 11 through a congested router forwarding that supports ECN. When TCP-side B receives this packet, it sends an ACK that sets the ECE flag. When TCP side a receives the first ACK that has the ECE set, it lowers the send rate and sets its CWR flag when the next packet (6) is sent. The 6,tcp end of the receive packet will not set the ECE flag for the next ACK packet. Please refer to RFC 3168 for details.
Windows support for ECN
Windows Vista supports ECN but is turned off by default. You can open support through the netsh interface tcp set global ecncapability=enabled. Because the ECN uses bits that were not previously used or reserved in the IP and TCP headers, the intermediary network devices such as routers and firewalls silently discard the ECN domain set to a non-0-value package. To prevent this from happening, configure and upgrade your network devices appropriately to support ECN.
"Go" TCP ECE/CWR identity bit