Skip to content

Common Header

The common header is the first stable skeleton users should understand.

Across the public design evolution, NNRP keeps two key principles in its common header model:

  1. Fixed length for fast and uniform parsing.
  2. A self-describing meta_len + body_len model for reliable byte-stream transport bindings.

The current common header is 40B. This page keeps the whole layout, the field summary, and the per-field notes in one place for continuous reading.

0-3magic4BASCII `NNRP`, used for quick protocol identification.
4version_major1BMajor protocol version.
5wire_format1BWire-level format selector for the current header and payload encoding.
6msg_type1BTop-level message family selector.
7header_len1BCurrently fixed at 40 bytes.
8-11flags4BPublic flags shared across message families.
12-15meta_len4BLogical length of fixed metadata.
16-19body_len4BLogical length of the body region.
20-23session_id4BSession anchor for default context and flow-control scope.
24-27frame_id4BStable work-unit anchor carried forward from the historical frame-oriented model.
28-29view_id2BLogical lane identifier. Rendering-oriented profiles may map it to a camera or view.
30-31route_id2BReserved for routing and scheduling expansion.
32-39trace_id8B64-bit trace identifier for cross-component observability.

Field Summary

FieldData TypeOffsetSizeDescriptionValue Range
magicASCII[4]04BProtocol magic used for fast NNRP packet identificationFixed to NNRP
version_majoru841BMajor protocol version that defines the top major-version boundary1-255, current public line is 1
wire_formatenum(u8)51BWire-level format selector for the current common-header and metadata/body encodingCurrent public value is 0, meaning the current NNRP/1 wire format
msg_typeenum(u8)61BTop-level message type that selects the fixed metadata and body interpretation pathExamples include CLIENT_HELLO, SESSION_OPEN, RESULT_PUSH, and FLOW_UPDATE
header_lenu871BCommon-header length used to confirm whether the header shape changedCurrently fixed to 40
flagsbitset(u32)84BShared flag bits for cross-message public state and reserved extensions0x00000000-0xffffffff
meta_lenu32124BLogical length of the fixed metadata region after the common header0-4294967295 bytes
body_lenu32164BLogical length of the body region after fixed metadata0-4294967295 bytes
session_idu32204BSession identifier that anchors default context, reusable state, and session-scope flow control0x00000000-0xffffffff
frame_idu32244BWork-unit or frame-level identifier used to correlate submissions and result streams0x00000000-0xffffffff
view_idu16282BLogical lane or view identifier for parallel observation surfaces or subchannels0x0000-0xffff
route_idu16302BRouting or scheduling extension field reserved for future policy and execution splits0x0000-0xffff
trace_idu64328BCross-message, cross-component, and cross-runtime tracing identifier0x0000000000000000-0xffffffffffffffff

Reading Path

  1. Start with magic / version_major / wire_format to understand protocol identification, the major-version boundary, and the current wire identity.
  2. Then read msg_type / header_len / flags / meta_len / body_len to understand how the header controls downstream parsing.
  3. Finish with session_id / frame_id / view_id / route_id / trace_id to understand context, scheduling, and observability anchors.

magic

FieldData TypeOffsetSizeDescriptionValue Range
magicASCII[4]04BProtocol magic used for fast NNRP packet identificationFixed to NNRP

Receivers should validate magic first. If it does not match, the packet should not continue through the NNRP parser.

version_major

FieldData TypeOffsetSizeDescriptionValue Range
version_majoru841BMajor protocol version that defines the top major-version boundary1-255, current public line is 1

version_major answers whether the peer can continue under the same public compatibility contract. It is not meant to be a business-level feature flag.

wire_format

FieldData TypeOffsetSizeDescriptionValue Range
wire_formatenum(u8)51BWire-level format selector for the current common-header and metadata/body encodingCurrent public value is 0, meaning the current NNRP/1 wire format

This field expresses which wire-level encoding the current packet uses. It is not a preview/stable stage marker and does not replace capability negotiation. In the current public implementation, the value is fixed to 0.

msg_type

FieldData TypeOffsetSizeDescriptionValue Range
msg_typeenum(u8)61BTop-level message type that selects the fixed metadata and body interpretation pathExamples include CLIENT_HELLO, SESSION_OPEN, RESULT_PUSH, and FLOW_UPDATE

If magic answers whether the packet is NNRP, msg_type answers how the rest of the packet should be interpreted.

header_len

FieldData TypeOffsetSizeDescriptionValue Range
header_lenu871BCommon-header length used to confirm whether the header shape changedCurrently fixed to 40

The public docs currently freeze the common header at 40B. If the public header shape ever expands, this field is the first guard rail a receiver sees.

flags

FieldData TypeOffsetSizeDescriptionValue Range
flagsbitset(u32)84BShared flag bits for cross-message public state and reserved extensions0x00000000-0xffffffff

flags works well for cross-cutting booleans that many message families need to check quickly. It is the wrong place for profile-private semantics.

meta_len

FieldData TypeOffsetSizeDescriptionValue Range
meta_lenu32124BLogical length of the fixed metadata region after the common header0-4294967295 bytes

meta_len is transport-neutral. It tells the receiver exactly how many bytes belong to fixed metadata before the body region begins.

body_len

FieldData TypeOffsetSizeDescriptionValue Range
body_lenu32164BLogical length of the body region after fixed metadata0-4294967295 bytes

body_len lets the same application-level framing model work across QUIC, TCP+TLS, and other reliable byte-stream bindings.

session_id

FieldData TypeOffsetSizeDescriptionValue Range
session_idu32204BSession identifier that anchors default context, reusable state, and session-scope flow control0x00000000-0xffffffff

Different msg_type families may place different requirements on session_id, but its long-term role is stable: it is the default-context anchor.

frame_id

FieldData TypeOffsetSizeDescriptionValue Range
frame_idu32244BWork-unit or frame-level identifier used to correlate submissions and result streams0x00000000-0xffffffff

The name is historical. The field survives because it is a stable work-unit anchor, not because the protocol is limited to rendering frames.

view_id

FieldData TypeOffsetSizeDescriptionValue Range
view_idu16282BLogical lane or view identifier for parallel observation surfaces or subchannels0x0000-0xffff

In rendering-oriented profiles it can map to a camera or view. In non-rendering profiles it can remain a pure logical lane, or simply stay 0 when no sub-view split exists.

route_id

FieldData TypeOffsetSizeDescriptionValue Range
route_idu16302BRouting or scheduling extension field reserved for future policy and execution splits0x0000-0xffff

Even if a current implementation does not expose advanced routing yet, route_id should still be treated as protocol-reserved space rather than application-private reuse.

trace_id

FieldData TypeOffsetSizeDescriptionValue Range
trace_idu64328BCross-message, cross-component, and cross-runtime tracing identifier0x0000000000000000-0xffffffffffffffff

trace_id is about observability, not business meaning. It allows the host, gateway, runtime, and cache layers to stitch the same interaction into one trace line.

This layer explains the long-lived common-header skeleton. It is not a substitute for the exact fixed metadata, descriptor, or flow-control layouts frozen by a specific preview page.

NNRP Documentation