全部博文(41)
分类: LINUX
2009-08-12 11:44:24
tcp.c文件的tcp_retransmit_time函数
978计划工作组
/*
* 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
*
*
* 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);
}
重新设置重传计时器。
此函数功能为TCP 协议数据包超时重传,具体参见《tcp.c文件的tcp_do_retransmit函数(6).doc》
all:值为0,则表示只发送一个数据包后即可退出。
sk->retransmits:重传计数。
sk->backoff:退避计数,只做了退避次数的统计,并未根据退避的次数做其他工作。
sk->rto<<1:重传计时器时间乘以2。
120*HZ:2 分钟。
min(sk->rto<<1,120*HZ):此句为指数退避重传时间算法,即下一次数据包重传时间间隔为前一次的两倍,但不能超过2分钟上限。
TIME_WRITE:重传类型中的超时重传。
sk->rto:重传计时器时间,即延时时间值。