如果 TCP 握手段丢失怎么办? [英] What if a TCP handshake segment is lost?

查看:41
本文介绍了如果 TCP 握手段丢失怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 TCP 3 次握手中,将发送 3 个段(SYN、SYN ACK、ACK).如果第三个段(ACK)丢失了怎么办?发送方是要重新发送该段还是放弃建立连接?两个主机怎么知道段丢失了?

In TCP 3-way handshake, 3 segments will be sent (SYN, SYN ACK, ACK). What if the third segment(ACK) is lost? Is the sender going to resend the segment or give up establishing the connection? And how do the two hosts know the segment is lost?

推荐答案

TCP 在所有数据包中都有一个序列号.因此,很容易知道数据包是否丢失.如果主机没有收到一个数据包的 ACK,他就会重新发送它.

TCP has a sequence number in all packets. Hence it's easy to know if a packet was lost or not. If a host doesn't get an ACK on a packet he just resends it.

尽管在大多数情况下,即使该 ACK 丢失,也不会出于非常简单的原因重新发送.在 ACK 之后,打开 TCP 协议的主机很可能开始发送数据.与所有 TCP 数据包一样,该数据将具有 ACK 编号,因此接收方将通过这种方式获得 ACK.因此,SYN-ACK 的发送者应该合理地不在乎它没有得到 ACK,因为它在以下包中得到了一个隐式"ACK.

In most cases though, even if that ACK was lost, there will be no resending for a very simple reason. Directly after the ACK, the host that opened the TCP protocol is likely to start sending data. That data will, as all TCP packets, have an ACK number, so the recipient would get an ACK that way. Hence, the sender of the SYN-ACK should reasonably not care that it didn't get the ACK, because it gets an "implicit" ACK in the following package.

SYN-ACK 的重新发送仅在没有接收到任何数据的情况下是必要的.

The re-send of the SYN-ACK is only necessary of there no data is received at all.

更新:我在 RFC 中找到了明确规定的地方:

Update: I found the place in the RFC that specified exactly this:

如果我们的 SYN 已经被确认(也许在这个传入段)传入段的优先级必须完全匹配本地优先级,如果它没有重置必须发送.

If our SYN has been acknowledged (perhaps in this incoming segment) the precedence level of the incoming segment must match the local precedence level exactly, if it does not a reset must be sent.

换句话说,如果 ACK 被丢弃但下一个数据包没有被丢弃,那么一切都很好.否则,必须重置连接.这完全有道理.

In other words, if the ACK is dropped but the next packet is not dropped, then everything is fine. Otherwise, the connection must be reset. Which makes perfect sense.

这篇关于如果 TCP 握手段丢失怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆