Libre Gaming Infrastructure

Simple Reliable Messaging

Simple Reliable Messaging is a protocol designed to be implemented on top of reliable stream protocols such as TCP. SRM provides 2 key functions: clearly separating messages between each other and exchanging hearbeats to make sure that connection is still alive. The implementation must keep track of the time since the last arrived data and send heartbeats if there is no data for some time. After a few failed heartbeats the connection must be assumed to be broken and the underlying protocol must close the connection.


uint8_t Signature[N]

A signature is a sequence of bytes that is used to filter traffic for unwanted or incorrect messages. There are no constrains on the size of the signature, it may be 0 bytes long. The LGI signature is 4 bytes long with ASCII string “LGIP”:

uint8_t LGISignature[4] = {'L', 'G', 'I', 'P'}; /* 0x4C, 0x47, 0x49, 0x50 */


struct Message
	enum Type : uint8_t
		HeartbeatRequest = 0,
		HeartbeatAnswer = 1,
		Payload = 2

	Type type;
	switch (type)
		case Type::HeartbeatRequest:
		case Type::HeartbeatAnswer:
			/* Nothing */
		case Type::Payload:
			byte payload[0 ... 2^64-1];

If the signature does not match the one defined by application, the connection must be immediately closed.

Heartbeat request

If message of type HeartbeatRequest has arrived, you need to reply with HeartbeatAnswer message.

Heartbeat answer

If message of type HeartbeatAnswer has arrived, you can safely ignore it.


If message of type Payload has arrived, you need to read all bytes of payload and forward it to the application.