Skip to main content

Module clock

Module clock 

Source
Expand description

How far another node’s clock is from this one’s, and how fast the gap grows.

serve_clock answers on CLOCK_PROTOCOL with the node’s clock. measure sends a few requests, and from each reply takes the offset as the remote reading minus the midpoint of the local send and receive times; the sample with the shortest round trip wins, since its midpoint error is bounded by half that round trip. DriftFit fits offsets taken over time to a line, which gives the offset at any moment and the drift between the two clocks in parts per million.

Clocks are functions returning nanoseconds of a monotonic clock (ClockFn), so a node can use the clock its audio runs on.

Structs§

ClockSample
One measurement of another clock against this one.
ClockServer
Answering clock requests. Dropping it stops.
DriftFit
Clock samples over time fitted to a line: the offset at any moment, and the drift.

Constants§

CLOCK_PROTOCOL
The clock protocol id.

Functions§

measure
Measure the clock of peer (reached through addrs if not connected) with probes exchanges and keep the one with the shortest round trip.
monotonic
A clock counting from when it was made, on the process’s monotonic clock.
serve_clock
Answer clock requests on node with clock. Needs a tokio runtime context.

Type Aliases§

ClockFn
A monotonic clock in nanoseconds.