[ntp:questions] how to write a reference clock driver

Unruh unruh-spam at physics.ubc.ca
Thu Dec 11 21:52:57 UTC 2008


Juergen Kosel <juergen.kosel at freenet.de> writes:

>Hello,

>I have a system with hardware support for PTP (IEEE 1588 time
>synchronisation) [ http://en.wikipedia.org/wiki/Precision_Time_Protocol ].
>So the system can read from two 32 bit registers seconds and nanoseconds
>since 1.1.1970. It appears like the system time, but is n't the system time.
>To synchronize the system time to the PTP synchronized time and to
>provide it to other systems, I want to write a reference clock driver.

Don't bother. they already exist. Just write an program which uses shm to
place the PTP time and the computer system time into a shared memory
segment, and use the shm refclock driver. 


>I have already read http://www.eecis.udel.edu/~mills/ntp/html/howto.html
>and started with a copy of refclock_local.c.
>But from the documentation it is not clear, in what way the offset
>should be calculated and used. E.g.:
>offset = ref_clock_time - system_time;
>or
>offset = system_time - ref_clock_time;

ntp calculates offset. You supply it with the system time and the true
time, and ntp will do the rest. 

Ie, write a little program which reads the PTP time and the system time
once a second say, and place the two times into the shared memory
registers for the shm driver. 




More information about the questions mailing list