What should be the way to design code for such a situation?
Off the top of my head...

Given a Packet, encode both the slot and count into the number
with known limits.... a code can be computed ...
and both the Sender and Receiver know what the limits are.

For example: 5 slots, and 7 possible counts (max count from 0..6 is 7 )

A CODE to determine what slot and count in that slot when it arrives

Code = Count_in_slot + (slot_number * (Max_Counts ) )  

   Table of example CODES that could be sent or received

Slot            n counts 
       0   1   2   3   4   5   6 
      --- --- --- --- --- --- --- 
 0     0   1   2   3   4   5   6
 1     7   8   9  10  11  12  13 
 2    14  15  16  17  18  19  20
 3    21  22  23  24  25  25  27
 4    28  29  30  31  32  33  34


Decode a Slot  and count from the number : 

 Sequence Initialize all ZERO's

 for each Code received
   temp  = Code
   Count = temp mod max_count  (NOTE: Remainder of a division (Modular math )
   temp  = temp \ max_count    (NOTE: integer divide)
   Slot  = temp mod Number_of_slots
   Sequence(Slot) = Count


And when either all slots are received, or max time wait occurs the reconstructed sequence is completed.

ALSO NOTE:
 If time delay is used to close the sequence, then slots with ZERO do not need to be sent.