为什么 TCP 一直在确认?

网络工程 通讯协议
2021-07-26 20:33:13

我了解 seq/ack 用于提供可靠的连接服务。但似乎在 TCP 数据传输期间,ACK 位始终设置,如下图所示。

假设 A 刚刚确认了来自 B 的一个数据包,现在 A 想要向 B 发送一些东西。 A 设置 B 已经知道的 ACK 位和 ACK 编号有什么意义?

一个相关的问题:总是将 ACK 控制段与数据段分开不是更清楚吗?

图片来自网络: 在此处输入图片说明

4个回答

acks 本身不被承认 - 所以你认为对等方已经知道看似冗余的 ack 中的信息的想法不一定是正确的..并且可以自由地以这种方式对其进行编码,因此这样做有助于防止重新传输丢失的acks而无需任何成本。

正如RFC 793所说:

确认编号。32 位。

如果设置了 ACK 控制位,则该字段包含该段的发送方期望接收的下一个序列号的值。 一旦建立了连接,这总是被发送。

正如其他人所说,不是将 ACK 字段留空,而是始终填充它。它不会“花费”任何东西,并且始终确保另一端知道接下来需要什么字节。

ACK 位表示此数据包中的确认编号有效。在 SYN 数据包中,还没有来自另一端的 SEQ#,因此没有什么可确认的。确认字段中有一个零,但它只是一个占位符(有些解码器显示它有些不显示,但您可以在十六进制中看到它)。第一个数据包之后的每个数据包都将设置 ACK 位。每个数据包都有一个 SEQ 和 ACK 编号,所以总是有一个有效的 ACK,即使 ACK 与最后一个 ACK​​ 相同。

ACK 位连续用作传输数据过程的一部分。

由于 TCP 的目的是成为一个可靠的协议,因此它必须有某种方式来确认所有数据都已正确接收。与确认编号相关联的 ACK 用于执行此操作。

来自RFC793

可靠性:

The TCP must recover from data that is damaged, lost, duplicated, or
delivered out of order by the internet communication system.  This
is achieved by assigning a sequence number to each octet
transmitted, and requiring a positive acknowledgment (ACK) from the
receiving TCP.  If the ACK is not received within a timeout
interval, the data is retransmitted.  At the receiver, the sequence
numbers are used to correctly order segments that may be received
out of order and to eliminate duplicates.  Damage is handled by
adding a checksum to each segment transmitted, checking it at the
receiver, and discarding damaged segments.

As long as the TCPs continue to function properly and the internet
system does not become completely partitioned, no transmission
errors will affect the correct delivery of data.  TCP recovers from
internet communication system errors.

流量控制:

TCP provides a means for the receiver to govern the amount of data
sent by the sender.  This is achieved by returning a "window" with
every ACK indicating a range of acceptable sequence numbers beyond
the last segment successfully received.  The window indicates an
allowed number of octets that the sender may transmit before
receiving further permission.