在 linux TCP 系统调用的上下文中,什么是 "incomplete connection request"?

In context of linux TCP system calls, what is an "incomplete connection request"?

listen() 的 linux 手册页说:

The behavior of the backlog argument on TCP sockets changed with Linux 2.2. Now it speci‐ fies the queue length for completely established sockets waiting to be accepted, instead of the number of incomplete connection requests. The maximum length of the queue for incomplete sockets can be set using /proc/sys/net/ipv4/tcp_max_syn_backlog. When syncook‐ ies are enabled there is no logical maximum length and this setting is ignored. See tcp(7) for more information.

在这种情况下,"completely established sockets" 与 "incomplete connection requests" 是什么意思?

当主机 A 发起到主机 B 的连接时,TCP 协议使用所谓的三向握手建立连接:

  • A 到 B:SYN
  • B 到 A:SYN + ACK
  • A 到 B:ACK

不完整的连接请求是已发送 SYN 的连接,但主机尚未收到 SYN-ACK(因为第一条或第二条消息或其重试丢失)。

这与 listen()、"Completely established sockets" 参数的当前语义不同,后者指定 TCP 协议已接受但应用程序未处理的连接数(带有accept()),可以在 TCP 忽略进一步的连接请求之前排队。

低电平

有一个点可以打开一个连接,那就是A面或者A点。 还有一个监听点,也就是服务器点,也就是B点。

A send to B a SYN packet
B response to A a SYN ACK packet
Then A response is a ACK packet.

连接现已建立。

如果有一步没有做出来,或者响应不是ACK,则连接未建立。

在建立连接之前,"connection" 在 "pending connections" 的列表中。

如果响应不是 ACK,则连接被取消并从挂起连接列表中删除。明显有错误。

但是假设最后一个ACK没有发送,而是有另一个新的连接。 这个挂起的连接正在等待响应,一个新的连接被添加到列表中。 它一直在列表中,直到响应到达,或达到超时。

列表中的连接数为"incomplete connection requests",成功建立的连接数为"completely established sockets"