Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

lemon-mint/timeserver

Repository files navigation

Time Server

HTTP Time Server that returns the current server time

How it works

Terminology

  • t0: time when the client sends the request
  • t1: time when the server receives the request
  • t2: time when the server sends the response
  • t3: time when the client receives the response

Protocol

  1. The Client sends a request GET /tt to the server.

The server is written in Go and returns the current time in the following format:

1844674407370955161518446744073709551615ドル
  1. The Client can parse the response by splitting the string by $ and converting the first part to t1 and the second part to t2.

  2. The Client can calculate offset by the following formula:

offset = (t1 - t0 + t2 - t3) / 2;
  1. The Client also can calculate sync error by the following formula:
error = Math.abs(t3 - t0 - (t2 - t1)) / 2;
  1. The Client repeats the request several times and calculates and records the offset and error for each request.

  2. After that client calculates the confidence interval using the Intersection algorithm.

AltStyle によって変換されたページ (->オリジナル) /