Skip to content

Update Spotter to comply with the Discovery Spec - #1487

Draft
khyatimahendru wants to merge 14 commits into
faucetsdn:masterfrom
khyatimahendru:spotter-impl
Draft

khyatimahendru wants to merge 14 commits into
faucetsdn:masterfrom
khyatimahendru:spotter-impl

Conversation

@khyatimahendru

@khyatimahendru khyatimahendru commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Overhauls the UDMI Spotter reference edge node (edge/spotter/), upload/discovery schema/transport, UDMIS upload/# bridge routing, and Butler PCAP reassembly + MCP tools for strict UDMI discovery and ephemeral packet-capture (depth: "trace") compliance.

Key changes in this PR:

  • Zero-downtime BACnet PCAP streaming (upload/discovery): Spawns tcpdump on an explicit host network interface (rejecting missing or "any" interfaces) and waits for tcpdump readiness before launching 3 broadcast-only raw-socket (SOCK_RAW, IPPROTO_UDP) Who-Is rounds spaced across the capture window (t = 0, T/3, 2T/3), with CAP_NET_RAW pre-flight validation, tail-buffered inline I-Am/I-Am-Router-To-Network decoding, time- and size-based gzip chunk flushing, and optional trace.exclude_capture_host BPF filtering.
  • Discovery mode & coexistence (udmi.discovery.mode): Supports "full" (default; releases BAC0 UDP 47808 at the end of every scan and before trace) and "capture_only" (skips BAC0 registration and rejects non-trace BACnet scans with status 500 so Spotter can coexist with an external BACnet gateway on the same host).
  • Schema & cloud reassembly: Replaces events_streams with schema/upload_discovery.json (including ScanManifest device/duplicate counts), adds exclude_capture_host to schema/config_discovery_trace.json, routes upload/# in UDMIS, and adds PcapUploadHandler + trigger_bacnet_trace/get_pcap_capture MCP tools in Butler.

Verification

  • edge/spotter/bin/run_spotter_tests unit — 98 unit tests + 3 self-tests passed (exit 0)
  • bin/gencode check — schema/code/docs/presentation hashes verified (exit 0)
  • bin/test_schema — schema fixture validation passed (exit 0)
  • bin/test_generated_classes_py — 131 passed (exit 0)
  • PYTHONPATH=".:common/src/main/python:gencode/python" venv/bin/python3 -m unittest discover -s butler/tests — 27 passed (exit 0)
  • PYTHONPATH=".:common/src/main/python:gencode/python" venv/bin/python3 -m unittest tests/test_mcp_butler.py — 31 passed (exit 0)
  • udmis/bin/build check && validator/bin/build check && pubber/bin/build check — all Java builds, JUnit suites, and Checkstyle passed (exit 0)
  • bin/test_sites — all registrar site fixtures passed (exit 0)

Author Declaration

  • I have self-reviewed this PR.

Pull request created by Gemini

…Upload

- Add schema/upload_discovery.json defining DiscoveryUpload and ScanManifest for chunked packet capture streaming over upload/discovery.
- Add 'upload' to SubType enum in schema/envelope.json and remove legacy schema/events_streams.json.
- Regenerate Java and Python schema classes, HTML documentation, and .gencode_hash.txt.
- Add schema validation fixtures under tests/schemas/upload_discovery/ and document depth: 'trace' in docs/specs/discovery.md and docs/specs/discovery_bacnet.md.
- Ensure deterministic device ID ordering in SiteModel.getDeviceIds().
…entlib

- Add --upload_pubsub_topic_id support in MqttToPubSubBridge to route subType='upload' messages to a dedicated Pub/Sub publisher with graceful shutdown draining.
- Register uufi_upload flow in UdmiServicePod and udmis/etc/local_pod.json for local upload/# pass-through.
- Add publish_upload helper to clientlib BaseManager and include upload/# in MessageConnection default subscribe topics.
- Add unit tests in MqttToPubSubBridgeTest covering upload publisher routing and shutdown.
- Add PcapUploadHandler to reassemble gzip-compressed upload/discovery chunks in order, verify terminal SHA-256 digests, and archive .pcap and scan_manifest.json artifacts to GCS or local disk.
- Exclude subType='upload' messages from RawFallbackHandler so raw PCAP chunks are never persisted in udmi_messages.
- Add udmi_pcap_captures table in PostgresManager to track capture lifecycle metadata and URIs.
- Add trigger_bacnet_trace and get_pcap_capture tools across Butler discovery, ButlerProvider, ButlerMcpServer, and ButlerClient with unit tests and schema docs.
…CAP streaming

- Enforce strict UDMI discovery depth compliance ('buckets', 'entries', 'system', 'details', 'trace') across Spotter providers and fail fast on non-canonical legacy depths.
- Emit canonical '<TYPE>/<INSTANCE>' BACnet refs, hyphenated object types and ancillary keys, explicit families.ipv4.port (47808), ARP-resolved families.ethmac, and routed MS/TP '<net>:<mac>' bindings.
- Decode BACnet/IP BVLL Forwarded-NPDU real controller IPs/ports behind BBMDs, NPDU SNET/SADR MS/TP headers, and I-Am-Router-To-Network DNET lists in PassiveFamilyProvider.
- Implement raw-socket (SOCK_RAW) BACnet Who-Is and Who-Is-Router-To-Network discovery rounds during depth: 'trace' without binding UDP 47808, and stream gzipped DiscoveryUpload chunks with SHA-256 and ScanManifest over upload/discovery.
- Update reassemble_pcap, compare_field_parity, Spotter documentation, and unit/integration test suites.
…odel

- Lazily initialize Google Cloud Storage client in PcapUploadHandler._upload_to_gcs when BUTLER_PCAP_GCS_BUCKET is set and require sha256 on terminal EOF markers.
- Guard SpotterDiscoveryManager against superseded scan generation races when active scans are cancelled or replaced.
- Preserve BACnet I-Am enrichment and routed MS/TP re-emission across passive_sec holdoff intervals and bound I-Am-Router-To-Network parsing by bvlc_len.
- Issue per-range BACnet Who-Is discovery calls instead of collapsing disjoint addrs ranges and validate Nmap target specifications.
- Collect sorted device IDs into LinkedHashSet in SiteModel.getDeviceIds() and require connection spec in ButlerProvider.trigger_bacnet_trace.
- Wrap 101-character gracefulShutdown call in MqttToPubSubBridge.java to satisfy Checkstyle LineLength (<= 100 chars).
- Code-quote protocol and compression terms (BVLL, BBMD, NPDU, MS/TP, DNET, gzip) in docs/specs/discovery.md, docs/specs/discovery_bacnet.md, and docs/tools/spotter.md for Docs Spelling Checks.
…it interface, exclude_capture_host, and I-Am manifest counts
khyatimahendru added a commit to khyatimahendru/udmi that referenced this pull request Nov 27, 2026

This branch has not been deployed

No deployments
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