发送方缓冲区中未确认数据的 TCP 表示

发布于 2024-10-05 16:39:38 字数 132 浏览 0 评论 0原文

在 TCP 中保留未确认数据缓冲区(发送方缓冲区)的最佳方法是什么?

我在考虑保留数据本身和保留数据包(标头+数据)之间?

如果我只保留数据字节而不是保留数据包,那么数据包的重传似乎会很困难。

语言:C

What is the best way to keep unacknowledged data buffer (sender's buffer) in TCP?

I am thinking between keeping data itself, and keeping packets(header + data)?

It seems retransmission of packets would be hard if I keep just data bytes as opposed to keeping packets.

Language: C

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

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

发布评论

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

评论(1

顾铮苏瑾 2024-10-12 16:39:38

数据包边界在 TCP 中毫无意义:数据包的一半数据可能被确认(例如由于碎片),然后您必须重新传输剩余的一半。

所以答案是:你应该保留原始数据,而不是数据包。您应该问的真正问题是:我如何知道哪些数据已被确认。窗口中的每个数据字节都需要一个位掩码,并且可以将已确认的数据标记为 1,其余数据标记为 0。每当您发现窗口开头的连续数据块已被确认时,该部分可以滑出。

Packet boundaries are meaningless in TCP: it's possible for half of a packet's data to be acknowledged (say due to fragmentation) and then you would have to retransmit the remaining half.

So the answer is: you should keep raw data, not packets. The real question you should be asking is: how do I know what data has been acknowledged. You need a bit-mask for each byte of data in your window, and you could mark acknowledged data as 1 and the rest as 0. Whenever you find that a contiguous block of data from the beginning of your window has been acknowledged, that portion can be slid out.

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