[ntp:questions] Re: NTP4 has 3 different time formats! Namly (32, 64, 128) bits wide

Terje Mathisen terje.mathisen at hda.hydro.com
Wed Jul 19 09:16:09 UTC 2006

Richard B. Gilbert wrote:
> I was thinking of the cost of doing all the arithmetic in BCD.  The NTP 
> timestamps are exchanged between systems for the purpose of 
> synchronizing to UTC; there is no advantage to exchanging them in BCD. 
> They do not have to be "people readable"!

OK, that's perfectly valid. I agree that the NTP protocol should always 
use a compact format which is hardware friendly, i.e. something _very_ 
similar to the current 32:32 fixed-bit format. The only obvious 
improvement would be for all packets to also keep around a TAI-UTC 
offset number, since that would make it trivial to handle both leap 
seconds and provide the OS/applications with a monotonic time scale 
along with the regular UTC pseudo-seconds.

OTOH, using BCD really wouldn't matter much since effectively all 
(modulo a few startup packets with -g in force) NTP timestamp 
comparisons/subtractions happen on numbers which are very close, i.e. 
only the seconds and fraction fields needs to be operated on, and this 
is easy to do in parallel for BCD numbers, it is only a small constant 
factor slower than a binary subtraction.

The other important part, which is steering the local clock via adjtime 
is much more dependent upon binary numbers, since it needs to do 
multiplications and/or divisions on fractional numbers.

- <Terje.Mathisen at hda.hydro.com>
"almost all programming can be viewed as an exercise in caching"

More information about the questions mailing list