Skip to content
CVL COREEngine

Authoritative Binary Wire Protocol & Master Opcodes

[SPECIFICATION] Binary Wire Protocol Invariant

The CVL CORE Binary Wire Protocol defines the deterministic, Little-Endian network transport contract bridging the Authoritative Spatial Micro-Kernel and the CVL CORE Presentation Bridge. Engineered for high-density 3D spatial tracking across autonomous robotics, AGV logistics corridors, and virtual worlds ("The Crucible"), the protocol enforces a two-phase admission state machine, zero-allocation blittable struct marshaling, and asymmetric egress conflation to sustain 500 Full Broadcasting concurrent kinematic proxies with minimal bandwidth overhead.


[SEC 01.0] Executive Architecture & Subsystem Topology

Section titled “[SEC 01.0] Executive Architecture & Subsystem Topology”

The transport layer eliminates JSON serialization overhead, dynamic string allocations, and reflection-based parsing on the simulation hot path. All multi-byte primitives serialize strictly in Little-Endian byte order, allowing client and server runtimes to cast raw network buffers directly into contiguous memory structures.

[INVARIANT] Two-Phase Admission & Binary Promotion Gate
Section titled “[INVARIANT] Two-Phase Admission & Binary Promotion Gate”

Network connections transition through a strict two-phase parser managed by the Asymmetric Network Reactor and the Session Admission Controller:

  • Phase 1 (ASCII Handshake & Parity Gate): Unauthenticated sockets initialize in a bounded, newline-delimited (\n) ASCII parsing state. The client dispatches an authentication envelope containing its requested identity prefix and an 8-character hexadecimal IEEE 802.3 CRC32 hash (ATH:{cleanName}:{crcHash:X8}\n). Inbound Phase 1 buffers are strictly capped at 1,024 bytes; streams exceeding this ceiling without a newline terminator are immediately severed to neutralize buffer-exhaustion vectors.
  • Boot-Time Structural Parity Verification: Prior to establishing a session or loading client scenes, both endpoints compute a canonical IEEE 802.3 CRC32 digest across all active wire stride lengths and header dimensions (ProtocolConstants.ComputeProtocolCRC32()). Any structural divergence between the client SDK and the micro-kernel triggers an immediate ERR_PROTOCOL_VERSION_MISMATCH rejection prior to binary promotion.
  • Phase 2 (High-Velocity Binary Stream): Once structural parity is verified and world geometry is hydrated (CHR\n), the connection promotes to Phase 2. The parser switches to a zero-copy binary stream reader that evaluates Byte 0 as a symbolic look-ahead opcode, unpacking deterministic fixed-length strides directly into lock-free Single-Producer Single-Consumer (SPSC) ingress conduits.
[INVARIANT] Fixed 16-Byte Identity Tokens & Dual-ID Addressing
Section titled “[INVARIANT] Fixed 16-Byte Identity Tokens & Dual-ID Addressing”

To prevent variable-length string parsing during 30Hz simulation ticks, the wire protocol enforces a two-tier addressing taxonomy:

  1. Permanent Entity Identifier (EID): Every admitted entity is assigned a globally unique identifier padded or truncated to an immutable 16-byte UTF-8/ASCII byte array on the wire. Identity collisions are resolved automatically during admission via sequential numeric suffixing clamped strictly to the 16-byte boundary.
  2. Ephemeral Network Identifier (NetID): During Phase 1 admission, the server leases an unsigned 16-bit integer (uint16, range 1 to 65535, with 0 reserved as unassigned). High-frequency kinematic broadcasts (OP_BROADCAST), vitals streams (OP_VITALS), and discrete actions reference this compact 2-byte NetID on the wire. The client Presentation Bridge automatically resolves NetID tokens back to permanent EID strings before firing public developer events.
[PROTOCOL] Protected Binary Layout & SDK Encapsulation
Section titled “[PROTOCOL] Protected Binary Layout & SDK Encapsulation”

In accordance with commercial security and competitive defense standards, raw hexadecimal opcode assignments, internal bitfield packing masks, and exact byte-offset struct strings are encapsulated inside the pre-compiled CVL CORE Presentation Bridge headers (ProtocolConstants.cs). Public integration code interacts exclusively with symbolic constants and strongly typed event payloads.


[SEC 02.0] Concurrency & State Ownership / Lifecycle

Section titled “[SEC 02.0] Concurrency & State Ownership / Lifecycle”

The Authoritative Simulation Orchestrator and the Unity Main Thread execute zero operating system socket syscalls. All network I/O, stream reassembly, and buffer management are isolated within dedicated background reactor threads communicating across lock-free ring buffers and SPSC queues.

Architecture: Dual-Phase Wire Pipeline & Asymmetric Egress Conflation
+-----------------------------------------------------------------------------------+
| CLIENT PRESENTATION BRIDGE (SDK) |
| |
| [30Hz Fixed-Step Sampler] ---> Quantize (x30 / x10) ---> [Egress ConcurrentQueue]|
| | |
| [65,536-Slot Spatial Ring] <-- MemoryMarshal.Cast <----- [Background Rx Thread] |
+---------------------------------------------------------------------|-------------+
|
Little-Endian Binary TCP Stream | (TCP_NODELAY)
(IEEE 802.3 CRC32 Parity Verified) v
+-----------------------------------------------------------------------------------+
| CVL CORE ASYMMETRIC NETWORK REACTOR |
| |
| [Pre-Allocated Rx Buffer] ---> In-Place Frame Slide ---> [Byte 0 Opcode Demux] |
| | | |
| +---> (OP_TELEMETRY) -------> [Kinematics Ingress Conduit] | |
| +---> (OP_CLIENT_ACTION) ---> [Actions Ingress Conduit] | |
| +---> (OP_PING / ASCII) ----> [Control Ingress Conduit] | |
| +---> (OP_GAME_EVENT) ------> [Sidecar IPC Ingress Conduit]| |
| v |
| [Dual-Buffered Egress Multiplexer] <==================== [Egress Command Conduit]|
| | |
| +---> 1. Critical FIFO Buffer (OP_SET_POS, OP_BUNDLE, OP_REMOVE, Vitals) |
| +---> 2. Keyed Conflation Buffer (15Hz OP_BROADCAST Spatial Overwrite) |
+-----------------------------------------------------------------------------------+
[INGRESS] Ingress Demultiplexing & In-Place Stream Realignment
Section titled “[INGRESS] Ingress Demultiplexing & In-Place Stream Realignment”

Inbound TCP streams are ingested into pre-allocated memory buffers without intermediate heap allocations:

  • Five-Lane SPSC Demultiplexing: As complete binary frames are validated, the reactor routes primitive tuples directly into five isolated ingress conduits: the Kinematics Ingress Conduit (OP_TELEMETRY), the Actions Ingress Conduit (OP_CLIENT_ACTION), the Control Ingress Conduit (ASCII handshakes and OP_PING), the Teardown Ingress Conduit (socket resets and LOGOUT tokens), and the Sidecar Ingress Conduit (OP_GAME_EVENT).
  • Zero-Copy Residual Sliding: When a TCP read ends on a partial frame boundary, unparsed trailing bytes are slid to index 0 in-place within the pre-allocated receive buffer, completely eliminating byte-array slicing allocations and garbage collection pressure.
  • Reactor Flood Circuit Breakers: The binary parser enforces inline rate governors at the socket boundary. Inbound telemetry frames exceeding 45Hz are dropped inline; sustained floods exceeding 60Hz or control packet bursts exceeding 10 packets/sec increment per-connection flood strikes, automatically severing the descriptor and recording a 60.0-second IP penalty box ban upon crossing the strike threshold.
[EGRESS] Dual-Buffered Asymmetric Egress Conflation
Section titled “[EGRESS] Dual-Buffered Asymmetric Egress Conflation”

While the Authoritative Simulation Orchestrator evaluates kinematics and broadphase collisions at a deterministic 30Hz (33.3 ms frame budget), the outbound pipeline decouples simulation frequency from network transmission via a BROADCAST_DIVIDER = 2 cadence:

  • Priority 1 — Critical FIFO Buffer: Discrete state transitions—including initial peer hydration bundles (OP_BUNDLE), authoritative coordinate overrides (OP_SET_POS), entity evictions (OP_REMOVE), flash vitals deltas (OP_FLASH_DAMAGE), and Sidecar RPC responses (OP_GAME_EVENT)—append into a strict First-In, First-Out (FIFO) critical buffer. These frames are guaranteed never to be overwritten or dropped.
  • Priority 2 — Keyed Spatial Conflation Buffer: Outbound 15Hz world movement frames (OP_BROADCAST) route into a keyed conflation slot. If a client socket experiences transient congestion, subsequent 15Hz spatial broadcasts overwrite the stagnant kinematic payload in-place. Upon socket write-readiness, the reactor flushes the Critical FIFO Buffer to completion before transmitting the single most recent spatial snapshot, cutting outbound bandwidth by over 50% and eliminating historical queue lag.

[SEC 03.0] Master Symbolic Opcode Taxonomy & Wire Mechanics

Section titled “[SEC 03.0] Master Symbolic Opcode Taxonomy & Wire Mechanics”

All wire frames are governed by symbolic definitions in ProtocolConstants.cs. The protocol categorizes frames into four operational domains: Spatial Kinematics, Lifecycle & World State, Vitals & Discrete Actions, and Out-of-Process Sidecar RPC.

Symbolic Constant Direction Cadence / Trigger Stride Profile Primary Functional Responsibility
OP_BROADCAST Server -> Client 15Hz Conflated 7B Header + 10B or 18B Strides Bulk world spatial transform synchronization across active proxies.
OP_TELEMETRY Client -> Server 30Hz Fixed-Step 16B Fixed Envelope Quantized local proxy position, orientation, speed, sequence, and epoch.
OP_SET_POS Server -> Client Event-Driven 32B Fixed Envelope Authoritative coordinate rollback, spawn anchor, and macro-zone epoch sync.
OP_BUNDLE Server -> Client Admission / AOI 3B Header + 64B Strides Full entity identity, display name, role, prefab catalog ID, and mount hierarchy.
OP_REMOVE Server -> Client Event-Driven 4B Fixed Envelope Authoritative proxy eviction carrying a 1-byte discrete REASON_* code.
OP_CONFIG Server -> Client Boot / 1.0Hz 3B Header + UTF-8 Payload World dimensions, admission waiting room queue index, and 1.0Hz server vitals.
OP_ZONE_EVENT Server -> Client Event-Driven 22B Fixed Envelope Macro-zone boundary transition notification and spatial origin tracking.
OP_FLASH_DAMAGE Server -> Client Event-Driven 3B Header + 4B Strides Immediate signed health/integrity delta notification (targetNetId, signedDelta).
OP_VITALS Server -> Client 5Hz Dirty-Gated 3B Header + 16B Strides Secondary telemetry stream for health, primary/secondary resources, stances, and status bitmasks.
OP_MAP_GEOMETRY Bidirectional Stage 2 / Live Stream 5B Header + 20B Strides (21B In) Static obstacle Axis-Aligned Bounding Box (AABB) hydration and live geometry mutations.
OP_PING Bidirectional 1.0Hz Autonomous 5B Fixed Envelope Background transport heartbeat, RTT calculation, and flatline timeout refresh.
OP_CLIENT_ACTION Client -> Server Event-Driven 4B Fixed Envelope Discrete interaction trigger (actionId + targetNetId).
OP_GAME_EVENT Bidirectional Asynchronous RPC 3B Outer (7B In / 8B Out) Zero-overhead passthrough envelope routing to the Loopback Sidecar IPC Bus (127.0.0.1:55557).
[QUANTIZATION] Telemetry Quantization & Packed Spatial Precision
Section titled “[QUANTIZATION] Telemetry Quantization & Packed Spatial Precision”

To minimize ingress/egress bandwidth while preserving deterministic sub-centimeter physical accuracy, OP_TELEMETRY and OP_BROADCAST utilize hardware-aligned fixed-point quantization and bitfield compression:

  • Inbound Fixed-Point Quantization (OP_TELEMETRY): Client egress quantizes local floating-point coordinates (qX, qY, qZ) into signed 16-bit integers (short) by multiplying by 30.0f, while orientation and velocity scalars (qYaw, qPitch, qSpeed) are scaled by 10.0f. On server ingress, the orchestrator restores floating-point precision via reciprocal multiplication (* 0.03333333333333333 and * 0.1) to avoid division instructions on the hot path.
  • High-Concurrency 64-Bit Spatial Profile (PROFILE_HIGH_CONCURRENCY_PERSISTENT): Packs an entity’s complete local zone coordinates, heading, action flags, and 2-bit modulo-4 ZoneEpoch generation tag into a single 8-byte (uint64) word paired with a 2-byte NetID (10-byte total stride). This profile guarantees physical resolution steps of 7.812 mm across X and Y axes, 6.10 cm vertical Z resolution, and 0.087 degrees rotational yaw precision.
  • Rich 128-Bit Spatial Profile (PROFILE_RICH_CUSTOM): Expands the per-entity broadcast stride to 18 bytes (2-byte NetID + two 8-byte uint64 words) to accommodate full 6-DOF aerial robotics and complex simulations, adding dedicated bitfields for Pitch, Roll, extended elevation bounds, and 24 bits of custom application telemetry.
  • Centering Bucket Reconstruction: During client bitfield unpacking, the Presentation Bridge evaluates inverse scalars using 64-bit double precision and adds a 0.5 half-step offset to raw integer extractions, centering truncated quantization buckets to prevent directional coordinate drift.
[SPEC] Blittable C# Wire Struct Integration
Section titled “[SPEC] Blittable C# Wire Struct Integration”

The CVL CORE Presentation Bridge unpacks incoming network streams without heap allocations by casting ReadOnlySpan<byte> slices directly onto sequentially packed value types using System.Runtime.InteropServices.MemoryMarshal.

Assets/CVL_CORE_SDK/Network/ProtocolConstants.cs
using System.Runtime.InteropServices;
namespace CVLCore.SDK
{
public static class ProtocolConstants
{
// Symbolic Header & Payload Limits (Exact byte offsets encapsulated in SDK binary)
public const int BROADCAST_HEADER_SIZE = 7;
public const int GAME_EVENT_HEADER_SIZE = 3;
public const int GAME_EVENT_WIRE_HEADER_SIZE = 7;
public const int SIDECAR_MAX_PAYLOAD_SIZE = 4096;
// Public Discrete Eviction Reason Taxonomy (OP_REMOVE)
public const byte REASON_LOGOUT = 0x00;
public const byte REASON_TIMEOUT = 0x01;
public const byte REASON_SPEEDHACK = 0x02;
public const byte REASON_DUPLICATE_AUTH = 0x03;
public const byte REASON_AOI_EXIT = 0x04;
public const byte REASON_SERVER_SHUTDOWN = 0x05;
public const byte REASON_PROJECTILE_EXPIRE = 0x06;
// Boot-Time IEEE 802.3 CRC32 Structural Parity Gate
public static uint ComputeProtocolCRC32() => InternalWireValidator.ComputeDigest();
}
// Decoded Public Event Payload (NetIDs pre-resolved to permanent 16-Byte EID strings)
public readonly struct VitalsUpdatePayload
{
public readonly string EID;
public readonly ushort Health;
public readonly ushort Resource1;
public readonly ushort Shield;
public readonly string TargetEID;
public readonly ushort StanceCode;
public readonly uint StatusBitmask;
}
}
[SIDECAR] Sidecar Event Bus Wire Envelope (OP_GAME_EVENT)
Section titled “[SIDECAR] Sidecar Event Bus Wire Envelope (OP_GAME_EVENT)”

To keep the 30Hz spatial micro-kernel completely decoupled from database I/O, chat relays, and transactional ledgers, OP_GAME_EVENT operates as a transparent binary tunnel:

  • Reactor Ingress Bypass: When the Asymmetric Network Reactor encounters an OP_GAME_EVENT frame (capped at SIDECAR_MAX_PAYLOAD_SIZE = 4096 bytes), it validates the 3-byte outer framing header and routes the raw payload directly to the Sidecar Ingress Conduit alongside the sender’s authenticated 16-byte EID. This path incurs 0.00 ms of execution overhead on the Authoritative Simulation Orchestrator.
  • Client-to-Server Request Header (7 Bytes): Encapsulates the outer opcode, 16-bit payload length, 8-bit serviceId (indexing the 256-slot Sidecar routing table), 8-bit subOpcode, and 16-bit requestId for asynchronous callback correlation.
  • Server-to-Client Response Header (8 Bytes): Appends a 1-byte SidecarStatusCode (Success = 0x00, GenericError = 0x01, RateLimited = 0x06, ServiceOffline = 0x07). If a targeted external microservice is offline, the IPC broker immediately synthesizes and returns an 8-byte fast-fail ServiceOffline envelope without stalling client state.

[SEC 04.0] Architectural Invariants & Guardrails

Section titled “[SEC 04.0] Architectural Invariants & Guardrails”

Maintaining deterministic wire synchronization across high-density entity swarms requires strict adherence to mathematical and lifecycle invariants across both engine tiers.

[GUARDRAIL] Unsigned Coordinate Bias & Overflow Prevention
Section titled “[GUARDRAIL] Unsigned Coordinate Bias & Overflow Prevention”

To eliminate signed two’s-complement bit-packing complexity across macro-zone boundaries, spatial wire coordinates apply an immutable +512.0 local coordinate offset and a configurable vertical Z_AXIS_BIAS prior to serialization. When unpacking 17-bit or 20-bit horizontal coordinates on the client, extracted bitfields must be cast explicitly to 32-bit unsigned integers (uint) prior to arithmetic reconstruction to prevent 16-bit integer overflow at 65535.

[GUARDRAIL] Modulo-4 Circular Zone Epoch Gate
Section titled “[GUARDRAIL] Modulo-4 Circular Zone Epoch Gate”

Every kinematic telemetry frame (OP_TELEMETRY), spatial broadcast stride (OP_BROADCAST), and authoritative position override (OP_SET_POS) carries a 2-bit ZoneEpoch generation counter (0 to 3). When an entity transitions across a macro-zone boundary (exceeding the hysteresis margin), the server increments the entity’s ZoneEpoch modulo 4 and dispatches a 32-byte OP_SET_POS re-anchoring frame. Both endpoints evaluate circular epoch deltas via delta_epoch = (incoming_epoch - current_epoch + 4) % 4:

  • delta_epoch == 0: Frame is synchronized with the active zone origin; process normally.
  • delta_epoch == 1: Client receives a newer epoch ahead of the discrete transition notice; auto-heal local epoch state.
  • delta_epoch in (2, 3): Stale in-flight packet originating from a prior zone generation; drop silently to prevent cross-border coordinate teleportation.
[GUARDRAIL] Local Proxy Self-NetID Ingestion Filter
Section titled “[GUARDRAIL] Local Proxy Self-NetID Ingestion Filter”

To maximize server CPU efficiency, the Authoritative Simulation Orchestrator pre-serializes a single master OP_BROADCAST byte buffer per 15Hz tick rather than permuting custom buffers for every connected socket. Consequently, a client will receive its own NetID stride inside the master broadcast stream. The client Presentation Bridge must advance its stream read pointer across the stride and silently skip applying transform updates when stride.NetId == localNetId, preventing historical self-data from rubberbanding the local prediction controller.

[CRITICAL // GUARDRAIL] CRITICAL CLIENT INTEGRATION INVARIANTS

1. Never Halt 30Hz Telemetry During UI Focus or Mounting: The server enforces a strict 10.0-second FLATLINE_TIMEOUT transport silence threshold refreshed exclusively by OP_TELEMETRY and OP_PING. When a human operator opens a UI menu, switches to a free-fly camera, or boards a vehicle (parent_net_id > 0), client code must set CVLEngineAPI.IsInputSuspended = true to lock physical WASD translation while allowing the background 30Hz OP_TELEMETRY heartbeat to continue transmitting uninterrupted.
2. Never Expose Ephemeral NetID Tokens to Gameplay Logic: Unsigned 16-bit NetID values are recycled immediately upon entity teardown. Client gameplay scripts, UI nameplates, and targeting systems must bind exclusively to the permanent 16-byte EID string surfaced by CVLEngineAPI delegates.
3. Graceful Logout Dispatch (LOGOUT|{eid}\n): Client applications must invoke CVLEngineAPI.Disconnect() on exit rather than abruptly closing the TCP descriptor. This transmits an inline logout control frame that triggers Tier-1 server slot reclamation in under 45 ms, preventing rapid reconnection attempts from colliding with lingering ghost sessions (REASON_DUPLICATE_AUTH).


Section titled “[SEC 05.0] Client Wire Bridge & Related Specifications”

Client engineers interact with the binary wire protocol through the CVL CORE Presentation Bridge (CVLEngineAPI), which abstracts socket threading, ArrayPool<byte> memory leasing, and Little-Endian struct marshaling behind zero-allocation C# events.

[IMPLEMENTATION] Public Client SDK Wire Hooks (CVLEngineAPI.cs)
Section titled “[IMPLEMENTATION] Public Client SDK Wire Hooks (CVLEngineAPI.cs)”

The snippet below demonstrates subscribing to decoded wire streams and dispatching binary Sidecar RPC payloads and discrete actions without allocating managed heap memory:

Assets/CVL_CORE_SDK/API/WireIntegrationExample.cs
using System;
using UnityEngine;
using CVLCore.SDK;
public class WireIntegrationExample : MonoBehaviour
{
private const byte SERVICE_LEDGER = 0x02;
private const byte SUB_OP_QUERY_BALANCE = 0x01;
private ushort _nextRequestId = 1;
private void OnEnable()
{
// Subscribe to zero-allocation decoded wire delegates
CVLEngineAPI.OnEntitySpawned += HandleEntitySpawned;
CVLEngineAPI.OnEntityDespawned += HandleEntityDespawned;
CVLEngineAPI.OnVitalsUpdated += HandleVitalsUpdated;
CVLEngineAPI.OnGameEventReceived += HandleSidecarResponse;
}
private void OnDisable()
{
// Mandatory subscription hygiene to prevent delegate leaks
CVLEngineAPI.OnEntitySpawned -= HandleEntitySpawned;
CVLEngineAPI.OnEntityDespawned -= HandleEntityDespawned;
CVLEngineAPI.OnVitalsUpdated -= HandleVitalsUpdated;
CVLEngineAPI.OnGameEventReceived -= HandleSidecarResponse;
}
public void TriggerDiscreteInteraction(string targetEid, byte actionCode)
{
// Resolves targetEid -> ushort NetID internally and queues 4-byte OP_CLIENT_ACTION
CVLEngineAPI.SendClientAction(targetEid, actionCode);
}
public void RequestLedgerBalance()
{
// Stack-allocated payload transmitted via 7-byte OP_GAME_EVENT header
Span<byte> requestPayload = stackalloc byte[4] { 0x01, 0x00, 0x00, 0x00 };
CVLEngineAPI.SendGameEvent(
serviceId: SERVICE_LEDGER,
subOpcode: SUB_OP_QUERY_BALANCE,
requestId: _nextRequestId++,
payload: requestPayload
);
}
private void HandleEntitySpawned(string eid, GameObject proxy, bool isLocal)
{
// Invoked upon time-sliced OP_BUNDLE (64B) or OP_SET_POS (32B) hydration
}
private void HandleEntityDespawned(string eid, byte reasonCode)
{
// Invoked upon 4-byte OP_REMOVE receipt; inspect ProtocolConstants.REASON_*
if (reasonCode == ProtocolConstants.REASON_SPEEDHACK)
{
Debug.LogWarning($"Entity {eid} evicted by authoritative kinematics guardrail.");
}
}
private void HandleVitalsUpdated(VitalsUpdatePayload vitals)
{
// Invoked from 5Hz dirty-flagged OP_VITALS (16B stride)
// vitals.EID and vitals.TargetEID are pre-resolved to permanent string handles
}
private void HandleSidecarResponse(
byte serviceId,
byte subOpcode,
ushort requestId,
byte statusCode,
ReadOnlySpan<byte> payload)
{
// Zero-allocation ReadOnlySpan<byte> slice leased from ArrayPool<byte>.Shared
if (statusCode == (byte)SidecarStatusCode.Success && payload.Length >= 8)
{
ulong balance = BitConverter.ToUInt64(payload);
}
}
}