![]() |
reactor-c 1.0
C Runtime for Lingua Franca
|
Utility functions for clock synchronization in federated Lingua Franca programs. More...
#include "low_level_platform.h"Go to the source code of this file.
Data Structures | |
| struct | lf_stat_ll |
| Holds generic statistical data. More... | |
| struct | socket_stat_t |
| Statistics and state for clock synchronization over a socket connection. More... | |
Macros | |
| #define | _LF_CLOCK_SYNC_ATTENUATION 10 |
| Runtime clock offset updates will be divided by this number. | |
| #define | _LF_CLOCK_SYNC_COLLECT_STATS true |
| By default, collect statistics on clock synchronization. | |
| #define | _LF_CLOCK_SYNC_EXCHANGES_PER_INTERVAL 10 |
| Number of required clock sync T4 messages per synchronization interval. | |
| #define | CLOCK_SYNC_GUARD_BAND USEC(100) |
| Define a guard band to filter clock synchronization messages based on discrepancies in the network delay. | |
| #define | LF_CLOCK_SYNC LF_CLOCK_SYNC_INIT |
| Clock synchronization mode. | |
| #define | LF_CLOCK_SYNC_INIT 2 |
| Indicator for clock synchronization to be turned on at initialization. | |
| #define | LF_CLOCK_SYNC_OFF 1 |
| Indicator for clock synchronization to be turned off altogether. | |
| #define | LF_CLOCK_SYNC_ON 3 |
| Indicator for clock synchronization to be turned on at initialization and runtime. | |
Typedefs | |
| typedef struct lf_stat_ll | lf_stat_ll |
| Holds generic statistical data. | |
| typedef struct socket_stat_t | socket_stat_t |
| Statistics and state for clock synchronization over a socket connection. | |
Functions | |
| void | clock_sync_add_offset (instant_t *t) |
| Add the current clock synchronization offset to a specified timestamp. | |
| void | clock_sync_set_constant_bias (interval_t offset) |
| Set a fixed offset to the physical clock. | |
| void | clock_sync_subtract_offset (instant_t *t) |
| Subtract the clock synchronization offset from a timestamp. | |
| int | create_clock_sync_thread (lf_thread_t *thread_id) |
| Create the thread responsible for handling clock synchronization with the RTI if (runtime) clock synchronization is on. | |
| 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 | handle_T4_clock_sync_message (unsigned char *buffer, int socket, instant_t r4) |
| Handle a clock synchronization message T4 coming from the RTI. | |
| void | reset_socket_stat (struct socket_stat_t *socket_stat) |
| Reset statistics on the socket. | |
| uint16_t | setup_clock_synchronization_with_rti (void) |
| Setup necessary functionalities to synchronize clock with the RTI. | |
| void | synchronize_initial_physical_clock_with_rti (int *rti_socket_TCP) |
| Synchronize the initial physical clock with the RTI. | |
Utility functions for clock synchronization in federated Lingua Franca programs.
This file provides utility functions and data structures for synchronizing physical clocks between federates and the RTI in federated Lingua Franca programs. It implements a variant of the Precision Time Protocol (PTP) for clock synchronization, with support for both initial synchronization and runtime synchronization. The file includes functions for handling clock synchronization messages, managing synchronization statistics, and adjusting clock offsets.