[ntp:hackers] review of offset calculation in simple querying client
sean finney
seanius at seanius.net
Fri Apr 28 05:48:58 UTC 2006
hi ntp-hackers,
first, please forgive me if this is not the correct list...
i'm one of the developers in the nagios-plugins project. for those
unfamiliar with nagios, it's a host and resource monitoring system
using various plugins to monitor stuff such as disk space, availability
of http service, and more relevantly, ntp offset/jitter.
up until now, the check_ntp plugin has been a perl script that uses
and parses the output of ntpdate/ntpq for calculating offset and jitter.
however, i've recently been working on a rewrite in C which does all
the network io and calculations internally. after having spent
much time rtfrfc'ing i've hacked together a "simple" implementation.
however, the offset calculation is constantly off by a factor of 0.0x or
so, and i suspect that there's some error in my offset-calculating
logic.
currently, the offset calculation looks lsomething like this:
static inline double calc_offset(const ntp_message *m, const struct timeval *t){
double client_tx, peer_rx, peer_tx, client_rx, rtdelay;
client_tx = NTP64asDOUBLE(m->origts);
peer_rx = NTP64asDOUBLE(m->rxts);
peer_tx = NTP64asDOUBLE(m->txts);
client_rx=TVasDOUBLE((*t));
rtdelay=NTP32asDOUBLE(m->rtdelay);
return (.5*((peer_tx-client_rx)+(peer_rx-client_tx))-rtdelay);
}
assuming that the macros in question do what they're supposed to do,
is there anything fundamentally wrong with how i'm calculating the
offset? any insight would be appreciated!
thanks,
sean
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://support.ntp.org/pipermail/hackers/attachments/20060428/8d8fc51a/attachment.bin
More information about the hackers
mailing list