English
ours-ntp-wire
libs/ntp-wire — the SNTP packet, and what an exchange with a server says about its clock.
Design
A port of common/ntp/message.go from sing (RFC 5905):
NtpTime— 64-bit fixed-point time, seconds since 1900 (from_time).Message— the packet:request,encode,decode,stamp;Leap.Response::validate— a response is usable only if it is fresh and close to its reference clock;answers(request, response)— whether the response echoes the request's transmit time;ClockError— why not.ClockOffset(fromours-clock) — the offset computed from the four timestamps.exchange(response, sent, received)— the rtt and the offset from the four timestamps, as sing'sparseTimecomputes them. The socket and dialing are not here: the module provides them.
Who uses it
ours-mod-ntp (modules/system/ntp), which re-exports it as ours_mod_ntp::Message and so on.
Specifics
Depends only on ours-clock.
Tests
Unit tests in src/lib.rs; the fuzz target packet in fuzz/; a scenario with a time server — modules/system/ntp/tests/instance.rs.