Multicast Message Framing - Clearpool/Panda GitHub Wiki

Multicast Message Framing


------------------------------------------
| Header (11 bytes) | Payload (variable) |
------------------------------------------

Header

------------------------------
| HL | SR | SEQ# | MSG COUNT |  
------------------------------

HL - Header Length

Size = 1 byte
Type = byte
Possible Values = 11

This is used to define length of the header excluding any topic or message information. We have a header length in case future versions have different header sizes.

SR - Supports Re-transmission

1 byte
Type = boolean
Possible Values = [0 = FALSE, 1 = TRUE]

Indicates if the sender of the packet supports re-transmissions. In case the receiver loses data, this flag indicates to the receiver that the sender caches data prior to sending. If TRUE, the receiver has the option to make a TCP re-transmission request. If FALSE, the receiver should not send a request because it will be denied.

SEQ# - Sequence Number

8 bytes
Type = Big Endian long
Possible Values = [1, 2^63 - 1]

Each Panda frame sent by a sender will be stamped with a sequence number starting with 1. Each subsequent packet will be sent with previous value plus one. If the sender restarts their instance, it is assumed that they will begin at 1. The receivers should take this as a signal to clear any state for that sender and reset the sequence count. If a receiver ever receives a sequence count that is less than the previous AND is not 1, it should be considered an out of sequence packet and should be discarded if the receiver has already processed that sequence. If a receiver receives a sequence that is ahead of the last sequence by more than 1, the receiver should queue the data before declaring a drop; this allows for out of sequence packets to come in and fill in the gap. The receiver should identify a unique receiver by their source IP + source PORT tuple. This will be guaranteed to be unique even if the sender host have multiple panda adapter instances.

MSG COUNT - Message Count

1 byte
Type = byte
Possible Values = [1, 127]

A single Panda frame can contain multiple message payloads. This defines how many will be in the Panda frame.

Payload

| MSG 1 TL | MSG 1 TOPIC | MSG 1 PL | MSG 1 PAYLOAD |  
| MSG 2 TL | MSG 2 TOPIC | MSG 2 PL | MSG 2 PAYLOAD |  
| ........ | ........... | ........ | ............. |    
| MSG N TL | MSG N TOPIC | MSG N PL | MSG N PAYLOAD |  

MSG TL - Message Topic Length

1 byte
Type = byte
Possible Values = [1, 127]

Defines the number of ascii characters in the topic string of the payload.

MSG TOPIC - Message Topic

n bytes
Type = String
Possible Values = n ASCII characters

Each payload will have a topic associated with it when calling PandaAdapter.send. This topic is a descriptor of what's in the payload. This allows for a subscriber to quickly filter out any unwanted data from being delivered to the application. When a subscriber subscribes, they subscribe to a multicast channel and a topic. Even though in Java a character in a String is composed of two bytes, this assumes the topic does not implment Extended ASCII characters.

MSG PL - Message Payload Length

2 bytes
Type = Big Endian Short
Possible Values = [1, 32,767]

Defines the number of bytes consumed by the packet payload in bytes.

MSG PAYLOAD- Message Payload

m bytes
Type = byte[]

Defines the byte array that needs to be published by the sender.