发送方缓冲区中未确认数据的 TCP 表示
在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
数据包边界在 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.