[PATCH] Increase NTP update period

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Contributions Upload
Author Message
matjon
DD-WRT Novice


Joined: 05 Jan 2019
Posts: 3

PostPosted: Sat Jan 05, 2019 13:16    Post subject: [PATCH] Increase NTP update period Reply with quote
Hello,

process_monitor used to execute ntpclient (which synchronized time with NTP) every hour, which caused unnecessary load on NTP servers. In a vast majority of cases, routers don't need that precise timekeeping.

This patch changes the default NTP update period from one hour to three days, which was determined enough for a router.

I have posted this patch some time ago on
https://svn.dd-wrt.com//ticket/6463
but have received no response.

I am going to post future patches concerning NTP once this one will be merged.

Code:

process_monitor: Increase NTP update period

process_monitor used to execute ntpclient (which synchronized time with NTP)
every hour, which caused unnecessary load on NTP servers.
In a vast majority of cases, routers don't need that precise timekeeping.

This patch changes the default NTP update period from one hour to three days,
which was determined enough for a router.

Signed-Off-By: Mateusz Jończyk
Helped-By: Broly

As it is difficult to specify under which license process_monitor.c is
distributed, this patch is licensed under the Creative Commons Zero license.

diff -U3 -pr original/src/router/rc/process_monitor.c modified/src/router/rc/process_monitor.c
--- original/src/router/rc/process_monitor.c   2018-07-29 12:30:05.000000000 +0200
+++ modified/src/router/rc/process_monitor.c   2018-10-19 22:47:40.000000000 +0200
@@ -27,7 +27,8 @@ static void check_udhcpd(timer_t t, int
 extern void init_event_queue(int n);
 extern int timer_connect(timer_t timerid, void (*routine) (timer_t, int), int arg);
 
-static unsigned int NTP_M_TIMER = 3600;
+// Updating the time every third day is enough for a router
+static unsigned int NTP_M_TIMER = 3*24*3600;
 static unsigned int NTP_N_TIMER = 30;
 
 static int process_monitor_main(int argc, char **argv)
@@ -38,7 +39,7 @@ static int process_monitor_main(int argc
    long int leasetime = 0;
 
    init_event_queue(40);
-   NTP_M_TIMER = nvram_default_geti("ntp_timer", 3600);
+   NTP_M_TIMER = nvram_default_geti("ntp_timer", 3*24*3600);
    openlog("process_monitor", LOG_PID | LOG_NDELAY, LOG_DAEMON);
 
    if (nvram_invmatchi("dhcp_dnsmasq", 1)) {

Sponsor
Wildlion
DD-WRT User


Joined: 24 May 2016
Posts: 391

PostPosted: Mon Jan 07, 2019 20:01    Post subject: Reply with quote
I actually have to disagree with you... I think that an hour is a good amount of time, standard linux systems poll multiple times an hour. In the ntp source code the maxpoll is allowed max of 2^17 (~36 hours), 1 and a half days, not three days.

If the option could be changed, then I would have no problem, because those people that need or want to higher resolution could have it, but 1 hour is a good compromise. Not all router clocks are very good and many of us keep logs and having the times from the router shifted or off, make it hard to trouble shoot or understand what is going on.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum 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