Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to calculate offset #6

Closed
marcbowes opened this issue Apr 14, 2014 · 3 comments
Closed

Unable to calculate offset #6

marcbowes opened this issue Apr 14, 2014 · 3 comments

Comments

@marcbowes
Copy link
Contributor

According to RFC 958, to calculate your offset, you need to use run a calculation that includes the timestamp of when the client received the packet.

Right now, this timestamp is being set in the constructor of Response - see

@client_time_receive = Time.new.to_i
.

  1. it is private
  2. it is an integer

Would it be reasonable to:

  1. add the receive timestamp as a parameter to Response#initialize
  2. simply add an offset method which does the calculation as described in the RFC
offset = ( (response.receive_timestamp - response.originate_timestamp) + (response.transmit_timestamp - response.client_time_receive) ) / 2
@davispuh
Copy link

To me it looks like @client_time_receive is not used at all.

@marcbowes
Copy link
Contributor Author

Not that I could see!

@brandonarbini
Copy link
Contributor

That certainly seems reasonable.

marcbowes added a commit to marcbowes/net-ntp that referenced this issue Apr 15, 2014
The test is quite hard if your clock is in sync. I'm not sure the right
way to actually do this because we're using a pool of NTP servers and
ntpdate and Net::NTP could hit different servers.

I think this is good enough for now to verify that things actually
work and return reasonable results.

closes zencoder#6
brandonarbini pushed a commit that referenced this issue Apr 16, 2014
Fix for 1.9, expose Response#offset. Fixes #5 and fixes #6.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants