Module: caf_cli/TimeAdjuster

Approximates a time offset to match the UTC time in the server.

This is needed when the client does not have accurate time, e.g., it cannot rely on NTP, or an RTC with battery.

The approach that follows is very similar to NTP: assume symmetric propagation times in a round trip, and pick the shortest round trip time within a window of requests. If needed, we also low pass filter the resulting time offsets.

Every client request to a CA piggybacks time information. And after a few requests, the time error after applying the offset is <100ms in most cases.

Source:

Methods

endRequest(response)

Ends a roundtrip with a response.

Parameters:
Name Type Description
response msgType

A response.

Source:

offset() → {number}

Returns the time offset.

Add this value to the current time to match server time, e.g.:

 var now = new Date().getTime();
 now = now + timeAdjuster.getOffset();
Source:
Returns:

A time offset

Type
number

startRequest(request)

Starts a request to be timed.

Parameters:
Name Type Description
request msgType

A request to be timed.

Source:

TimeAdjuster(options)

Constructor.

See types.js for a description of type timeAdjusterOptionsType.

Parameters:
Name Type Description
options timeAdjusterOptionsType

Configuration options.

Source: