如果 TCP 握手段丢失怎么办?

编程入门 行业动态 更新时间:2024-10-27 04:24:35
本文介绍了如果 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 握手段丢失怎么办?

本文发布于:2023-07-09 14:56:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1087134.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:TCP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!