文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>tcp.c文件的tcp_retransmit_time函数(8)

tcp.c文件的tcp_retransmit_time函数(8)

时间:2009-08-12  来源:978计划

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*HZ:2 分钟。

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

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

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

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

相关阅读 更多 +
排行榜 更多 +
Event Horizon

Event Horizon

飞行射击 下载
Counter Terrorist Sniper Shoot

Counter Terrorist Sniper Shoot

飞行射击 下载
Special Agent

Special Agent

飞行射击 下载