TCP 四次挥手,第一次挥手报文丢失会发生什么?
TCP 四次挥手,第二次挥手报文丢失会发生什么?
TCP 四次挥手,第三次挥手报文丢失会发生什么?
客户端收到服务端的 FIN+ACK 报文后,会回给服务端 ACK 报文,如果第四次挥手报文丢失了,服务端就会触发「超时重传」机制,重新发送 FIN+ACK 报文,客户端是不会重传 ACK 报文的
下图以 Linux TCP 第四次挥手报文丢失为例,其中参数 tcp_orphan_retries 值为 2
/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;
}
Linux 内核提供参数 tcp_max_tw_buckets,当 TIME_WAIT 状态的连接数 > tcp_max_tw_buckets 时,新关闭的连接不再经历 2MSL 的等待过程