HSC welcomes all external visitors to this site, especially students and members of the academic community. Please use the comments box at the bottom of each page to record any comments or suggestions for improvement.
Explicit Congestion Notification
TCP use two flags (ECE and CWR) in TCP header for negotiating and subsequently indicating ECN for a connection. When congestion situation occurs, TCP sends packets with ECE bit set till it receives a TCP packet with CWR set thus indicating the reduction in congestion window in response to congestion experienced.
Detailed functionality
ECN flag
ECN flag values indicate what should be the value of ECN fields in TCP header of outgoing packets. ECN flag can have following values:
- TCP_ECN_OK : ECN is negotiated for TCP stream
- TCP_ECN_QUEUE_CWR: Congestion window reduction is indicated to TCP receiver
- TCP_ECN_DEMAND_CWR: Indicate the congestion state to TCP sender and demand reduction of congestion window
Negotiating ECN
In case ECN is supported in sysctl variable (sysctl_tcp_ecn):
- Set ECE and CWR fields in TCP header of outgoing SYN
- ECN flag is set as TCP_ECN_OK
In case ECN is supported in sysctl variable (sysctl_tcp_ecn) and ECE and CWR flags are set in received SYN, set ECN as OK for use on this TCP connection.
If ECN is Oked on SYN reception, set ECE bit in TCP header of outgoing SYN-ACK
During simultaneous SYN situation
Processing ECN in received SYN (TCP_ECN_rcv_syn)
If TCP_ECN_OK but the received SYN packet has either ECE or CWR not set then mark ECN flags for ECN not OK.
Responding with SYN-ACK (TCP_ECN_send_synack)
Received SYN packet header is modified for:
- Reset CWR
- If ECN is not OK, reset ECE
If TCP_ECN_OK and in received SYN-ACK either ECE is not set or CWR is set, then mark ECN flags for ECN not OK
ECN occurrence
Explicit congestion is declared primarily on two events:
- If TCP is not able to transmit a packet due to congestion experienced by the device tcp v4 error
- ICMP Source Quench is received tcp transmit skb
In both the scenarios, TCP_ECN_DEMAND_CWR is set.
Behavior for TCP receiver
On receiving data following ECN specific actions are taken:
If the peer has indicated CWR, reset TCP_ECN_DEMAND_CWR so that the subsequent packets will not demand congestion window reduction.
If TCP_ECN_OK and the data received has CE bit set in IP header, set TCP_ECN_DEMAND_CWR in ecn flag.
If TCP_ECN_OK and the ECT bits are not set in IP header, this indicates a retransmitted packet, TCP falls into quick ack mode.
Behavior for TCP Sender
While transmitting data (TCP_ECN_send)
If the packet is not being retransmitted
- set ECT bit in IP header
- If congestion window was reduced, indicate to peer by setting CWR bit in TCP header.
In case this is a retransmission, reset the ECT bits in IP header.
If CE bit was received set in some packet from peer (TCP_ECN_DEMAND_CWR), set ECE bit in TCP header.
ECN echo is declared when
- ECE is set in received packet
- Its not a SYN packet
- TCP_ECN_OK (ECN was negotiated)
When Congestion window is reduced on detection of loss, if TCP_ECN_OK set TCP_ECN_QUEUE_CWR
When TCP decides to undo the reduction in congestion window, TCP_ECN_DEMAND_CWR flag is reset.
Maintainer: seema.garg@hsc.com
Categories: Inside_Linux_TCP Software
Comments