Module crystalorb::clocksync[][src]

Expand description

The clocksync module is responsible for managing the difference between the clocks on the local and remote machine (aka client and server clocks), and for the client to estimate the server’s local time.

The design of this module is currently suboptimal and could be improved:

  • Only the client-side clocksyncing logic is located here. The server-side logic is located in the Server itself.
  • This clocksync module serves double duty for also informing the client which client_id has been allocated to this client by the server.

Structs

ClockSyncMessage

A message sent between client and server to measure the number of seconds difference between the clocks of the two machines.

ClockSyncer

Client-side clock syncing logic. This is responsible for sending out clock synchronization request messages to the server, and handling the server’s responses. This also serves double duty for determining what client identifier has been allocated by the server to this client. For each server response, a sample of the time clock offset between the client and the server is calculated, and a rolling average (ignoring outliers) of these samples is used to update the effective clock offset that is used by the client once the effective clock offset deviates too far from the rolling average.