谁能解释一下接收方如何知道两个不连续的 TCP 段是否属于同一个数据包?

发布于 2024-12-04 14:55:41 字数 70 浏览 0 评论 0原文

谁能解释一下接收方如何知道两个不连续的 TCP 段属于相同还是不同的数据包?它如何知道下一个分段是否是数据包中的最后一个分段?

Can anybody explain how does the receiver know if two nonconsecutive TCP segments belong to the same or different packets ? And how does it know if the next segment is the last segments in the packet ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

世界如花海般美丽 2024-12-11 14:55:41

接收方并不将 TCP 段组装成数据包,而是将它们组装成流。接收方通过其序列号知道其接收到的段在流中的位置。

您是否可能期望接收应用程序的 read() 系统调用的计数结果符合发送应用程序的 write() 系统调用?如果是这样,你会失望的。 TCP 流是字节流,而不是数据包流。它们既不保留也不尊重发送系统调用的边界。

The receiver doesn't assemble TCP segments into packets, it assembles them into streams. The receiver knows the location, in the stream, of its received segment by its sequence number.

Is it possible that you are expecting the count result of the receiving application's read() system call to conform to the sending application's write() system call? If so, you will be disappointed. TCP streams are byte-wise, not packet-wise, streams. They neither preserve nor honor the boundaries of the sending system calls.

卸妝后依然美 2024-12-11 14:55:41

TCP 不处理碎片。那是IP问题。数据包仅在完成后才到达 TCP 级别。 IP 在标头中使用特殊字段来指示数据包是否已分片,如果是,则指示收到的分片是否是最后一个分片。

您可以看一下:
传输控制协议
互联网协议

TCP does not deal with fragmentation. That's an IP problem. Packets arrive at the TCP level only when complete. IP uses special fields in the header that indicates whether the packet is fragmented or not, and, if yes, whether the fragment received is the last one or not.

You may take a look :
Transmission Control Protocol
Internet Protocol

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文