What's new

ntpMerlin ntpMerlin: Can't get chronyd as accurate as ntpd?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

CriticJay

Senior Member
I have been using ntpMerlin for a long time, however only recently did I try switching from ntpd to chronyd.

I tried to configure chronyd as best as I could, using the same upstream Time server as before, but I can't seem to get it the same accuracy as the previous ntpd configuration.

I "test" the config by visiting the site "time.is" from my various Windows machines right after I force a windows time sync. Before when I utilized ntpd on the router, I would get a message like "Your time is exact" but now I frequently get "you are 1 second slow" or something like that.

Any tips on chronyd config?
 
Did you reboot (both the router and the computer you're using to test with) after making that change? And, waiting at least 10 to 15 minutes for both systems to settle down?
 
Never mind.

It looks like I was mixing smeared and non-smeared NTP servers on my network. D'oh!
 
You mean Google servers mixed with the ntp pool? That wouldn't make a difference unless there was a leap second, right?
 
You mean Google servers mixed with the ntp pool? That wouldn't make a difference unless there was a leap second, right?
I don't know... Regardless, once I stopped mixing servers everything was good :)
 
There is the Windows side to this and the router side to this.

Windows
In my case I am synchronized with a GPS connected NTP server on my LAN.
In your case you should be synchronized with your router.
Note: I enabled more accurate time than out of the box Windows by following Microsoft's recommendations.
Microsoft Windows accurate time
Code:
C:\WINDOWS\system32>w32tm /query /status /verbose
Leap Indicator: 0(no warning)
Stratum: 2 (secondary reference - syncd by (S)NTP)
Precision: -23 (119.209ns per tick)
Root Delay: 0.0002205s
Root Dispersion: 0.0136018s
ReferenceId: 0xC0A832E6 (source IP:  192.168.50.230)
Last Successful Sync Time: 8/13/2022 9:09:25 AM
Source: 192.168.50.230,0x9
Poll Interval: 6 (64s)

Phase Offset: 0.0000146s
ClockRate: 0.0156248s
State Machine: 2 (Sync)
Time Source Flags: 0 (None)
Server Role: 0 (None)
Last Sync Error: 0 (The command completed successfully.)
Time since Last Good Sync Time: 53.4622475s

Router
Code:
# chronyc tracking
Reference ID    : C0A832E6 (LeoNTP.)
Stratum         : 2
Ref time (UTC)  : Sat Aug 13 13:23:52 2022
System time     : 0.000000703 seconds slow of NTP time
Last offset     : -0.000000686 seconds
RMS offset      : 0.000000609 seconds
Frequency       : 7.653 ppm slow
Residual freq   : -0.000 ppm
Skew            : 0.003 ppm
Root delay      : 0.000536370 seconds
Root dispersion : 0.000025848 seconds
Update interval : 60.7 seconds
Leap status     : Normal
# chronyc -N authdata
Name/IP address             Mode KeyID Type KLen Last Atmp  NAK Cook CLen
=========================================================================
192.168.50.230                 -     0    0    0    -    0    0    0    0
time.apple.com                 -     0    0    0    -    0    0    0    0
time.apple.com                 -     0    0    0    -    0    0    0    0
time.apple.com                 -     0    0    0    -    0    0    0    0
time.apple.com                 -     0    0    0    -    0    0    0    0
time.apple.com                 -     0    0    0    -    0    0    0    0
time.cloudflare.com          NTS     4   15  256  19d    0    0    8  100
time.cloudflare.com          NTS     4   15  256  19d    0    0    8  100
time.cloudflare.com          NTS     4   15  256  19d    0    0    8  100
time.cloudflare.com          NTS     4   15  256  19d    0    0    8  100
# chronyc sources
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* LeoNTP.                       1   2   377    33  -4103ns[-4269ns] +/-  359us
^- usnyc3-ntp-003.aaplimg.c>     1  10   377   493  -3658us[-3660us] +/- 8152us
^- usnyc3-ntp-004.aaplimg.c>     1  10   377   726  -1972us[-1972us] +/- 6427us
^- usnyc3-ntp-001.aaplimg.c>     1  10   377   971  -2965us[-2968us] +/- 7509us
^- usqas2-ntp-001.aaplimg.c>     1  10   377   485  -2480us[-2482us] +/-   10ms
^- usqas2-ntp-002.aaplimg.c>     1  10   377    89  -2433us[-2434us] +/-   10ms
^- time.cloudflare.com           3  10   377   298   -393us[ -394us] +/-   12ms
^- time.cloudflare.com           3  10   377   963  -1356us[-1358us] +/-   13ms
^- time.cloudflare.com           3  10   377   382   -358us[ -359us] +/-   12ms
^- time.cloudflare.com           3  10   377   938  -1238us[-1239us] +/-   13ms
# chronyc sourcestats
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================
LeoNTP.                    50  24   51m     -0.000      0.004     -1ns  7082ns
usnyc3-ntp-003.aaplimg.c>   6   3   86m     -0.039      0.391  -2247us   177us
usnyc3-ntp-004.aaplimg.c>  12   7  206m     +0.002      0.007  -1972us    21us
usnyc3-ntp-001.aaplimg.c>  11   7  206m     -0.020      0.038  -2327us    97us
usqas2-ntp-001.aaplimg.c>  10   5  154m     -0.004      0.041  -1898us    77us
usqas2-ntp-002.aaplimg.c>  25  14  431m     -0.027      0.014  -1994us   156us
time.cloudflare.com        14   7  223m     -0.004      0.025   -421us    95us
time.cloudflare.com        12   8  189m     -0.033      0.101  -1085us   250us
time.cloudflare.com         8   6  120m     +0.002      0.127   -281us   126us
time.cloudflare.com        14   8  224m     -0.013      0.061   -768us   221us
# chronyc serverstats
NTP packets received       : 4160
NTP packets dropped        : 0
Command packets received   : 803
Command packets dropped    : 0
Client log records dropped : 0
NTS-KE connections accepted: 0
NTS-KE connections dropped : 0
Authenticated NTP packets  : 0
Interleaved NTP packets    : 0
NTP timestamps held        : 0
NTP timestamp span         : 0
# chronyc activity
200 OK
10 sources online
0 sources offline
0 sources doing burst (return to online)
0 sources doing burst (return to offline)
0 sources with unknown address
#

There is another useful chrony command but do not post the output because it will contain your LAN devices.
It tells you which of your devices are using chrony for time.
Code:
chronyc clients
 
Last edited:
Hey @EmeraldDeer , your 703 nSecs slow. Maybe a cloud overhead?

You need to tighten that up a bit. ;-)
 
@EmeraldDeer

Thanks for the info. Here's my config file and the results of the various chronyc commands on my router. Even though I don't notice the out-of-sync time anymore, let me know what you think:

/jffs/addons/ntpmerlin.d/chrony.conf:
Code:
# grep -E -v "^#|^!|^%|^;" /jffs/addons/ntpmerlin.d/chrony.conf | sort -u

allow 10.0.0.0/8
allow 172.16.0.0/12
allow 192.168.0.0/16
driftfile /opt/var/lib/chrony/drift
dumpdir /opt/var/lib/chrony
dumponexit
lock_all
logchange 0.5
makestep 0.1 3
maxupdateskew 5
ntsdumpdir /opt/var/lib/chrony
pidfile /opt/var/run/chrony/chronyd.pid
pool ntp.torix.ca iburst


Code:
# chronyc tracking
Reference ID    : CE6C0085 (ntp3.torix.ca)
Stratum         : 2
Ref time (UTC)  : Sat Aug 13 20:00:17 2022
System time     : 0.000353721 seconds slow of NTP time
Last offset     : -0.000186145 seconds
RMS offset      : 0.000287024 seconds
Frequency       : 1.722 ppm slow
Residual freq   : -0.006 ppm
Skew            : 0.055 ppm
Root delay      : 0.006273892 seconds
Root dispersion : 0.003050488 seconds
Update interval : 3111.3 seconds
Leap status     : Normal

# chronyc -N authdata:
Name/IP address             Mode KeyID Type KLen Last Atmp  NAK Cook CLen
=========================================================================
ntp.torix.ca                   -     0    0    0    -    0    0    0    0
ntp.torix.ca                   -     0    0    0    -    0    0    0    0
ntp.torix.ca                   -     0    0    0    -    0    0    0    0
ntp.torix.ca                   -     0    0    0    -    0    0    0    0

# chronyc sources
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^+ ntp1.torix.ca                 1   9   377   826  -1831us[-1831us] +/- 5977us
^+ 2602:fde5:2a::11              1  10   377   730  -3424us[-3424us] +/- 7503us
^+ ntp2.torix.ca                 1  10   377   227  -3201us[-3201us] +/- 6902us
^* ntp3.torix.ca                 1  10   377   38m  -1835us[-2021us] +/- 6003us

# chronyc sourcestats
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================
ntp1.torix.ca               6   5  171m     -0.023      0.137   +159us   131us
2602:fde5:2a::11            8   7  138m     -0.016      0.063  -2052us    89us
ntp2.torix.ca               9   7  223m     -0.028      0.066   -467us   148us
ntp3.torix.ca               6   5  207m     -0.016      0.078   +906us    74us

# chronyc serverstats
NTP packets received       : 1740
NTP packets dropped        : 0
Command packets received   : 218
Command packets dropped    : 0
Client log records dropped : 0
NTS-KE connections accepted: 0
NTS-KE connections dropped : 0
Authenticated NTP packets  : 0
Interleaved NTP packets    : 0
NTP timestamps held        : 0
NTP timestamp span         : 0

# chronyc activity
200 OK
4 sources online
0 sources offline
0 sources doing burst (return to online)
0 sources doing burst (return to offline)
0 sources with unknown address

And according to chronyc clients, all of my home LAN devices appear to be using my router's chronyd service, so that seems fine...
 
In my case I am synchronized with a GPS connected NTP server on my LAN.
I remember there was a thread on here a looooong time ago about using/hacking a Garmin GPS receiver...I just found one that I haven't tested, but I have no reason to believe it doesn't work.
as the colder weather approaches in my location, I will add that to the project list for the winter
 
@EmeraldDeer

Thanks for the info. Here's my config file and the results of the various chronyc commands on my router. Even though I don't notice the out-of-sync time anymore, let me know what you think:

/jffs/addons/ntpmerlin.d/chrony.conf:
Code:
# grep -E -v "^#|^!|^%|^;" /jffs/addons/ntpmerlin.d/chrony.conf | sort -u

allow 10.0.0.0/8
allow 172.16.0.0/12
allow 192.168.0.0/16
driftfile /opt/var/lib/chrony/drift
dumpdir /opt/var/lib/chrony
dumponexit
lock_all
logchange 0.5
makestep 0.1 3
maxupdateskew 5
ntsdumpdir /opt/var/lib/chrony
pidfile /opt/var/run/chrony/chronyd.pid
pool ntp.torix.ca iburst


Code:
# chronyc tracking
Reference ID    : CE6C0085 (ntp3.torix.ca)
Stratum         : 2
Ref time (UTC)  : Sat Aug 13 20:00:17 2022
System time     : 0.000353721 seconds slow of NTP time
Last offset     : -0.000186145 seconds
RMS offset      : 0.000287024 seconds
Frequency       : 1.722 ppm slow
Residual freq   : -0.006 ppm
Skew            : 0.055 ppm
Root delay      : 0.006273892 seconds
Root dispersion : 0.003050488 seconds
Update interval : 3111.3 seconds
Leap status     : Normal

# chronyc -N authdata:
Name/IP address             Mode KeyID Type KLen Last Atmp  NAK Cook CLen
=========================================================================
ntp.torix.ca                   -     0    0    0    -    0    0    0    0
ntp.torix.ca                   -     0    0    0    -    0    0    0    0
ntp.torix.ca                   -     0    0    0    -    0    0    0    0
ntp.torix.ca                   -     0    0    0    -    0    0    0    0

# chronyc sources
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^+ ntp1.torix.ca                 1   9   377   826  -1831us[-1831us] +/- 5977us
^+ 2602:fde5:2a::11              1  10   377   730  -3424us[-3424us] +/- 7503us
^+ ntp2.torix.ca                 1  10   377   227  -3201us[-3201us] +/- 6902us
^* ntp3.torix.ca                 1  10   377   38m  -1835us[-2021us] +/- 6003us

# chronyc sourcestats
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================
ntp1.torix.ca               6   5  171m     -0.023      0.137   +159us   131us
2602:fde5:2a::11            8   7  138m     -0.016      0.063  -2052us    89us
ntp2.torix.ca               9   7  223m     -0.028      0.066   -467us   148us
ntp3.torix.ca               6   5  207m     -0.016      0.078   +906us    74us

# chronyc serverstats
NTP packets received       : 1740
NTP packets dropped        : 0
Command packets received   : 218
Command packets dropped    : 0
Client log records dropped : 0
NTS-KE connections accepted: 0
NTS-KE connections dropped : 0
Authenticated NTP packets  : 0
Interleaved NTP packets    : 0
NTP timestamps held        : 0
NTP timestamp span         : 0

# chronyc activity
200 OK
4 sources online
0 sources offline
0 sources doing burst (return to online)
0 sources doing burst (return to offline)
0 sources with unknown address

And according to chronyc clients, all of my home LAN devices appear to be using my router's chronyd service, so that seems fine...
Your chrony is running about as good as it gets with close NTP servers.

So the intermittent issue is your Windows computer synchronizing to chrony. This can be addressed by the Microsoft article I linked. But this involves editing the registry.
 
Last edited:
I remember there was a thread on here a looooong time ago about using/hacking a Garmin GPS receiver...I just found one that I haven't tested, but I have no reason to believe it doesn't work.
as the colder weather approaches in my location, I will add that to the project list for the winter
The challenges are having a serial port and creating a custom cable addressing GPS mouse power supply provided by some serial ports or splicing it in, the NMEA date/time output and the pulse per second signal and connecting all of this to the correct pins. Chrony decidedly did not inherit all of the legacy drivers like serial port but I think there is still a way to do it.
 
with a gps receiver, just use the pps1 signal to discipline the chronyd/ntpd...

that way you don't need to mess with gpsd and realize that GPS time is not UTC (they don't do leap seconds, so they're off by a bit these days)

btw - i wouldn't do ntp on the router, the clocks there are not stable enough if one wants to geek out on time keeping.
 
The challenges are having a serial port and creating a custom cable addressing GPS mouse power supply provided by some serial ports or splicing it in, the NMEA date/time output and the pulse per second signal and connecting all of this to the correct pins. Chrony decidedly did not inherit all of the legacy drivers like serial port but I think there is still a way to do it.
Uh oh...some of it may be beyond my capabilities, then. winter is long/dark/cold in my neck of the woods, though, so maybe I'll learn some things to get this done
with a gps receiver, just use the pps1 signal to discipline the chronyd/ntpd...

that way you don't need to mess with gpsd and realize that GPS time is not UTC (they don't do leap seconds, so they're off by a bit these days)

btw - i wouldn't do ntp on the router, the clocks there are not stable enough if one wants to geek out on time keeping.
Noted - where is a better place/what is the better method?
 
Here is how to check Windows advanced time settings from a command prompt run as administrator:
Code:
C:\WINDOWS\system32>w32tm /query /configuration | findstr "MinPollInterval MaxPollInterval UpdateInterval SpecialPollInterval FrequencyCorrectRate"
MinPollInterval: 6 (Local)
MaxPollInterval: 6 (Local)
FrequencyCorrectRate: 2 (Local)
UpdateInterval: 100 (Local)
SpecialPollInterval: 64 (Local)
Above are the recommended settings for more accurate synchronization. With these settings, browsing time.is should always result in "Your time is exact!". The website can detect offsets down to the tens of milliseconds and your Windows offset should be less than that.
 
One more concept: out of the box, NTP and chrony calculate a clock speed adjustment averaging out fluctuations over hours. Perhaps your daily ambient temperature swings are large enough that your clock could be off by as much as hundreds of milliseconds at any one time, I don't know.

Since I have an NTP server on my LAN, I can take another approach. Frequently sample the correct time and go along for the ride from temperature changes adjusting the clock speed accordingly instead of averaging them out over hours. This can be more accurate in the short term but does not consider temporary loss of all time sources.

Besides temperature, network response time variations, even on the local LAN, can be a factor. I also use median filtering where I sample frequently but only use the median sample in a group, discarding the rest.
 
Last edited:
with a gps receiver, just use the pps1 signal to discipline the chronyd/ntpd...

that way you don't need to mess with gpsd and realize that GPS time is not UTC (they don't do leap seconds, so they're off by a bit these days)

I mispoke a bit - for most folks, having GPSD and PPS1 via the USB port is the shortest path when working with ntpd or chrony (use Chrony if you can, in past experience, it is a better solution, IMHO)

I was/am working with custom software that ties the PPS1 signal directly to a GPIO, and a SW driver that presents it up the stack to chrony directly...
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top