What is the best way to keep unacknowledged data buffer (sender's buffer) in TCP?
I am thinking 开发者_C百科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
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.
精彩评论