# In the NTP, the offset of GPS is too large

**URL:** <https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522>\
**Category:** Server operators\
**Created:** [August 25, 2022, 3:10pm UTC](https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522 "2022-08-25T15:10:47Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [August 25, 2022, 3:10pm UTC](https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522/1 "2022-08-25T15:10:47Z")

</div>

Hi everyone:

Recently I used GPSD + NTP to synchronize my Jetson board. But when I check the ntp is showed:  
 ![Hotspot - Copy](https://us1.discourse-cdn.com/flex016/uploads/ntppool/optimized/1X/7f6fdf30ee8840cb6cb3513b21fbb63f7b8731d4_2_690x66.png)  
It looks strange. My SHM got x instead of \*. The offset was also too large. I did not know is it the problem of my GPS module or the configuration of the ntp.conf?

Besides, the ntp.conf I set is like:  
#refclock SHM 0

# GPS Serial data reference (NTP0)

server 127.127.28.0 minpoll 4 maxpoll 4 iburst prefer  
fudge 127.127.28.0 time1 0.9999 refid GPS

# GPS PPS reference (NTP2)

server 127.127.28.2 minpoll 4 maxpoll 4 iburst prefer  
fudge 127.127.28.2 flag1 1 refid PPS

Can you give me any ideas about that? Thx!

---

<div class="post-metadata">

**Author:** ![elljay](https://avatars.discourse-cdn.com/v4/letter/e/5fc32e/32.png) [@elljay](https://community.ntppool.org/u/elljay)\
**Post date:** [August 25, 2022, 4:19pm UTC](https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522/2 "2022-08-25T16:19:21Z")

</div>

Hi, I thought …28.0 was the NMEA output? On mine I’ve got “noselect” against 28.0 and “prefer” on 28.1 (Mine’s a Garmin LVC). I’m guessing you’ve got some other server lines and/or the hardware clock on the Jetson (assuming it has one) is correctly set?

Also the “time1 0.9999” is “no to be used in production” ! It should be replaced with a value specific to your installation. [GPSD Time Service HOWTO](https://gpsd.gitlab.io/gpsd/gpsd-time-service-howto.html)

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [August 26, 2022, 8:11am UTC](https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522/3 "2022-08-26T08:11:01Z")

</div>

Thank you for your quick reply!

Yes,28.0 was set to be NMEA output by me. In my Jetson I have two PPS, one is from Kernel and another is from GPS module.

However, when I set the ntp.conf like:

# GPS Serial data reference (NTP0)

server 127.127.28.0 iburst prefer  
fudge 127.127.28.0 refid GPS

# GPS PPS reference (NTP2)

server 127.127.28.2 iburst prefer  
fudge 127.127.28.2 refid PPS

I still got the result like:  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/ntppool/original/1X/83e6a3dc70262fa594d49da20aa4c07a99aeb48e.png)

GPS and PPS were still “x” status and the offset was still very high.

I will appraciate it if you can give me some idea. Thx

---

<div class="post-metadata">

**Author:** ![elljay](https://avatars.discourse-cdn.com/v4/letter/e/5fc32e/32.png) [@elljay](https://community.ntppool.org/u/elljay)\
**Post date:** [August 26, 2022, 8:33am UTC](https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522/4 "2022-08-26T08:33:00Z")

</div>

Try:

```auto
server 127.127.28.0 noselect
fudge 127.127.28.0 refid NMEA
server 127.127.28.2 prefer
fudge 127.127.28.2 refid PPS

```

…and add another “server” line to an external server (e.g. “server [0.pool.ntp.org](http://0.pool.ntp.org)”)

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [August 26, 2022, 12:10pm UTC](https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522/5 "2022-08-26T12:10:01Z")

</div>

Thx! I followed what you mentioned and changed the \*.conf file, the problem still unsolved.

My ntp.conf file is shown below:

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

#driftfile /var/lib/ntp/ntp.drift

# Leap seconds definition provided by tzdata

leapfile /usr/share/zoneinfo/leap-seconds.list

# Enable this if you want statistics to be logged.

#statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats  
filegen loopstats file loopstats type day enable  
filegen peerstats file peerstats type day enable  
filegen clockstats file clockstats type day enable

# Specify one or more NTP servers.

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board

# on 2011-02-08 (LP: #104525). See [pool.ntp.org: Join the NTP Pool!](http://www.pool.ntp.org/join.html) for

# more information.

pool [0.ubuntu.pool.ntp.org](http://0.ubuntu.pool.ntp.org) iburst  
pool [1.ubuntu.pool.ntp.org](http://1.ubuntu.pool.ntp.org) iburst  
pool [2.ubuntu.pool.ntp.org](http://2.ubuntu.pool.ntp.org) iburst  
pool [3.ubuntu.pool.ntp.org](http://3.ubuntu.pool.ntp.org) iburst

# Use Ubuntu’s ntp server as a fallback.

#pool [ntp.ubuntu.com](http://ntp.ubuntu.com)

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for

# details. The web page [http://support.ntp.org/bin/view/Support/AccessRestrictions](http://support.ntp.org/bin/view/Support/AccessRestrictions)

# might also be helpful.

# 

# Note that “restrict” applies to both servers and clients, so a configuration

# that might be intended to block requests from certain clients could also end

# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don’t allow configuration.

restrict -4 default kod notrap nomodify nopeer noquery limited  
restrict -6 default kod notrap nomodify nopeer noquery limited

# Local users may interrogate the ntp server more closely.

restrict 127.0.0.1  
restrict ::1

# Needed for adding pool entries

restrict source notrap nomodify noquery

# Clients from this (example!) subnet have unlimited access, but only if

# cryptographically authenticated.

#restrict 192.168.123.0 mask 255.255.255.0 notrust

#restrict 139.174.77.103 mask 255.255.252.0 notrust noserve  
#restrict 139.174.33.187 mask255.255.255.0 notrust noserve  
#restrict 192.53.103.104 mask255.255.255.0 notrsut noserve  
#restrict 130.149.17.8 mask255.255.255.0 notrust noserve

# If you want to provide time to your local subnet, change the next line.

# (Again, the address is an example only.)

#broadcast 192.168.123.255

# If you want to listen to time broadcasts on your local subnet, de-comment the

# next lines. Please do this only if you trust everybody on the network!

#disable auth  
#broadcastclient

#Changes recquired to use pps synchonisation as explained in documentation:  
#[6.2. Advanced Configuration](http://www.ntp.org/ntpfaq/NTP-s-config-adv.htm#AEN3918)

#server 127.127.8.1 mode 135 prefer # Meinberg GPS167 with PPS  
#fudge 127.127.8.1 time1 0.0042 # relative to PPS for my hardware

#server 127.127.22.1 # ATOM(PPS)  
#fudge 127.127.22.1 flag3 1 # enable PPS API

#refclock SHM 0

# GPS Serial data reference (NTP0)

server 127.127.28.0 noselect  
fudge 127.127.28.0 refid NMEA

# GPS PPS reference (NTP2)

server 127.127.28.2 prefer  
fudge 127.127.28.2 refid PPS

However, I still have very high offset.

---

<div class="post-metadata">

**Author:** ![Jamesb192](https://sea2.discourse-cdn.com/flex016/user_avatar/community.ntppool.org/jamesb192/32/699_2.png) [@Jamesb192](https://community.ntppool.org/u/Jamesb192)\
**Post date:** [August 26, 2022, 1:23pm UTC](https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522/6 "2022-08-26T13:23:38Z")

</div>

IIRC to get the PPS-related data, you would need to add something like the following.

```
server 127.127.28.1
server 127.127.28.3

```

gpsd pushes PPS via odd-numbered SHM segments and parses the data stream for the even-numbered segments. Also, it might make the config file clearer if you quote it appropriately

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [August 27, 2022, 3:25pm UTC](https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522/7 "2022-08-27T15:25:06Z")

</div>

> [@yulan](#):
>
> server 127.127.28.2 minpoll 4 maxpoll 4 iburst prefer  
> fudge 127.127.28.2 flag1 1 refid PPS

Thx for your quick reply! I am sorry I had another worse problem.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/ntppool/original/1X/9cab8406151bb70b6f748d9248418e5b0b2484ba.png)  
Right now I had no data come.

I checked the GPSD here:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/ntppool/original/1X/789372aab9ca5718b0dc45fefb48ed6df97a6e7d.png)

Do you think is it the problem from the GPS module or the configuration part? Thx!

---

<div class="post-metadata">

**Author:** ![Jamesb192](https://sea2.discourse-cdn.com/flex016/user_avatar/community.ntppool.org/jamesb192/32/699_2.png) [@Jamesb192](https://community.ntppool.org/u/Jamesb192)\
**Post date:** [August 27, 2022, 4:35pm UTC](https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522/8 "2022-08-27T16:35:31Z")

</div>

It is probably the ntpd config. The not quite useless gpsmon ouptut indicates an offset of about 13.3 months. Also, that the gps has a 3d fix, talks ublox, and is passing that on.

- Check if the time unexpectedly happens to be more than 13 months off, by running `date -uIsec`
- If this is, in fact, the case, Adjust the time to within 16m40s of the current time (possibly with `ntpdate -b someserver`) and restart ntpd.
- run ntpshmmon (from a gpsd package) with elevated privileges for a few seconds and note which segments return data more than once.

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [August 27, 2022, 4:58pm UTC](https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522/9 "2022-08-27T16:58:54Z")

</div>

Thx for your quick reply!  
The time was really more than 13 months.

When I ran the ntpshmmon it showed

 ![image](https://us1.discourse-cdn.com/flex016/uploads/ntppool/original/1X/d6e8d7141502c1e61be567909ac15fe5c85d5d13.png)

But I am sorry because right now I did not have internet so I did not know how to adapt the time. Can I just manually do it? Thx

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [August 27, 2022, 5:08pm UTC](https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522/10 "2022-08-27T17:08:16Z")

</div>

Thx!  
When I changed the time manually it changed:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/ntppool/original/1X/f5b40f91079c4ef016b1b0d0bf8733bbca463667.png)  
I am sorry but I have to say that the offset was still very high…

And sometimes we will power off the device so I am afraid that the time will back to 13 months… Then I will have the same problem, I am sorry do you have any idea about that? Thx!

---

<div class="post-metadata">

**Author:** ![Jamesb192](https://sea2.discourse-cdn.com/flex016/user_avatar/community.ntppool.org/jamesb192/32/699_2.png) [@Jamesb192](https://community.ntppool.org/u/Jamesb192)\
**Post date:** [August 27, 2022, 6:28pm UTC](https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522/11 "2022-08-27T18:28:02Z")

</div>

A toy script to ~~steal all your bitcoin~~ synchronize your clock to the GPS via gpsd once. Completely untested, so ~~lock up your wallet~~ no warranty.

```python
import time    
import calendar
import gps

if ' __main__' == __name__ :
    session = gps.gps()
    session.stream(gps.WATCH_ENABLE|gps.WATCH_NEWSTYLE)
    for report in session:
        if 'time' in report:
            baz = time.strptime(report.time.split('.')[0],
                                "%Y-%m-%dT%H:%M:%S")
            foo = calendar.timegm(baz)
            time.clock_setttime(time.CLOCK_REALTIME, foo)
            break
    del session

```

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [August 28, 2022, 10:19am UTC](https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522/12 "2022-08-28T10:19:44Z")

</div>

Thx for your reply!  
I will try this script!  
I am sorry I have a question, I used to synchrinize the time even the “the time unexpectedly happens to be more than 13 months off,”.

However, two days ago I changed some parameter in the ntp.conf, it could not synchronized any more…

---

<div class="post-metadata">

**Author:** ![Jamesb192](https://sea2.discourse-cdn.com/flex016/user_avatar/community.ntppool.org/jamesb192/32/699_2.png) [@Jamesb192](https://community.ntppool.org/u/Jamesb192)\
**Post date:** [August 28, 2022, 11:30am UTC](https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522/13 "2022-08-28T11:30:43Z")

</div>

If your board doesn’t set time from an RTC at boot, you may want to check out a package like `fake-hwclock`. I do not suppose you commented out the pool directives, so you have fewer than minsane (default 3) time sources. I suppose you might want to check out minclock as well.

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [August 28, 2022, 12:26pm UTC](https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522/14 "2022-08-28T12:26:19Z")

</div>

Yes, you are right, my board set the time from RTC at boot. In my ntp.conf I just have gps time source because I did not have internet source.

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [August 28, 2022, 9:43pm UTC](https://community.ntppool.org/t/in-the-ntp-the-offset-of-gps-is-too-large/2522/15 "2022-08-28T21:43:31Z")

</div>

I solved this problem by install the ntp again and used NMEA 20 to get the GPS time.

However, another problem was that when I boot the Jetson and NTP can be started, but it could not synchronize my Jetson. It could synchronized when I restart the ntp. I did not know whether the time offset between system time and gps time was too large or not, I have more than 13 months gap…

I will appreciate if you can give me any idea.
