Thread: [Linuxptp-users] Question about meanPathDelay (possible bug?)
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Wolfgang W. <wol...@gm...> - 2013-07-30 13:06:36
|
Hello, I have a question about the calculation of the meanPathDelay by the functions process_delay_resp() and clock_path_delay(). The standard says the following about the meanPathDelay computation (section 11.3.2): <meanPathDelay> shall be computed as: <meanPathDelay> = [(t2 - t3) + (receiveTimestamp of Delay_Resp message – originTimestamp of Sync message) – correctionField of Sync message – correctionField of Delay_Resp message]/2. I'm not sure, but I think the "receiveTimestamp of Delay_Resp message"-part is not implemented correctly in LinuxPTP. The function process_delay_resp() calls clock_path_delay() as follows: clock_path_delay(p->clock, p->delay_req->hwts.ts, m->ts.pdu, m->header.correction); The third argument is used by clock_path_delay() as what is called t4 in the standard. As far as I understand the code, the third argument (m->ts.pdu) is the ingress timestamp on the slave of the DelayResp-message. But I think what should be passed here should be the ingress timestamp on the master of the DelayReq-message, which is contained in the "receiveTimestamp"-field of the DelayResp-message (rsp->receiveTimestamp). Any comments on what is actually correct are welcome :) I'm new to LinuxPTP and try to use it to improve my understanding of 1588. regards, Wolfgang Wallner |
From: Miroslav L. <mli...@re...> - 2013-07-30 15:47:13
|
On Tue, Jul 30, 2013 at 03:06:28PM +0200, Wolfgang Wallner wrote: > I'm not sure, but I think the "receiveTimestamp of Delay_Resp > message"-part is not implemented correctly in LinuxPTP. > > The function process_delay_resp() calls clock_path_delay() as follows: > > clock_path_delay(p->clock, p->delay_req->hwts.ts, m->ts.pdu, > m->header.correction); > > The third argument is used by clock_path_delay() as what is called t4 in > the standard. > As far as I understand the code, the third argument (m->ts.pdu) is the > ingress timestamp on the slave of the DelayResp-message. > But I think what should be passed here should be the ingress timestamp on > the master of the DelayReq-message, which is contained in the > "receiveTimestamp"-field of the DelayResp-message (rsp->receiveTimestamp). To me, it seems it's the DelayResp receiveTimestamp in the ts.pdu field and used as t4 in the delay calculation. It's filled by the following code in the msg_post_recv() function. case DELAY_RESP: timestamp_post_recv(m, &m->delay_resp.receiveTimestamp); Why do you think it's the ingress time of the DelayResp message? -- Miroslav Lichvar |
From: Wolfgang W. <wol...@gm...> - 2013-07-31 08:41:21
|
On Tue, 30 Jul 2013 17:46:58 +0200, Miroslav Lichvar <mli...@re...> wrote: > On Tue, Jul 30, 2013 at 03:06:28PM +0200, Wolfgang Wallner wrote: >> I'm not sure, but I think the "receiveTimestamp of Delay_Resp >> message"-part is not implemented correctly in LinuxPTP. >> >> The function process_delay_resp() calls clock_path_delay() as follows: >> >> clock_path_delay(p->clock, p->delay_req->hwts.ts, m->ts.pdu, >> m->header.correction); >> >> The third argument is used by clock_path_delay() as what is called t4 in >> the standard. >> As far as I understand the code, the third argument (m->ts.pdu) is the >> ingress timestamp on the slave of the DelayResp-message. >> But I think what should be passed here should be the ingress timestamp >> on >> the master of the DelayReq-message, which is contained in the >> "receiveTimestamp"-field of the DelayResp-message >> (rsp->receiveTimestamp). > > To me, it seems it's the DelayResp receiveTimestamp in the ts.pdu > field and used as t4 in the delay calculation. It's filled by the > following code in the msg_post_recv() function. > > case DELAY_RESP: > timestamp_post_recv(m, &m->delay_resp.receiveTimestamp); Oh, thanks for making this clear :) > > Why do you think it's the ingress time of the DelayResp message? Because at first I misinterpreted the standard. When it says "receiveTimestamp of Delay_Resp message" I thought of the Ingress timestamp of DelayResp. I was confused, and had a look at the source code of LinuxPTP. I found "m->ts.pdu", which at first looks like a timestamp assigned by a lower layer, e.g. the ingress timestamp. I did not think of the possibility that the lower layer puts the value of delay_resp.receiveTimestamp into this field. Sorry for broadcasting my confusion, I should have dug deeper in the code :) Thanks for clearing this up, Wolfgang |
From: Richard C. <ric...@gm...> - 2013-07-31 14:33:18
|
On Wed, Jul 31, 2013 at 10:41:07AM +0200, Wolfgang Wallner wrote: > I did not think of the possibility that the lower layer puts the value of > delay_resp.receiveTimestamp into this field. pdu = protocol data unit, here protocol means the PTP. There is a long comment in msg.h that describes the time stamp fields. Thanks, Richard |
From: Wolfgang W. <wol...@gm...> - 2013-07-31 15:30:26
|
On Wed, 31 Jul 2013 16:32:56 +0200, Richard Cochran <ric...@gm...> wrote: > On Wed, Jul 31, 2013 at 10:41:07AM +0200, Wolfgang Wallner wrote: >> I did not think of the possibility that the lower layer puts the value >> of >> delay_resp.receiveTimestamp into this field. > > pdu = protocol data unit, here protocol means the PTP. > > There is a long comment in msg.h that describes the time stamp fields. Do you mean the following comment? struct { /** * Contains the time stamp from the packet data in a * native binary format for the host machine. The * exact source of the time stamp's value depends on * the message type: * * - announce originTimestamp * - follow_up preciseOriginTimestamp * - sync originTimestamp * - delay_req originTimestamp * - pdelay_resp requestReceiptTimestamp * - pdelay_resp_fup responseOriginTimestamp */ struct timestamp pdu; /** * Approximate ingress time stamp using the relative * CLOCK_MONOTONIC. Used to determine when announce * messages have expired. */ struct timespec host; } ts; This comment does not fully match the behavior in the msg_post_recv()-function , as timestamps of delay_req-frames are not handled in this functions, and delay_resp-frames are missing in the comment description. IMHO it would be more accurate to replace the delay_req-line with "delay_resp receiveTimestamp". regards, Wolfgang |
From: Richard C. <ric...@gm...> - 2013-07-31 16:33:43
|
On Wed, Jul 31, 2013 at 05:30:17PM +0200, Wolfgang Wallner wrote: > IMHO it would be more accurate to replace the delay_req-line with > "delay_resp receiveTimestamp". Yes, you are right. Care to submit a patch? Thanks, Richard |