pub struct DriftModel { /* private fields */ }Expand description
Sliding-window RTT-weighted linear model of clock offset and drift
(docs/roadmap.md, step 17).
Each burst contributes its lowest-RTT (local_time, offset, rtt) triple.
Observations are weighted by 1 / max(rtt, 1e-6)^2 with one iteratively
reweighted outlier-rejection pass so asymmetric Wi-Fi RTT spikes do not pull
the fitted line.
Implementations§
Source§impl DriftModel
impl DriftModel
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Clear all observations and the fitted line (for example after a source restart).
Sourcepub fn fit(&self) -> Option<DriftFit>
pub fn fit(&self) -> Option<DriftFit>
Current fitted linear parameters, or None before the first burst.
Sourcepub fn drift(&self) -> Option<f64>
pub fn drift(&self) -> Option<f64>
Estimated relative clock drift in seconds per second (e.g., 25e-6 for
+25 ppm), or None before the first burst.
Sourcepub fn offset_for_remote(&self, remote_ts: f64) -> Option<f64>
pub fn offset_for_remote(&self, remote_ts: f64) -> Option<f64>
Smooth offset for remote_ts, or None before the first burst.
Sourcepub fn update(&mut self, local_time: f64, offset: f64, rtt: f64) -> DriftFit
pub fn update(&mut self, local_time: f64, offset: f64, rtt: f64) -> DriftFit
Record one burst estimate and recompute the weighted linear fit.
local_time is the local midpoint (t0 + t3) / 2, offset is the
burst time_offset() (local - remote), and rtt is the burst
round-trip uncertainty in seconds.