Leviathan  0.8.0.0
Leviathan game engine
Format of Leviathan packets

Main packet format

This is the format of the packets that are received from the UDP socket and unpacked into objects.

Packet Format
Type PKT_ID Start Ack [Ack count] [Packed acks] Message count
uint16_t uint32_t uint32_t uint8_t uint8_t * Ack count uint8_t
Defines packet type Packet types ID number of packet. First is 1. 0 is invalid The PKT_ID of the first ack. Or 0 if no acks. If there are no acks the next 2 fields are missing. The number of bytes (uint8_t's) that are in Packed acks. Packed acks where each set bit specifies that Start ack + index inside acks + 1 PKT_ID has been received by the sender of this packet. Number of messages that follow. 0 means that there is no more data.

Message format

After the main packet format there is a specified number of messages (Message count). Messages can be in one of these valid formats:

Normal Response Message Format
Type MessageNumber ResponseType Response to Data
uint8_t uint32_t uint16_t uint32_t variable size
0x12 Identifier of this message. Starts at 1 Type of response from Leviathan::NETWORK_RESPONSE_TYPE MessageNumber of the request or 0 if not in response to anything Data that the Leviathan::NetworkResponse class will handle


Normal Request Message Format
Type MessageNumber RequestType Data
uint8_t uint32_t uint16_t variable size
0x28 Identifier of this message. Starts at 1 Type of request from Leviathan::NETWORK_REQUEST_TYPE Data that the Leviathan::NetworkRequest class will handle
See also
Leviathan::NetworkResponse Leviathan::NetworkRequest

Packet types

Packet Types
Type / Description HEX Code
Normal packet. Follows the rules in the packet format 0x4C6E (Ln)
Ack only packet. Ack Only Special Packet

0x4C61 (La)

New types for encrypted packets may be added later. Some message types (like login) will probably force the type to be encrypted.

Ack Only Special Packet
Type Ack Count Acks
uint16_t uint8_t uint32_t * Ack Count
0x4C61 Number of acks in this packet. Should always be > 0.
And less than 5 because at that point it would be better to send a full packet
The IDs of the packets that are being acknowledged