Skip to content

Protocol Specification (Draft)

Amir Nathoo edited this page Jan 6, 2025 · 3 revisions

Packet Structure

Header Format (35 bytes total)

- Protocol Version      (1 byte)  : Protocol version identifier
- Source Device ID      (4 bytes) : Origin device identifier
- Destination Device ID (4 bytes) : Final destination identifier
- Packet ID             (4 bytes) : Unique message identifier
- Topic                 (1 byte)  : Message type/purpose
- Device Type           (1 byte)  : Source device type
- Hop Count             (1 byte)  : Number of relays
- Data CRC              (4 bytes) : Payload integrity check
- Frame Counter         (4 bytes) : Sequence number  
- Last Hop ID           (4 bytes) : Previous relay identifier
- Next Hop ID           (4 bytes) : Next relay identifier
- Reserved              (3 bytes) : Future use

Message Topics

Reserved topics (0x00-0x0F):

- UNUSED          (0x00)
- PING            (0x01)
- PONG            (0x02)
- ACK             (0x03)
- CMD             (0x04)
- BYE             (0x05)
- INCLUDE_REQUEST (0x06)
- INCLUDE_RESPONSE(0x07)
- INCLUDE_OPEN    (0x08)
- INCLUDE_CONFIRM (0x09)
- INCLUDE_SUCCESS (0x0A)

Application topics start from 0x10.

Routing Mechanism

  • Adaptive routing based on signal strength (RSSI) and hop count
  • Route discovery through passive learning from packet traffic
  • Maximum hop limit (7 hops) to prevent endless packet circulation
  • Next hop selection using routing table with fallback to broadcast

Packet Processing

  1. Packet Reception

    • CRC validation
    • Duplicate detection using PacketTracker
    • Route table updates based on source/last hop information
  2. Packet Forwarding

    • Hop count increment
    • Next hop determination
    • Optional encryption
    • Route table consultation
  3. Packet Callbacks

    • RX Callback invoked after a packet is received: typedef void (*PacketReceivedCallback)(const RadioMeshPacket*, int);
    • TX Callback invoked after a packet is sent: typedef void (*PacketSentCallback)(const RadioMeshPacket*, int);

Device Types

  • STANDARD: Regular mesh nodes
  • HUB: Network coordinators
  • UNKNOWN: Uninitialized state

Clone this wiki locally