32#define LF_CLOCK_SYNC LF_CLOCK_SYNC_INIT
39#define LF_CLOCK_SYNC_OFF 1
45#define LF_CLOCK_SYNC_INIT 2
51#define LF_CLOCK_SYNC_ON 3
60#ifndef _LF_CLOCK_SYNC_EXCHANGES_PER_INTERVAL
61#define _LF_CLOCK_SYNC_EXCHANGES_PER_INTERVAL 10
68#ifndef _LF_CLOCK_SYNC_ATTENUATION
69#define _LF_CLOCK_SYNC_ATTENUATION 10
76#ifndef _LF_CLOCK_SYNC_COLLECT_STATS
77#define _LF_CLOCK_SYNC_COLLECT_STATS true
89#define CLOCK_SYNC_GUARD_BAND USEC(100)
int64_t instant_t
Time instant.
Definition tag.h:101
int64_t interval_t
Interval of time.
Definition tag.h:107
void handle_T4_clock_sync_message(unsigned char *buffer, int socket, instant_t r4)
Handle a clock synchronization message T4 coming from the RTI.
void synchronize_initial_physical_clock_with_rti(int *rti_socket_TCP)
Synchronize the initial physical clock with the RTI.
void clock_sync_set_constant_bias(interval_t offset)
Set a fixed offset to the physical clock.
void clock_sync_add_offset(instant_t *t)
Add the current clock synchronization offset to a specified timestamp.
uint16_t setup_clock_synchronization_with_rti(void)
Setup necessary functionalities to synchronize clock with the RTI.
#define _LF_CLOCK_SYNC_EXCHANGES_PER_INTERVAL
Number of required clock sync T4 messages per synchronization interval.
Definition clock-sync.h:61
int create_clock_sync_thread(lf_thread_t *thread_id)
Create the thread responsible for handling clock synchronization with the RTI if (runtime) clock sync...
int handle_T1_clock_sync_message(unsigned char *buffer, int socket, instant_t t2)
Handle a clock synchroninzation message T1 coming from the RTI.
void reset_socket_stat(struct socket_stat_t *socket_stat)
Reset statistics on the socket.
void clock_sync_subtract_offset(instant_t *t)
Subtract the clock synchronization offset from a timestamp.
Holds generic statistical data.
Definition clock-sync.h:201
int64_t standard_deviation
Definition clock-sync.h:203
int64_t variance
Definition clock-sync.h:204
int64_t max
Definition clock-sync.h:205
int64_t average
Definition clock-sync.h:202
Statistics and state for clock synchronization over a socket connection.
Definition clock-sync.h:108
interval_t network_stat_round_trip_delay_max
Maximum observed round-trip network delay.
Definition clock-sync.h:162
instant_t remote_physical_clock_snapshot_T1
Remote (RTI) physical time when sending sync message (T1).
Definition clock-sync.h:116
int network_stat_sample_index
Current index in the network statistics samples array.
Definition clock-sync.h:171
interval_t local_delay
Estimated local processing delay (T3 - T2).
Definition clock-sync.h:134
interval_t network_stat_samples[10]
Array of network delay samples.
Definition clock-sync.h:194
interval_t clock_synchronization_error_bound
Bound on clock synchronization error.
Definition clock-sync.h:181
interval_t history
Running history of clock synchronization data.
Definition clock-sync.h:153
int received_T4_messages_in_current_sync_window
Counter for T4 messages received in current sync window.
Definition clock-sync.h:144
instant_t local_physical_clock_snapshot_T2
Local (federate) physical time when receiving T1 (T2).
Definition clock-sync.h:125