I wish to write a C program which obtains the system time and hence
uses this time to print out its ntp equivalent.
Am I right in saying that the following is correct for the seconds part
of the ntp time?
long int ntp.seconds = time(NULL) + 2208988800;
How might I calculate the fraction part?
The fractional part to add obviously is 0ps … 😉
So the question for the fraction could be reduced to how accurate is the system clock.
gettimeofday()gets you micro seconds.clock_gettime()could get you nano seconds.Anyhow I doubt you’ll be reaching the theoratically possible resolution the 32bit wide value for the fraction allows (at least on a standard PC).