reactor-c 1.0
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
socket_stat_t Struct Reference

Statistics and state for clock synchronization over a socket connection. More...

#include <clock-sync.h>

Data Fields

interval_t clock_synchronization_error_bound
 Bound on clock synchronization error.
interval_t history
 Running history of clock synchronization data.
interval_t local_delay
 Estimated local processing delay (T3 - T2).
instant_t local_physical_clock_snapshot_T2
 Local (federate) physical time when receiving T1 (T2).
interval_t network_stat_round_trip_delay_max
 Maximum observed round-trip network delay.
int network_stat_sample_index
 Current index in the network statistics samples array.
interval_t network_stat_samples [10]
 Array of network delay samples.
int received_T4_messages_in_current_sync_window
 Counter for T4 messages received in current sync window.
instant_t remote_physical_clock_snapshot_T1
 Remote (RTI) physical time when sending sync message (T1).

Detailed Description

Statistics and state for clock synchronization over a socket connection.

This struct maintains the state and statistics needed for clock synchronization between a federate and the RTI using a variant of the Precision Time Protocol (PTP). The synchronization process involves four timestamps (T1-T4) to estimate network delays and clock offsets:

  1. T1: RTI's physical time when sending sync message
  2. T2: Federate's physical time when receiving T1
  3. T3: Federate's physical time when sending reply
  4. T4: RTI's physical time when receiving reply

The round trip delay is estimated as: (T4 - T1) - (T3 - T2) The clock offset can be estimated as: ((T2 - T1) + (T3 - T4)) / 2

Field Documentation

◆ clock_synchronization_error_bound

interval_t socket_stat_t::clock_synchronization_error_bound

Bound on clock synchronization error.

Represents the maximum expected difference between this federate's clock and the remote clock. This bound is used to ensure the reliability of clock synchronization and to detect potential synchronization failures.

◆ history

interval_t socket_stat_t::history

Running history of clock synchronization data.

Maintains a history of clock synchronization measurements. For the AVG strategy, this stores a partially computed average of the clock offset measurements.

◆ local_delay

interval_t socket_stat_t::local_delay

Estimated local processing delay (T3 - T2).

Measures the time taken by the federate to process the sync message and prepare a reply. This is subtracted from the total round-trip time to get a more accurate network delay estimate.

◆ local_physical_clock_snapshot_T2

instant_t socket_stat_t::local_physical_clock_snapshot_T2

Local (federate) physical time when receiving T1 (T2).

Recorded by the federate when it receives the RTI's sync message. Used in conjunction with T1 to estimate the one-way network delay and clock offset.

◆ network_stat_round_trip_delay_max

interval_t socket_stat_t::network_stat_round_trip_delay_max

Maximum observed round-trip network delay.

Tracks the highest estimated delay between the local socket and the remote socket. Used to establish bounds on clock synchronization accuracy and to detect network anomalies.

◆ network_stat_sample_index

int socket_stat_t::network_stat_sample_index

Current index in the network statistics samples array.

Points to the next position in network_stat_samples where a new measurement should be stored. Used to maintain a circular buffer of recent network delay measurements.

◆ network_stat_samples

interval_t socket_stat_t::network_stat_samples[10]

Array of network delay samples.

Stores the most recent _LF_CLOCK_SYNC_EXCHANGES_PER_INTERVAL network delay measurements. These samples are used to calculate statistics about network performance and to detect anomalies in clock synchronization.

Note
This array must be the last field in the struct due to C++ restrictions on designated initializers.

◆ received_T4_messages_in_current_sync_window

int socket_stat_t::received_T4_messages_in_current_sync_window

Counter for T4 messages received in current sync window.

Tracks the number of T4 messages received in the current synchronization interval. Must be reset to 0 when it reaches _LF_CLOCK_SYNC_EXCHANGES_PER_INTERVAL. Used to determine when enough samples have been collected to update the clock offset.

◆ remote_physical_clock_snapshot_T1

instant_t socket_stat_t::remote_physical_clock_snapshot_T1

Remote (RTI) physical time when sending sync message (T1).

This is the first timestamp in the PTP exchange, recorded by the RTI when it initiates a clock synchronization round. Used to calculate network delays and clock offsets.


The documentation for this struct was generated from the following file:
  • /Users/runner/work/reactor-c/reactor-c/include/core/federated/clock-sync.h