20141128 – Putting it all together

Today was the big day where I started to pull all the bits and pieces together.

In the first iteration, the result will be a simulator which can read a file of captured NTP packets, and go through all the motions and control a simulated clock.

Here is some eye-candy which shows that it sorta-works:

../../_images/20141128_fig1.png

First, about the plot.

When the simulator runs it prints a LOT of information on stdout, 680 thousand lines in this case, and while that is great for digging into some nit somewhere, its not very easy to get an idea about the big picture. So out comes gnuplot etc.

But at some point it pays of to spend a little time automating the big picture, and the plot above is the result so far.

The four colums show the immediate startup, where all sorts of transient bogosities happen, the swing-in where the offset is eliminated, a short-term view and the long-term view.

Starting from the top:

  • p/freq is the PLL integrators frequency adjustment. (PPM)

  • p/off is the PLL phase adjustment. (microseconds)

  • c/in is the input to the triangular combiner. (seconds)

  • c/peak is the output of the triangular combiner. (seconds)

  • c/weight is the estimated quality of the combined output. (seconds -1)

This is a testrun where I use two LAN distance stratum 2 servers at a poll-rate of 16 seconds, but it is amazing how little difference it makes if I use nz.pool.ntp.org instead.

But now that I have hole through it all, and a way to see what happens, I can start to polish up the code, stage by stage:

  • NTP packet handling

  • NTP peer state

  • NTP filter

  • Triangular combiner

  • PLL

If you are underwhelmed by the PLL performance in the plot it’s perfectly understandable, it’s just a trivial conservative PI without any of the planned smarts. It doesn’t make sense to tune the PLL until the NTP filter and the combiner are tuned.

It is quite conceiveable that having multiple filter/combiner strategies will make sense, for instance based on the NTP servers stratum, refid or distance. Therefore I have made the NTP filter and the combiner pluggable interfaces, or as modern people call it, “Object Oriented”.

The only difference between the simulator and the real thing will be that we don’t read reality from a input file and that time passes at a natural rate.

phk