Stratum-1 NTP server, part 2


It took me about an hour to work out that I had the board plugged in the wrong way around, and that’s why nothing worked. My excuse is we’re in the middle of a heatwave at the moment ….

Anyway, the picture above is how you’re supposed to do it.

The R-Pi is running standard Raspbian, and the rest of the software setup can be found on this page update: this is the right link.

The board almost immediately finds a timepulse.

After running for a little while:

# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
xPPS(0)          .PPS.            0 l   13   16  377    0.000   -7.334   0.159    3 u   51   64  377   72.959   -1.776   0.711

(and yes I know it says Stratum 0 …)

The output is saying that the GPS source (PPS) has an offset of 7.3ms from the internal clock. The stratum 3 internet source is 1.8ms from the internal clock (but note the internal clock is likely wrong). The delay (round trip?) to the local clock is 0, and the delay from the internet source is 73ms.

They are both currently marked as “x” meaning “falsetickers”. I think ntpd needs a bit longer to decide to use the GPS source.

# ntpq -c rv
associd=0 status=0018 leap_none, sync_unspec, 1 event, no_sys_peer,
version="ntpd 4.2.6p5@1.2349-o Sat Jul  4 15:08:48 UTC 2015 (1)",
processor="armv7l", system="Linux/3.18.11-v7+", leap=00, stratum=1,
precision=-20, rootdelay=0.000, rootdisp=86.994, refid=PPS,
reftime=d942771e.6dc41fc9  Sat, Jul  4 2015 16:15:42.428,
clock=d9427c3a.d8cd27b8  Sat, Jul  4 2015 16:37:30.846, peer=0, tc=4,
mintc=3, offset=0.003, frequency=0.000, sys_jitter=0.116,
clk_jitter=3.476, clk_wander=0.000

Update: After reading this Red Hat article and this document, I realized my mistake was having only two clocksources, which is the worst configuration for ntpd. Adding a bunch more sources makes it better:

# ntpq -c peers
     remote           refid      st t when poll reach   delay   offset  jitter
oPPS(0)          .PPS.            0 l   16   16  377    0.000   -0.094   0.008
*server.104media    2 u   30   64  377   29.748    3.890   0.610     3 u   29   64  377   50.536    0.622   0.268   .GPS.            1 u   27   64  377   71.089    4.371   0.619
-frankfurt1.firs    3 u   26   64  377   35.655    5.620   0.541       3 u   40   64  377   19.761    3.070   0.197    2 u   43   64  377   18.153    3.659   0.176    2 u   48   64  377   25.761    3.648   0.219    2 u   47   64  377   21.566    3.783   0.520

However for some reason it only works when I restart the NTP server a minute after boot. It may be that the kernel PPS device isn’t ready when the NTP server starts first time. In any case, I added this to /etc/rc.local:

( sleep 60 ; service ntp restart ) &

1 Comment

Filed under Uncategorized

One response to “Stratum-1 NTP server, part 2

  1. problemchild68

    Yeah the GPS is Stratum 0 does that make you 0 or 1 depends if our talking locally or remote I suppose.

    BTW I do something similar you can just use one of the 10-20£ USB GPS modules and a 5M cable then tie it to the rafters in the loft , job done for most folk even with slates on the roof that way you can use any old crappy computer and not buy RPI dedicated gear.

    Good project though Richard

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.