This document defines the on-wire frame structure currently used by MTRP.
This document describes:
An MTRP frame consists of:
Only the serialized header, payload, and optional CRC are transmitted on the wire.
Local metadata is not serialized as part of the MTRP frame.
In native mode, the serialized frame layout is:
Flags (1 byte)Version (1 byte)Payload Length (2 bytes)Message ID (2 bytes)Origin Node ID (2 bytes)Destination Node ID (2 bytes)Previous Hop Node ID (2 bytes)Network ID (2 bytes)TTL (1 byte)Payload (variable)CRC16 (optional, 2 bytes, only if WITH_CRC is set)Native header length is 15 bytes.
In constrained mode, the serialized frame layout is:
Flags (1 byte)Version/Length (1 byte)Message ID (2 bytes)Origin Node ID (2 bytes)Destination Node ID (2 bytes)Previous Hop Node ID (2 bytes)Network ID (2 bytes)TTL (1 byte)Payload (variable)CRC16 (optional, 2 bytes, only if WITH_CRC is set)Compact header length is 13 bytes.
The current serialized field order is identical in both modes after the first header bytes.
| Order | Native | Compact | Size | Notes |
|---|---|---|---|---|
| 1 | Flags | Flags | 1 byte | protocol flags |
| 2 | Version | Version/Length | 1 byte | compact mode packs version and payload length together |
| 3 | Payload Length | Message ID | 2 bytes in native | compact mode does not store payload length separately |
| 4 | Message ID | Origin Node ID | 2 bytes | per-origin message identifier |
| 5 | Origin Node ID | Destination Node ID | 2 bytes | original sender |
| 6 | Destination Node ID | Previous Hop Node ID | 2 bytes | intended recipient |
| 7 | Previous Hop Node ID | Network ID | 2 bytes | most recent forwarding node |
| 8 | Network ID | TTL | 2 bytes native / 1 byte compact | logical network identifier |
| 9 | TTL | Payload | 1 byte | remaining hop count |
For clarity, the actual compact order on wire is:
The flags byte carries protocol behavior bits.
Current flags are:
| Bit Mask | Name | Meaning |
|---|---|---|
0x01 | RELIABLE | frame requests acknowledgment |
0x02 | ACK | frame is an acknowledgment |
0x04 | FRAGMENT | frame is a fragment |
0x08 | SECURE | frame is secured/encrypted |
0x10 | RELAY_REQ | frame is intended for relaying |
0x20 | IS_CONTROL | frame carries control-plane content |
0x40 | IS_COMPACT | frame uses compact header format |
0x80 | WITH_CRC | frame includes trailing CRC16 |
The version field identifies the protocol/header format in use.
In native mode, version occupies one full byte.
In compact mode, version occupies the upper 3 bits of the combined Version/Length byte.
A received frame MUST match the implementation's configured protocol version.
In native mode, payload length is stored as a 16-bit value.
In compact mode, payload length is stored in the lower 5 bits of the combined Version/Length byte.
As currently implemented, compact mode payload length is limited to 31 bytes.
The message ID is a per-origin identifier used for duplicate suppression and message tracking.
The origin node ID identifies the original sender of the frame.
The destination node ID identifies the intended recipient of the frame.
The previous hop node ID identifies the node that most recently forwarded or transmitted the frame.
The network ID distinguishes one logical MTRP network from another.
The TTL field limits how many forwarding hops a frame may traverse.
In compact mode, the second header byte is packed as follows:
| Bit Range | Meaning |
|---|---|
| bits 7..5 | version |
| bits 4..0 | payload length |
Equivalent expression:
version = (byte ยป 5) & 0x07payloadLength = byte & 0x1FThis means:
The payload immediately follows the serialized header.
Payload length is determined by the serialized length field.
The payload may carry:
If the WITH_CRC flag is set, the frame includes a trailing 16-bit CRC after the payload.
Current behavior:
header + payload
If WITH_CRC is not set, no CRC footer is serialized.
On receive:
IS_COMPACT determines whether compact or native header parsing is usedWITH_CRC is set, CRC validation MUST succeedA frame that fails these checks MUST be rejected.
MTRP also carries internal metadata that is not serialized on wire.
Examples include:
These values exist only for local router behavior.
IS_COMPACT flag on wireWITH_CRC flag