Refclock NMEA behaves perversely on GPS signal loss.

Using refclock NMEA for NMEA and PPS can lead to more time instability than it should when the GPS signal gets lost and re-acquired.

The test is simple, just setup an NMEA refclock, like this:

# #20 GPS direct
server 127.127.20.0 mode 16 minpoll 4 maxpoll 4
fudge 127.127.20.0 flag1 1 flag2 0 refid GPS

For fun, I setup another GPS on SHM for comparison:

# SHM for gpsd
server 127.127.28.0 minpoll 4 maxpoll 4
fudge 127.127.28.0 time1 0.480  refid GPS

# SHM for PPS and gpsd
server 127.127.28.1 prefer minpoll 4 maxpoll 4
fudge 127.127.28.1 refid GPS1

Yes, there is no time2 to correct the NMEA fudge on the NMEA refclock, but that is a common configuration since it is hard to see the fudge, so people do not set it properly. It makes this problem easier to see, but setting time2 does not fix the problem.

In normal usage, the NMEA refclock takes the NMEA time to find the nearest second for the PPS, then uses the PPS time going forward to compute the offset and jitter.

Now cover the GPS with Aluminium foil, until it loses signal lock, ntpd will properly remove that refclock as bad, after the expected delays.

Now uncover the GPS, and watch the fun.

ntpd will first see the now good NMEA 480 millisSec off. Since it still has a low jitter (from the PPS), ntpd will now jump the local clock part way of the 480 milliSec NMEA offset. ntpd now marks the GPS as high jitter, and transfers to other good chimers.

This leaves the system clock somewhere between the NMEA and other good chimers. So now all the refclocks get marked high jitter.

Next ntpd will see the PPS on the SHM, 480 milliSec off the other way, and mark GPS as high jitter.

Eventually, if the PPS stays stable, the computed jitter will decrease, and ntpd will one again select the NMEA PPS.

Not good, and hard to spot since the underlying NMEA and PPS data is mushed and hidden from the user. This scenario is not a problem when using the SHM refclock. Also not a problem when using NMEA and PPS, or GPSD_JSON in undocumented tandem mode.

Refclock NMEA can likely be fixed the way refclock GPSD_JSON was partially fixed, by not mushing the NMEA and PPS times together into the jitter, offset, etc.

Until NMEA is fixed, consider it unhealthy with marginal GPS signals.

Edited by Eric S. Raymond