N8UR's NTP Stuff

Updated 12/31/97


I've been experimenting with getting the Network Time Protocol (ntp) software working with a Linux computer and the TAPR Totally Accurate Clock/Motorola Oncore GPS receiver unit.

This page is a collection of stuff that I've found useful.

First, if you're interested in the TAC project and other GPS stuff that TAPR makes available, go to http://www.tapr.org/tapr/html/tac2.html/. If you want to learn a lot about TAC, you should join the tacgps@tapr.org mailing list. You can subscribe to it from the TAPR page.

Second, you'll need to have the xntp3 software suite installed on your system. The home page for ntp generally is http://www.eecis.udel.edu/~ntp and the latest version of xntp3 (currently xntp3-5.91) is available there. There's lots of other interesting stuff there, too.

Next, to enable the high-accuracy "kernel timekeeping model" mode in Linux, you need the PPSkit developed by Ulrich Windl, which is a set of patches B for both the xntpd daemon, and the Linux kernel. It's available from ftp://pcphy4.physik.uni-regensburg.de/pub/wiu09524/PPS/.

Apply the PPSkit patches to the Linux kernel and recompile. Then, apply the patches to xntp3-5.91/xntpd directory, cd up to the main xntp3 directory, and run "make" and then "make install". If you want to include an updated driver for the Motorola GPS receiver, read the next section before you build xntpd.

A new Reference Clock Driver for the Motorola Oncore

The xntpd daemon supports a number of different reference clocks. Figuring out which one to use and how to configure the software isn't particularly intuitive.

The standard package includes a generic GPS driver that will work with any receiver that outputs the "RMC" NMEA sentence. Unfortunately, (a) the Motorola Oncore would like to use a different NMEA sentence ("ZDA") when it's operating in its most accurate timekeeping mode, and (b) there is a tremendous amount of jitter in the time this driver reports. That's because it is simply looking for the CR character at the end of the NMEA sentence for the time mark. The first problem is that that character isn't positioned right at the second mark; you can configure an offset into the software to deal with this. In addition, the position of the selected sentence within the second (and therefore the position of the time mark) moves around by up to a couple of hundred milliseconds depending on what sentences the Oncore is programmed to output, and how long those sentences are. This jitter is enough to cause havoc in the system.

To address these problems, there's a new (experimental) driver available. Jeremy Bishop modified the generic GPS NMEA driver to support the ZDA sentence (by the way -- the GPRMC sentence is still supported, so this driver will still work with TACs that use GPS-20 or GPS-25 receivers), and I cobbled code into it to support the precise 1pps tick available from the Motorola/TAC combination for the time mark. This driver has a jitter of only a couple of milliseconds compared to the kernel pps signal.

The end result is available from ftp://ftp.febo.com/pub/linux_ham/refclock_mot.c.gz. At present, this driver is simply a replacement for generic nmea driver in the ./xntpd subdirectory of the xntpd3 source tree. You'll need to rename it from refclock_mot.c to refclock_nmea.c in the ./xntpd directory, then cd up to the main xntpd directory and build the program as normal.

I hope that either this, or another TAC driver based on a more sophisticated GPS driver, will be registered as a distinct driver type for future xntp3 releases.

Here is a sample /etc/ntp.conf file that seems to work for this combination:


# /etc/ntp.conf for Linux pps kernel and TAC GPS receiver
driftfile /var/lib/ntp/ntp.drift # remember the drift value
logfile /var/log/ntp/xntpd # log file
statsdir /var/log/ntp/ # directory for stats filesBR>
statistics loopstats peerstats clockstats # keep these stats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

# Use GPS/TAC clock
server 127.127.20.0 prefer # GPS/NMEA clock
fudge 127.127.20.0 flag3 1 # PPS processing

# Enable kernel PPS
enable pps

# Servers for backup
server ntp1.foo.bar
server ntp2.foz.bar
server ntp3.faz.bar

A couple of notes:

  • You need to set flag 3 for the nmea driver to 1, even though the docs will tell you the driver doesn't support that flag. Otherwise, the pps code won't run.

  • The "ATOM" driver and the kernel pps discpline are separate creatures. You don't need to run the ATOM driver to make the kernel pps work. In fact, you don't even need to run the GPS driver. You do need to have a "prefer" peer defined, though.

  • If someone can tell me how to interpret the results from "ntptime", I'd sure appreciate it.

    There is still an awful lot I don't understand about fine-tuning Linux and xntpd to work optimally with the Oncore/TAC system. Thanks to Jeremy Bishop, Ulrich Windl, Henk Uijterwaal, Randolph Bentson, and Dave Mills for telling me just about everything that's on this page. I didn't create much, I just collected it...

    Return to NTP & GPS page.