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

Compute and remove communication latency #92

Open
jdoe1024 opened this issue Mar 16, 2020 · 2 comments
Open

Compute and remove communication latency #92

jdoe1024 opened this issue Mar 16, 2020 · 2 comments
Labels
type: enhancement Proposed improvement

Comments

@jdoe1024
Copy link

Current implementation only decodes the Transmit Timestamp and adopts it as the time when the NTP request was sent. It does not take into account the transmission latency between the device and the server, which can be important, especially when using Wi-Fi. The NTP protocol provides for that already, so why not do it?

There are 4 timestamps:

  • the Origin Timestamp (t0) which is taken when the client send the request packet
  • the Receive Timestamp (t1) which is taken when the server receives the request packet
  • the Transmit Timestamp (t2) which is taken when the server sends the response packet (t2 - t1 is the server processing time)
  • the Destination Timestamp (t4) which is taken when the client receives the response packet

The Origin Timestamp should be written in the request packet (bytes 20-28) before sending it and the Destination Timestamp should be measured when processing the response packet. t0 and t4 are taken using the same clock, which is different than the clock for t1 and t2. The transmission time is then:

T = (t4 - t0) - (t2 - t1)  ( = CLIENT_WAIT_TIME - SERVER_PROCESS_TIME)

What we want is the time it took between the sending of the response packet server and its reception by the client. The easiest approximation we can get is T / 2 (supposing it took the same time to send the request between client and server as to send the response between server and client).

@per1234 per1234 added the type: enhancement Proposed improvement label Mar 16, 2020
@MisterAwesome23
Copy link

Should the calculated latency be reduced in the existing returned time or do we need a separate more accurate function?

@WhymustIhaveaname
Copy link

I add this feature in my Pull Request #102.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

4 participants