[ntp:questions] C api to ntpd

Patrik Arlos patrik.arlos at gmail.com
Sat Dec 7 11:54:43 UTC 2013


On Friday, December 6, 2013 11:53:02 PM UTC+1, David Woolley wrote:
> On 06/12/13 12:13, Patrik Arlos wrote:
> 
> [ Very long lines! ]
> 
> > I have a C program that needs to evaluate the system (where it runs)
> > clock synchronization status on a regular interval(every ~60s). On the
> > same system there is a ntpd running, that synchronized to other ntp servers.
> 
> 
> A system goes from being effectively synchronized to effectively 
> unsynchronised over an extended amount of time and the boundary is 
> fuzzy.  60s seems far to rapid.
> 
> 
The program just needs to keep track/detect when the synchronization is lost. Its used to correlate measurements at multiple locations, and the measurements include time. So, as long as the system is synchronized everything is assumed 
fine. 

> 
> 
> 
> > * Is the server synchronized to any server, i.e. the presence of '*' for any of the servers.
> > If there is a server that is '*'
> 
> The server is synchronised if there is a *, but it is not synchronised 
> to just that server.
> 
> 
> 
> > * What is the delay associated with that server?
> 
> 
> 
> Root distance is more likely to be useful, but is a very pessimistic 
> estimator of the likely error.
> 
> 
> 
> > * What is the offset associated with that server?
> 
> 
> 
> The offset is probably not very useful.
> 
> 
> 
> 1) it is an instantaneous measurement, which should normally vary 
> randomly about zero and should consist mainly of measurement noise.
> 
> 2) the clock is disciplined by a combination of the offsets from * and + 
> servers, not just the single one from the * server.
> 
You are probably right with offset, but it provides a number. Would root distance be better? I'd like to compare time stamps (t1,t2) from two different locations (L1,L2). I was thinking to use the offset from each 
location (O1, O2) to a common server(t0), in order to have an idea of how close the time stamps are to each other. 


> 
> 
> > I've looked around to find some API/library that provides this, but
> > obviously I have not found it.
> 
> 
> 
> Most people use ntpq and parse the output.  ntpd itself uses a limit on 
> root dispersion.

Is there a C api for ntpq? or is the only solution to read the ntpq code, and extract the needed 'bits'?

BR/Patrik

[sorry for the long lines]




More information about the questions mailing list