Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: How to calculate the offset of your local time against an NTP reference server

by martin (Friar)
on Feb 09, 2015 at 00:24 UTC ( [id://1115979]=note: print w/replies, xml ) Need Help??


in reply to How to calculate the offset of your local time against an NTP reference server

The Reference Timestamp is the time at which the server clock was last set or corrected. That does not tell anything about the local clock offset.

In order to guess the local clock offset an SNTP client has to evaluate four timestamps:

t1 = local clock, time request sent by client;
t2 = server clock, time request received by server;
t3 = server clock, time reply sent by server;
t4 = local clock, time reply received by client

The offset o is then calculated as:

o = ((t2 - t1) + (t3 - t4)) / 2

Net::NTP will save you the trouble of doing this explicitly and give you the offset right away. It will also not suffer additional inaccuracy from the delay between your gettimeofday() and get_ntp_response() calls.

  • Comment on Re: How to calculate the offset of your local time against an NTP reference server

Replies are listed 'Best First'.
Re^2: How to calculate the offset of your local time against an NTP reference server
by thanos1983 (Parson) on Feb 09, 2015 at 08:59 UTC

    Hello Martin,

    Thank you for your time and effort reading my question and replying. I was afraid that I was so wrong when I also read the RFC4330 where it explains the way it should it should be calculated.

    As you mentioned I do not really need to calculate the offset since I can use the Net::NTP module. The reason that I need to use it is I am planning to apply this process on several remote OS through SSH, where I will not be able to have the NET::NTP module available.

    Again thank you for your feedback it is really valuable to me to contineou with my experimentation.

    Seeking for Perl wisdom...on the process of learning...not there...yet!

      If you can run your own script, then you can use Net::NTP

      It is pure perl, with only core dependencies.

        Hello SuicideJunkie,

        Thank you for your time and effort reading and replying to my question.

        You mean I run my script into an external the same script?

        Seeking for Perl wisdom...on the process of learning...not there...yet!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1115979]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-16 19:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found