DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2008-10-15 21:56:53

jesbo
Member
From: Falls Church, VA
Registered: 2008-08-28
Posts: 101

Tweaking system clock for ntpd.

I recently enabled ntpd in my fun_plug. Seems to be working, but I need a little help understanding how to use the info in ntp.drift to adjust the value for adjtimex in fun_plug.local. Instructions and discussion are a bit sketchy in this area.

I deleted the /ffp/etc/ntp.drift file and allowed the system to create a new one.  The value stored in it changed several times as I checked it periodically over 24 hours (i observed 49.099, 147.866, 191.244, 327.346, and finally 500.000 where it has remained).  This implies I should make further adjustments to the system clock with adjtimex.

My initial value in fun_plug.local was "adjtimex -t 9953".

Can someone explain briefly what the numbers in the ntp.drift represent and how to calculate the necessary adjustment value needed in adjtimex?

I have read various descriptions on the web, but have not put the relationship together as it pertains to the DNS-323.

Any pointers would be useful.  Thanks in advance. smile


DNS-323 (H/W ver. B1) |  2 x 1 TB WD Caviar Black (Raid 1) | Corsair Flash Voyager - 16 GB USB | FW 1.08 | fun_plug 0.5

Offline

 

#2 2008-10-15 22:24:16

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Tweaking system clock for ntpd.

With 9965, I get a drift around 300. I don't know the details, only that a perfect clock has 10000 ticks a day. If a positive drift means your clock is going too fast, you should try larger tick values to lengthen the day. Did you try 9965?

Offline

 

#3 2008-10-15 23:52:48

jesbo
Member
From: Falls Church, VA
Registered: 2008-08-28
Posts: 101

Re: Tweaking system clock for ntpd.

Thanks.  I'm going to set it back to 9965 and let it run for a day or two and see how the drift stabilizes.  When I set it to 9953 I may have not allowed the clock to run long enough - so I may have overadjusted.

Have to say your fun_plug package is great.  Makes an otherwise boring device a lot mor fun to work with.  I just got my USB drive working too. smile


DNS-323 (H/W ver. B1) |  2 x 1 TB WD Caviar Black (Raid 1) | Corsair Flash Voyager - 16 GB USB | FW 1.08 | fun_plug 0.5

Offline

 

#4 2008-10-16 00:53:53

rolfsky
Member
From: sunny California
Registered: 2008-10-14
Posts: 19
Website

Re: Tweaking system clock for ntpd.

I was poking around at this myself, and this page has some useful info: (the man page for adjtimex)

http://gd.tuwien.ac.at/linuxcommand.org … imex8.html

I also found this comment interesting:

For a machine connected to the Internet, or equipped with a precision oscillator or radio clock, the best way is to regulate the system clock with ntpd.  The kernel will automatically update the hardware clock every eleven minutes.

Maybe it's not even worth fussing with adjtimex if you're running ntpd?

Here's some additional advice on choosing good adjtimex values:

If your system clock gained 8 seconds in 24 hours, you could set the tick to 9999, and then it would lose 0.64 seconds a day (that is, 1 tick unit = 8.64 seconds per day). To correct the rest of the error, you could set the frequency offset to (2^16)*0.64/.0864 = 485452. Thus, putting the following in rc.local would approximately correct the system clock:

Code:

adjtimex  --tick 9999  --freq 485452

Offline

 

#5 2008-10-16 01:35:58

jesbo
Member
From: Falls Church, VA
Registered: 2008-08-28
Posts: 101

Re: Tweaking system clock for ntpd.

Thanks rolfsky.  I was also thinking it may be pointless to mess with adjtimex given a 24x7 internet connection and ntpd running. 

However, if the software clock is drifting away from reality and it is resetting the hardware clock every 11 minutes, then technically it is making the hardware clock inaccurate until ntpd resets the software clock back to reality.  Its a moot point except for the fact that the software clock gets initialized from the hardware clock at boot time, and if its off, the software clock will start off wrong.  Of course it will get corrected by ntpd when it syncs with an internet clock.  Getting the adjtimex value correct (or close) will minimize the drift in the software clock and thereby minimize the incorrectness of the hardware clock.  Also, it will allow the system software clock to not require much correction by ntpd each time it gets updated.

Perhaps I'm just being too anal here.  But in the end its probably more of a learning process for me.  I just what to understand how it works, and by making it real accurate, I will have learned well. smile  (clearly I have too  much free time on my hands sad )


DNS-323 (H/W ver. B1) |  2 x 1 TB WD Caviar Black (Raid 1) | Corsair Flash Voyager - 16 GB USB | FW 1.08 | fun_plug 0.5

Offline

 

#6 2008-10-16 11:32:18

skydreamer
Member
From: At the Atlantic Coast
Registered: 2007-01-06
Posts: 232

Re: Tweaking system clock for ntpd.

I am using ntpd on both my DNS-323's and it does a pretty good job. No need for adjtimex.

The ntpd keeps record of the clock drift and also evaluates the variations in the drift. If the drift changes frequently then it connects at shorter intervals to the Internet time servers.

There is another issue related to the accuracy of the Stratum 2 clocks, in previous versions of ntpd the accuracy caused the clock to drift by up to 50ms, I think the algorithm has been improved and it is down to 5 ms now.

DNS-323 internal clock is unfortunately quite challenging for ntpd, it is both off the real time and drifting with temperature- I think that D-link did not bother to use temperature compensation.

Compare the following reports, first the master LAN clock server temperature compensated clock:

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+87.232.1.41     195.177.253.180  3 u  205 1024  377   49.872   -8.228   3.901
+87.32.0.19      193.120.10.3     2 u  222 1024  377   47.413   -1.571   0.756
87.32.8.19      .INIT.          16 u    - 1024    0    0.000    0.000   0.000
127.127.1.0     .LOCL.          10 l   29   64  377    0.000    0.000   0.001
*134.226.81.3    .GPS.            1 u  279 1024  377   47.991   -3.741   0.052


Note the difference to the DNS-323- the offset is very high and also the jitter is double or even 4 times the reference LAN time server.

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*192.168.111.254 134.226.81.3     3 u  367 1024  377    0.156  105.980   6.824
127.127.1.0     .LOCL.          10 l   61   64  377    0.000    0.000   0.008

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*192.168.111.254 134.226.81.3     3 u  736 1024  377    0.152   77.342  15.791
127.127.1.0     .LOCL.          10 l   51   64  377    0.000    0.000   0.008


Edit: Just re-read you posts: ntpd uses clock skew do adjust the clock offset so it is incorrect that it fixes the time only at the time sync intervals.

Last edited by skydreamer (2008-10-16 11:35:10)

Offline

 

#7 2008-10-16 11:40:29

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Tweaking system clock for ntpd.

skydreamer wrote:

I am using ntpd on both my DNS-323's and it does a pretty good job. No need for adjtimex.

Without adjtimex, the drift hits the limit (+/- 500), resulting in periodic step adjustments (too much drift to compensate smoothly).

Offline

 

#8 2008-10-16 11:59:07

skydreamer
Member
From: At the Atlantic Coast
Registered: 2007-01-06
Posts: 232

Re: Tweaking system clock for ntpd.

fonz wrote:

Without adjtimex, the drift hits the limit (+/- 500), resulting in periodic step adjustments (too much drift to compensate smoothly).

I would dare to disagree, there is no evidence from ntpq of that. Initially the ntpd may be wobbly before it checks out the host sytem clock but it settles down after a week and works fine from there on.

Then again I can only comment on my existing hardware there might be some misbehaving boxes out there plus I have modded mine in terms of cooling and this is probably the single biggest reason for clock variations.

Offline

 

#9 2008-10-16 12:15:12

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Tweaking system clock for ntpd.

skydreamer wrote:

fonz wrote:

Without adjtimex, the drift hits the limit (+/- 500), resulting in periodic step adjustments (too much drift to compensate smoothly).

I would dare to disagree, there is no evidence from ntpq of that.

Run syslogd and check /var/log/messages. ntpd logs step adjustments.

Offline

 

#10 2008-10-17 04:53:42

jesbo
Member
From: Falls Church, VA
Registered: 2008-08-28
Posts: 101

Re: Tweaking system clock for ntpd.

Thanks for all the input... definitely a learning exercise.  I'm finding that ntpd on the DNS-323 is keeping the clock far better than the Windows client machines - which appear to only update clock from internet timeservers about once a week.

I can see the temperature fluctuations on the DNS very clearly.  I'm running ffp from USB disk now and the unit powers down disks during periods of inactivity (mostly night). I've got the fan control script shutting the fan off completely when temp drops below 100F. So the unit runs anywhere from about 95F (everything off) to 110F (disks spining and under heavy use).


DNS-323 (H/W ver. B1) |  2 x 1 TB WD Caviar Black (Raid 1) | Corsair Flash Voyager - 16 GB USB | FW 1.08 | fun_plug 0.5

Offline

 

#11 2008-10-17 12:07:20

skydreamer
Member
From: At the Atlantic Coast
Registered: 2007-01-06
Posts: 232

Re: Tweaking system clock for ntpd.

jesbo wrote:

Thanks for all the input... definitely a learning exercise.  I'm finding that ntpd on the DNS-323 is keeping the clock far better than the Windows client machines - which appear to only update clock from internet timeservers about once a week.

Changing the time update interval of Windows XP

The default update interval for XP synchronization is once every 7 days. Due to the fact that the computer clock could drift several seconds or even minutes in this time frame, you will want to change the update interval in the system registry

   1. Start the Registry Editor.
   2. Go to HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ W32Time \ TimeProviders \ NTPClient \
   3. Double-click the SpecialPollInterval value, and change the Base of the Value data to Decimal.
   4. Now change the Value data to the time interval you desire. The time units is seconds. The default value is 604800 seconds (seven days). A more reasonable interval is once-per-hour or 3600 seconds.
   5. Close the Registry Editor.

Offline

 

#12 2008-10-17 18:28:45

jesbo
Member
From: Falls Church, VA
Registered: 2008-08-28
Posts: 101

Re: Tweaking system clock for ntpd.

Thanks...

I knew there was likely someplace in the registry to change the ntp behavior... Just hadn't gone the extra step to research it.

I appreciate you offering the info.

- Jim


DNS-323 (H/W ver. B1) |  2 x 1 TB WD Caviar Black (Raid 1) | Corsair Flash Voyager - 16 GB USB | FW 1.08 | fun_plug 0.5

Offline

 

#13 2008-11-06 00:32:54

rolfsky
Member
From: sunny California
Registered: 2008-10-14
Posts: 19
Website

Re: Tweaking system clock for ntpd.

fonz wrote:

Run syslogd and check /var/log/messages. ntpd logs step adjustments.

resurrecting this thread...

after adjusting my ticks and settling my drift down to ~32 ppm, the time seems to be behaving normally (though frequency does look like it's trending slowly upwards)

however, in /var/log/messages I'm getting about half of my updates from ntpd are saying "kernel time sync error 0001":

Code:

Nov  5 12:37:11 turtle daemon.notice ntpd[4723]: kernel time sync error 0001
Nov  5 13:11:33 turtle daemon.notice ntpd[4723]: kernel time sync error 0001
Nov  5 13:30:09 turtle daemon.info ntpd[4723]: offset 0.024911 sec freq 32.551 ppm error 0.043327 poll 10
Nov  5 14:20:17 turtle daemon.notice ntpd[4723]: kernel time sync error 0001

anybody else seeing this?

Offline

 

#14 2008-11-06 01:01:41

jesbo
Member
From: Falls Church, VA
Registered: 2008-08-28
Posts: 101

Re: Tweaking system clock for ntpd.

Yes; I see the sync errors. However, I never see the "offset" messages; only "synchronized" messages.

Probably need to change logging options in the ntp.conf file?

Nov  5 14:34:38 NAS01 daemon.notice ntpd[1890]: kernel time sync error 0001
Nov  5 14:40:00 NAS01 cron.notice crond[1696]: USER root pid 20103 cmd /usr/sbin/getdhcp&
Nov  5 14:50:01 NAS01 cron.notice crond[1696]: USER root pid 20183 cmd /usr/sbin/getdhcp&
Nov  5 14:52:23 NAS01 daemon.info ntpd[1890]: synchronized to 64.202.112.65, stratum 2             <===== ***
Nov  5 15:00:01 NAS01 cron.notice crond[1696]: USER root pid 20249 cmd /usr/sbin/getdhcp&
Nov  5 15:10:00 NAS01 cron.notice crond[1696]: USER root pid 20331 cmd /usr/sbin/getdhcp&
Nov  5 15:20:01 NAS01 cron.notice crond[1696]: USER root pid 20401 cmd /usr/sbin/getdhcp&
Nov  5 15:30:01 NAS01 cron.notice crond[1696]: USER root pid 20467 cmd /usr/sbin/getdhcp&
Nov  5 15:40:01 NAS01 cron.notice crond[1696]: USER root pid 20544 cmd /usr/sbin/getdhcp&
Nov  5 15:42:03 NAS01 daemon.notice ntpd[1890]: kernel time sync error 0001
Nov  5 15:50:01 NAS01 cron.notice crond[1696]: USER root pid 20610 cmd /usr/sbin/getdhcp&

Last edited by jesbo (2008-11-06 01:04:25)


DNS-323 (H/W ver. B1) |  2 x 1 TB WD Caviar Black (Raid 1) | Corsair Flash Voyager - 16 GB USB | FW 1.08 | fun_plug 0.5

Offline

 

#15 2008-11-06 05:53:23

DaveN
Member
Registered: 2008-01-12
Posts: 21

Re: Tweaking system clock for ntpd.

Re: kernel time sync error 0001

This is a known bug with a kernel that is too old (<2.6.19), and NTP 4.2.4.

Ref: http://www.debian-administration.org/us … weblog/169
and https://support.ntp.org/bugs/show_bug.cgi?id=780

Offline

 

#16 2008-11-06 18:03:54

jesbo
Member
From: Falls Church, VA
Registered: 2008-08-28
Posts: 101

Re: Tweaking system clock for ntpd.

Thanks for the explanation.  Given that ntpd seems to be keeping the time adjusted correctly, I'm going to ignore the error for the time being and readdress it  when the next firmware release comes out.  Maybe Dlink will have upgraded the kernel.


DNS-323 (H/W ver. B1) |  2 x 1 TB WD Caviar Black (Raid 1) | Corsair Flash Voyager - 16 GB USB | FW 1.08 | fun_plug 0.5

Offline

 

#17 2008-11-06 18:23:57

rolfsky
Member
From: sunny California
Registered: 2008-10-14
Posts: 19
Website

Re: Tweaking system clock for ntpd.

jesbo wrote:

I'm going to ignore the error for the time being and readdress it  when the next firmware release comes out.  Maybe Dlink will have upgraded the kernel.

or, we could get off our keesters and compile an older version of ntpd, but you might be trading one bug for a set of others...

Offline

 

#18 2008-11-06 20:25:04

jesbo
Member
From: Falls Church, VA
Registered: 2008-08-28
Posts: 101

Re: Tweaking system clock for ntpd.

True... I just haven't had time to set up a development environment on the DNS yet.  I'm waiting for a cold/rainy Saturday to tackle that project.


DNS-323 (H/W ver. B1) |  2 x 1 TB WD Caviar Black (Raid 1) | Corsair Flash Voyager - 16 GB USB | FW 1.08 | fun_plug 0.5

Offline

 

#19 2008-11-07 01:47:29

skydreamer
Member
From: At the Atlantic Coast
Registered: 2007-01-06
Posts: 232

Re: Tweaking system clock for ntpd.

jesbo wrote:

....  I'm waiting for a cold/rainy Saturday to tackle that project.

Plenty of these on the West coast of Ireland- will I send you some? :-)

Offline

 

#20 2008-11-07 03:55:14

jesbo
Member
From: Falls Church, VA
Registered: 2008-08-28
Posts: 101

Re: Tweaking system clock for ntpd.

skydreamer wrote:

jesbo wrote:

....  I'm waiting for a cold/rainy Saturday to tackle that project.

Plenty of these on the West coast of Ireland- will I send you some? :-)

Yes... But you've got the Irish Whiskey and my fav... Guinness to make it more pleasant. smile


DNS-323 (H/W ver. B1) |  2 x 1 TB WD Caviar Black (Raid 1) | Corsair Flash Voyager - 16 GB USB | FW 1.08 | fun_plug 0.5

Offline

 

#21 2009-11-30 22:16:31

fmb
New member
Registered: 2009-11-30
Posts: 1

Re: Tweaking system clock for ntpd.

I've been reading this topic and others related to ntpd. I've learned that the "clock drift" can be compensated with the adjtimex -t in fun_plug.local and that the message "kernel time sync error 0001" in ntp.log is not really to worry about.

But, looking at my ntp.log i'm not fully confident that my setup is correct. Is see sometimes "synchronized to 192.87.36.4, stratum 1" or "synchronized to 131.211.84.189, stratum 2" which looks right. But I also see (very often) messages like "frequency error 512 PPM exceeds tolerance 500 PPM" and "system event 'event_clock_reset' (0x05) status 'sync_alarm, sync_unspec, 15 events, event_peer/strat_chg' (0xc0f4)", which don't look right.

Can you help me by giving your opinion on the next (last lines) of the ntp.log of my DNS-323 and advice me what I can improve?

Code:

30 Nov 20:31:51 ntpd[1889]: synchronized to 131.211.84.189, stratum 2
30 Nov 20:31:51 ntpd[1889]: frequency error 512 PPM exceeds tolerance 500 PPM
30 Nov 20:31:51 ntpd[1889]: system event 'event_sync_chg' (0x03) status 'leap_none, sync_ntp, 15 events, event_peer/strat_chg' (0x6f4)
30 Nov 20:31:51 ntpd[1889]: system event 'event_peer/strat_chg' (0x04) status 'leap_none, sync_ntp, 15 events, event_sync_chg' (0x6f3)
30 Nov 20:31:55 ntpd[1889]: peer 85.234.224.216 event 'event_reach' (0x84) status 'unreach, conf, 15 events, event_reach' (0x80f4)
30 Nov 20:31:57 ntpd[1889]: peer LOCAL(0) event 'event_reach' (0x84) status 'unreach, conf, 15 events, event_reach' (0x80f4)
30 Nov 20:32:04 ntpd[1889]: peer 145.24.129.6 event 'event_reach' (0x84) status 'unreach, conf, 15 events, event_reach' (0x80f4)
30 Nov 20:32:19 ntpd[1889]: peer 192.87.36.4 event 'event_reach' (0x84) status 'unreach, conf, 15 events, event_reach' (0x80f4)
30 Nov 20:33:03 ntpd[1889]: synchronized to 192.87.36.4, stratum 1
30 Nov 20:33:03 ntpd[1889]: frequency error 512 PPM exceeds tolerance 500 PPM
30 Nov 20:34:26 ntpd[1889]: frequency error 512 PPM exceeds tolerance 500 PPM
30 Nov 20:35:02 ntpd[1889]: offset 0.031128 sec freq 500.000 ppm error 0.076643 poll 6
30 Nov 20:35:29 ntpd[1889]: frequency error 512 PPM exceeds tolerance 500 PPM
30 Nov 20:36:33 ntpd[1889]: frequency error 512 PPM exceeds tolerance 500 PPM
30 Nov 20:41:58 ntpd[1889]: synchronized to 131.211.84.189, stratum 2
30 Nov 20:41:58 ntpd[1889]: frequency error 512 PPM exceeds tolerance 500 PPM
30 Nov 20:47:05 ntpd[1889]: synchronized to 192.87.36.4, stratum 1
30 Nov 20:52:47 ntpd[1889]: time reset +0.452444 s
30 Nov 20:52:47 ntpd[1889]: frequency error 512 PPM exceeds tolerance 500 PPM
30 Nov 20:52:47 ntpd[1889]: system event 'event_clock_reset' (0x05) status 'sync_alarm, sync_unspec, 15 events, event_peer/strat_chg' (0xc0f4)
30 Nov 20:52:47 ntpd[1889]: system event 'event_peer/strat_chg' (0x04) status 'sync_alarm, sync_unspec, 15 events, event_clock_reset' (0xc0f5)
30 Nov 20:52:49 ntpd[1889]: peer 131.211.84.189 event 'event_reach' (0x84) status 'unreach, conf, 15 events, event_reach' (0x80f4)
30 Nov 20:52:52 ntpd[1889]: peer 192.87.36.4 event 'event_reach' (0x84) status 'unreach, conf, 15 events, event_reach' (0x80f4)
30 Nov 20:52:53 ntpd[1889]: peer 85.234.224.216 event 'event_reach' (0x84) status 'unreach, conf, 15 events, event_reach' (0x80f4)
30 Nov 20:53:01 ntpd[1889]: peer 145.24.129.6 event 'event_reach' (0x84) status 'unreach, conf, 15 events, event_reach' (0x80f4)
30 Nov 20:53:01 ntpd[1889]: synchronized to 192.87.36.4, stratum 1
30 Nov 20:53:01 ntpd[1889]: frequency error 512 PPM exceeds tolerance 500 PPM
30 Nov 20:53:01 ntpd[1889]: system event 'event_sync_chg' (0x03) status 'leap_none, sync_ntp, 15 events, event_peer/strat_chg' (0x6f4)
30 Nov 20:53:01 ntpd[1889]: system event 'event_peer/strat_chg' (0x04) status 'leap_none, sync_ntp, 15 events, event_sync_chg' (0x6f3)
30 Nov 20:53:27 ntpd[1889]: peer LOCAL(0) event 'event_reach' (0x84) status 'unreach, conf, 15 events, event_reach' (0x80f4)
30 Nov 20:55:04 ntpd[1889]: frequency error 512 PPM exceeds tolerance 500 PPM
30 Nov 20:57:16 ntpd[1889]: frequency error 512 PPM exceeds tolerance 500 PPM
30 Nov 21:04:17 ntpd[1889]: synchronized to LOCAL(0), stratum 10
30 Nov 21:04:17 ntpd[1889]: frequency error 512 PPM exceeds tolerance 500 PPM
30 Nov 21:04:48 ntpd[1889]: synchronized to 131.211.84.189, stratum 2
30 Nov 21:08:03 ntpd[1889]: synchronized to 192.87.36.4, stratum 1

Last edited by fmb (2009-11-30 22:16:57)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB