5 ex_clock_sync_8c example
gullradriel edited this page 2026-10-09 00:51:57 +02:00

ex_clock_sync.c

Clock synchronization demo using UDP networking Demonstrates the N_CLOCK_SYNC module by running a server (time authority) and a client that estimates the clock offset between them.

The client periodically sends sync requests containing its local timestamp. The server echoes back the client timestamp along with its own timestamp. The client feeds these into N_CLOCK_SYNC to compute the median offset and RTT.

Usage: Server: ./ex_clock_sync -p 12345 Client: ./ex_clock_sync -s 127.0.0.1 -p 12345

Use -o OFFSET on the server to simulate a clock offset (seconds).