Building a Stratum 1 NTP Server Using Raspberry Pi
-
Hi all --
This is a follow up post from a thread started here:
https://forum.netgate.com/topic/143285/sg-2340-mbt-4220-gps-lure-stratum-1-ntp-clock-under-pfsense
I'm curious if anyone out there as built a Stratrum 1 NTP server using a Raspberry Pi and GPS HAT? It sounds like a fun little weekend project. If so, what components did you use (e.g. Raspberry Pi version, GPS HAT, case, etc.)? Also, I found this guide online -- for those that have build an NTP server using a Pi -- is this what you followed?
https://www.ntpsec.org/white-papers/stratum-1-microserver-howto/
Here also is a nice comparison between using a custom built Pi solution vs. a couple off the shelf solutions:
https://coverclock.blogspot.com/2017/03/my-stratum-1-desk-clock.html
Thanks in advance for your help and insight.
-
@johnpoz specifically said in that thread that he was running exactly that configuration. Perhaps he could share the details with you.
-
Yeah I have 1 running... Be happy to share..
Let me look up what hat I specifically ordered... BRB
edit: here you go this is the one I bought
https://store.uputronics.com/index.php?route=product/product&path=60_64&product_id=81Back on 01/03/2016, here is link to guide in setting it up on a pi
https://ava.upuaut.net/?p=951Part of the reason when with this one back when I was doing the same thing - weekend fun project :) I didn't want to have to do any soldering at all, etc.. just click the parts together ;) And do some commands and bing bang zoom instant ntp server..
All total came to £61.22, with international shipping and external antenna and case..
You could prob do cheaper today... But that is what I found when was looking over 3 years ago where I didn't have to do any soldering, and they had nice easy to follow instructions as well.
pi@ntp:~ $ ntpq ntpq> pe remote refid st t when poll reach delay offset jitter ======================================================================================================= *SHM(1) .PPS. 0 l 61 64 377 0.0000 -0.5712 0.0131 xSHM(0) .GPS. 0 l 37 64 377 0.0000 -116.273 1.5973 +ntp.your.org .CDMA. 1 u 23 64 377 31.5511 11.7484 3.7774 ntpq>
Thanks for bringing this up - looking up the links to what I bought and then reading comments on that guide I found this
https://github.com/SlightlyLoony/gpsctlGoing to be playing with that soon ;)
-
@johnpoz - thanks for sharing details of your setup. I came across those same sources today in my searches (both guides and retailers for parts). Interestingly enough, it doesn't seem too much cheaper today compared to when you ordered the parts three years ago.
One quick question I did have for you - what kind of case did you decide to go with? Was it clear so you could see the PPS pulse LED, or just a regular black case? Curious what your preferences were at the time. Granted in my case (no pun intended) this box will probably be stashed away with the rest of my networking gear so no benefit of seeing internals unless I was trying to debug something.
Also, what made you follow this guide
https://ava.upuaut.net/?p=951
over this guide?
https://www.ntpsec.org/white-papers/stratum-1-microserver-howto/
Was there any particular reason? Thanks again!
-
@tman222 I followed this guide which uses a odroid c2 which is similar to the pi.
https://nguvu.org/pfsense/network%20time%20protocol%20(ntp)/ntp-server/ -
-
That guide should work fine..
And I got a dog bone clear case - so yeah can see the blinking lights ;)
here took a quick pic
-
Thanks guys - I really appreciate all the additional information! This is starting to sound like a really fun (and affordable) way to tinker around with SBCs while learning a thing or two about precision timekeeping in a networking environment. :)
@q54e3w - I looked through the nguvu.org guide and I liked the Odroid hardware stack that was chosen, especially the integration of PoE and (what appears to be) native gigabit ethernet support on the SBC. I didn't realize that there were PoE HAT's available that allowed further stacking of additional HAT's -- the one I found on the Raspberry Pi site didn't have that functionality unfortunately. Now, the $64,000 question I have for you (and everyone else) is -- is there even a case available out there to protect an SBC and taller double HAT stack like that? Or would it have to be custom machined? Does anyone have any idea?
Thanks again for your help and insight, I really appreciate it!
-
@johnpoz said in Building a Stratum 1 NTP Server Using Raspberry Pi:
0.0131
That's some fine jitter!
Steve
-
@tman222 said in Building a Stratum 1 NTP Server Using Raspberry Pi:
is there even a case available out there to protect an SBC and taller double HAT stack like that?
While I have not actually looked into these particular hats your talking about, etc. The typical dogbone cases normally allow for extra spacers to allow for different hats...
Once you get your ntp up and running - let us know the particulars ;)
Maybe this summer when get some free time I will be looking into using the Galileo satellites, from what I have been reading after this thread re perked my interest is that those are disabled by default for use in the hat.. and have to use the gpsctl code that is out there to enable them, etc..
-
@johnpoz said in Building a Stratum 1 NTP Server Using Raspberry Pi:
@tman222 said in Building a Stratum 1 NTP Server Using Raspberry Pi:
is there even a case available out there to protect an SBC and taller double HAT stack like that?
While I have not actually looked into these particular hats your talking about, etc. The typical dogbone cases normally allow for extra spacers to allow for different hats...
Once you get your ntp up and running - let us know the particulars ;)
Maybe this summer when get some free time I will be looking into using the Galileo satellites, from what I have been reading after this thread re perked my interest is that those are disabled by default for use in the hat.. and have to use the gpsctl code that is out there to enable them, etc..
Thanks @johnpoz - coincidentally, the same thing dawned on me a little bit ago while looking at Odroid cases, i.e. that the dogbone cases (i.e. cases hat just have a top and bottom plate) can we made height variable using multiple standoffs / spacers. For instance, I believe this is essentially the same style of case for the Odroid - would you agree?
https://ameridroid.com/collections/cases/products/odroid-c-series-raspberry-pi-case-black?variant=12363871911970
I think a PoE powered variant will be cool - also gives some flexibility in terms of location around the house (for best satellite signal).
-
@tman222 I pimped my Pi-hole a week ago. It's on the standard Raspbian OS. Far from an expert, but it works fine I guess.
# ntpq -crv -pn associd=0 status=0415 leap_none, sync_uhf_radio, 1 event, clock_sync, version="ntpd 4.2.8p10@1.3728-o Sat Mar 10 18:03:33 UTC 2018 (1)", processor="armv7l", system="Linux/4.19.42-v7+", leap=00, stratum=1, precision=-19, rootdelay=0.000, rootdisp=1.045, refid=NMEA, reftime=e09a0a64.10b97e83 Thu, May 30 2019 9:53:08.065, clock=e09a0a67.928ebe6a Thu, May 30 2019 9:53:11.572, peer=43985, tc=4, mintc=3, offset=0.001561, frequency=-7.225, sys_jitter=0.002188, clk_jitter=0.002, clk_wander=0.001 remote refid st t when poll reach delay offset jitter ============================================================================== o127.127.20.0 .NMEA. 0 l 3 16 377 0.000 0.002 0.002
I used the cheapest GPS USB stick I could get and soldered the PPS cable. (https://blog.elektrowolle.de/2017/04/27/gps-pps-basierter-ntp-server-auf-raspberry-pi/)
This is my relevant ntp.conf part, the other examples would not work.
# GPSD server 127.127.20.0 minpoll 3 maxpoll 4 prefer fudge 127.127.20.0 flag1 1 refid NMEA
Comparing it to 0.de.pool.ntp.org with Zabbix:
-
Thanks @athurdent for sharing your setup - that looks very cool! I find it interesting that you chose to go with a USB receiver instead of the Pi GPS HAT's that everyone else has been using. Was there any particular reason for that? Are you seeing any adverse effects from using USB (e.g. timing issues, extra jitter, etc.)? I suppose it could also be that using PPS helps offset some of that.
Looking through the link you posted - I did find this interesting part regarding reducing jitter:
http://www.satsignal.eu/ntp/Raspberry-Pi-NTP.html#nohz
https://www.kernel.org/doc/Documentation/timers/NO_HZ.txtHas anyone tried this and seen noticeable reduction in jitter?
Thanks again everyone.
-
@tman222 Thanks! :)
I went with a USB receiver, because it's just a little home project and I did not want to spend too much money on it. I wanted to show my son how to disassemble something electronic and (hopefully) not break it, also how to solder without completely melting anything.
I had a good laugh on this one, when it came to configure NTP and compare time sources:
“A man with one watch knows what time it is. A man with two watches is never sure.”While I am no expert on NTP and did not really dive into all the background info, I think this is important to note:
"/dev/ttyAMA0
The UART device on a Raspberry Pi. Has the side effect of opening /dev/pps0 for RFC2783 1PPS data." (http://www.catb.org/gpsd/gpsd.html)So, you probably don't need to specify a separate PPS source in ntp.conf because of that. At least here that did not work anyways, maybe because GPSD already uses PPS that way.
Also, on the lastest Raspbian, there is no need to compile NTP yourself, everything is build in already now. You just have to get the symlinks for GPS and PPS in place.
This took care of it here, if I documented it right:systemctl disable hciuart systemctl mask serial-getty@ttyAMA0.service vi /etc/udev/rules.d/09.pps.rules KERNEL=="pps0", OWNER="root", GROUP="tty", MODE="0660", SYMLINK+="gpspps0"
I have not tried that nohz option. I think jitter is OK and does not vary too much. But then again, I am far from an expert, just the firewall guy trying to play a little with something else :)
-
I've been meaning to put a quick how-to together for a NTP server based on a pcengine apu2 which offers much better performance at a slightly higher price. You may not need the increased accuracy but its available if you want to join the ranks of time-nuts.
chronyc tracking Reference ID : 47505330 (GPS0) Stratum : 1 Ref time (UTC) : Sat Jun 01 06:56:35 2019 System time : 0.000000004 seconds fast of NTP time Last offset : +0.000000004 seconds RMS offset : 0.000000008 seconds Frequency : 4.568 ppm fast Residual freq : +0.000 ppm Skew : 0.001 ppm Root delay : 0.000000001 seconds Root dispersion : 0.000000941 seconds Update interval : 1.0 seconds Leap status : Normal
-
That 4ns fast? Nice!
-
@q54e3w said in Building a Stratum 1 NTP Server Using Raspberry Pi:
I've been meaning to put a quick how-to together for a NTP server based on a pcengine apu2 which offers much better performance at a slightly higher price. You may not need the increased accuracy but its available if you want to join the ranks of time-nuts.
chronyc tracking Reference ID : 47505330 (GPS0) Stratum : 1 Ref time (UTC) : Sat Jun 01 06:56:35 2019 System time : 0.000000004 seconds fast of NTP time Last offset : +0.000000004 seconds RMS offset : 0.000000008 seconds Frequency : 4.568 ppm fast Residual freq : +0.000 ppm Skew : 0.001 ppm Root delay : 0.000000001 seconds Root dispersion : 0.000000941 seconds Update interval : 1.0 seconds Leap status : Normal
Hi @q54e3w - those are some very impressive figures! As someone who is a always obsessed with performance and efficiency I just may have to try this too. :) Do you mind sharing with us what parts you used for this setup? In particular, I'm quite curious what you chose for the GPS receiver module in the APU2 box. Also, what OS did you end up running on the machine to get that level of performance (accuracy)? Was it a flavor of Linux (e.g. Debian) or something more custom?
Thanks again!
-
With the Raspberry Pi 4 having just been released, do you guys think it will perform better for this purpose given the improvements to the network on the SoC?
Also, @q54e3w - when you have a moment, could you please share some additional details with us what you are using for an APU2 based setup? I'm very curious. Thanks again!
-
i will tell you in a few days, i'm waiting for the courier ...
raspberry pi 4, but gps is from adafruit.
this will be my first experiment with this toys
...
reviced it today, i just had the time to install raspbian and soldered the gps hat, now i need to find a way to have a gps fix. i don't have the time now to do any test, the only first impression is that the board become very hot, i will probably buy something to cool it down@johnpoz maybe you know, do you think it will be possible to add a display on top of the gps hat or it will not work ? RX/TX pins are for gps data and pin #4 is used for PPS on my case
-
and this is how it work here, i have some trouble because the "howto" available are a little outdated, i need to do some research
pi@raspberrypi:~ $ ntpq -crv -pn associd=0 status=0115 leap_none, sync_pps, 1 event, clock_sync, version="ntpd 4.2.8p13@1.3847-o Tue Jul 2 16:07:07 UTC 2019 (2)", processor="armv7l", system="Linux/4.19.50-v7l+", leap=00, stratum=1, precision=-20, rootdelay=0.000, rootdisp=1938.001, refid=PPS, reftime=e0c75f48.32187a6c Wed, Jul 3 2019 19:07:20.195, clock=e0c75f56.2a9026ff Wed, Jul 3 2019 19:07:34.166, peer=43403, tc=4, mintc=3, offset=-0.147120, frequency=-17.048, sys_jitter=0.036991, clk_jitter=0.118, clk_wander=0.024 remote refid st t when poll reach delay offset jitter ============================================================================== *172.16.0.100 193.204.114.232 2 u 32 32 3 0.468 0.169 0.027 +31.14.131.188 195.113.144.238 2 u 56 64 1 18.466 0.815 0.075 -213.251.52.250 193.0.0.229 2 u 55 64 1 21.270 4.187 21.794 +85.199.214.99 .GPS. 1 u 54 64 1 35.809 -0.642 0.217 -185.19.184.35 193.204.114.233 2 u 53 64 1 22.388 4.127 23.813 o127.127.22.0 .PPS. 0 l 14 16 7 0.000 -0.147 0.037 127.127.20.0 .GPS. 0 l - 64 0 0.000 0.000 0.000
-
ok this is working now, i found out that on my raspberry pi 4 the gps is not on ttyAMA0 as all the tutorial around is based on, but under ttyS0, took my awhile to find out what was wrong ...
pi@raspberrypi:~ $ ntpq -crv -pn associd=0 status=0115 leap_none, sync_pps, 1 event, clock_sync, version="ntpd 4.2.8p12@1.3728-o (1)", processor="armv7l", system="Linux/4.19.50-v7l+", leap=00, stratum=1, precision=-20, rootdelay=0.000, rootdisp=7938.582, refid=PPS, reftime=e0c78921.5335fc30 Wed, Jul 3 2019 22:05:53.325, clock=e0c7892f.6faf75ea Wed, Jul 3 2019 22:06:07.436, peer=4517, tc=4, mintc=3, offset=-0.858325, frequency=-16.929, sys_jitter=0.000954, clk_jitter=0.406, clk_wander=0.000, tai=37, leapsec=201701010000, expire=201912280000 remote refid st t when poll reach delay offset jitter ============================================================================== *172.16.0.100 134.64.19.180 2 u 23 32 1 0.474 0.189 0.167 it.pool.ntp.org .POOL. 16 p - 1024 0 0.000 0.000 0.001 x127.127.20.0 .GPS. 0 l 31 64 1 0.000 -1.180 0.001 o127.127.22.0 .PPS. 0 l 14 16 1 0.000 -0.858 0.001 +37.247.53.178 193.204.114.232 2 u 20 1024 1 12.891 -0.781 0.375 -213.251.52.250 193.0.0.229 2 u 14 1024 1 21.182 3.930 0.230 +85.199.214.99 .GPS. 1 u 13 1024 1 36.061 -1.087 7.806 -185.19.184.35 193.204.114.233 2 u 12 1024 1 22.180 3.048 0.105
-
Looks like it's marked the GPS as a false ticker. You probably need to adjust the fudge time.
Steve
-
yes, indeed, it's still a work in progress
as i say a have trouble because i was unable to find any recent howto, anyway now i have this
pi@raspberrypi:~ $ ntpq -crv -pn associd=0 status=0115 leap_none, sync_pps, 1 event, clock_sync, version="ntpd 4.2.8p12@1.3728-o (1)", processor="armv7l", system="Linux/4.19.50-v7l+", leap=00, stratum=1, precision=-20, rootdelay=0.000, rootdisp=500.060, refid=PPS, reftime=e0c8c525.ed3084d9 Thu, Jul 4 2019 20:34:13.926, clock=e0c8c52a.0f3a2862 Thu, Jul 4 2019 20:34:18.059, peer=42571, tc=4, mintc=3, offset=0.000149, frequency=-19.939, sys_jitter=0.000954, clk_jitter=0.001, clk_wander=0.000, tai=37, leapsec=201701010000, expire=201912280000 remote refid st t when poll reach delay offset jitter ============================================================================== o127.127.22.0 .PPS. 0 l 5 16 377 0.000 0.000 0.001 *127.127.28.0 .GPS. 1 l 4 16 377 0.000 -146.34 85.899 +193.204.114.232 .CTD. 1 u 41 64 377 30.981 0.240 0.166 +193.204.114.233 .CTD. 1 u 38 64 377 30.653 0.695 0.148 +79.36.117.15 .GPS. 1 u 60 64 377 37.111 -1.756 0.177 +2001:4b20::beef 85.158.25.74 2 u 65 64 377 17.923 -0.204 2.899 +2001:67c:8:abcd .PPS. 1 u 33 64 377 31.323 0.117 6.783 +81.94.123.17 85.158.25.74 2 u 3 64 377 21.208 -2.684 5.947
-
ok i'm putting here what i have done so far, if someone can check and give feedback pls
inside /boot/config.txt :
dtoverlay=pi3-disable-bt force_turbo=1 init_uart_baud=9600 dtoverlay=pps-gpio,gpiopin=4
inside /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=b55c365b-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles nohz=off
inside /etc/modules
# /etc/modules: kernel modules to load at boot time. # # This file contains the names of kernel modules that should be loaded # at boot time, one per line. Lines beginning with "#" are ignored. i2c-dev pps-gpio
i have created /etc/udev/rules.d/99-gps.rules :
KERNEL=="pps0",SYMLINK+="gpspps0" KERNEL=="ttyAMA0",SUBSYSTEM=="tty",MODE=="0777", SYMLINK+="gps0"
sudo apt update sudo apt dist-upgrade sudo systemctl disable hciuart sudo systemctl disable serial-getty@ttyAMA0.service sudo apt-get install pps-tools ntp dnsutils setserial
inside /etc/rc.local
systemctl stop ntp #otherwise the next command will not work stty -F /dev/ttyAMA0 raw 9600 cs8 clocal -cstopb #set to 9600bps as per adafruit spec setserial /dev/ttyAMA0 low_latency # improve latency.. maybe #we need only GPMRC out /bin/echo -e '$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29\r\n' > /dev/ttyAMA0 systemctl start ntp
inside /etc/ntp.conf
# /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 # By default, exchange time with everybody, but don't allow configuration. restrict 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 -6 ::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.1.0 mask 255.255.255.0 # 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 logfile /var/log/ntp.log server 127.127.20.0 mode 17 minpoll 4 maxpoll 4 iburts prefer fudge 127.127.20.0 flag1 1 time2 0.350 refid GPS pool 0.it.pool.ntp.org pool 1.it.pool.ntp.org pool 2.it.pool.ntp.org pool 3.it.pool.ntp.org
result is:
pi@raspberrypi:~ $ ntpq -crv -pn associd=0 status=0418 leap_none, sync_uhf_radio, 1 event, no_sys_peer, version="ntpd 4.2.8p12@1.3728-o (1)", processor="armv7l", system="Linux/4.19.50-v7l+", leap=00, stratum=1, precision=-19, rootdelay=0.000, rootdisp=1.180, refid=GPS, reftime=e0cb6dbc.b9fa8540 Sat, Jul 6 2019 20:58:04.726, clock=e0cb6dc9.863ed46d Sat, Jul 6 2019 20:58:17.524, peer=65419, tc=4, mintc=3, offset=-0.000335, frequency=-18.876, sys_jitter=0.001907, clk_jitter=0.002, clk_wander=0.000, tai=37, leapsec=201701010000, expire=201912280000 remote refid st t when poll reach delay offset jitter ============================================================================== o127.127.20.0 .GPS. 0 l 13 16 377 0.000 0.000 0.002 0.it.pool.ntp.o .POOL. 16 p - 64 0 0.000 0.000 0.002 1.it.pool.ntp.o .POOL. 16 p - 64 0 0.000 0.000 0.002 2.it.pool.ntp.o .POOL. 16 p - 64 0 0.000 0.000 0.002 3.it.pool.ntp.o .POOL. 16 p - 64 0 0.000 0.000 0.002 -213.251.52.250 193.0.0.229 2 u 21 64 377 20.446 3.853 0.146 -94.177.187.22 193.204.114.233 2 u 14 64 377 16.930 -0.241 0.118 -147.135.207.213 85.199.214.99 2 u 17 64 337 28.742 -0.525 0.150 -212.45.144.3 193.204.114.232 2 u 18 64 377 11.872 0.162 0.148 -188.213.165.209 193.204.114.232 2 u 19 64 377 17.956 0.459 0.136 -80.211.52.109 85.199.214.99 2 u 22 64 377 21.608 -1.141 0.134 #5.158.71.217 94.177.187.22 3 u 17 64 377 30.960 -3.933 0.626 +85.199.214.99 .GPS. 1 u 13 64 377 35.659 -0.337 0.172 +37.247.53.178 193.204.114.233 2 u 16 64 377 12.341 0.191 0.159 +185.19.184.35 193.204.114.233 2 u 21 64 377 22.090 3.996 0.139 -80.211.178.99 194.146.251.100 2 u 10 64 377 18.669 -2.758 6.145
pi@raspberrypi:~ $ sudo lsof /dev/pps0 /dev/gps0 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ntpd 11340 ntp 4u CHR 204,64 0t0 1165 /dev/ttyAMA0 ntpd 11340 ntp 5u CHR 242,0 0t0 1495 /dev/pps0
from what i understand there is no need for gpsd as it was causing alot of offset/jitter
plus from what i have read around ntp now bind to /dev/pps0 and /dev/ttyAMA0 (GPS) automatically. mode 17 is 16+1 so 9600bps + GPMRC
rif. https://www.eecis.udel.edu/~mills/ntp/html/drivers/driver20.html
fudge 127.127.20.0 flag1 1 this flag tell ntp to use PPS, i can set flag1 0 and eventually add 127.127.0.22 back and adjust offset, but i don't see why if ntp do the work for me?
my score on pool.ntp.org si now 20 and identified as stratum 1pi@raspberrypi:~ $ iperf -c 192.168.1.90 ------------------------------------------------------------ Client connecting to 192.168.1.90, TCP port 5001 TCP window size: 232 KByte (default) ------------------------------------------------------------ [ 3] local 192.168.1.89 port 52616 connected with 192.168.1.90 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 1.08 GBytes 931 Mbits/sec
-
Hi @kiokoman - thanks for posting your experience using a Raspberry Pi 4. I'm looking to give this project another go this summer and catching up again on the instructions/advice in this thread and the equipment I would need to purchase. Do you mind listing what exact equipment you ended up using and any steps you took that weren't detailed in your prior posts? At this point, I'm looking to generally follow this guide I found, however, using a Raspberry Pi 4 B instead of the Odroid C2 board.
https://nguvu.org/pfsense/network%20time%20protocol%20(ntp)/ntp-server/
At the time this was written the Pi 4 had not been released yet and the Odroid presented a better option over the Pi 3 given true gigabit network support. I also like the PoE hat integration which helps simplify cabling.
Thanks in advance for any help and advice you can provide.
-
- Raspberry PI 4
- Memory Card with raspian
- GPS Adafruit ultimate GPS hat
- battery cr1220
- external active antenna
- uFL to SMA converter
https://www.kiokoman.eu.org/index.php/per-non-dimenticare/24-howto-raspberry-pi-4-headless-ntp-stratum-1-gps-pps
https://www.ntppool.org/scores/ntp.kiokoman.eu.org
-
Thanks @kiokoman for sharing your setup and instructions, I really appreciate it. I wanted to bring this thread back up because I'm looking into this again as a small tinkering project and was also curious to learn more about the alternative APU2 based Stratum 1 NTP server setup @q54e3w mentioned above. @q54e3w - could you share some more details on your setup? Thanks in advance.
-
I had a half finished build and setup guide I was in the process of putting finishing touches to but didn't get to. I'll push it to the top of the list.
The downside of the PTP protocol is that the accuracy isn't preserved across the LAN unless you have hardware that supports it and because of the clients who typically care about this level of accuracy, its seems to be only available in more expensive switches etc, take a look here for a starter and please follow up if you find any more home lab friendly pieces.
https://en.wikipedia.org/wiki/List_of_PTP_implementations
My hardware solution that data came from was a Intel i210 based SBC that supports IEEE1588 and a regular GPS received running stock debian with mild kernel optimization.I've migrated from using NTP to Chrony which syncs up quicker especially from a cold start which was one of the drawbacks of the NTP implementation. I tried the Odroid C4 which is an updated C2 but the earlier kernels didn't have PPS deciding included and I didn't have the time to build a custom kernel. Im sure things have evolved since then.
All of this is perhaps irrelevant though as Ive had great success with a LeoNTP server, unbelievably accurate and consistent across the year through temperature fluctuations etc and outperforms a non temperature controlled Pi substantially.
http://leobodnar.com/shop/index.php?main_page=product_info&products_id=272
When I update that guide I'll include some performance graphs etc. -
@q54e3w said in Building a Stratum 1 NTP Server Using Raspberry Pi:
I had a half finished build and setup guide I was in the process of putting finishing touches to but didn't get to. I'll push it to the top of the list.
The downside of the PTP protocol is that the accuracy isn't preserved across the LAN unless you have hardware that supports it and because of the clients who typically care about this level of accuracy, its seems to be only available in more expensive switches etc, take a look here for a starter and please follow up if you find any more home lab friendly pieces.
https://en.wikipedia.org/wiki/List_of_PTP_implementations
My hardware solution that data came from was a Intel i210 based SBC that supports IEEE1588 and a regular GPS received running stock debian with mild kernel optimization.I've migrated from using NTP to Chrony which syncs up quicker especially from a cold start which was one of the drawbacks of the NTP implementation. I tried the Odroid C4 which is an updated C2 but the earlier kernels didn't have PPS deciding included and I didn't have the time to build a custom kernel. Im sure things have evolved since then.
All of this is perhaps irrelevant though as Ive had great success with a LeoNTP server, unbelievably accurate and consistent across the year through temperature fluctuations etc and outperforms a non temperature controlled Pi substantially.
http://leobodnar.com/shop/index.php?main_page=product_info&products_id=272
When I update that guide I'll include some performance graphs etc.Thanks @q54e3w, I really appreciate the response. If you don't mind me asking, where did you purchase the LeoNTP server? Is there a US distributor or did you purchase directly from the UK? Thanks again.
-
@tman222 https://v3.airspy.us/product/upu-leontp/
-
yesterday I received the waveshare max-m8q GPS hat for raspberry, I have configured it with the shared memory with gpsd, I still need to understand how to remove unnecessary GPS sentences, this is based on ublox, the adafruit was easier to configure. it seems to me that with SHM the offset is more unstable
UBLOX status=0115 leap_none, sync_pps, 1 event, clock_sync, version="ntpd ntpsec-1.1.3 2019-11-18T06:04:00Z", processor="armv7l", system="Linux/5.4.72-v7l+", leap=00, stratum=1, precision=-20, rootdelay=0.0, rootdisp=1.135, refid=PPS, reftime=e37124c1.ed9d57a5 2020-12-01T20:23:29.928Z, clock=e37124cb.3ec99709 2020-12-01T20:23:39.245Z, peer=13250, tc=4, mintc=0, offset=0.000691, frequency=-18.836975, sys_jitter=0.000413, clk_jitter=0.000419, clk_wander=0.000275, tai=37, leapsec="2017-01-01T00:00Z", expire="2021-06-28T00:00Z" remote refid st t when poll reach delay offset jitter ===================================================================================================== *SHM(0) .GPS. 0 l 10 16 377 0.0000 2.6169 1.5005 oPPS(0) .PPS. 0 l 9 16 377 0.0000 0.0007 0.0004 -192.168.10.200 .GPS. 1 u 63 64 377 0.0923 -2.0291 0.0163 -151.3.106.211 .GPS. 1 u 64 64 376 31.6928 -1.2702 1.2323 +193.204.114.232 .CTD. 1 u 27 64 377 39.7531 0.6983 0.9118 +193.204.114.233 .CTD. 1 u 20 64 375 30.1307 5.2933 0.7851 0.it.pool.ntp.org .POOL. 16 p - 256 0 0.0000 0.0000 0.0010 1.it.pool.ntp.org .POOL. 16 p - 256 0 0.0000 0.0000 0.0010 -194.0.5.123 85.199.214.100 2 u 58 64 377 20.8733 -0.5592 1.2309 +37.247.53.178 193.204.114.232 2 u - 64 375 19.3794 0.6783 0.8454
ADAFRUIT status=0415 leap_none, sync_uhf_radio, 1 event, clock_sync, version="ntpd ntpsec-1.1.3 2019-11-18T06:04:00Z", processor="armv7l", system="Linux/5.4.72-v7l+", leap=00, stratum=1, precision=-20, rootdelay=0.0, rootdisp=100.12, refid=GPS, reftime=e37127b4.87c1698d 2020-12-01T20:36:04.530Z, clock=e37127bc.a80fc6d1 2020-12-01T20:36:12.656Z, peer=52517, tc=6, mintc=0, offset=-0.392457, frequency=-12.429184, sys_jitter=1.986283, clk_jitter=2.402087, clk_wander=0.192477, tai=37, leapsec="2017-01-01T00:00Z", expire="2021-06-28T00:00Z" remote refid st t when poll reach delay offset jitter ===================================================================================================== oNMEA(0) .GPS. 0 l 8 64 373 0.0000 -0.3925 1.9863 +192.168.10.203 .PPS. 1 u 30 64 377 0.1134 2.0148 0.2716 193.204.114.232 .CTD. 1 u - 64 375 31.0446 6.9845 0.8522 193.204.114.233 .CTD. 1 u 30 64 377 32.4280 6.2898 0.5521 0.it.pool.ntp.org .POOL. 16 p - 256 0 0.0000 0.0000 0.0010 1.it.pool.ntp.org .POOL. 16 p - 256 0 0.0000 0.0000 0.0010 +212.45.144.88 193.204.114.233 2 u 60 64 377 18.1799 1.5251 1.2220 +95.110.248.206 193.204.114.233 2 u 14 64 377 29.5371 3.1092 0.6852 -162.159.200.123 10.48.8.4 3 u 83 128 257 45.1323 -3.8529 11.8599 -80.211.178.99 216.239.35.0 2 u 33 128 337 29.3981 3.7633 20.6043
-
How long has it been running? Give it 24 hours to find its groove.
-
yeah i'm still playing with both.. you know start / restart / reconfigure / compare :)
-
You really need to compare over a long time window, add both NTP sources to pfSense's NTP server, enable monitoring and you can observe long term trends under diagnostics.
-
@johnpoz do you still have that uptronic running? it's basically the same one I have but from another vendor
would you mind sharing your ntp.conf?
i actually have this on my ntp.conf but compared to the adafruit is not that goodublox config ->
server 127.127.20.0 mode 89 iburst prefer fudge 127.127.20.0 flag1 0 flag3 0 time1 0.0 time2 0.048 refid GPS server 127.127.22.0 fudge 127.127.22.0 flag3 1 time2 0.0 refid PPS
gps output
pi@raspberrypi3:~ $ cat /dev/gps0 $GNRMC,124146.00,A,4520.67417,N,01147.19928,E,0.138,,051220,,,A*6C $GNZDA,124146.00,05,12,2020,00,00*7A
ublox ->
*127.127.20.0 .GPS. 0 l 46 64 377 0.000 9.572 0.800 o127.127.22.0 .PPS. 0 l 45 64 377 0.000 4.465 0.339
adafruit part of it.pool.ntp.org ->
oNMEA(0) .GPS. 0 l 1 64 377 0.0000 0.0042 0.0199
-
what are you looking for exactly? I am running ntpsec
Keep in mind the sat signal just meant to get you close - the thing that keeps your time the pps
The signal from gps will almost never be the selected source..
And unless you don't have internet to get you close via another ntp source the gps signal doesn't mean all that much...
Your looking for a ntp server that time is stable and doesn't drift, that comes from the pps signal.
I don't bother playing with the fudge factors trying to get the gps to be inline with other time sources with very little offset, because in the big picture it doesn't matter.
But this does remind me that should prob update my ntpsec version.. Its a bit dated.. 1.2 came out back in oct.
Here is what I used to setup mine when I switched to ntpsec
https://www.ntpsec.org/white-papers/stratum-1-microserver-howto/edit: Well this turned into a bit more than just clockmaker --update ;) updating my pi to buster from stretch.. Lets hope it works ;) I didn't bother to take a backup.. And just doing a dist-upgrade.. Either be real simple - or will force me to do a clean install.. Seems openssl doesn't have package for tls 1.3 support in stretch.. It's always something, and the new version of ntpsec seems to want that to compile.
-
@johnpoz
i was referring to the offset and jitter , it's much loweron the adafruit,
the difference between the adafruit and the ublox is that the adafruit have the pps signal inside /dev/gps0 so i only need
server 127.127.20.0
and with flag1 1 I have gps+pps
you see it because NMEA have the 'o' instead of only the '*'with the ublox instead i have to use /dev/gps0 and /dev/pps0 but it end up with larger offset/jitter and it drift up and down very mutch during the day compare to the adafruit, i will wait another 24h and i'll show you how the graph from the adafruit is linear but the ublox is not
I'm not using gpsd / shm but direct driver, thanks for the link i will try that if i'm unable to achieve better results with my config
-
Ok... So I just rebooted and updated mine to ntpsec 1.2 so current values a bit off..
ntpq> version ntpsec-1.2.0+ 2020-12-05T14:15:31Z (git rev 9842b560f)
But looking over the data for last 2 days so can see 5 min entries.. This looks pretty stable to me
Those are micro seconds.. Not miliseconds.. Max offset of 0.42 ms, or 0.00042 seconds..
That clock jitter is pretty flat..
edit: Question for you, your running min pi install right? Or did you install the gui on your pi?
edit2: If your looking for some tuning advice check out
https://gpsd.gitlab.io/gpsd/gpsd-time-service-howto.html#_performance_tuning -
@johnpoz
yes, i'm running min install without any gui / stripped services -
Lets see what your graphs look like after some time.. Its going to take a bit to stabilize.. How often are you polling your shm entries?
If you were using ntpsec vs ntp you could just use the refclock entry in the ntp.conf to set an offset for your gps after you have determined what that is via say syncing with some very stable stratum 1 servers..
With ntp you have to use the fudge servers to do a specific offset.. But that is not what effects jitter..
I understand there is something to do with the different hats and if they are using edge or falling of the pps signal which could introduce offset, etc. And yeah I think jitter because of some bug... There was something I was reading about that - I believe it was in the link I provided about ntpsec setup.
edit: Yup here it was
https://www.ntpsec.org/white-papers/stratum-1-microserver-howto/#_edge_detection_issues_and_new_hatsedit2: I just finished up playing with mine.. Have to check it in a few days.. But yeah mine is going to take a bit to fall back into rhythm.. I updated the distro, I updated ntpsec and couple of reboots in there, etc..
So you can see mine is a bit crazy right now as well
edit3: If your going to run ntp server - you might want to add it to the pool.. For one you get an email if it gets too wacky or is not working.. So its a way to monitor how your ntp is performing.. As you can see mine is going to take a bit to get back into good running.. Check out the last entries compared to how well grouped the previous checks were..