52#ifndef __N_CLOCK_SYNC_HEADER
53#define __N_CLOCK_SYNC_HEADER
67#ifndef N_CLOCK_SYNC_SAMPLE_COUNT
68#define N_CLOCK_SYNC_SAMPLE_COUNT 11
72#ifndef N_CLOCK_SYNC_INTERVAL
73#define N_CLOCK_SYNC_INTERVAL 3.0
int sample_index
current write position in circular buffer
double last_sync_time
local time of last sync request sent
double estimated_offset
add to local time to get estimated server time
double estimated_rtt
current estimated round-trip time
int sample_count
number of samples collected so far
double rtt_samples[11]
circular buffer of RTT values
double offset_samples[11]
circular buffer of offset estimates
#define N_CLOCK_SYNC_SAMPLE_COUNT
number of samples for the median filter
N_CLOCK_SYNC * n_clock_sync_new(void)
allocate and initialize a new clock sync estimator
int n_clock_sync_should_send(const N_CLOCK_SYNC *cs, double local_now)
check if it's time to send a new sync request (returns TRUE/FALSE)
double n_clock_sync_server_time(const N_CLOCK_SYNC *cs, double local_now)
get estimated server time given a local time value
void n_clock_sync_delete(N_CLOCK_SYNC **cs)
free a clock sync estimator
void n_clock_sync_mark_sent(N_CLOCK_SYNC *cs, double local_now)
mark that a sync request was just sent
int n_clock_sync_process_response(N_CLOCK_SYNC *cs, double client_send_time, double server_time, double local_now)
record a sync response: client_send_time is the local time the request was sent, server_time is the s...
clock synchronization estimator
Common headers and low-level functions & define.