Skip to content

mDNS device beacon (_waybeam-venc._tcp): zero-config LAN discovery#89

Merged
snokvist merged 2 commits into
OpenIPC:masterfrom
snokvist:feature/mdns-device-beacon-upstream
Jun 23, 2026
Merged

mDNS device beacon (_waybeam-venc._tcp): zero-config LAN discovery#89
snokvist merged 2 commits into
OpenIPC:masterfrom
snokvist:feature/mdns-device-beacon-upstream

Conversation

@snokvist

Copy link
Copy Markdown
Collaborator

Summary

Adds a lightweight mDNS/DNS-SD device beacon so the encoder is discoverable on the LAN with no configuration. A client (ground station / viewer) can browse _waybeam-venc._tcp, resolve the encoder, and read endpoints via GET /api/v1/config.

What's in this PR

  • src/mdns_beacon.c — own-thread responder on UDP 5353 multicast; announces PTR/SRV/TXT/A for _waybeam-venc._tcp; sends goodbye on stop. Bare waybeam.local alias (default on) with RFC 6762 §8.2 conflict resolution (highest-IP tiebreak; suppression sticky until restart).
  • src/mdns_wire.c — DNS wire codec, adapted from the OpenIPC herald DNS-SD helpers. Bounds-checked against malformed/truncated inbound packets (compression-pointer loop cap, per-field length guards).
  • src/device_id.c — SoC die-ID read → serial-suffix instance naming; full die ID exposed read-only as device.serial via GET /api/v1/config; graceful fallback on parts with no readable die ID.
  • New discovery config block (enabled, serviceType, name, bareAlias; default on), wired through defaults/parse/print/serialize.
  • TXT carries only proto + version; endpoints/identity are probe-discovered via GET /api/v1/config (keeps TXT minimal).
  • tests/test_mdns_beacon.c — unit suite for wire encode/parse + beacon behavior.

Verification

  • make test1701 passed / 0 failed
  • make verifyMaruko + Star6E backends cross-build clean
  • Device-verified on Star6E (IMX335) — beacon browsed/resolved by a LAN client end-to-end.

Deliberately NOT included (kept in the Waybeam fork)

This is the encoder-side feature only. The broader Waybeam discovery/trust migration (cross-repo spec doc, and the S95waybeam apfpv init-script changes that depend on a Waybeam-specific wfbmode boot env) are intentionally left out of this upstream PR as they're ecosystem/deployment-specific.

Opened as a draft for review.

🤖 Generated with Claude Code

…very

Add a lightweight mDNS/DNS-SD responder so the encoder is discoverable on the
LAN without configuration.

- src/mdns_beacon.c: own-thread responder, UDP 5353 multicast, announces
  PTR/SRV/TXT/A for `_waybeam-venc._tcp`; goodbye on stop; bare `waybeam.local`
  alias (default on) with RFC 6762 §8.2 conflict resolution (highest-IP
  tiebreak, suppression sticky until restart).
- src/mdns_wire.c: DNS wire codec (adapted from the OpenIPC herald helpers),
  bounds-checked against malformed/truncated inbound packets (compression-
  pointer loop cap, per-field length guards).
- src/device_id.c: SoC die-ID read → serial-suffix instance naming; full die ID
  exposed read-only as `device.serial` via GET /api/v1/config; graceful
  fallback on parts with no readable die ID.
- New `discovery` config block (enabled, serviceType, name, bareAlias; default
  on), wired through defaults/parse/print/serialize.
- TXT carries only `proto` + `version`; endpoints/identity are probe-discovered
  via GET /api/v1/config (keeps TXT minimal).
- tests/test_mdns_beacon.c: 296-line unit suite for wire encode/parse + beacon.

make test → 1701 passed/0 failed; make verify → Maruko + Star6E clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@snokvist snokvist marked this pull request as ready for review June 17, 2026 20:40
Two RFC 6762 conformance fixes so the beacon matches the OpenIPC herald
responder it derives from:

- IP multicast TTL 1 -> 255 (§11). Receivers can verify a packet originated
  on the local link; strict mDNS stacks drop TTL != 255. The 224.0.0.251
  group is link-local regardless, so propagation does not widen.
- Query responses now jitter 20-119 ms before answering (§6) and coalesce
  every query drained in one poll cycle into a single response. Proactive
  announces stay prompt.

The wire format was already herald-compatible (record order PTR/SRV/TXT/A,
cache-flush classes, name compression, TTL=0 goodbye); these are timing/IP
fixes only, no wire-codec change. The deliberate divergences (short record
TTL + periodic refresh; serial-suffixed primary name skips §8.1 probing) are
documented at the top of mdns_beacon.c.

Device-verified on SigmaStar Star6E (ssc338q): multicast TTL observed 255,
response latency measured 24-117 ms across repeated PTR queries, service +
host + bare alias all resolve. make test: 1701 passed, 0 failed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@snokvist

Copy link
Copy Markdown
Collaborator Author

Pushed a follow-up commit aligning the beacon more closely with the herald responder it derives from — two RFC 6762 conformance fixes:

  • IP multicast TTL 1 → 255 (§11) — strict mDNS stacks drop TTL ≠ 255; the group stays link-local regardless.
  • 20–119 ms response jitter (§6) before answering queries, coalescing a poll cycle's queries into one response.

No wire-codec change (record order / cache-flush classes / name compression / TTL=0 goodbye were already herald-compatible).

Device-verified on SigmaStar Star6E (ssc338q): captured multicast TTL = 255 (was 1), response latency measured 24–117 ms across repeated PTR queries, and service + suffixed host + bare waybeam.local alias all resolve. make test: 1701 passed, 0 failed.

@snokvist snokvist merged commit 407e8ec into OpenIPC:master Jun 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant