@suaveplan/network-plugin-protocol - Network protocol plugin: 13-byte binary header, message encoder/decoder, pipeline, serialization strategies, priority queue, batching, TTL, and route cache
Summary
Network protocol plugin for the mesh system.
Documentation tree
- batcher — (no submodules)
- batcher — (no submodules)
- decoder — (no submodules)
- decoder — (no submodules)
- encoder — (no submodules)
- encoder — (no submodules)
- pipeline — (no submodules)
- pipeline — (no submodules)
- protocol — (no submodules)
- protocol-plugin — The main plugin implementation that integrates the protocol layer into a
NetworkNode.ProtocolPluginimplements the… - protocol — (no submodules)
- protocol-plugin — The main plugin implementation that integrates the protocol layer into a
- queue — (no submodules)
- queue — (no submodules)
- serializer — (no submodules)
- serializer — (no submodules)
- ttl — (no submodules)
- ttl — (no submodules)
- error-codes — Defines the stable error-code registry for the
@suaveplan/network-plugin-protocolpackage. All runtime failures withi…
- protocol — (no submodules)- queue — (no submodules)- queue — (no submodules)- serializer — (no submodules)- serializer — (no submodules)- ttl — (no submodules)- ttl — (no submodules)- error-codes — Defines the stable error-code registry for the
@suaveplan/network-plugin-protocolpackage. All runtime failures withi… - batcher — (no submodules)- decoder — (no submodules)- decoder — (no submodules)- encoder — (no submodules)- encoder — (no submodules)- pipeline — (no submodules)- pipeline — (no submodules)- protocol — (no submodules)- protocol-plugin — The main plugin implementation that integrates the protocol layer into a
NetworkNode.ProtocolPluginimplements the…- protocol — (no submodules)- queue — (no submodules)- queue — (no submodules)- serializer — (no submodules)- serializer — (no submodules)- ttl — (no submodules)- ttl — (no submodules)- error-codes — Defines the stable error-code registry for the
@suaveplan/network-plugin-protocolpackage. All runtime failures withi…
- protocol — (no submodules)- queue — (no submodules)- queue — (no submodules)- serializer — (no submodules)- serializer — (no submodules)- ttl — (no submodules)- ttl — (no submodules)- error-codes — Defines the stable error-code registry for the
- batcher — (no submodules)- decoder — (no submodules)- decoder — (no submodules)- encoder — (no submodules)- encoder — (no submodules)- pipeline — (no submodules)- pipeline — (no submodules)- protocol — (no submodules)- protocol-plugin — The main plugin implementation that integrates the protocol layer into a
NetworkNode.ProtocolPluginimplements the…- protocol — (no submodules)- queue — (no submodules)- queue — (no submodules)- serializer — (no submodules)- serializer — (no submodules)- ttl — (no submodules)- ttl — (no submodules)- error-codes — Defines the stable error-code registry for the
@suaveplan/network-plugin-protocolpackage. All runtime failures withi…
- protocol — (no submodules)- queue — (no submodules)- queue — (no submodules)- serializer — (no submodules)- serializer — (no submodules)- ttl — (no submodules)- ttl — (no submodules)- error-codes — Defines the stable error-code registry for the
- batcher — (no submodules)- decoder — (no submodules) - decoder — (no submodules)- encoder — (no submodules) - encoder — (no submodules)- pipeline — (no submodules) - pipeline — (no submodules)- protocol — (no submodules) - protocol-plugin — The main plugin implementation that integrates the protocol layer into a
NetworkNode.ProtocolPluginimplements the…- protocol — (no submodules)- queue — (no submodules) - queue — (no submodules)- serializer — (no submodules) - serializer — (no submodules)- ttl — (no submodules) - ttl — (no submodules)- error-codes — Defines the stable error-code registry for the
@suaveplan/network-plugin-protocolpackage. All runtime failures withi…
- protocol — (no submodules)- queue — (no submodules) - queue — (no submodules)- serializer — (no submodules) - serializer — (no submodules)- ttl — (no submodules) - ttl — (no submodules)- error-codes — Defines the stable error-code registry for the
Purpose
Implements the compact binary protocol layer for all peer-to-peer messages. This plugin provides the 13-byte binary header, message encoder/decoder, serialization strategy framework, priority message queueing, adaptive batching, TTL/loop detection, and transform pipeline. It plugs into NetworkNode via the NetworkPlugin interface.
Features
- 13-byte binary header — version, flags, message type, timestamp, payload length
- MessageEncoder / MessageDecoder — wire-format serialization
- SerializerFactory — JSON, binary, and MessagePack strategies with fallback
- PriorityMessageQueue — 5-tier priority with CRITICAL bypass
- MessageBatcher — groups messages by type/target, flushes on size/time
- MessageTTL / LoopDetector — prevents infinite propagation and cycles
- ProtocolPipeline — ordered transform stages for outgoing and incoming data
Usage
Basic Example
import { ProtocolPlugin } from "@suaveplan/network-plugin-protocol";
const plugin = new ProtocolPlugin();
node.use(plugin);
Advanced Example
import { ProtocolPlugin, PriorityMessageQueue } from "@suaveplan/network-plugin-protocol";
const plugin = new ProtocolPlugin({
queue: { capacity: 2000, policy: "drop-oldest" },
batch: { maxSize: 50, maxWaitMs: 25, priorityTrigger: "HIGH" },
});
node.use(plugin);
API Reference
See per-module documentation in src/:
src/protocol/—BinaryProtocol,ProtocolPluginsrc/encoder/—MessageEncodersrc/decoder/—MessageDecodersrc/serializer/—SerializerFactory,JsonSerializer,BinarySerializer,MessagePackSerializersrc/queue/—PriorityMessageQueuesrc/batcher/—MessageBatchersrc/ttl/—MessageTTL,LoopDetectorsrc/pipeline/—ProtocolPipeline
Implementation Notes
The protocol plugin is transport-agnostic. It serializes envelopes to byte arrays but does not send them over the wire. Transports consume the encoded bytes and handle actual delivery. The bitpacker integration uses @suaveplan/bitpacker for header field packing. The pipeline integrates with @suaveplan/streams transforms for compression and encryption.