Describe once. Generate everything.
protocollab is an open-source framework for declaring, validating, and generating implementations of network and binary protocols from human-readable YAML specifications.
Write a single .yaml spec and generate Python parsers, Wireshark dissectors, mock runtimes, Scapy Layer 2 demos, TCP Layer 3 demos, test suites, and documentation from the same source of truth.
Most serialization tools are data-first or RPC-first. protocollab is protocol-first: it treats the protocol specification itself as the primary artifact and builds validators, generators, demos, and tooling around it.
| Feature | Protobuf / Thrift | Kaitai Struct | protocollab |
|---|---|---|---|
| Protocol-first workflow | No | Partial | Yes |
| Wireshark dissector generation | No | Yes | Yes |
| Python parser generation | Yes | Yes | Yes |
| JSON Schema validation | No | No | Yes |
| Hardened YAML loader | No | No | Yes |
| Live demo runtimes | No | No | Yes |
| Stateful protocol roadmap | Limited | No | Planned |
- A secure YAML-based authoring format for protocol definitions
- CLI commands to load, validate, and generate artifacts from a spec
- A dedicated
yaml_serializerpackage for hardened YAML processing - A dedicated
jsonschema_validatorpackage for pluggable JSON Schema validation - Generators for Python parsers, Wireshark Lua dissectors, mock runtimes, L2 Scapy runtimes, and L3 socket runtimes
- Demo workflows that validate end-to-end generated artifacts
Community-driven protocol specifications live in protocollab-specs.
The protocollab-specs repository is the central, curated collection of YAML protocol definitions compatible with protocollab. Every spec can be validated, versioned, and used to generate parsers, Wireshark dissectors, and test suites.
Use protocollab when you want the framework and generators. Use protocollab-specs when you want reusable specifications maintained as a community catalog.
protocollab-octapi – a hackathon MVP that generates Lua code for MWS Octapi using protocollab components.
See: github.com/protocollab-co/protocollab-octapi
git clone https://github.com/cherninkiy/protocollab
cd protocollab
poetry install
# Optional JSON Schema validation backends for the full validator test suite
poetry install --extras "validator-jsonscreamer validator-fastjsonschema"protocollab uses Poetry for dependency management. Core and optional dependencies are declared in pyproject.toml.
Optional backend tests in src/jsonschema_validator/tests/ are skipped automatically unless the matching extras are installed.
meta:
id: ping_protocol
endian: le
title: Ping Protocol
description: Simple ICMP-like ping/pong protocol
seq:
- id: type_id
type: u1
doc: Message type (0 = request, 1 = reply)
- id: sequence_number
type: u4
doc: Sequence number, wraps at 2^32
- id: payload_size
type: u2
doc: Size of payload that follows this header, in bytespc load examples/simple/ping_protocol.yaml --output-format json
pc validate examples/simple/ping_protocol.yaml
pc validate examples/simple/ping_protocol.yaml --strictpc generate python examples/simple/ping_protocol.yaml --output build/
pc generate wireshark examples/simple/ping_protocol.yaml --output build/
pc generate mock-client examples/simple/ping_protocol.yaml --output build/
pc generate mock-server examples/simple/ping_protocol.yaml --output build/
pc generate l2-client examples/simple/ping_protocol.yaml --output build/
pc generate l2-server examples/simple/ping_protocol.yaml --output build/
pc generate l3-client examples/simple/ping_protocol.yaml --output build/
pc generate l3-server examples/simple/ping_protocol.yaml --output build/CLI command name is now pc.
The scripts/check_pc_conflicts.sh helper is repository-only and is not installed from PyPI.
If you are working from this repository and pc is already used by another executable in your environment, run:
scripts/check_pc_conflicts.shEquivalent manual checks:
command -v pc
python -m protocollab --helpFallback invocation is always available:
python -m protocollab --helpimport io
from build.ping_protocol_parser import PingProtocol
data = bytes([0x00, 0x01, 0x00, 0x00, 0x00, 0x40, 0x00])
proto = PingProtocol.parse(io.BytesIO(data))
print(proto.type_id, proto.sequence_number, proto.payload_size)instances: can define virtual Wireshark fields when an entry contains a value: expression and a wireshark: block.
Supported expression forms in instances.*.value include:
-
Ternary:
"lan" if src_ip == 1 else "inet" -
Membership:
type_id in [1, 2, 3] -
List/dict literals:
[1, type_id, 3],{"count": type_id} -
Comprehensions:
any(x > 2 for x in values),filter(x > 0 for x in values) -
Match:
match type_id with 1 -> "req" | _ -> "other" -
Use
wireshark.type: boolwithfilter-only: truefor shortcut fields such asmyproto.lan -
Use
wireshark.type: stringfor summary fields such asmyproto.scope == "lan"
Relevant examples:
examples/simple/ip_scoped_packet.yamlfor a singlescopefieldexamples/simple/ip_scoped_frame.yamlfor splitsrc_scopeanddst_scopefilters
Critical modules currently have full coverage and the main CLI and generator workflows are in place.
| Area | Status | Notes |
|---|---|---|
yaml_serializer |
Stable | Secure YAML loader, !include, round-trip preservation, 100% coverage |
jsonschema_validator |
Stable | Pluggable backends, unified error model, safe auto mode, 100% coverage |
protocollab.loader |
Available | Secure loading, caching, session-based integration |
protocollab.validator |
Available | Base and strict schema validation via facade backend selection |
protocollab.generators |
Available | Python, Wireshark, mock, L2, and L3 generators |
| CLI | Available | load, validate, and generate commands |
| Demo workflows | Available | demo/mock, demo/l2, demo/l3 |
Three demo entry points are included for the same examples/simple/ping_protocol.yaml specification.
demo/mockgenerates a parser and queue-basedMockClientandMockServerruntimedemo/l2generates a parser,L2ScapyClient,L2ScapyServer, and a Wireshark Lua dissectordemo/l3generates a parser,L3SocketClient,L3SocketServer, and a Wireshark Lua dissector
Validation commands:
python demo/mock/demo.py checkpython demo/l2/demo.py checkpython demo/l3/demo.py check
Live transport demos:
python demo/l2/demo.py run --iface <name>python demo/l3/demo.py run
src/
|-- yaml_serializer/ # Secure YAML loading and round-trip saving
|-- jsonschema_validator/ # Pluggable JSON Schema validation facade
`-- protocollab/ # CLI, loaders, validators, generators, utilities
demo/
|-- mock/ # Queue-based generated runtime demo
|-- l2/ # Scapy Layer 2 generated runtime demo
`-- l3/ # TCP Layer 3 generated runtime demo
examples/
|-- simple/ # Standalone protocol definitions
`-- with_includes/ # Multi-file examples using !include
docs/
`-- adr/ # Architecture decision records
High-level dependency chain:
CLI
|-- protocollab.loader -> yaml_serializer
|-- protocollab.validator -> jsonschema_validator
`-- protocollab.generators -> Jinja2 templates
| Area | Tool |
|---|---|
| Language | Python 3.10+ |
| YAML processing | ruamel.yaml |
| CLI | Click 8.x |
| Schema validation | jsonschema, jsonscreamer, fastjsonschema |
| Templates | Jinja2 3.x |
| Models | Pydantic v2 |
| Packaging | Poetry |
| Testing | pytest, pytest-cov |
poetry run pytest src/ -q
poetry run pytest src/yaml_serializer/tests/ --cov=yaml_serializer --cov-report=term-missing
poetry run pytest src/jsonschema_validator/tests/ --cov=jsonschema_validator --cov-report=term-missing
poetry run pytest src/protocollab/tests/ --cov=protocollab --cov-report=term-missing- Primitive and user-defined types in
protocollab.core - Import resolution across files
- Safe expression engine without
eval - Semantic validation
- Early C++ generation support
- Stateful protocols with flat FSM in Community Edition
- Hierarchical statecharts in Pro
- Additional generators for C++, Rust, and Java
- Test generation and fuzzing
- Plugin system and enterprise integrations
| Capability | Community | Pro | Enterprise |
|---|---|---|---|
| Python and Lua generation | Yes | Yes | Yes |
| Mock, L2, and L3 demo runtimes | Yes | Yes | Yes |
| Base and strict schema validation | Yes | Yes | Yes |
| Flat FSM | Planned | Yes | Yes |
| C++, Rust, Java generators | No | Yes | Yes |
| Hierarchical statecharts | No | Yes | Yes |
| Test generation and fuzzing | No | Yes | Yes |
| Custom generators and CI/CD actions | No | No | Yes |
Contributions are welcome. Read CONTRIBUTING.md and CODE_OF_CONDUCT.md before opening a pull request.
- Fork the repository.
- Create a feature branch from
dev. - Add or update tests for your changes.
- Run the relevant local test suite.
- Open a pull request against
dev.
Development branch: github.com/cherninkiy/protocollab/tree/dev