Skip to content

camera_streamer: add a UDP clock exchange responder to the sender - #1475

Open
gareth-morgan-nv wants to merge 2 commits into
teng/5ef2afafrom
gmorgan/CameraStreamingClockControl
Open

gareth-morgan-nv wants to merge 2 commits into
teng/5ef2afafrom
gmorgan/CameraStreamingClockControl

Conversation

@gareth-morgan-nv

Copy link
Copy Markdown
Contributor

Summary

Lets the sender answer a four-timestamp clock exchange over UDP on its CLOCK_MONOTONIC, so a receiving host can measure the offset between its clock and the sender's. It is independent of the camera backend and of the AVS1 timing record, and off by default.

What changed

  • ClockExchange: the 13-byte request (Q, u32 seq, i64 t1) and 29-byte reply (R, seq, t1 echoed, t2, t3), little-endian; t2 and t3 are the sender's CLOCK_MONOTONIC in nanoseconds.
  • ClockResponder: a stateless UDP responder started with the sender and kept for the life of the process, whether or not a receiver is connected. t2 is read as soon as the receive returns and t3 just before the reply is sent. Anything that is not exactly one request is ignored.
  • network.clock_port (0 = off, the default) sets the port. The README documents the exchange and how a requester computes round-trip delay and offset from its own t1 and t4.

Validation

  • clang-format-14 and pre-commit clean on the changed files.
  • aarch64 cross-compile: syntax check and full link.
  • New unit tests clock_exchange and clock_responder, plus the config key, built and run by hand on a PC.
  • Native build and unit tests on a Jetson Orin (R39.2.1), including both new tests (17 of 17 camera-free tests on a build that also contained the sender-timing PR).
  • Probed from a PC over WiFi against a running sender: 299 of 299 requests answered, round-trip delay floor about 2 ms, and malformed datagrams got no reply. A later run with a real receiver sent 161 requests and its best delay was 2.27 ms.

Known limitations / follow-ups

  • The responder has no authentication and exposes only the sender's own clock readings, like the AVS1 stream beside it; keep the port on a trusted camera network.
  • The offset estimate is wrong by up to half of any difference between the two network directions; this change serves the clocks and makes no claim about accuracy beyond that. A requester should accept only replies matching a request it still has outstanding and reset its estimate when the AVS1 session_id changes or the connection is re-established; the responder keeps no session state.

Test plan

  • Query the responder from a second host and confirm the offset estimate is stable across a sender restart.
  • CI.

🤖 Generated with Claude Code

gareth-morgan-nv and others added 2 commits November 10, 2026 23:13
…LOCK_MONOTONIC

ClockResponder is a stateless, unauthenticated UDP responder that lives as long as the sender process, whether or not a
receiver is connected. A datagram of exactly 13 bytes ('Q', u32 seq, i64 t1, little-endian) is answered to its source
with 29 bytes ('R', seq, t1 echoed, t2, t3) where t2 is read as soon as the receive returns and t3 immediately before
the send, both on CLOCK_MONOTONIC; anything else is ignored. The requester matches replies to its outstanding (seq, t1)
and resets on a media session change, so the responder keeps no session state. network.clock_port (0 = off, the default)
turns it on. Tests cover the payload encoding, a loopback round trip, bursts, malformed datagrams, concurrent clients,
prompt shutdown, bind errors and the config key.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Gareth Morgan <gmorgan@nvidia.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Gareth Morgan <gmorgan@nvidia.com>
@coderabbitai

coderabbitai Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

This branch had an error being deployed

1 failed deployment
dev — 68e7ed26 Deployed Nov 11, 2026 by gareth-morgan-nv via publish-wheel #6763
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants