• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

Building a Stratum 1 NTP Server Using Raspberry Pi

Scheduled Pinned Locked Moved Off-Topic & Non-Support Discussion
57 Posts 9 Posters 26.8k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T
    tman222 @johnpoz
    last edited by May 27, 2019, 10:57 PM

    @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!

    Q B 2 Replies Last reply May 28, 2019, 7:12 AM Reply Quote 0
    • Q
      q54e3w @tman222
      last edited by May 28, 2019, 7:12 AM

      @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/

      1 Reply Last reply Reply Quote 0
      • B
        bigsy @tman222
        last edited by bigsy May 28, 2019, 9:11 AM May 28, 2019, 9:08 AM

        @tman222 I followed the same guide as @johnpoz

        I'm using this case from ModMyPi in the UK. It has a light pipe so the LED pulses are visible: https://www.modmypi.com/raspberry-pi/cases-183/raspberry-pi-b-plus2-and-3-cases-1122/cases-for-hats-and-boards-1133/gps-case-black

        1 Reply Last reply Reply Quote 0
        • J
          johnpoz LAYER 8 Global Moderator
          last edited by johnpoz May 28, 2019, 11:01 AM May 28, 2019, 10:56 AM

          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
          Image-1(4).jpg

          An intelligent man is sometimes forced to be drunk to spend time with his fools
          If you get confused: Listen to the Music Play
          Please don't Chat/PM me for help, unless mod related
          SG-4860 24.11 | Lab VMs 2.7.2, 24.11

          1 Reply Last reply Reply Quote 0
          • T
            tman222
            last edited by May 28, 2019, 11:47 AM

            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!

            1 Reply Last reply Reply Quote 0
            • S
              stephenw10 Netgate Administrator
              last edited by May 28, 2019, 1:46 PM

              @johnpoz said in Building a Stratum 1 NTP Server Using Raspberry Pi:

              0.0131

              That's some fine jitter! 😀

              Steve

              1 Reply Last reply Reply Quote 0
              • J
                johnpoz LAYER 8 Global Moderator
                last edited by johnpoz May 28, 2019, 1:56 PM May 28, 2019, 1:50 PM

                @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..

                An intelligent man is sometimes forced to be drunk to spend time with his fools
                If you get confused: Listen to the Music Play
                Please don't Chat/PM me for help, unless mod related
                SG-4860 24.11 | Lab VMs 2.7.2, 24.11

                T 1 Reply Last reply May 28, 2019, 2:19 PM Reply Quote 0
                • T
                  tman222 @johnpoz
                  last edited by May 28, 2019, 2:19 PM

                  @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).

                  1 Reply Last reply Reply Quote 0
                  • A
                    athurdent
                    last edited by May 30, 2019, 8:04 AM

                    @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:
                    Screenshot 2019-05-30 at 09.52.36.png

                    IMG_0315.jpg

                    1 Reply Last reply Reply Quote 0
                    • T
                      tman222
                      last edited by May 30, 2019, 12:12 PM

                      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.txt

                      Has anyone tried this and seen noticeable reduction in jitter?

                      Thanks again everyone.

                      kiokomanK 1 Reply Last reply Dec 11, 2020, 9:41 PM Reply Quote 0
                      • A
                        athurdent
                        last edited by May 30, 2019, 2:25 PM

                        @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 :)

                        1 Reply Last reply Reply Quote 0
                        • Q
                          q54e3w
                          last edited by q54e3w Jun 1, 2019, 6:55 AM Jun 1, 2019, 4:25 AM

                          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
                          
                          T 1 Reply Last reply Jun 1, 2019, 12:53 PM Reply Quote 0
                          • S
                            stephenw10 Netgate Administrator
                            last edited by Jun 1, 2019, 9:02 AM

                            That 4ns fast? Nice!

                            1 Reply Last reply Reply Quote 0
                            • T
                              tman222 @q54e3w
                              last edited by Jun 1, 2019, 12:53 PM

                              @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!

                              1 Reply Last reply Reply Quote 0
                              • T
                                tman222
                                last edited by Jun 29, 2019, 7:11 PM

                                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!

                                1 Reply Last reply Reply Quote 0
                                • kiokomanK
                                  kiokoman LAYER 8
                                  last edited by kiokoman Jul 2, 2019, 1:24 PM Jun 30, 2019, 6:05 PM

                                  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

                                  ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
                                  Please do not use chat/PM to ask for help
                                  we must focus on silencing this @guest character. we must make up lies and alter the copyrights !
                                  Don't forget to Upvote with the 👍 button for any post you find to be helpful.

                                  1 Reply Last reply Reply Quote 0
                                  • kiokomanK
                                    kiokoman LAYER 8
                                    last edited by kiokoman Jul 3, 2019, 5:13 PM Jul 3, 2019, 5:08 PM

                                    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
                                    

                                    ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
                                    Please do not use chat/PM to ask for help
                                    we must focus on silencing this @guest character. we must make up lies and alter the copyrights !
                                    Don't forget to Upvote with the 👍 button for any post you find to be helpful.

                                    1 Reply Last reply Reply Quote 0
                                    • kiokomanK
                                      kiokoman LAYER 8
                                      last edited by kiokoman Jul 3, 2019, 8:11 PM Jul 3, 2019, 8:11 PM

                                      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
                                      

                                      ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
                                      Please do not use chat/PM to ask for help
                                      we must focus on silencing this @guest character. we must make up lies and alter the copyrights !
                                      Don't forget to Upvote with the 👍 button for any post you find to be helpful.

                                      1 Reply Last reply Reply Quote 0
                                      • S
                                        stephenw10 Netgate Administrator
                                        last edited by Jul 4, 2019, 6:05 PM

                                        Looks like it's marked the GPS as a false ticker. You probably need to adjust the fudge time.

                                        Steve

                                        1 Reply Last reply Reply Quote 0
                                        • kiokomanK
                                          kiokoman LAYER 8
                                          last edited by Jul 4, 2019, 6:37 PM

                                          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
                                          

                                          ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
                                          Please do not use chat/PM to ask for help
                                          we must focus on silencing this @guest character. we must make up lies and alter the copyrights !
                                          Don't forget to Upvote with the 👍 button for any post you find to be helpful.

                                          1 Reply Last reply Reply Quote 0
                                          • First post
                                            Last post
                                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                                            This community forum collects and processes your personal information.
                                            consent.not_received