[PATCH] Increase NTP update period

Post new topic   Reply to topic    DD-WRT Forum Index -> Contributions Upload
Goto page 1, 2  Next
Author Message
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1013
Location: Hung Hom, Hong Kong

PostPosted: Thu Dec 10, 2020 18:56    Post subject: Reply with quote
Wildlion wrote:
these lines show that it tries to go to a pool.ntp.org (this is correct and what ntp project prefers).

I have been through the ntp source code here, not as much as the full ntp source code and it adheres to everything properly.

DD-WRT does have its hard-coded DNS record for that:
line 90-100 in https://svn.dd-wrt.com/browser/src/router/rc/ntp.c
Code:
  servers = nvram_safe_get("ntp_server");
  if (*servers == 0 || nvram_matchi("dns_crypt", 1)) {
    servers = "2.pool.ntp.org 212.18.3.19 88.99.174.22";
  }
But it's used only when the Server IP/Name (nvram show ntp_server) is blank!!

And this behavior is also related to DNScrypt. I am wondering whether Unbound should be checked because it also requires a correct clock to work. That should be (nvram get recursive_dns)!

Should I open a ticket for that?
Quote:
As for your comment about restarting processes multiple times, that is a DD-WRT developer decision, you would have to ask BrainSlayer.

Agree... should be a new topic!


_________________
Router: Asus RT-N18U (rev. A1)

May the Force and farces be with you! Live long and prosper!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
Sponsor
Wildlion
DD-WRT Guru


Joined: 24 May 2016
Posts: 1286

PostPosted: Fri Dec 11, 2020 0:05    Post subject: Reply with quote
Interesting, I forgot about those others, I knew he had the 2.pool.ntp.org

I always am more concerned with the ntp algorithms/code itself.
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 1583
Location: All over YOUR webs

PostPosted: Wed Sep 29, 2021 19:46    Post subject: Reply with quote
A year nearly of necroposting revival. Hurrah, shame on me.

The solution here is to increase
Code:
ntp_timer
This value in nvram is responsible for the period between updates,(there inst a UI option as far as I can tell). Currently set on mine
Code:
ntp_timer=172800
which is 48-hours.

Run
Code:
:~# nvram show | grep ntp_timer
to see what you have.

I wouldn't recommend default values which constantly spam NTP servers. Sane values for home users in my opinion, is once a week, for business critical where you cant be 200ms off, every 24 hours is OK, I doubt you be off by less than a second, if at all.

_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 12837
Location: Texas, USA

PostPosted: Fri May 20, 2022 15:38    Post subject: Reply with quote
NTP sync is now a configurable webUI option that will be in the next public beta:

​https://svn.dd-wrt.com/changeset/48900
​https://svn.dd-wrt.com/changeset/48901
​https://svn.dd-wrt.com/changeset/48902
​https://svn.dd-wrt.com/changeset/48917

Associated ticket #6463 has been closed.

_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Pogo - A minimal level of ability is expected and needed...
At some point, people just get plain tired of this place.

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 1583
Location: All over YOUR webs

PostPosted: Fri May 20, 2022 15:56    Post subject: Reply with quote
The added ntp offset sync delta time currently is spitting out some bullshit value that makes no sense.
_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 12837
Location: Texas, USA

PostPosted: Fri May 20, 2022 16:45    Post subject: Reply with quote
Well, these days only stock firmware and DD-WRT are the only two worlds still using a modified/patched ntpclient that I am aware of. Everyone else has switched to using the included ntpd in busybox which is based on OpenNTPD, AFAIK. I haven't dug very deep to get fully verified details, but. Not sure how that even relates, but I felt the need to spit out some trivial information just because Wink Rolling Eyes
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Pogo - A minimal level of ability is expected and needed...
At some point, people just get plain tired of this place.

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1013
Location: Hung Hom, Hong Kong

PostPosted: Mon May 23, 2022 8:21    Post subject: Reply with quote
#6463 ([PATCH] ntpclient too frequently synchronizes time (workaround in comments)) – DD-WRT
https://svn.dd-wrt.com/ticket/6463#comment:9
Quote:
NTP sync is now a configurable webUI option that will be in the next public beta:


Related:

DD-WRT Forum :: View topic - USB script executed during sysinit, ntp_timer setup
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=332094&start=15

The option is visible in build 48954!

DD-WRT Forum :: View topic - New Build - 05/23/2022 - r48954
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=332149

In case you were interested, "118.143.17.83" in the screenshot is actually "time.hko.hk". Avoid using domain name in the field, especially if you don't use DNSmasq as DNS server.


_________________
Router: Asus RT-N18U (rev. A1)

May the Force and farces be with you! Live long and prosper!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832


Last edited by mwchang on Mon May 23, 2022 8:42; edited 1 time in total
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 1583
Location: All over YOUR webs

PostPosted: Mon May 23, 2022 8:39    Post subject: Reply with quote
Please note....

The syslog now prints the delta offset on NTP update, the delta offset is expressed in milliseconds.

When you first reboot the router e.g. after a FW upgrade and goto syslog.
The first delta offset after the initial NTP update is crap, because the syslog date at that time is counting from 1970, so you will a total bullshit delta.

The subsequent NTP updates depending on the interval set will have a realistic delta offset. Remember most routers dont have internal RTC and heavy CPU loads can cause the software clock to drift more.

Please use that realistic drift delta offset to determine the ideal drift vs interval and adjust the interval to suit your most desired outcome.

_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1013
Location: Hung Hom, Hong Kong

PostPosted: Mon May 23, 2022 8:48    Post subject: Reply with quote
the-joker wrote:
Please note....

The syslog now prints the delta offset on NTP update, the delta offset is expressed in milliseconds.

When you first reboot the router e.g. after a FW upgrade and goto syslog.

The first delta offset after the initial NTP update is crap, because the syslog date at that time is counting from 1970, so you will a total bullshit delta.

The subsequent NTP updates depending on the interval set will have a realistic delta offset. Remember most routers dont have internal RTC and heavy CPU loads can cause the software clock to drift more.

Please use that realistic drift delta offset to determine the ideal drift vs interval and adjust the interval to suit your most desired outcome.

Here was part of my syslog right after firmware upgrade reboot:
Code:
> grep -i -E 'ntp|changmw|clean|sfe' /var/log/messages

Jan  1 08:00:12 RT-N18U-HST kern.info kernel: [    0.150267] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
.....
May 23 16:30:06 RT-N18U-HST user.notice root: 4: changmw re-starting minidlna

_________________
Router: Asus RT-N18U (rev. A1)

May the Force and farces be with you! Live long and prosper!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832


Last edited by mwchang on Mon May 23, 2022 9:02; edited 1 time in total
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 1583
Location: All over YOUR webs

PostPosted: Mon May 23, 2022 8:53    Post subject: Reply with quote
That doesnt show anything delta related

youre looking for something like

daemon.info process_monitor[1716]: Local timer delta is 1653237546 for instance of an initial bullshit value counting from 1970 or whatever, a realistic value for me after 12 hours interval is daemon.info process_monitor[1716]: Local timer delta is 0

So the NTP interval is incrementing by additional 12 hours, until I find the delta is no longer acceptable.

_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1013
Location: Hung Hom, Hong Kong

PostPosted: Mon May 23, 2022 8:58    Post subject: Reply with quote
the-joker wrote:
That doesnt show anything delta related

youre looking for something like

daemon.info process_monitor[1716]: Local timer delta is 1653237546 for instance of an initial bullshit value counting from 1970 or whatever, a realistic value for me after 12 hours interval is daemon.info process_monitor[1716]: Local timer delta is 0

So the NTP interval is incrementing by additional 12 hours, until I find the delta is no longer acceptable.

Tried again:
Code:
> grep -i -E 'ntp|changmw|clean|sfe|process_mon' /var/log/messages

Jan  1 08:00:12 RT-N18U-HST kern.info kernel: [    0.150267] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
Jan  1 08:00:12 RT-N18U-HST kern.info kernel: [    0.941384] PCI: bus0: Fast back to back transfers disabled
Jan  1 08:00:12 RT-N18U-HST kern.info kernel: [    0.941838] PCI: bus1: Fast back to back transfers disabled
Jan  1 08:00:21 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Jan  1 08:00:24 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Jan  1 08:00:28 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
Jan  1 08:00:28 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Jan  1 08:00:29 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
Jan  1 08:00:30 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Jan  1 08:00:31 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
Jan  1 08:00:31 RT-N18U-HST user.info : [process_monitor] : successfully started
Jan  1 08:00:31 RT-N18U-HST daemon.debug ntpclient[1680]: Connecting to 118.143.17.83 [118.143.17.83] ...
May 23 16:29:29 RT-N18U-HST daemon.info ntpclient[1680]: Time set from 118.143.17.83 [118.143.17.83].
May 23 16:29:29 RT-N18U-HST daemon.info process_monitor[1678]: Cyclic NTP Update success (servers 118.143.17.83)

May 23 16:29:29 RT-N18U-HST daemon.info process_monitor[1678]: Local timer delta is 1653294538

May 23 16:29:29 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
May 23 16:29:29 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
May 23 16:29:30 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully stopped
May 23 16:29:31 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
May 23 16:29:33 RT-N18U-HST user.info : [sfe] : shortcut forwarding engine successfully started
May 23 16:29:33 RT-N18U-HST daemon.debug process_monitor[1678]: Restarting unbound (time sync change)
May 23 16:29:34 RT-N18U-HST daemon.debug process_monitor[1678]: Restarting unbound (time sync change)
May 23 16:29:34 RT-N18U-HST user.info : [process_monitor] : daemon successfully stopped
May 23 16:29:34 RT-N18U-HST daemon.info process_monitor[1678]: [process_monitor] : cleanup timers
May 23 16:29:34 RT-N18U-HST user.info : [process_monitor] : successfully started
May 23 16:29:34 RT-N18U-HST daemon.debug process_monitor[2240]: We need to re-update after 172800 seconds
May 23 16:29:34 RT-N18U-HST daemon.info process_monitor[2240]: [process_monitor] : set timer: 172800 seconds, callback: ntp_main()
May 23 16:29:44 RT-N18U-HST user.notice root: changmw: starting .rc_usb
May 23 16:29:44 RT-N18U-HST user.notice root: changmw: starting .rc_usb
May 23 16:29:44 RT-N18U-HST user.notice root: 0: changmw waiting for init for 5 seconds
May 23 16:29:44 RT-N18U-HST user.notice root: changmw: .rc_usb already started
May 23 16:29:49 RT-N18U-HST user.notice root: 1: changmw waiting for init for 5 seconds
May 23 16:29:54 RT-N18U-HST user.notice root: 2: changmw waiting for init for 5 seconds
May 23 16:29:59 RT-N18U-HST user.notice root: 3: changmw waiting for init for 5 seconds
May 23 16:30:04 RT-N18U-HST user.notice root: 4: changmw re-starting unbound
May 23 16:30:06 RT-N18U-HST user.notice root: 4: changmw re-starting minidlna

_________________
Router: Asus RT-N18U (rev. A1)

May the Force and farces be with you! Live long and prosper!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 1583
Location: All over YOUR webs

PostPosted: Mon May 23, 2022 9:16    Post subject: Reply with quote
Yep, lets see what it says in 48 hours or 172800 seconds.
_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1013
Location: Hung Hom, Hong Kong

PostPosted: Mon May 23, 2022 10:54    Post subject: Reply with quote
the-joker wrote:
Yep, lets see what it says in 48 hours or 172800 seconds.

I turn off everything electronic when going to sleep or leaving home. SO let others help you out... Smile

Anyway, will have a look at the log again before turning off my router....


_________________
Router: Asus RT-N18U (rev. A1)

May the Force and farces be with you! Live long and prosper!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1013
Location: Hung Hom, Hong Kong

PostPosted: Mon May 23, 2022 12:10    Post subject: Reply with quote
the-joker wrote:
That doesnt show anything delta related

youre looking for something like

daemon.info process_monitor[1716]: Local timer delta is 1653237546 for instance of an initial bullshit value counting from 1970 or whatever, a realistic value for me after 12 hours interval is daemon.info process_monitor[1716]: Local timer delta is 0

So the NTP interval is incrementing by additional 12 hours, until I find the delta is no longer acceptable.

Related changes:

Changeset 48932 – DD-WRT
https://svn.dd-wrt.com/changeset/48932

Changeset 48931 – DD-WRT
https://svn.dd-wrt.com/changeset/48931

_________________
Router: Asus RT-N18U (rev. A1)

May the Force and farces be with you! Live long and prosper!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 1583
Location: All over YOUR webs

PostPosted: Mon May 23, 2022 12:32    Post subject: Reply with quote
mwchang wrote:
the-joker wrote:
Yep, lets see what it says in 48 hours or 172800 seconds.

I turn off everything electronic when going to sleep or leaving home. SO let others help you out... Smile

Anyway, will have a look at the log again before turning off my router....



If thats true your ntp interval only needs to be 12 hours or 15 hours max. there's no point setting 48 hours interval otherwise if you shut everything off at night.

When router starts up or reboots regardless of ntp interval set it will update ntp and then only re-update on the interval set. this makes your choices more confounding with respect to your practices (commendable energy saving choices)

You are essentially only under normal circumstances updating ntp once in 24 hours.

_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> Contributions Upload All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum