谁能解释一下接收方如何知道两个不连续的 TCP 段是否属于同一个数据包?
谁能解释一下接收方如何知道两个不连续的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
接收方并不将 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'swrite()
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.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