Every MAVLink packet has three logical sections: header, payload, and checksum (plus an optional signature in v2). Understanding the byte layout is essential for debugging with Wireshark or writing raw parsers.
text
── MAVLink 2 Packet ───────────────────────────────────────── Byte Field Size Description ───── ───────────────── ───── ──────────────────────────── 0 STX (magic) 1 Start marker: 0xFD (v2) 1 Payload length 1 Length of payload (0–255) 2 Incompat flags 1 Flags that must be understood 3 Compat flags 1 Flags that can be ignored 4 Packet sequence 1 Per-link sequence counter 5 System ID 1 Sender system (1–255) 6 Component ID 1 Sender component (1–255) 7-9 Message ID 3 24-bit message identifier 10+ Payload 0–255 Serialized message fields N Checksum 2 CRC-16/MCRF4XX + CRC_EXTRA N+2 Signature (opt) 13 Link ID + timestamp + SHA-256
CRC_EXTRA explained
Each message definition has a CRC_EXTRA seed derived from the XML schema (field names, types, order). The checksum includes this seed so that a parser can detect if it was compiled against a different version of the message definition — a form of schema validation on the wire.
In MAVLink 1, the header is simpler: STX (0xFE), length, sequence, sysid, compid, and a single-byte message ID. There are no flag bytes and no signing. The checksum algorithm is the same CRC-16/MCRF4XX with CRC_EXTRA.
text
── MAVLink 1 Packet ───────────────────────────────────────── Byte Field Size Description ───── ───────────────── ───── ──────────────────────────── 0 STX (magic) 1 Start marker: 0xFE (v1) 1 Payload length 1 0–255 2 Packet sequence 1 Per-link counter 3 System ID 1 Sender system 4 Component ID 1 Sender component 5 Message ID 1 8-bit message ID (0–255) 6+ Payload 0–255 Serialized fields N Checksum 2 CRC-16/MCRF4XX + CRC_EXTRA