I am trying to currently deal with IP packet fragmentation. I need to somehow flag fragmented packets with some value (sort them to a bucket according to some information), but I receive them after they're fragmented. I can't assure the order of the arriving fragments, nor that I'll receive fragments for each in order. For example, for packets A, B and C I can receive fragments in the following order: A1, B1, B2, C1, A2, C2, B3, C4, C3, A4, A3... I can't assume anything.
Now I'm using the simplest method available, and saving these fragments in lists. My question is, when (And whether it's even possible) can I know that all of the fragments of a specific packet have been arrived and that I can discard this packet from my cache? I'm probably missing something in the IP header field...
Thank you for your help.