[[ntpgps]]

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ntpgps [2016/02/26 10:19]
admin
ntpgps [2018/03/06 08:59]
Line 1: Line 1:
-====== ntp gps setup ====== 
-This process has been complicated and messy, because of the combination of 1) I don't know what I'm doing, and 2) the resources on this are good but complicated. Almost everything I've figured out has come from these two pages: 
-  * http://​kenyonralph.com/​~kenyon/​Time_server/​ 
-  * http://​superuser.com/​questions/​828036/​how-can-i-check-whether-my-ntp-daemon-has-pps-support 
  
-I had to fill in a few holes here and there, so I am going to try and get a comprehensive guide in place here, because I will forget. ​ 
- 
-===== Setup ===== 
-  * dc7900 running ubu server 14.04 
-  * Garmin 18x LVC to ttyS0 on above, spliced in USB conn for power 
- 
-===== Guide ===== 
-  - Install and update ubuntu server on machine. Desktop works but server is lighter. This guide will also probably work for debian but I am writing it for ubu now because that's what I have working. 
-  - [[http://​www.techytalk.info/​disable-and-remove-apparmor-on-ubuntu-based-linux-distributions/​|Disable apparmor]]. This is a single purpose server. Apparmor is garbage and gets in the way of everything. Do so by: <​code>​sudo service apparmor stop</​code><​code>​sudo update-rc.d -f apparmor remove</​code>​ 
-  - Prepare to build ntp with pps support (get all the bits) <​code>#​ apt-get build-dep ntp</​code><​code>​ # apt-get install pps-tools ubuntu-dev-tools</​code><​code>#​ apt-get source ntp</​code><​code>#​ cd ntp*</​code>​ 
-  - Attempt to build. THIS WILL FAIL! Whatever. If not, who knows. <​code>#​ dpkg-buildpackage -uc -us -nc</​code>​ 
-  - It failed. Fix it by editing: <​code>​nano ntpd/​refclock_jupiter.c</​code>​ 
-  - Go to line 904. Comment it out as such <​code>/​* fprintf(stdout,​ buffer); */</​code>​ (yes this commenting could be done before the attempted build, but if it works before hand, you save a step. Compiling again after the failure is very fast anyway) 
-  - Compile again <​code>#​ dpkg-buildpackage -uc -us -nc</​code>​ 
-  - Install! <​code>#​ dpkg -i *.deb</​code>​ (the deb will be up a level) 
-  - Configure udev rules to properly configure the devices at boot. <​code>#​ Provide a symlink to /dev/ttyS0 and set low_latency for latency improvement 
-KERNEL=="​ttyS0",​ SYMLINK+="​gps0",​ MODE="​0666"​ 
-KERNEL=="​ttyS0",​ RUN+="/​bin/​setserial /dev/%k low_latency"​ 
-KERNEL=="​ttyS0",​ RUN+="/​usr/​sbin/​ldattach pps /​dev/​%k"​ 
- 
-# Symlink /dev/pps0 to /​dev/​gpspps0 
-KERNEL=="​pps0",​ SUBSYSTEM=="​pps",​ DRIVER=="",​ SYMLINK+="​gpspps0"​ 
-KERNEL=="​pps0",​ GROUP="​dialout"​ 
-KERNEL=="​pps0",​ MODE="​0666"</​code>​ For some reason, the ldattach bit never works for me and I have to run it manually after rebooting. This is a huge pain and I don't know how to fix it yet. 
-  - Add user ntp to the dialout group <​code>​sudo gpasswd -a ntp dialout</​code>​ 
-  - Configure /​etc/​ntp.conf as such:<​code>#​ /​etc/​ntp.conf,​ configuration for ntpd; see ntp.conf(5) for help 
- 
-driftfile /​var/​lib/​ntp/​ntp.drift 
- 
-# 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. 
-# local mess 
-server 127.127.20.0 mode 18 minpoll 4 iburst prefer true 
-fudge 127.127.20.0 flag1 1 flag2 0 flag3 1 flag4 1 
- 
-# Use time-a and b ntp servers as a fallback. 
-server time-a.nist.gov 
-server time-b.nist.gov 
- 
-# By default, exchange time with everybody, but don't allow configuration. 
-restrict -4 default kod notrap nomodify nopeer noquery 
-restrict -6 default kod notrap nomodify nopeer noquery 
- 
-# Local users may interrogate the ntp server more closely. 
-restrict 127.0.0.1 
-restrict ::1 
- 
-# Clients from this subnet have unlimited access, but only if 
-# cryptographically authenticated. 
- 
-restrict 10.0.0.0 mask 255.0.0.0 notrust</​code>​Tweak as necessary. I don't know all the fudge flags yet. This can be improved. 
-  - Restart ntp service <​code>​sudo service ntp restart</​code>​ 
-  - Check ntpq -p output. If everything went well, you should see something like this:<​code>​john@dc7900:​~$ ntpq -p 
-     ​remote ​          ​refid ​     st t when poll reach   ​delay ​  ​offset ​ jitter 
-============================================================================== 
-oGPS_NMEA(0) ​    ​.GPS. ​           0 l    6   ​16 ​ 377    0.000    0.623   0.072 
-*time-a.nist.gov .ACTS. ​          1 u   ​25 ​  ​64 ​ 373   ​91.647 ​  ​36.162 ​  4.774 
-+time-b.nist.gov .ACTS. ​          1 u   ​18 ​  ​64 ​ 165   ​96.251 ​  ​41.469 ​  ​2.220</​code>​If anything failed, check journalctl -xe to see if there are any hints. There almost always are. 
-  - Just for funsies, ntpq -pcrv output:<​code>​john@dc7900:​~$ ntpq -pcrv 
-     ​remote ​          ​refid ​     st t when poll reach   ​delay ​  ​offset ​ jitter 
-============================================================================== 
-oGPS_NMEA(0) ​    ​.GPS. ​           0 l   ​15 ​  ​16 ​ 377    0.000    0.492   0.044 
-+time-a.nist.gov .ACTS. ​          1 u   ​26 ​  ​64 ​ 337   ​91.647 ​  ​36.162 ​  4.632 
-*time-b.nist.gov .ACTS. ​          1 u   ​23 ​  ​64 ​ 257   ​92.135 ​  ​38.865 ​  4.538 
-associd=0 status=041d leap_none, sync_uhf_radio,​ 1 event, kern, 
-version="​ntpd 4.2.6p5@1.2349-o Fri Feb 26 13:56:57 UTC 2016 (1)", 
-processor="​x86_64",​ system="​Linux/​4.2.0-16-generic",​ leap=00, stratum=1, 
-precision=-21,​ rootdelay=0.000,​ rootdisp=0.979,​ refid=GPS, 
-reftime=da7ae733.9e1ec802 ​ Fri, Feb 26 2016 10:​01:​07.617,​ 
-clock=da7ae742.600f0f00 ​ Fri, Feb 26 2016 10:​01:​22.375,​ peer=45935, tc=4, 
-mintc=3, offset=0.492,​ frequency=22.723,​ sys_jitter=0.044,​ 
-clk_jitter=0.000,​ clk_wander=0.145</​code>​ 
- 
- 
-====== To D0 & Thoughts ====== 
-Right now my offset and jitter can be improved. This can be done by: 
-  * Disable all but GPGGA 
-  * Push pulse width to 200ms 
-  * Some people don't like, and have trouble with, the 18x LVC: 
-    * http://​support.ntp.org/​bin/​view/​Support/​ConfiguringGarminRefclocks 
-  * Similar to above: 
-    * http://​support.ntp.org/​bin/​view/​Support/​ConfiguringNMEARefclocks 
-    * I think it's worth noting that my jitter is WAY lower than being reported there. One guy is setting 5-10ms jitter while I am seeing <0.024ms jitter. Either that guy has a bad unit and is being a negative nancy, or firmware updates have made them notably better. 
-  * Get serial pass-through working on the TS140. This will take some tinkering but should be doable. Latency is my only concern. 
ntpgps.txt ยท Last modified: 2018/03/06 08:59 (external edit)
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0