Clock discipline and clock adjust paragraphs

This commit is contained in:
Martin Fouilleul 2022-06-04 16:45:14 +02:00
parent b3138e3529
commit 0750fc8b9e
1 changed files with 19 additions and 5 deletions

View File

@ -176,7 +176,7 @@ Note that peers also transmit the delay and dispersion statistics accumulated at
Simple NTP clients that are only synchronized to one server, that don't act as a source for other peers, and that don't need a high precision, can implement only the on-wire protocol and directly use $\theta$ to correct their local clock. However this estimate is vulnerable to network jitter, delay asymetry, clock drift and wander. To get better precision, the samples produced by the on-wire protocol must be processed by a number of mitigation algorithms.
Links: [Analysis and Simulation of the NTP On-Wire Protocols](https://www.eecis.udel.edu/~mills/onwire.html), [RFC5905 - section 8](https://datatracker.ietf.org/doc/html/rfc5905#section-8)
Links: [Mills, Analysis and Simulation of the NTP On-Wire Protocols](https://www.eecis.udel.edu/~mills/onwire.html), [RFC5905 - section 8](https://datatracker.ietf.org/doc/html/rfc5905#section-8)
### Clock Filter
@ -199,7 +199,7 @@ The server's jitter $\psi_p$ is computed as the root mean square (RMS) of the of
$\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)
Links: [Mills, 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
@ -209,7 +209,7 @@ The algorithm is based on the observation that for a non-faulty peer, the time o
The true offset thus lies in the correctness interval $[\theta - \lambda_r, \theta + \lambda_r]$ ($\lambda_r$ being the accumulated distance to the root). Two peers whose correctness intervals do not intersect can not possibly agree on the time, and one of them must be wrong. The algorithm tries to find the biggest majority of candidates whose correctness intervals share a common intersection, and discards the other candidates.
Links: [Clock Select Algorithm](https://www.eecis.udel.edu/~mills/ntp/html/select.html), [RFC5905 - section 11.2.1](https://datatracker.ietf.org/doc/html/rfc5905#section-11.2.1), [Marzullo and Owicki, 1983](https://dl.acm.org/doi/pdf/10.1145/800221.806730)
Links: [Mills, Clock Select Algorithm](https://www.eecis.udel.edu/~mills/ntp/html/select.html), [RFC5905 - section 11.2.1](https://datatracker.ietf.org/doc/html/rfc5905#section-11.2.1), [Marzullo and Owicki, 1983](https://dl.acm.org/doi/pdf/10.1145/800221.806730)
### Cluster Algorithm
@ -221,13 +221,27 @@ The cluster algorithm continues until a specified minimum of survivors remain, o
To get some grasp of _why_ it is designed that way, imagine all samples are coming from the same "idealized" peer, and that we select one "most likely accurate" sample. Then as we already saw in the clock filter algorithm, we can compute the jitter of that idealized peer. The selection jitter is essentially a measure of the jitter implied by the decision to consider that sample the most accurate. Now to understand the termination condition, remember that each sample is produced by a peer that itself exhibits some jitter. There is no point in trying to get a better jitter from the combination of all samples, than the minimum peer jitter.
Links: [Cluster Algorithm](https://www.eecis.udel.edu/~mills/ntp/html/cluster.html), [RFC5905 - section 11.2.2](https://datatracker.ietf.org/doc/html/rfc5905#section-11.2.2)
Links: [Mills, Cluster Algorithm](https://www.eecis.udel.edu/~mills/ntp/html/cluster.html), [RFC5905 - section 11.2.2](https://datatracker.ietf.org/doc/html/rfc5905#section-11.2.2)
### Combine
The combined offset and jitter are computed as an average of the survivor's offsets and jitters, weighted by the inverse of the root server's distance.
### Clock Discipline
The combined estimates are passed to the clock discipline algorithm which implements a feedback control loop, whose role is to direct the local system clock towards the reference clock. At its core the clock discipline consists of the non linear combination of a phase locked loop (PLL) and a frequency locked loop (FLL). It results in a frequency correction and a phase correction.
The discipline is further enhanced by a state machine that is designed to adapt the polling interval, and the relative contribution of the PLL and FLL, in order to allow fast initial convergence and high stability in steady state. It also handles special situations such as bursts of high latency and jitter caused by temporarily degraded network conditions.
Links: [Mills, Clock Discipline Algorithm](https://www.eecis.udel.edu/~mills/ntp/html/discipline.html), [Mills, Clock State Machine](https://www.eecis.udel.edu/~mills/ntp/html/clock.html), [Mills, Clock Displine Principles](https://www.eecis.udel.edu/~mills/database/brief/clock/clock.pdf), [RFC5905 - section 11.3](https://datatracker.ietf.org/doc/html/rfc5905#section-11.3)
### Clock Adjust
The clock adjust process is called every second to adjust the system clock. It sums the frequency correction and a percentage of the offset correction to produce an adjustment value. The residual offset correction then replaces the offset correction. Thus, the offset correction decays exponentially over time. When the time since the last poll exceeds the poll interval, the clock adjust process triggers a new poll.
It is worth noting that because it is crucially important to preserve a monotony property, the system clock is never actually stepped back or forth: instead, the system usually throttles the clock up or down until the desired correction has been achieved.
Links: [RFC5905 - section 12](https://datatracker.ietf.org/doc/html/rfc5905#section-12)
# How long things take: durations