[ntp:questions] Re: NTP timestamp format
no_spam_please at swenker.xs4all.nl
Mon Apr 24 21:51:21 UTC 2006
On Mon, 24 Apr 2006 08:16:45 -0700, Franz wrote:
> thanks for the explanation. In theory it's clear now :)
> Is my calculation correct, when I multiply microseconds with (1000 /
> 233) * 2^32 for decoding it in NTP format? (In this way I understood
> the NTP FAQ 220.127.116.11.)
No, you should multiply seconds with 2^32.
> So for 250 millisec it would be 4608334008583
That is 250 millisec = 0.25 sec => 1073741824 in NTP timestamp format.
Binary this is 1000000000000000000000000000000, when adding leading zeros
to get to a 32 bit number this is 01000000000000000000000000000000 .
Now it's yor turn:
- start with 1.5 seconds.
- multiply by 2^32
- rewrite in binary
- add leading zeros to get a 64 bit number
- compare the result with the text in your original posting
To mathematicians, this is normal. To mere mortals this is magic :)
> For vice versa I would multiply the NTP fraction part with 2^-32 and
> then multiply it with 0.233
2^-32 seconds is *approximately* 0.233 nano seconds. Thus you should only
multiply the fraction part by 2^-32. Never ever use the 0.233 nano seconds
as you will end up with an error of nearly a milli second.
> Am I correct with these calculations?
Not yet, a little more practice is needed so the theory fits with
> Thanks, Franz
Regards, Johan Swenker
More information about the questions