tcp拥塞分析七(scalble)

本文分析linux-4.19.12代码的scalble拥塞算法

hstcp相对reno算法,通过两个固定的值TCP_SCALABLE_AI_CNT和TCP_SCALABLE_MD_SCALE改变了拥塞避免阶段窗口增长速度,以及丢包后ssthresh的设置.

/* These factors derived from the recommended values in the aer:
 * .01 and and 7/8. We use 50 instead of 100 to account for
 * delayed ack.
 */
#define TCP_SCALABLE_AI_CNT	50U
#define TCP_SCALABLE_MD_SCALE	3

AI阶段(拥塞避免阶段):reno算法窗口增长速度为1/snd_cwnd,与当前的发送窗口有关,一个rtt增长一个窗口(会考虑延迟ack,不是简单加1而是加acked).注释已经很清楚了,TCP_SCALABLE_AI_CNT也考虑到了ack延迟的情况,但只是固定认为acked=2, 控制拥塞避免阶段,每收到一次ack窗口增长1/50个窗口. 一个rtt大约增加 snd_cwnd*(1/100)个窗口

MD阶段(超时丢包)减小ssthresh为7/8*snd_cwnd 相比reno固定降为1/2*snd_cwnd会多占用些带宽.

static void tcp_scalable_cong_avoid(struct sock *sk, u32 ack, u32 acked)
{
	struct tcp_sock *tp = tcp_sk(sk);

	if (!tcp_is_cwnd_limited(sk))
		return;

	if (tcp_in_slow_start(tp))
		tcp_slow_start(tp, acked);
	else
		tcp_cong_avoid_ai(tp, min(tp->snd_cwnd, TCP_SCALABLE_AI_CNT),
				  1);
}

static u32 tcp_scalable_ssthresh(struct sock *sk)
{
	const struct tcp_sock *tp = tcp_sk(sk);

	return max(tp->snd_cwnd - (tp->snd_cwnd>>TCP_SCALABLE_MD_SCALE), 2U);
}

 
 

猜你喜欢

转载自blog.csdn.net/u013218035/article/details/88843438