Re: [Linuxptp-users] How pch2sys calcs the offset
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Richard C. <ric...@gm...> - 2013-07-25 17:09:59
|
On Thu, Jul 25, 2013 at 03:01:22PM +0000, Ledda William EXT wrote: > > *offset = (tdst1.tv_sec - tsrc.tv_sec) * NS_PER_SEC + tdst1.tv_nsec - tsrc.tv_nsec + interval / 2; > > Can someone explain to me why the half interval is added at the end? * We have two clocks, TSRC and TDST. * We want to know the offset, OFFSET = TDST - TSRC. * We take three readings, in order, TDST1, TSRC, and TDST2. * We assume that the TSRC reading occured exactly half way between TDST1 and TDST2. TDST = TDST1 + (TDST2 - TDST1) / 2 OFFSET = TDST1 + (TDST2 - TDST1) / 2 - TSRC OFFSET = TDST - TSRC + (TDST2 - TDST1) / 2 HTH, Richard |