- The sender starts by sending a small number of packets (usually one MSS ) and waits for an acknowledgment (ACK) from the receiver.
- When the ACK is received, the sender doubles the number of packets it sends and waits for ACKs for all of them.
- This process continues until the sender detects congestion or the receiver’s window has been reached.
- At this point, slow start has served its purpose and allows data to be transmitted at maximum capacity without congesting the network.
TCP 中的拥塞控制算法,防止发送超过网络能处理的数据量。
主要思想是:逐渐提高数据传输速率,而不是一开始就很高。
- 一开始时:建立 TCP 连接,发送方的拥塞窗口大小(cwnd)会被设置为一个很小的值,通常是 1 或 2 个 MSS 的大小。
- 每当发送方收到一个对之前发送的数据包的确认(ACK)时,它就会将拥塞窗口大小加倍。(所以其实不慢的)
- 当拥塞窗口大小达到一个阈值(ssthresh)时,发送方就会停止慢开始算法,转而使用拥塞避免算法。这个阈值通常就是网络能够承受的最大负载。
- 如果在传输过程中发生了数据包丢失,那么发送方会将阈值减半,并将拥塞窗口大小重置为 1,然后重新开始慢开始算法。
这里,我需要提一下的是一篇Google的论文《An Argument for Increasing TCP’s Initial Congestion Window》Linux 3.0后采用了这篇论文的建议——把cwnd 初始化成了 10个MSS。 而Linux 3.0以前,比如2.6,Linux采用了RFC3390,cwnd是跟MSS的值来变的,如果MSS< 1095,则cwnd = 4;如果MSS>2190,则cwnd=2;其它情况下,则是3。