[PATCH] Increase NTP update period

Post new topic   Reply to topic    DD-WRT Forum Index -> Contributions Upload
Goto page Previous  1, 2
Author Message
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 2143
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)
Sponsor
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1287
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)

Drink, Blink, Stretch! Live long and prosper!
May the Force and farces be with you!

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: 2143
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: 1287
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)

Drink, Blink, Stretch! Live long and prosper!
May the Force and farces be with you!

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: 2143
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: 1287
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)

Drink, Blink, Stretch! Live long and prosper!
May the Force and farces be with you!

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

Drink, Blink, Stretch! Live long and prosper!
May the Force and farces be with you!

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: 2143
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)
mwchang
DD-WRT Guru


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

PostPosted: Mon May 23, 2022 16:44    Post subject: Reply with quote
the-joker wrote:

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.


Thank you for the tip!

The log didn't change much related to time, turning the router off... Good night (HKT)! Smile


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

Drink, Blink, Stretch! Live long and prosper!
May the Force and farces be with you!

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: 1287
Location: Hung Hom, Hong Kong

PostPosted: Wed Nov 16, 2022 5:47    Post subject: Reply with quote
mwchang wrote:
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?


Related:

Changeset 50848 – DD-WRT
* no need to duplicate
https://svn.dd-wrt.com/changeset/50848

Changeset 50851 – DD-WRT
* may now work with any time
https://svn.dd-wrt.com/changeset/50851

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

Drink, Blink, Stretch! Live long and prosper!
May the Force and farces be with you!

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
Goto page Previous  1, 2 Display posts from previous:    Page 2 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