Imagine a chord-like network $N$. each machine $m \in N$ is directly connected to $N_m \subset N$.
Without relying on official timeservers, I want all machines to synchronize to some time with millisecond precision.
my algorithm is executed some time after a machine joined the network, and works as follows:
- the machine asks each machine it is directly adjacent to what it thinks the network time is, adjust for latency and subtract local time from that
- take the median delta of that list, and apply that to the local time as the network time.
Intuitively I think that this method is self-stabilizing because the deviation, and its error should be normally distributed around a consensus, and the $\sigma$ of the delta should decrease over time.
Problem is, I think that a relatively small number of bad actors can poison the network: if only $|N_{m_0}|/2 +1$ of the machines in $N_{m_0}$ don't abide by the protocol and report a doctored time, $m_0$ becomes poisoned and starts trying to poison other innocent nodes in $N_{m_0}$, and so forth, until all of $N$ is poisoned.
I was wondering whether I was correct, and if you know of any papers on the topic, because this seems more complex than I originally thought. Is a blockchain really required?