13#if defined STANDALONE_RTI
18#include <sys/socket.h>
20#include <netinet/in.h>
28#include <openssl/rand.h>
29#include <openssl/hmac.h>
40#define MAX_TIME_FOR_REPLY_TO_STOP_REQUEST SEC(30)
423void usage(
int argc,
const char* argv[]);
socket_type_t
Type of socket.
Definition socket_common.h:115
pqueue_t pqueue_tag_t
Type of a priority queue sorted by tags.
Definition pqueue_tag.h:89
void wait_for_federates(int socket_descriptor)
Start the runtime infrastructure (RTI) interaction with the federates and wait for the federates to e...
void handle_address_query(uint16_t fed_id)
Handle address query messages.
void handle_timestamp(federate_info_t *my_fed)
A function to handle timestamp 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 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 lf_connect_to_federates(int socket_descriptor)
Wait for one incoming connection request from each federate, and, upon receiving it,...
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.
int32_t start_rti_server(uint16_t port)
Start the socket server for the runtime infrastructure (RTI) and return the socket descriptor.
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:85
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 send_reject(int *socket_id, unsigned char error_code)
Send a MSG_TYPE_REJECT message to the specified socket and close the socket.
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.
void * federate_info_thread_TCP(void *fed)
Thread handling TCP communication with a federate.
@ clock_sync_on
Definition rti_remote.h:85
@ clock_sync_init
Definition rti_remote.h:85
@ clock_sync_off
Definition rti_remote.h:85
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
int lf_critical_section_enter(environment_t *env)
int lf_critical_section_exit(environment_t *env)
Common socket operations and utilities for federated Lingua Franca programs.
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:55
struct sockaddr_in UDP_addr
The UDP address for the federate.
Definition rti_remote.h:66
int socket
The TCP socket descriptor for communicating with this federate.
Definition rti_remote.h:64
bool clock_synchronization_enabled
Indicates the status of clock synchronization for this federate.
Definition rti_remote.h:68
pqueue_tag_t * in_transit_message_tags
Record of in-transit messages to this federate that are not yet processed.
Definition rti_remote.h:71
struct in_addr server_ip_addr
Information about the IP address of the socket server of the federate.
Definition rti_remote.h:78
char server_hostname[INET_ADDRSTRLEN]
Human-readable IP address of the federate's socket server.
Definition rti_remote.h:73
scheduling_node_t enclave
The base scheduling node information for this federate.
Definition rti_remote.h:57
int32_t server_port
Port number of the socket server of the federate.
Definition rti_remote.h:76
lf_thread_t thread_id
The ID of the thread handling communication with this federate.
Definition rti_remote.h:62
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:60
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:100
int socket_descriptor_TCP
The TCP socket descriptor for the socket server.
Definition rti_remote.h:136
int num_feds_proposed_start
Number of federates that have proposed start times.
Definition rti_remote.h:108
uint16_t user_specified_port
The desired port specified by the user on the command line.
Definition rti_remote.h:130
uint16_t final_port_UDP
The final port number that the UDP socket server ends up using.
Definition rti_remote.h:139
rti_common_t base
The base RTI common data structure.
Definition rti_remote.h:102
clock_sync_stat clock_sync_global_status
Indicates whether clock sync is globally on for the federation.
Definition rti_remote.h:152
bool stop_in_progress
Boolean indicating that a stop request is already in progress.
Definition rti_remote.h:164
uint64_t clock_sync_period_ns
Frequency (period in nanoseconds) between clock sync attempts.
Definition rti_remote.h:155
volatile bool all_federates_exited
Boolean indicating that all federates have exited.
Definition rti_remote.h:119
bool authentication_enabled
Boolean indicating that authentication is enabled.
Definition rti_remote.h:161
const char * federation_id
The ID of the federation that this RTI will supervise.
Definition rti_remote.h:127
int32_t clock_sync_exchanges_per_interval
Number of messages exchanged for each clock sync attempt.
Definition rti_remote.h:158
int socket_descriptor_UDP
The UDP socket descriptor for the socket server.
Definition rti_remote.h:142
lf_thread_t clock_thread
Thread performing PTP clock sync sessions periodically.
Definition rti_remote.h:145
uint16_t final_port_TCP
The final port number that the TCP socket server ends up using.
Definition rti_remote.h:133
int64_t max_start_time
Maximum start time seen so far from the federates.
Definition rti_remote.h:105
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