Sequence Number Management - Clearpool/Panda GitHub Wiki

Sequence Numbers

Sequence numbers are used by receivers to know if there has been any data lost from a sender.

Sending Rules

When a sender produces a Panda Packet, which may contain 1 or many application messages, the sender should generate a sequence number that honors the following rules:

  1. Senders should maintain the last sequence number sent per multicast ip + port.
  2. If a sender is sending the first packet for a multicast ip + port, its sequence number should be 1.
  3. Sequence number should be 1 greater than the previous sequence number sent for that multicast ip + port.

Receiving Rules

When a receiver consumes a Panda Packet, the receiver should validate the incoming sequence number (ISN) against the last seen sequence numbers (LSSN) that honors the following rules:

  1. Receivers should maintain the LSSN per sender/multicast ip/multicast port
  2. If a packet has an ISN of 1, consume the packet and set the LSSN for the sender to 1.
  3. If a packet has an ISN of any value, but the receiver doesn't have a known LSSN, consume the packet and set the LSSN to ISN.
  4. If a packet has an ISN that is 1 greater than the LSSN, consume the packet and set the LSSN to ISN.
  5. If a packet has an ISN that is more than 1 greater than the LSSN, then there has been packet loss. The receiver can choose to take on recovery or move on by setting the LSSN to ISN.

How to identify a sender

Sequence numbers in the Panda network are unique per: sender/multicast ip/multicast port. A receiver can identify a sender by checking the IP Header. A sender is uniquely identified by the following two properties:

  1. IP Header's source IP
  2. IP Header's source Port