• 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.
  • J
    johnpoz LAYER 8 Global Moderator @kiokoman
    last edited by johnpoz Dec 5, 2020, 2:03 PM Dec 5, 2020, 1:06 PM

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

    K 1 Reply Last reply Dec 5, 2020, 2:18 PM Reply Quote 0
    • K
      kiokoman LAYER 8 @johnpoz
      last edited by kiokoman Dec 9, 2020, 3:20 PM Dec 5, 2020, 2:18 PM

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

      J Q 2 Replies Last reply Dec 5, 2020, 2:37 PM Reply Quote 0
      • J
        johnpoz LAYER 8 Global Moderator @kiokoman
        last edited by johnpoz Dec 5, 2020, 2:57 PM Dec 5, 2020, 2:37 PM

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

        K 1 Reply Last reply Dec 5, 2020, 4:15 PM Reply Quote 1
        • K
          kiokoman LAYER 8 @johnpoz
          last edited by Dec 5, 2020, 4:15 PM

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

          J 1 Reply Last reply Dec 5, 2020, 4:19 PM Reply Quote 0
          • J
            johnpoz LAYER 8 Global Moderator @kiokoman
            last edited by johnpoz Dec 5, 2020, 4:35 PM Dec 5, 2020, 4:19 PM

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

            K 1 Reply Last reply Dec 5, 2020, 5:56 PM Reply Quote 0
            • K
              kiokoman LAYER 8 @johnpoz
              last edited by kiokoman Dec 5, 2020, 6:01 PM Dec 5, 2020, 5:56 PM

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

              J 1 Reply Last reply Dec 5, 2020, 6:01 PM Reply Quote 0
              • J
                johnpoz LAYER 8 Global Moderator @kiokoman
                last edited by johnpoz Dec 5, 2020, 6:02 PM Dec 5, 2020, 6:01 PM

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

                K 1 Reply Last reply Dec 5, 2020, 6:02 PM Reply Quote 0
                • K
                  kiokoman LAYER 8 @johnpoz
                  last edited by Dec 5, 2020, 6:02 PM

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

                  J 1 Reply Last reply Dec 5, 2020, 6:04 PM Reply Quote 0
                  • J
                    johnpoz LAYER 8 Global Moderator @kiokoman
                    last edited by johnpoz Dec 5, 2020, 6:18 PM Dec 5, 2020, 6:04 PM

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

                    K 1 Reply Last reply Dec 5, 2020, 6:23 PM Reply Quote 0
                    • K
                      kiokoman LAYER 8 @johnpoz
                      last edited by kiokoman Dec 5, 2020, 6:27 PM Dec 5, 2020, 6:23 PM

                      @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 Dec 5, 2020, 7:49 PM Reply Quote 0
                      • stephenw10S
                        stephenw10 Netgate Administrator @kiokoman
                        last edited by Dec 5, 2020, 7:49 PM

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

                        Steve

                        K 1 Reply Last reply Dec 5, 2020, 8:12 PM Reply Quote 0
                        • K
                          kiokoman LAYER 8 @stephenw10
                          last edited by Dec 5, 2020, 8:12 PM

                          @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 Dec 6, 2020, 12:05 AM Reply Quote 0
                          • stephenw10S
                            stephenw10 Netgate Administrator @kiokoman
                            last edited by Dec 6, 2020, 12:05 AM

                            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 Dec 6, 2020, 1:12 AM

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

                              K 1 Reply Last reply Dec 6, 2020, 10:59 AM Reply Quote 0
                              • K
                                kiokoman LAYER 8 @q54e3w
                                last edited by kiokoman Dec 6, 2020, 11:03 AM Dec 6, 2020, 10:59 AM

                                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
                                • K
                                  kiokoman LAYER 8 @tman222
                                  last edited by kiokoman Dec 12, 2020, 9:27 PM Dec 11, 2020, 9:41 PM

                                  @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 Dec 19, 2020, 8:12 AM

                                    This post is deleted!
                                    1 Reply Last reply Reply Quote 0
                                    • T
                                      tman222
                                      last edited by Oct 27, 2021, 3:23 PM

                                      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!

                                      K Q 2 Replies Last reply Oct 27, 2021, 5:32 PM Reply Quote 0
                                      • K
                                        kiokoman LAYER 8 @tman222
                                        last edited by kiokoman Oct 27, 2021, 5:33 PM Oct 27, 2021, 5:32 PM

                                        @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
                                        • Q
                                          q54e3w @tman222
                                          last edited by Oct 27, 2021, 6:36 PM

                                          @tman222 I run a few Pi based GPS devices that don't offer the same accuracy, and a few external sources for backup. The LeoNTP takes precedence as primary source of time due to its accuracy.

                                          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