[ntp:questions] Re: ntpd transmit timestamp precision
Damion de Soto
damion at cyberguard.com.au
Fri Feb 17 01:14:44 UTC 2006
Harlan Stenn wrote:
> I see to points Damion has raised where I do not see your response.
> The first is that there exist several libraries where the C library provides
> the nano calls but implements them using the (older) microsecond
> calls. Therefore there is no data available below the microsecond and our
> code is not handling this case.
> Damion, what does clock_getres() return on these systems?
I've justed tested it on a few different linux systems here (SH, ARM, x86 and MIPS)
and linux 2.4.x kernels always return 10ms, and linux 2.6.0 kernels always return 1ms.
Looking at the source, it would seem this is always going to be wrong - it just
returns the clock tick frequency (100Hz for 2.4 kernel and 1000Hz for 2.6 kernel)
>> the system clock precision is calculated in default_get_precision()
>> in ntp_proto.c - this function uses consecutive calls to
>> get_systime() to calculate the minimum tick difference. Won't this
>> be always wrong if the random fuzz code in get_systime() is used,
>> and give a much higher precision than is really available?
> This could easily be fixed by adding another parameter to get_systime() that
> would disable the fuzz, assuming it really is a problem (from my initial
> glance I think it is a problem, but I am working on way too many things
> right now).
That could work.
If get_systime() only optionally added fuzz, then it can still be used to calculate
the real precision when called from default_get_precision().
That sys_precision value can then be used on subsequent calls to get_systime(fuzz =
yes) to add the exact amount of random bits to the time. This should happen no
matter which time function is used clock_gettime(), getclock() or gettimeofday().
| Damion de Soto --------------------------------------------------
| Software Engineer email: Damion_deSoto at au.securecomputing.com
| Secure Computing Corporation web: http://www.securecomputing.com
| fax: +61 7 3891 3630 ph: +61 7 3435 2809
---- Free Embedded Linux Distro at http://www.snapgear.org ----
More information about the questions