From 1ffb3750b4445384921b69f5978c2dadf6777254 Mon Sep 17 00:00:00 2001 From: Martin Fouilleul Date: Sat, 4 Jun 2022 13:14:22 +0200 Subject: [PATCH] Description of the on-wire protocol --- selected/NTP_on_wire.svg | 273 +++++++++++++++++++++++++++++++++++++++ selected/time.md | 38 +++++- 2 files changed, 310 insertions(+), 1 deletion(-) create mode 100644 selected/NTP_on_wire.svg diff --git a/selected/NTP_on_wire.svg b/selected/NTP_on_wire.svg new file mode 100644 index 0000000..30ba9de --- /dev/null +++ b/selected/NTP_on_wire.svg @@ -0,0 +1,273 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/selected/time.md b/selected/time.md index fcf1e42..a215d3a 100644 --- a/selected/time.md +++ b/selected/time.md @@ -149,9 +149,45 @@ To maintain a consistent notion of time accross the internet, you first need som The protocol selects sources in order to avoid loops and minimize the round-trip delay to a primary server. As such peers collaborate to automatically reorganize the network to produce the most accurate time, even in the presence of failures in the network. -## Peer Architecture +## NTP Architecture + +Now let's see the implementation of one node of the network. The following diagram shows the various stages of the pipeline used to collect time information and mitigate errors caused by network delays and clock inaccuracies. I'll explain each one in a short paragraph and give links to dig deeper. + ![NTP architecture flow graph](./NTP_architecture_summary.svg) +### On-Wire Protocol +The first stage consists of getting time estimates from each peer. In the simplest mode of operations, the node polls a peer by sending a request packet timestamped with the transmission time, $t_1$. Upon reception of the request, the peer stores a timestamp $t_2$, processes the message, and sends a response packet containing $t_1$, $t_2$ and the response transmission time $t_3$. The node receives the response at time $t_4$. + +![NTP architecture flow graph](./NTP_on_wire.svg) + +The node then compute the tuple $(\delta, \theta, \epsilon)$, where: + +- $\delta$ is the round-trip delay. +- $\theta$ is the estimated offset of the server clock with respect to the local clock. +- $\varepsilon$ is the dispersion of the sample, i.e. the maximum error due to the frequency tolerances $\varphi_p$ and $\varphi_c$ of the peer's clock and of the client's clock, and the time elapsed since the request was sent. + +$\begin{align*} +\delta = (t_4 - t_1) - (t_3 - t_2) \, ,\qquad +\theta = ((t_2 - t_1) + (t_3 - t_4))/2 \, ,\qquad +\varepsilon = \varphi_p \times \varphi_c \times \delta\,. +\end{align*}$ + +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) + +### Clock Filter + +### Clock Selection + +### Cluster Algorithm + +### Clock Discipline + +### Clock Adjust + + + # How long things take: durations Computer clocks