Can please someone one explain how to deal with out-of-order packets. I'm using raw socket to capture packets, and parse them as they come, but some of them come in wrong order, for example:
- Id...........Flags
- 16390 : (PSH, ACK)
- 16535 : (PSH, ACK)
- 16638 : (ACK)
- 16640 : (PSH, ACK)
- 16639 : (ACK)
- 16695 : (PSH, ACK)
Packets with IDs: 16390, 16535, 16695 are separate packets and can be processed freely Packets with IDs: 16638, 16640, 16639 are a sequence of packets and should be put in ascending order before parsing.
To make it worse packets with Push flag sometimes come first so I just pass them along to parser, and then packet that preceds it comes and parser just discards it as corrupted.
Is there any way to deal with it?