慢启动SS,加性
增AIMD算法
当出现丢包时,减少拥塞窗口CWin长度降低发送速率,在一般情况下谨慎增加CWin长度。
阈值:帮助TCP判断何时进入阻塞避免区域,表示从慢启动阶段进入阻塞阶段的阈值。
void slow_start(void){
CWin=1MSS;
n=0;
while(没有丢包){
if(在RTT期间接受到了ACK){
CWin=CWin*2的n次方;
n++;
if(CWin>=ssthresh){ //若窗口大于阈值
//去执行加性增算法
break;
}
}else{
CWin=1MSS;
}
}
}
void additive_increase(void){
ssthresh=CWin/2;
while(收到ACK){
if(CWin>=ssthresh){
CWin=CWin+MSS*(MSS/CWin);
if(收到三个冗余的ACK){
ssthresh=CWin/2;
CWin=CWin/2;
break;
}
if(检测到超时事件){
ssthresh=CWin/2;
CWin=1MSS;
if(CWin<ssthresh){
//执行slow_start算法
break;
}
}
}
}
}
案例:现在阈值ssthresh=8MSS,一旦CWin=12MSS时就会发生超时事件。 当T=15时,CWin的走势。
分析,首先慢启动,一直到阈值跳转到加性增直到超时阈值减半,重新执行慢启动。
执行慢启动算法
T=1 CWin=1 ssthresh=8MSS
T=2 CWin=2 ssthresh=8MSS
T=3 CWin=4 ssthresh=8MSS
T=4 CWin=8 ssthresh=8MSS //达到阈值,跳转到加性增,阈值为CWin/2
T=5 CWin=9 ssthresh=4MSS
T=6 CWin=10 ssthresh=4MSS
T=7 CWin=11 ssthresh=4MSS
T=8 CWin=12 ssthresh=4MSS //超时则CWin为1阈值为CWin/2,跳转到加性增
T=9 CWin=1 ssthresh=6MSS
T=10 CWin=2 ssthresh=6MSS
T=11 CWin=4 ssthresh=6MSS
T=12 CWin=6 ssthresh=6MSS //当CWin=8时超过了阈值则为6,跳转到加性增
T=13 CWin=7 ssthresh=3MSS
T=14 CWin=8 ssthresh=3MSS
T=15 CWin=9 ssthresh=3MSS
参考:《计算机网络:原理与实践》陈鸣
我是菜鸟,我在路上。