user1047069
user1047069

Reputation: 953

TCP - received in wrong order

Is it possible to get TCP packets in wrong order, indicated by sequence number? What happens then in the receiving side? Is there any queue that holds pockets that arrived "too early", for instance?

Upvotes: 4

Views: 2691

Answers (1)

Ross Patterson
Ross Patterson

Reputation: 9570

Maybe. The receiving TCP engine has several choices about what to do. The only thing it cannot do is deliver the data in those out-of-order packets to the receiving process out of order.

  • The receiving TCP engine can discard the out-of-order data. Eventually, the sending TCP engine will retransmit them. Before that happens, it will certainly also retransmit the data in the gap. When the data in the gap arrives, the receiving engine can pass it to the receiving process in order.
  • The receiving TCP engine can save the out-of-order data. Eventually, either the data in the gap will arrive, or the sending TCP engine will retransmit it. Either way, the gap will get filled in and the receiving engine can pass all the data to the receiving process in order.
  • The receiving TCP engine can save the out-of-order data and hint to the sending TCP engine that it should retransmit the data in the gap. It does this by responding with a re-acknowledgement of the last in-order data byte received. This is what most TCP engines do.

Upvotes: 4

Related Questions