tcp拥塞分析六(HSTCP)

news/2024/5/17 19:51:45 标签: tcp, 拥塞算法

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

hstcp相对reno算法,通过一个与发送窗口相关的固定数组hstcp_aimd_vals,改变了拥塞避免阶段窗口增长逻辑,以及丢包后ssthresh的设置.也就是改了AIMD (Additive Increase Multiplicative Decrease)的发送窗口.

根据当前发送窗口snd_cwnd,找到数组位置i满足hstcp_aimd_vals[i-1]. cwnd < snd_cwnd <= hstcp_aimd_vals[i].cwnd.  


/* From AIMD tables from RFC 3649 appendix B,
 * with fixed-point MD scaled <<8.
 */
static const struct hstcp_aimd_val {
	unsigned int cwnd;
	unsigned int md;
} hstcp_aimd_vals[] = {
	{     38,  128, /*  0.50 */ },
	{    118,  112, /*  0.44 */ },
	{    221,  104, /*  0.41 */ },
	{    347,   98, /*  0.38 */ },
	{    495,   93, /*  0.37 */ },
	{    663,   89, /*  0.35 */ },
	{    851,   86, /*  0.34 */ },
	{   1058,   83, /*  0.33 */ },
	{   1284,   81, /*  0.32 */ },
	{   1529,   78, /*  0.31 */ },
	{   1793,   76, /*  0.30 */ },
	{   2076,   74, /*  0.29 */ },
	{   2378,   72, /*  0.28 */ },
	{   2699,   71, /*  0.28 */ },
	{   3039,   69, /*  0.27 */ },
	{   3399,   68, /*  0.27 */ },
	{   3778,   66, /*  0.26 */ },
	{   4177,   65, /*  0.26 */ },
	{   4596,   64, /*  0.25 */ },
	{   5036,   62, /*  0.25 */ },
	{   5497,   61, /*  0.24 */ },
	{   5979,   60, /*  0.24 */ },
	{   6483,   59, /*  0.23 */ },
	{   7009,   58, /*  0.23 */ },
	{   7558,   57, /*  0.22 */ },
	{   8130,   56, /*  0.22 */ },
	{   8726,   55, /*  0.22 */ },
	{   9346,   54, /*  0.21 */ },
	{   9991,   53, /*  0.21 */ },
	{  10661,   52, /*  0.21 */ },
	{  11358,   52, /*  0.20 */ },
	{  12082,   51, /*  0.20 */ },
	{  12834,   50, /*  0.20 */ },
	{  13614,   49, /*  0.19 */ },
	{  14424,   48, /*  0.19 */ },
	{  15265,   48, /*  0.19 */ },
	{  16137,   47, /*  0.19 */ },
	{  17042,   46, /*  0.18 */ },
	{  17981,   45, /*  0.18 */ },
	{  18955,   45, /*  0.18 */ },
	{  19965,   44, /*  0.17 */ },
	{  21013,   43, /*  0.17 */ },
	{  22101,   43, /*  0.17 */ },
	{  23230,   42, /*  0.17 */ },
	{  24402,   41, /*  0.16 */ },
	{  25618,   41, /*  0.16 */ },
	{  26881,   40, /*  0.16 */ },
	{  28193,   39, /*  0.16 */ },
	{  29557,   39, /*  0.15 */ },
	{  30975,   38, /*  0.15 */ },
	{  32450,   38, /*  0.15 */ },
	{  33986,   37, /*  0.15 */ },
	{  35586,   36, /*  0.14 */ },
	{  37253,   36, /*  0.14 */ },
	{  38992,   35, /*  0.14 */ },
	{  40808,   35, /*  0.14 */ },
	{  42707,   34, /*  0.13 */ },
	{  44694,   33, /*  0.13 */ },
	{  46776,   33, /*  0.13 */ },
	{  48961,   32, /*  0.13 */ },
	{  51258,   32, /*  0.13 */ },
	{  53677,   31, /*  0.12 */ },
	{  56230,   30, /*  0.12 */ },
	{  58932,   30, /*  0.12 */ },
	{  61799,   29, /*  0.12 */ },
	{  64851,   28, /*  0.11 */ },
	{  68113,   28, /*  0.11 */ },
	{  71617,   27, /*  0.11 */ },
	{  75401,   26, /*  0.10 */ },
	{  79517,   26, /*  0.10 */ },
	{  84035,   25, /*  0.10 */ },
	{  89053,   24, /*  0.10 */ },
};

AI阶段(拥塞避免阶段)增加的速度为i/snd_cwnd, 而不是reno中的acked/snd_cwnd.对于cwnd>38,且无延迟ack的时候会多占用带宽

MD阶段(超时丢包)减小ssthresh为snd_cwnd-hstcp_aimd_vals[i].md*snd_cwnd. (注意这里为了处理小数,实际操作ssthresh和md时有右移8位). 相比reno固定降一半(就是md=0.5),对于cwnd>38的时候,会多占用带宽.


static void hstcp_cong_avoid(struct sock *sk, u32 ack, u32 acked)
{
	struct tcp_sock *tp = tcp_sk(sk);
	struct hstcp *ca = inet_csk_ca(sk);

	if (!tcp_is_cwnd_limited(sk))
		return;

	if (tcp_in_slow_start(tp))
		tcp_slow_start(tp, acked);
	else {
		/* Update AIMD parameters.
		 *
		 * We want to guarantee that:
		 *     hstcp_aimd_vals[ca->ai-1].cwnd <
		 *     snd_cwnd <=
		 *     hstcp_aimd_vals[ca->ai].cwnd
		 */
		if (tp->snd_cwnd > hstcp_aimd_vals[ca->ai].cwnd) {
			while (tp->snd_cwnd > hstcp_aimd_vals[ca->ai].cwnd &&
			       ca->ai < HSTCP_AIMD_MAX - 1)
				ca->ai++;
		} else if (ca->ai && tp->snd_cwnd <= hstcp_aimd_vals[ca->ai-1].cwnd) {
			while (ca->ai && tp->snd_cwnd <= hstcp_aimd_vals[ca->ai-1].cwnd)
				ca->ai--;
		}

		/* Do additive increase */
		if (tp->snd_cwnd < tp->snd_cwnd_clamp) {
			/* cwnd = cwnd + a(w) / cwnd */
			tp->snd_cwnd_cnt += ca->ai + 1;
			if (tp->snd_cwnd_cnt >= tp->snd_cwnd) {
				tp->snd_cwnd_cnt -= tp->snd_cwnd;
				tp->snd_cwnd++;
			}
		}
	}
}

static u32 hstcp_ssthresh(struct sock *sk)
{
	const struct tcp_sock *tp = tcp_sk(sk);
	struct hstcp *ca = inet_csk_ca(sk);

	/* Do multiplicative decrease */
	return max(tp->snd_cwnd - ((tp->snd_cwnd * hstcp_aimd_vals[ca->ai].md) >> 8), 2U);
}

 


http://www.niftyadmin.cn/n/1000195.html

相关文章

LoadRunner如何监控Linux系统资源

LoadRunner如何监控Linux系统资源 一 简述&#xff1a;LoadRunner监控Linux资源时弹出如下错误&#xff1a; Monitor name :UNIX Resources. Cannot initialize the monitoring on 192.168.52.189. Error while creating the RPC client. Ensure that the machine can be conne…

关于bridge-nf-call-iptables的设计问题

分享一下我老师大神的人工智能教程&#xff01;零基础&#xff0c;通俗易懂&#xff01;http://blog.csdn.net/jiangjunshow也欢迎大家转载本篇文章。分享知识&#xff0c;造福人民&#xff0c;实现我们中华民族伟大复兴&#xff01;熟悉ebtables和iptables的都知道&#xff0c…

iOS网络加载图片缓存与SDWebImage

加载网络图片可以说是网络应用中必备的。如果单纯的去下载图片&#xff0c;而不去做多线程、缓存等技术去优化&#xff0c;加载图片时的效果与用户体验就会很差。 一、自己实现加载图片的方法 tips&#xff1a; *iOS中所有网络访问都是异步的.(自己开线程去下载) *普通为模型增…

程序框架的作用

2019独角兽企业重金招聘Python工程师标准>>> 一年之前的那段时间&#xff0c;我一直在维护一个断断续续持续了近5年的项目的程序&#xff0c;直观的印象的惨不忍睹&#xff0c;从未读过如此糟糕的代码。没有任何的设计&#xff0c;完全是想到哪里写到哪里。代码中细…

tcp拥塞分析七(scalble)

本文分析linux-4.19.12代码的scalble拥塞算法 hstcp相对reno算法&#xff0c;通过两个固定的值TCP_SCALABLE_AI_CNT和TCP_SCALABLE_MD_SCALE改变了拥塞避免阶段窗口增长速度&#xff0c;以及丢包后ssthresh的设置. /* These factors derived from the recommended values in …

leetcode解题报告:10 Regular Expression Matching

问题描述&#xff1a;给定字符串s与模式串p&#xff0c;其 p中.可以匹配s中任意字符&#xff0c;*可以匹配0个或者任意多个之前字符&#xff0c; 判断模式串p是否匹配全部字符串s&#xff08;不是部分&#xff09;。例子&#xff1a;isMatch("aa","a") → …

独立双 N 拥塞窗口的TCP单边加速思想

分享一下我老师大神的人工智能教程&#xff01;零基础&#xff0c;通俗易懂&#xff01;http://blog.csdn.net/jiangjunshow也欢迎大家转载本篇文章。分享知识&#xff0c;造福人民&#xff0c;实现我们中华民族伟大复兴&#xff01;让TCP以流水线方式工作靠谱吗&#xff1f;也…

ABAP开发顾问必备:SAP ABAP开发技术总结

该文档是根据我过去多年学习与工作经验总结而成&#xff0c;项目开发过程中我都会参考此文档&#xff0c;主要ABAP很多细节上的东西还是还多&#xff0c;不可能你记得很牢固&#xff0c;或者你记得一时&#xff0c;但过不了几天就会忘记&#xff0c;毕竟同一东西你不可能一直做…