[ntp:questions] A question about the NTP delay time formula

Terje Mathisen "terje.mathisen at tmsw.no" at ntp.org
Tue Jun 23 07:04:39 UTC 2009


Lei wrote:
> In RFC 2030(written by Prof. D.Mills), we have roundtrip delay time
> formula as follows:
> 
>  d = (T4 - T1) - (T2 - T3) .................(1)
> 
> However, IMHO, it should be
> 
>  d = (T4-T1) - (T3 - T2)....................(1)'

This is the same as

   d = -T1 + T2 -T3 +T4
or
   d = (T2-T1) - (T3-T4)

right?

"Use the source, Luke" :-)

 From ntp_proto.c, around line 1200:
> 	 * Let t1 = p_org, t2 = p_rec, t3 = p_xmt, t4 = peer->rec:
> 	 */
> 	ci = p_xmt;			/* t3 - t4 */
> 	L_SUB(&ci, &peer->rec);
> 	LFPTOD(&ci, t34);
> 	ci = p_rec;			/* t2 - t1 */
> 	L_SUB(&ci, &p_org);
> 	LFPTOD(&ci, t21);

I.e Dr. Mills have here calculated (T3-T4) and (T2-T1), both of which 
should be small (normally positive) numbers, and the difference between 
them is the same as in your formula.

The conclusion is that I'm almost certain you've found a typo in the RFC:

The total on-network-cable time must of course be the total time from 
request to reply (T4-T1), minus the time spent inside the server 
(T3-T2), so your second version is correct.

Assuming the RFC does indeed use the first form, that would also be 
against the written description of the algorithm.

Terje

-- 
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"




More information about the questions mailing list