avb
Rust crates for AVB and Milan: discovering, describing and connecting IEEE 1722.1 entities, reserving streams, raw Ethernet on Linux, macOS and Windows, and sending and receiving AVTP audio on gPTP time. They are the networking under triib, an ATDECC controller, and plaa, a media player, and are meant for other apps with very different constraints too: a blocking command line tool, an async daemon, a GUI, or firmware on a microcontroller.
| Crate | What it does |
|---|---|
atdecc |
IEEE 1722.1-2021 with Milan 1.3, MAAP and AVB Lite's vendor unique messages: frame codecs, controller state machines (discovery, AECP commands, enumeration, ACMP, unsolicited notifications), entity state machines (AEM responder, Milan listener binding, ACMP talker) and the entity model as data |
avb-lite |
The AVB Lite profile: CVU SRP's declarations, admission and escalation; gptp weighs the fallback |
avb-mrp |
IEEE 802.1Q MRP (applicant, registrar, LeaveAll, periodic timers), MSRP and MVRP, and a port's participant shared between programs on one computer; with the bridge feature, a bridge's MSRP and MVRP: attribute propagation between ports, stream admission, and the forwarding and idle slope changes that follow |
avb-net |
Raw Ethernet for AVB: raw-ether's interfaces, frames, multicast membership, hardware time stamps, the PTP hardware clock, link settings and captures, under the paths AVB crates use, and whole frames for AVTP streams |
avb-stream |
AVTP audio: AAF and AM824 talkers and listeners paced on gPTP time, CRF media clock streams, and audio to and from the computer's devices through cpal |
avb-endpointd, the daemon that runs this computer's entities for any
app, with avb-pipewire and avb-netraw, began here and is now in
Linux-AVB-Endpoint.
Rules for the protocol crates
atdecc, avb-mrp and avb-net keep to these:
- Sans-I/O core. No sockets, threads, clock or runtime in the protocol
code. The caller feeds received frames and the current time
(
handle_frame(now, bytes),handle_timeout(now)) and drains frames to send, events and the next deadline (poll_transmit,poll_event,poll_timeout). Commands return an ID and complete as an event. This fits a blocking loop, tokio, embassy or a firmware main loop alike. no_std. Codecs need neither std nor alloc: fixed-size PDUs decode into plain values, variable ones as views over the received bytes, and both encode into the caller's buffer. Reserved values are kept, so a frame decodes and encodes back unchanged. State machines needalloconly. Thestdfeature (default) adds theavb-nettransports and a small blocking driver for simple apps.- No dependencies beyond each other.
avb-netdepends only onraw-ether, in gptp's repository, which holds the platform code (libcon Linux and macOS,windows-syson Windows), and onlibcfor AVTP streams on Linux. No serde, no logging framework, no async runtime. - Never panic on input. Malformed frames are errors.
- Checked in CI: each crate tested on its own, and built with
--no-default-featuresforriscv32imac-unknown-none-elf(the ESP32-C6).
avb-lite keeps to them too, with no std feature of its own.
avb-stream is for computers: it needs std, threads and an audio device.
Using them
They are on crates.io:
[]
= "0.1"
To change them together with an app that uses them, point the app at a
local checkout from its own git-ignored .cargo/config.toml:
[]
= { = "../avb/crates/atdecc" }
= { = "../avb/crates/avb-lite" }
= { = "../avb/crates/avb-mrp" }
= { = "../avb/crates/avb-net" }
= { = "../avb/crates/avb-stream" }
= { = "../gptp/crates/gptp" }
= { = "../gptp/crates/raw-ether" }
Platform needs
- Linux: raw Ethernet needs
CAP_NET_RAW, but only to open a socket. Rather than granting it to the app, which then runs as a process others may not look into (the desktop portals refuse it file dialogs and screen sharing; debuggers and crash reports pass it by), ship a tiny helper whosemaincallsavb_net::broker::serve(), grant the capability to that alone (sudo setcap cap_net_raw+ep <helper>), and at startinstallaBroker::start(<helper>): every raw socketavb-netandavb-streamopen then comes from the helper, passed over a Unix socket.raw-ether'snetrawexample is such a helper. gPTP comes from gptpd, in gptp's repository; the stream crates read the grandmaster's time from the record it keeps for the interface. - macOS: raw Ethernet needs read and write access to
/dev/bpf*. - Windows: raw Ethernet needs Npcap.
Building
On Linux, avb-stream builds against ALSA's headers (libasound2-dev,
alsa-lib).
License
MIT or Apache-2.0, at your option.