TCP/IP and RFC 2661 define two algorithms--slow start and congestion avoidance--used to throttle control message traffic between
a NAS and a tunnel server. Slow start and congestion avoidance are two independent algorithms that work together to control
congestion. Slow start and congestion avoidance require that two variables, a slow start threshold (SSTHRESH) size and a congestion
window (CWND) size, be maintained by the sending device for each connection.
The congestion window defines the number of packets that can be transmitted before the sender must wait for an acknowledgment
from its peer. The size of the congestion window expands and contracts, but can never exceed the size of the peer device’s
advertised receive window.
The slow start threshold defines the point at which the sending device switches operation from slow start mode to congestion
avoidance mode. When the congestion window size is smaller than the slow start threshold, the device operates in slow start
mode. When the congestion window size equals the slow start threshold, the device switches to congestion avoidance mode.
When a new connection is established, the sending device initially operates in slow start mode. The congestion window size
is initialized to one packet, and the slow start threshold is set to the receive window size advertised by the peer tunnel
endpoint (the receiving side).
The sending device begins by transmitting one packet and waiting for it to be acknowledged. When the acknowledgment is received,
the congestion window size is incremented from one to two, and two packets can be sent. When those two packets are each acknowledged,
the congestion window is increased to four. The congestion window doubles for each complete round trip, resulting in an exponential
increase in size.
When the congestion window size reaches the slow start threshold value, the sending device switches over to operate in congestion
avoidance mode. Congestion avoidance mode slows down the rate at which the congestion window size grows. In congestion avoidance
mode, for every acknowledgment received the congestion window increases at the rate of 1 divided by the congestion window
size. This results in linear, rather than exponential, growth of the congestion window size.
At some point, the capacity of the peer device will be exceeded and packets will be dropped. This indicates to the sending
device that the congestion window has grown too large. When a retransmission event is detected, the slow start threshold value
is reset to half of the current congestion window size, the congestion window size is reset to one, and the device switches
operation to slow start mode (if it was not already operating in that mode).