Chinaunix首页 | 论坛 | 博客
  • 博客访问: 155897
  • 博文数量: 41
  • 博客积分: 2500
  • 博客等级: 少校
  • 技术积分: 425
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-14 10:16
文章分类
文章存档

2011年(1)

2010年(5)

2009年(35)

我的朋友

分类: LINUX

2009-08-12 11:44:24

tcp.c文件的tcp_retransmit_time函数

978计划工作组 2009-8-12

1函数源码

/*

 *   This is the normal code called for timeouts.  It does the retransmission

 *   and then does backoff.  tcp_do_retransmit is separated out because

 *   tcp_ack needs to send stuff from the retransmit queue without

 *   initiating a backoff.

 */

void tcp_retransmit_time(struct sock *sk, int all)

{

       tcp_do_retransmit(sk, all);

 

       /*

        * Increase the timeout each time we retransmit.  Note that

        * we do not increase the rtt estimate.  rto is initialized

        * from rtt, but increases here.  Jacobson (SIGCOMM 88) suggests

        * that doubling rto each time is the least we can get away with.

        * In KA9Q, Karn uses this for the first few times, and then

        * goes to quadratic.  netBSD doubles, but only goes up to *64,

        * and clamps at 1 to 64 sec afterwards.  Note that 120 sec is

        * defined in the protocol as the maximum possible RTT.  I guess

        * we'll have to use something other than TCP to talk to the

        * University of Mars.

        *

        * PAWS allows us longer timeouts and large windows, so once

        * implemented ftp to mars will work nicely. We will have to fix

        * the 120 second clamps though!

        */

 

       sk->retransmits++;

       sk->backoff++;

       sk->rto = min(sk->rto << 1, 120*HZ);

       reset_xmit_timer(sk, TIME_WRITE, sk->rto);

}

2函数用途

重新设置重传计时器。

3语句注释

3.1 tcp_do_retransmit(sk, all);

此函数功能为TCP 协议数据包超时重传,具体参见《tcp.c文件的tcp_do_retransmit函数(6.doc

all值为0,则表示只发送一个数据包后即可退出。

3.2 sk->retransmits++;

       sk->backoff++;

sk->retransmits:重传计数

sk->backoff:退避计数,只做了退避次数的统计,并未根据退避的次数做其他工作。

3.3 sk->rto = min(sk->rto << 1, 120*HZ);

sk->rto<<1重传计时器时间乘以2

120*HZ2 分钟。

min(sk->rto<<1,120*HZ)此句为指数退避重传时间算法,即下一次数据包重传时间间隔为前一次的两倍,但不能超过2分钟上限

3.4  reset_xmit_timer(sk, TIME_WRITE, sk->rto);

TIME_WRITE:重传类型中的超时重传。

sk->rto:重传计时器时间,即延时时间值。 

阅读(1084) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~