13#if defined STANDALONE_RTI
21#include <openssl/rand.h>
22#include <openssl/hmac.h>
27#include "net_abstraction.h"
33#define MAX_TIME_FOR_REPLY_TO_STOP_REQUEST SEC(30)
57 net_abstraction_t
net;
434void send_reject(net_abstraction_t net_abs, rejection_code_t error_code);
494void usage(
int argc,
const char* argv[]);
pqueue_t pqueue_tag_t
Type of a priority queue sorted by tags.
Definition pqueue_tag.h:89
void handle_address_query(uint16_t fed_id)
Handle address query messages.
void initialize_RTI(rti_remote_t *rti)
Initialize the _RTI instance.
void handle_latest_tag_confirmed(federate_info_t *fed)
Handle a latest tag confirmed (LTC) message.
void * clock_synchronization_thread(void *noargs)
A (quasi-)periodic thread that performs clock synchronization with each federate.
void reset_transient_federate(federate_info_t *fed)
Reset the federate.
void handle_port_absent_message(federate_info_t *sending_federate, unsigned char *buffer)
Handle a port absent message being received rom a federate via the RIT.
void handle_address_ad(uint16_t federate_id)
Handle address advertisement messages (.
void handle_stop_request_message(federate_info_t *fed)
Handle a MSG_TYPE_STOP_REQUEST message.
void wait_for_federates()
Start the runtime infrastructure (RTI) interaction with the federates and wait for the federates to e...
void send_physical_clock(unsigned char message_type, federate_info_t *fed, socket_type_t socket_type)
Take a snapshot of the physical clock time and send it to federate fed_id.
void update_federate_next_event_tag_locked(uint16_t federate_id, tag_t next_event_tag)
Update the next event tag of federate federate_id.
int process_args(int argc, const char *argv[])
Process the command-line arguments.
clock_sync_stat
The status of clock synchronization.
Definition rti_remote.h:94
void handle_timed_message(federate_info_t *sending_federate, unsigned char *buffer)
Handle a timed message being received from a federate by the RTI to relay to another federate.
void initialize_federate(federate_info_t *fed, uint16_t id)
Initialize the federate with the specified ID.
void free_federate_info(federate_info_t *fed)
Free a federate_info_t and all heap memory it owns.
void handle_stop_request_reply(federate_info_t *fed)
Handle a MSG_TYPE_STOP_REQUEST_REPLY message.
void * respond_to_erroneous_connections(void *nothing)
Thread to respond to new connections, which could be federates of other federations who are attemptin...
void handle_next_event_tag(federate_info_t *fed)
Handle a next event tag (NET) message.
void handle_physical_clock_sync_message(federate_info_t *my_fed, socket_type_t socket_type)
Handle clock synchronization T3 messages from federates.
int process_clock_sync_args(int argc, const char *argv[])
Process command-line arguments related to clock synchronization.
int start_rti_server()
Start the server for the runtime infrastructure (RTI).
void * federate_info_thread_TCP(void *fed)
Thread handling TCP communication with a federate.
void send_reject(net_abstraction_t net_abs, rejection_code_t error_code)
Send a MSG_TYPE_REJECT message to the specified channel and close the channel.
@ clock_sync_on
Definition rti_remote.h:94
@ clock_sync_init
Definition rti_remote.h:94
@ clock_sync_off
Definition rti_remote.h:94
void usage()
Print a usage message.
Type definitions that are widely used across different parts of the runtime.
Priority queue that uses tags for sorting.
Common declarations for runtime infrastructure (RTI) for scheduling enclaves and distributed Lingua F...
bool _lf_federate_reports_error
pqueue_tag_t pqueue_delayed_grants_t
Type of a delayed grants queue sorted by tags.
Definition rti_remote.h:117
federation_life_cycle_phase
The federation life cycle phases.
Definition rti_remote.h:99
@ startup_phase
Definition rti_remote.h:100
@ execution_phase
Definition rti_remote.h:101
@ shutdown_phase
Definition rti_remote.h:102
int lf_critical_section_enter(environment_t *env)
int lf_critical_section_exit(environment_t *env)
Execution environment.
Definition environment.h:52
Information about a federate known to the RTI, including its runtime state, mode of execution,...
Definition rti_remote.h:48
bool is_transient
Indicates whether the federate is transient or persistent.
Definition rti_remote.h:68
bool has_upstream_transient_federates
Indicates whether the federate has upstream transient federates.
Definition rti_remote.h:66
struct sockaddr_in UDP_addr
The UDP address for the federate.
Definition rti_remote.h:59
tag_t max_intended_tag
The highest delay-adjusted intended tag of any message the RTI has received addressed to this federat...
Definition rti_remote.h:78
bool clock_synchronization_enabled
Indicates the status of clock synchronization for this federate.
Definition rti_remote.h:61
net_abstraction_t net
The network abstraction for communicating with this federate.
Definition rti_remote.h:57
int32_t * downstream_transients
IDs of transient federates this federate has outbound connections to.
Definition rti_remote.h:87
pqueue_tag_t * in_transit_message_tags
Record of in-transit messages to this federate that are not yet processed.
Definition rti_remote.h:64
bool neighbor_structure_received
True after the first MSG_TYPE_NEIGHBOR_STRUCTURE has been accepted for this federate ID.
Definition rti_remote.h:81
scheduling_node_t enclave
The base scheduling node information for this federate.
Definition rti_remote.h:50
int32_t number_of_downstream_transients
Number of outbound connections to transient federates.
Definition rti_remote.h:83
lf_thread_t thread_id
The ID of the thread handling communication with this federate.
Definition rti_remote.h:55
bool requested_stop
Indicates that the federate has requested stop or has replied to a request for stop from the RTI.
Definition rti_remote.h:53
tag_t effective_start_tag
Records the start time of the federate, which is mainly useful for transient federates.
Definition rti_remote.h:70
The type for an element in a delayed grants priority queue that is sorted by tag.
Definition rti_remote.h:108
bool is_provisional
Definition rti_remote.h:111
pqueue_tag_element_t base
Definition rti_remote.h:109
uint16_t fed_id
Definition rti_remote.h:110
The type for an element in a priority queue that is sorted by tag.
Definition pqueue_tag.h:53
Common RTI data structure for both remote standalone RTI and local RTI used in enclaved execution.
Definition rti_common.h:103
Structure that an RTI instance uses to keep track of its own and its corresponding federates' state.
Definition rti_remote.h:132
int num_feds_proposed_start
Number of federates that have proposed start times.
Definition rti_remote.h:150
uint16_t user_specified_port
The desired port specified by the user on the command line.
Definition rti_remote.h:184
uint16_t final_port_UDP
The final port number that the UDP socket server ends up using.
Definition rti_remote.h:187
rti_common_t base
The base RTI common data structure.
Definition rti_remote.h:134
clock_sync_stat clock_sync_global_status
Indicates whether clock sync is globally on for the federation.
Definition rti_remote.h:205
bool stop_in_progress
Boolean indicating that a stop request is already in progress.
Definition rti_remote.h:217
uint64_t clock_sync_period_ns
Frequency (period in nanoseconds) between clock sync attempts.
Definition rti_remote.h:208
volatile bool all_federates_exited
Boolean indicating that all federates have exited.
Definition rti_remote.h:161
bool authentication_enabled
Boolean indicating that authentication is enabled.
Definition rti_remote.h:214
int32_t number_of_connected_transient_federates
Number of connected transient federates.
Definition rti_remote.h:227
volatile bool all_persistent_federates_exited
Boolean indicating that all persistent federates have exited.
Definition rti_remote.h:171
const char * federation_id
The ID of the federation that this RTI will supervise.
Definition rti_remote.h:179
int32_t clock_sync_exchanges_per_interval
Number of messages exchanged for each clock sync attempt.
Definition rti_remote.h:211
net_abstraction_t rti_net
The rti's network abstraction.
Definition rti_remote.h:195
int socket_descriptor_UDP
The UDP socket descriptor for the socket server.
Definition rti_remote.h:190
federation_life_cycle_phase phase
Indicates the life cycle phase of the federation.
Definition rti_remote.h:232
int64_t start_time_multiple
If nonzero, the federation start time is delayed so that the starting logical time is an integer mult...
Definition rti_remote.h:147
int32_t number_of_transient_federates
Number of transient federates.
Definition rti_remote.h:222
pqueue_delayed_grants_t * delayed_grants
Queue of the pending grants, in case transient federates are absent and issuing grants to their downs...
Definition rti_remote.h:238
lf_thread_t clock_thread
Thread performing PTP clock sync sessions periodically.
Definition rti_remote.h:198
int64_t max_start_time
Maximum start time seen so far from the federates.
Definition rti_remote.h:137
Information about the scheduling nodes coordinated by the RTI.
Definition rti_common.h:64
A tag is a time, microstep pair.
Definition tag.h:119