I was wondering how exactly does TCP implement in-order delivery.
lets say this is list of events
Can you describe to me what exactly happens sequentially?
The short answer is that each packet contains offset information (disguised as sequence number), specifying where in the stream its payload lies.
Let's say the following occurred: packet 1 is received, packet 2 is not received, and packet 3 and 4 are received. At this point receiving TCP stack knows where to copy contents of packets 3 and 4 on the buffer, and it knows that it still hasn't received prior data, so it will make packet 1 data available for reading, but it won't make packet 3 or 4 data available until packet 2 is received.
Transmitting TCP stack generally does not wait for acknowledgements for any single packet before sending out the next one, but if it does not receive an acknowledgement for a given packet (and ACKs can and are bundled together in a single packet for efficiency), it will retransmit it until an ACK is received.
Exact sequence of events depends on network conditions, TCP stack implementation, chosen TCP policy, socket options and other factors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With