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

client_time_receive should always be after originate_timestamp #14

Open
daxinc opened this issue Jun 25, 2022 · 0 comments
Open

client_time_receive should always be after originate_timestamp #14

daxinc opened this issue Jun 25, 2022 · 0 comments

Comments

@daxinc
Copy link

daxinc commented Jun 25, 2022

Hi, I wrote a simple program to send a NTP request to a local NTP server. The problem I found is that the client_time_receive is before originate_timestamp most of the time. If I ran 5 times, it happens 4 times.

Here's one of the output where client_time_receive is before originate_timestamp.

Complete NTP request:
	originate_timestamp=1656190742.9307978,
	receive_timestamp=1656190742.6455479,
	transmit_timestamp=1656190742.645609,
	client_time_receive=1656190742.6068008,
	offset=-0.12322092056274414
client_time_receive - originate_timestamp = -0.32399702072143555

Code:

require 'net/ntp'

LOCAL_HOST = 'localhost'

# measure NTP metrics by sending an NTP request to local host
def measure
  resp = Net::NTP.get(LOCAL_HOST)

  puts "Complete NTP request:\n\toriginate_timestamp=#{resp.originate_timestamp},\n\treceive_timestamp=#{resp.receive_timestamp},\n\ttransmit_timestamp=#{resp.transmit_timestamp},\n\tclient_time_receive=#{resp.client_time_receive},\n\toffset=#{resp.offset}"
  puts "client_time_receive - originate_timestamp = #{resp.client_time_receive - resp.originate_timestamp}"
end

measure

I also print out the client_localtime in the get method and the originate_timestamp in the response object. They should be exactly same, but not. The originate_timestamp is usually greater than client_localtime for about 0.17 second.

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

1 participant