LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement NTP time packet delay correction

Solved!
Go to solution

Hi, I am trying to modify Altenbach's code https://forums.ni.com/ni/attachments/ni/170/515627/1/QueryNTPparse2.vi for acquiring time over NTP so that the round trip delay can be accounted for appropriately in my use case. My problem is identifying which item in the NTP packet is which. Not being very familiar with the terms  I dont recognise those used by Altenbach in relation to those I have from other sources. Altenbach uses the following;

Reference timestamp

Originate timestamp

Receive timestamp 

Transmit timestamp

 

these are used in wikipedia:

t0 is the client's timestamp of the request packet transmission,
t1 is the server's timestamp of the request packet reception,
t2 is the server's timestamp of the response packet transmission and
t3 is the client's timestamp of the response packet reception

 

I am trying to achieve; Time Correction = ((t2+t1)/2) - ((t3+t0)/2)

 

I made the alterations and ran the vi to see if that helped identify which packet was which but "originate timestamp" inexplicably came out differently than the others as shown in the attached png of the front panel. Perhaps there is more in Altenbach's code than I recognise? Any suggestions gratefully received.

 

time stamp front panel.pngNTPclockSync.png

 

Download All
0 Kudos
Message 1 of 7
(2,495 Views)

I thought NTP already corrects for packet delay?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 7
(2,470 Views)

Windows NTP etc have packet delay correction but I dont think this original code does. It came from here  https://forums.ni.com/t5/LabVIEW/help-with-connecting-to-NIST-NTP-server-on-port-123/td-p/1030380/pa... 

0 Kudos
Message 3 of 7
(2,430 Views)

It's been a while since I've thought about NTP, but have you tried to go to https://ntp.org/ ?

 

Is setting up NTP on your computer an option?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 4 of 7
(2,413 Views)

Hi Bill,

Thanks, I am sure this process will work and I can trigger it with my main vi which is more useful. I have had problems with the time on my pc so like this I bypass all that.

Message 5 of 7
(2,405 Views)

Here's a slight update of the code which shows the times being output more clearly.

 

 

ntp3 front panel.png

I am guessing that the originate TS is zero as its 01/01/1900, Reference time stamp doesnt seem to change and my computed result is way off of receive and transmit time stamps.

0 Kudos
Message 6 of 7
(2,321 Views)
Solution
Accepted by topic author EdHarris

This is my solution with a decode of the terms used. I decided to record all four values t0 to t3 to work with later depending on the outcome. As long as the round trip delay (t3-t0)-(t2-t1) is small enough there shouldnt be a problem.

 

0 Kudos
Message 7 of 7
(1,991 Views)