Chinaunix首页 | 论坛 | 博客
  • 博客访问: 579682
  • 博文数量: 353
  • 博客积分: 1104
  • 博客等级: 少尉
  • 技术积分: 1457
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-23 23:02
个人简介

1、刚工作时做Linux 流控;后来做安全操作系统;再后来做操作系统加固;现在做TCP 加速。唉!没离开过类Unix!!!但是水平有限。。

文章存档

2015年(80)

2013年(4)

2012年(90)

2011年(177)

2010年(1)

2009年(1)

分类:

2015-06-09 14:24:31

tcp_max_ssthresh 参数是实现RFC3742时引入的,离现在已经有4年的时间了。
07年5月内核实现了这个RFC。
但是,tcp的这个参数在内核文档(ip-sysctl.txt)中找不到任何的说明。
本文章就是说明这个参数的含义,以及是如何实现的。
(我向社区发送了Patch。URL:)

慢启动阶段,就是当前拥塞窗口值比慢启动阈值(snd_ssthresh)小的时候,所处的阶段就叫做慢启动阶段。
当我们收到一个新的ACK时,则会调用tcp_slow_start()这个函数,并且为拥塞窗口增加1.
(Linux中拥塞窗口的值代表数据包的个数,而不是实际的发送
字节数目。实际可以发送的字节数等于可以发送的数据包个数*MSS。)
直到慢启动阶段出现数据包的丢失。

而引入了tcp_max_ssthresh 这个参数后,则可以控制在慢启动阶段拥塞窗口增加的频度。
默认这个参数不打开,如果这个参数的值设置为1000,则当拥塞窗口值大于1000时,
则没收到一个ACK,并不再增加拥塞窗口一个单位了,而是约收到2个ACK才增加一个窗口单位。

注意:收到2ACK并不是决定值!!
需要根据当前的拥塞窗口值,tcp_max_ssthresh值进行判断。

具体实现看源码:
tcp_slow_start()是慢启动阶段调节拥塞窗口用的。
void tcp_slow_start(struct tcp_sock *tp)
{
int cnt; /* increase in packets */

/* RFC3465: ABC Slow start
* Increase only after a full MSS of bytes is acked
*
* TCP sender SHOULD increase cwnd by the number of
* previously unacknowledged bytes ACKed by each incoming
* acknowledgment, provided the increase is not more than L
*/
if (sysctl_tcp_abc && tp->bytes_acked < tp->mss_cache)//sysctl_tcp_abc默认是关闭的,我们可以跳过。
return;


//启用Limited Slow-Start。
//当前拥塞窗口值大于sysctl_tcp_max_ssthresh. 限制拥塞窗口增长值。
if (sysctl_tcp_max_ssthresh > 0 && tp->snd_cwnd > sysctl_tcp_max_ssthresh)
cnt = sysctl_tcp_max_ssthresh >> 1; /* limited slow start */
else
cnt = tp->snd_cwnd; /* exponential increase */

/* RFC3465: ABC
* We MAY increase by 2 if discovered delayed ack
*/
if (sysctl_tcp_abc > 1 && tp->bytes_acked >= 2*tp->mss_cache)
cnt <<= 1;
tp->bytes_acked = 0;

//最多增加1/2 sysctl_tcp_max_ssthresh字节。也就是说,最多2个ACK才
//能让拥塞窗口增加1.
tp->snd_cwnd_cnt += cnt;
while (tp->snd_cwnd_cnt >= tp->snd_cwnd) {
tp->snd_cwnd_cnt -= tp->snd_cwnd;
if (tp->snd_cwnd < tp->snd_cwnd_clamp)
tp->snd_cwnd++;//拥塞窗口最小只能增加1.
}
}
阅读(2557) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~