TCP 四次挥手,第一次挥手报文丢失会发生什么?
TCP 四次挥手,第二次挥手报文丢失会发生什么?
服务端调用 close() 关闭连接时,会给客户端发送 FIN+ACK 报文,在这之后,如果服务端迟迟收不到客户端的 ACK 报文,就会触发「超时重传」机制,重新发送 FIN+ACK 报文
下图以 Linux TCP 第三次挥手报文丢失为例,其中参数 tcp_orphan_retries 值为 2

/* Linux Kernel 6.14.7 tcp.h */
#define TCP_TIMEWAIT_LEN (60*HZ) /* how long to wait to destroy TIME-WAIT
* state, about 60 seconds */
#define TCP_FIN_TIMEOUT TCP_TIMEWAIT_LEN
/* BSD style FIN_WAIT2 deadlock breaker.
* It used to be 3min, new value is 60sec,
* to combine FIN-WAIT-2 timeout with
* TIME-WAIT timer.
*/
/proc/sys/net/ipv4/tcp_orphan_retries 默认值为 0 是什么鬼?
实际上当为 0 时,特指 8 次
/* Linux Kernel 2.6.32 tcp_timer.c */
/* Calculate maximal number or retries on an orphaned socket. */
static int tcp_orphan_retries(struct sock *sk, int alive)
{
int retries = sysctl_tcp_orphan_retries; /* May be zero. */
/* We know from an ICMP that something is wrong. */
if (sk->sk_err_soft && !alive)
retries = 0;
/* However, if socket sent something recently, select some safe
* number of retries. 8 corresponds to >100 seconds with minimal
* RTO of 200msec. */
if (retries == 0 && alive)
retries = 8;
return retries;
}

被折叠的 条评论
为什么被折叠?



