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 28.6k 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.
    • kiokomanK
      kiokoman LAYER 8
      last edited by kiokoman

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

      ublox 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
      

      ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
      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.

      johnpozJ 1 Reply Last reply Reply Quote 0
      • johnpozJ
        johnpoz LAYER 8 Global Moderator @kiokoman
        last edited by johnpoz

        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.

        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.8, 24.11

        kiokomanK 1 Reply Last reply Reply Quote 0
        • kiokomanK
          kiokoman LAYER 8 @johnpoz
          last edited by kiokoman

          @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

          ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
          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.

          johnpozJ Q 2 Replies Last reply Reply Quote 0
          • johnpozJ
            johnpoz LAYER 8 Global Moderator @kiokoman
            last edited by johnpoz

            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

            finetome.png

            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

            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.8, 24.11

            kiokomanK 1 Reply Last reply Reply Quote 1
            • kiokomanK
              kiokoman LAYER 8 @johnpoz
              last edited by

              @johnpoz
              yes, i'm running min install without any gui / stripped services

              ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
              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.

              johnpozJ 1 Reply Last reply Reply Quote 0
              • johnpozJ
                johnpoz LAYER 8 Global Moderator @kiokoman
                last edited by johnpoz

                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_hats

                edit2: 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

                jitter.png

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

                pool.png

                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.8, 24.11

                kiokomanK 1 Reply Last reply Reply Quote 0
                • kiokomanK
                  kiokoman LAYER 8 @johnpoz
                  last edited by kiokoman

                  @johnpoz
                  i don't use shm anyway this is the difference i see between the 2 gps
                  i restarted the ublox service around 13:00, where you see the spike
                  Immagine2.jpg

                  adafruit
                  green is pps+gps
                  ublox
                  yellow is pps green is gps

                  ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
                  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.

                  johnpozJ 1 Reply Last reply Reply Quote 0
                  • johnpozJ
                    johnpoz LAYER 8 Global Moderator @kiokoman
                    last edited by johnpoz

                    That is same same pi make and model. Same setup just the difference in the hats?

                    Wow - something seems off there.. I can see why your interested now..

                    What specific pi? And what specific hat? Maybe I will order one ;)

                    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.8, 24.11

                    kiokomanK 1 Reply Last reply Reply Quote 0
                    • kiokomanK
                      kiokoman LAYER 8 @johnpoz
                      last edited by

                      @johnpoz
                      yes both are raspberry pi 4 with 4gb same debian but different hat

                      ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
                      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.

                      johnpozJ 1 Reply Last reply Reply Quote 0
                      • johnpozJ
                        johnpoz LAYER 8 Global Moderator @kiokoman
                        last edited by johnpoz

                        What are you using to graph that like that? I would be up for getting a pi4 and the same hat to test.. Always up for fun projects ;)

                        Trying to find an excuse to get a 4 ;) hehehe

                        You seem to be pretty for out on the same hat I have, your ublox

                             remote                                   refid      st t when poll reach   delay   offset   jitter
                        =======================================================================================================
                        *SHM(1)                                  .PPS.            0 l    2   16  377   0.0000  -0.3426   0.0026
                        

                        Is the hat you got.. You had to solder?
                        https://www.adafruit.com/product/2324

                        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.8, 24.11

                        kiokomanK 1 Reply Last reply Reply Quote 0
                        • kiokomanK
                          kiokoman LAYER 8 @johnpoz
                          last edited by kiokoman

                          @johnpoz
                          that is telegraf sending to grafana
                          grafana sitting on another raspberry ..
                          https://www.adafruit.com/product/2324
                          https://www.waveshare.com/max-m8q-gnss-hat.htm

                          adafruit need soldering this but it's easy
                          6567a574-19cb-40db-ac99-187a918ee3d8-immagine.png

                          ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
                          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.

                          stephenw10S 1 Reply Last reply Reply Quote 0
                          • stephenw10S
                            stephenw10 Netgate Administrator @kiokoman
                            last edited by

                            Are those values actually in milliseconds or is it microseconds and just mislabeled?

                            Steve

                            kiokomanK 1 Reply Last reply Reply Quote 0
                            • kiokomanK
                              kiokoman LAYER 8 @stephenw10
                              last edited by

                              @stephenw10
                              the values from ntpq afaik is milliseconds ?

                              ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
                              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.

                              stephenw10S 1 Reply Last reply Reply Quote 0
                              • stephenw10S
                                stephenw10 Netgate Administrator @kiokoman
                                last edited by

                                Yes, it reads in milliseconds but that can get confusing when is shows a value like 0.001 (1μs).

                                Values in microseconds are what you should expect if PPS is working.

                                Less than 1μs is impressive. I generally see between 1-2μs here.

                                Steve

                                1 Reply Last reply Reply Quote 0
                                • Q
                                  q54e3w @kiokoman
                                  last edited by

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

                                  and it drift up and down very mutch during the day compare to the adafruit

                                  Is your device thermally stable, without some kind of TCXO its likely drift. I see fluctuations around 11am to 4pm as the sun hits the room where my timing hardware is located. Temperature corrected devices are unaffected.

                                  Also, different drivers are very likely to introduce different levels of performance so try and ensure you are using same drivers (type 22 PPS vs SHM type 28 etc).

                                  kiokomanK 1 Reply Last reply Reply Quote 0
                                  • kiokomanK
                                    kiokoman LAYER 8 @q54e3w
                                    last edited by kiokoman

                                    yeah, i'm using only type 20 and type 22
                                    but i think i was finally able to find a configuration that suits it

                                    http://www.philrandal.co.uk/blog/archives/04-01-2019_04-30-2019.html
                                    with some minor adjustment

                                    Immagine.jpg
                                    Immagine2.jpg

                                    ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
                                    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 2
                                    • kiokomanK
                                      kiokoman LAYER 8 @tman222
                                      last edited by kiokoman

                                      @tman222

                                      I'll answer your question about nohz
                                      it does not work on raspberry pi 4 + raspbian
                                      the kernel isn't configured to allows the nohz parameter to work
                                      also, I found that you can only use
                                      flag 3 0 (use the ntpd clock discipline)
                                      and not
                                      flag 3 1 (use the kernel discipline)
                                      for PPS
                                      if you try to use flag 3 1 you see in the syslog this:

                                      refclock_params: time_pps_kcbind: Operation not supported
                                      

                                      this is because the kernel is compiled without CONFIG_NTP_PPS

                                      Immagine.jpg

                                      obviusly
                                      as a good nerd I recompiled ... 😑

                                      this is ublox now

                                      server 127.127.20.0 mode 89 iburst prefer minpoll 2 maxpoll 4
                                      fudge 127.127.20.0 flag1 1 flag3 1 time1 0.0 time2 0.025 refid GPS
                                      
                                      pi@raspberrypi3:~/linux $ uname -a
                                      Linux raspberrypi3 4.19.118-v7lntp+ #1 SMP Fri Dec 11 14:42:08 CET 2020 armv7l GNU/Linux
                                      
                                      pi@raspberrypi3:~/linux $ ntpq -crv -pn
                                      status=041d leap_none, sync_uhf_radio, 1 event, kern,
                                      version="ntpd ntpsec-1.1.3 2019-11-18T06:04:00Z", processor="armv7l", system=" Linux/4.19.118-v7lntp+", leap=00, stratum=1, precision=-20, rootdelay=0.0, rootdisp=2.18, refid=GPS, reftime=e37e600c.8bd6769d 2020-12-11T21:15:56.546Z,
                                      clock=e37e6018.d0a57250 2020-12-11T21:16:08.815Z, peer=11020, tc=4, mintc=0, offset=7.8e-05, frequency=-18.907623, sys_jitter=0.000277, clk_jitter=0.000728, clk_wander=0.001816, 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   12   16  377   0.0000   0.0001   0.0003
                                      

                                      Immagine.jpg

                                      ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
                                      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
                                        sagliklihayatimiz Banned
                                        last edited by

                                        This post is deleted!
                                        1 Reply Last reply Reply Quote 0
                                        • T
                                          tman222
                                          last edited by

                                          Hi all -

                                          Wanted to follow up on this thread as I recently acquired a Stratum 1 NTP server for my network (LeoNTP - very cool little device). Currently, I have it setup as the only NTP time server on pfSense (i.e. no other servers are configured). Is this an acceptable setup, or should I be adding a few additional public Stratum 1 servers as a sanity check, and set the LeoNTP device as the preferred server? I realize with just one server I don't have any redundancy, but is that the only main drawback? Thanks in advance!

                                          kiokomanK Q 2 Replies Last reply Reply Quote 0
                                          • kiokomanK
                                            kiokoman LAYER 8 @tman222
                                            last edited by kiokoman

                                            @tman222
                                            if I remember correctly you need at least 3 good ntp server on the list to see if the leontp is working correctly
                                            without any reference you don't know if the time is correct

                                            ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
                                            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.