diff --git a/selected/time.md b/selected/time.md index a215d3a..e2252b2 100644 --- a/selected/time.md +++ b/selected/time.md @@ -178,6 +178,27 @@ Links: [Analysis and Simulation of the NTP On-Wire Protocols](https://www.eecis. ### Clock Filter +The clock filter is a shift register containing the last 8 samples produced by the on-wire protocol. The filter algorithm select the sample with maximum expected accuracy. It is based on the observations that: + +* The samples with the low network delay were likely to exhibit a low error at the time they were produced. +* Older samples carry more accuracy than newer ones due to clock drift. + +As a new sample is pushed to the register, it evicts the oldest sample. The dispersion values of the other samples are the incremented by $\varphi_c\times\Delta_t$, where $\Delta_t$ is the time elapsed since the last update from the server. A distance metric $\lambda_i$ is affected to each sample: + +$\lambda_i = \frac{\delta_i}{2}+\varepsilon_i \,.$ + +The samples are then sorted in a temporary list by increasing value of $\lambda_i$. The list is pruned to leave only samples whose dispersion is less than a given maximum. The first sample in the list is chosen as the new best candidate, likely to give the most accurate estimate of the time offset $\theta$. However it is only used if it is not older than the last selected sample. + +The peer's dispersion $\varepsilon_p$ is computed as an exponentially weighted average of the sorted samples' dispersions: + +$\varepsilon_p = \sum_{i=0}^{N-1}\frac{\varepsilon_i}{2^{(i+1)}} \,.$ + +The server's jitter $\psi_p$ is computed as the root mean square (RMS) of the offsets differences with respect to the offset of the first sample's in the list: + +$\psi_p = \frac{1}{n-1}\sqrt{\sum_{i=0}^{N-1}(\theta_0-\theta_i)^2} \,.$ + +Links: [Clock Filter Algorithm](https://www.eecis.udel.edu/~mills/ntp/html/filter.html), [rfc5905 - section 10](https://datatracker.ietf.org/doc/html/rfc5905#section-10) + ### Clock Selection ### Cluster Algorithm