![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Clock synchronization estimator for networked games. More...
#include "n_common.h"
Include dependency graph for n_clock_sync.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| struct | N_CLOCK_SYNC |
| clock synchronization estimator More... | |
Macros | |
| #define | N_CLOCK_SYNC_INTERVAL 3.0 |
| default interval between sync requests in seconds | |
| #define | N_CLOCK_SYNC_SAMPLE_COUNT 11 |
| number of samples for the median filter | |
Functions | |
| 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 | |
| N_CLOCK_SYNC * | n_clock_sync_new (void) |
| allocate and initialize a new clock sync estimator | |
| 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 server's timestamp from the response, local_now is the current local time when the response was received. | |
| double | n_clock_sync_server_time (const N_CLOCK_SYNC *cs, double local_now) |
| get estimated server time given a local time value | |
| 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) | |
Clock synchronization estimator for networked games.
Estimates the time offset between a local clock and a remote clock using periodic sync request/response pairs. The offset is computed as the median of recent samples to reject outliers caused by network jitter.
Usage:
Definition in file n_clock_sync.h.