Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support of transient federates #358

Open
wants to merge 152 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
8df8cd7
Start on adding federate type (transient or not)
ChadliaJerad Feb 1, 2024
e20f58a
Add cmdline argument -nt to RTI and add nbr_transient_federates attri…
ChadliaJerad Feb 1, 2024
c61b22b
Differentiate between connecting to persistent federates and transien…
ChadliaJerad Feb 1, 2024
bc2b978
Differentiate between connecting to persistent federates and transien…
ChadliaJerad Feb 1, 2024
5fd6c95
Add support of the effective_start_tag
ChadliaJerad Feb 1, 2024
9fc49b9
Add support of the effective_start_tag cont.
ChadliaJerad Feb 1, 2024
7b4f8da
Federate shares its type (persistent or transient)
ChadliaJerad Feb 1, 2024
d70704e
Add federation life cycle phase
ChadliaJerad Feb 5, 2024
556b853
Make the federate read the effective start tag
ChadliaJerad Feb 14, 2024
93ca705
Drop the messages intended for a transient federate that is connected…
ChadliaJerad Feb 15, 2024
2de69d6
Granting TAG or PTAGs can be delayed if one of the upstream federates…
ChadliaJerad Feb 15, 2024
fc6e601
When all upstream federates are not connected (transients), then the …
ChadliaJerad Feb 15, 2024
9dff3d0
Only persistent federates are accounted for requesting stop
ChadliaJerad Feb 15, 2024
c1068df
Compute and send the effective start tag of a joining transient
ChadliaJerad Feb 15, 2024
71834e6
Start on enabling the hot swap mechanism
ChadliaJerad Feb 15, 2024
ba38bc1
More on the hot swap mechanism + various fixes
ChadliaJerad Feb 15, 2024
c0645cc
RTI can sent a request for immediate stop. This is required by the ho…
ChadliaJerad Feb 15, 2024
f244f85
Federate processes a stop request by the RTI
ChadliaJerad Feb 16, 2024
eb712c0
Stop the execution of a federate
ChadliaJerad Feb 16, 2024
96cb09e
Add lf_get_federates_bin_directory.
petervdonovan Aug 4, 2023
aaed909
A federate can get its id, its effective_start_time, and the start_ti…
ChadliaJerad Feb 16, 2024
d8f39f4
Add MST_TYPE_TIMESTAMP_START and its length
ChadliaJerad Feb 17, 2024
a4afdc4
Fix the use of lf_stop()
ChadliaJerad Feb 19, 2024
1a34221
Fix send_start_tag() to account for the effective start tag
ChadliaJerad Feb 19, 2024
6281234
Fix for transient connection
ChadliaJerad Feb 20, 2024
533fcec
Fix the initialization of the effective start tag
ChadliaJerad Feb 20, 2024
485bb94
Adjust doc
ChadliaJerad Feb 20, 2024
fa99eee
Adjust 2 debug messages in RTI
ChadliaJerad Feb 20, 2024
1e71976
Attemp to fix the hot swap mechanism
ChadliaJerad Feb 20, 2024
ef9d528
Remove overlooked instruction
ChadliaJerad Feb 20, 2024
07b2831
Augment fedsd to acount for transient federates
ChadliaJerad Feb 20, 2024
39b0291
Minor fixes
ChadliaJerad Feb 20, 2024
e020745
Fix lingua-france-ref.txt
ChadliaJerad Feb 20, 2024
0ac8787
Fix void* returns
ChadliaJerad Feb 20, 2024
c05b2ac
Fix based on code review
ChadliaJerad Feb 23, 2024
99207ec
Make immediate and delayed (p)tag notification functions
ChadliaJerad Feb 23, 2024
9d7e5b9
Control the type and value of the number of transients
ChadliaJerad Feb 23, 2024
f49287b
The number of transients should not be greater or equal to the number…
ChadliaJerad Feb 29, 2024
58a4a0d
Remove wrongly duplicated code
ChadliaJerad Feb 29, 2024
9f5090a
Code review: remove redundancy and add has_transient_upstream_federats
ChadliaJerad Feb 29, 2024
ece11b0
Fix the call to tracepoint() to account for the refactoring of the tr…
ChadliaJerad Feb 29, 2024
c04bfc1
Fix a call to tracepoint
ChadliaJerad Feb 29, 2024
e7f806a
Change _lf_fed_STA_offset to lf_fed_STA_offset and _lf_set_stop_tag t…
ChadliaJerad Feb 29, 2024
a9e7012
Fix the call to tracepoint in federate.c
ChadliaJerad Feb 29, 2024
ca0ac6e
Add comments and more formatting
ChadliaJerad Mar 14, 2024
8080a52
Fix bugs due to rebase + Tracepoint lf_stop()
ChadliaJerad Mar 14, 2024
df2eaae
Code review: document that MSG_TYPE_FED_IDS include the type of the f…
ChadliaJerad Mar 14, 2024
a705c11
Add return NULL in void* functions
ChadliaJerad Mar 14, 2024
279d1bb
Use a tag queue to manage delayed grants
ChadliaJerad Mar 3, 2024
c2d6779
Fix missing code from the previous commit
ChadliaJerad Mar 15, 2024
2eb27a7
Fix the type of max_number_of_delayed_grants
ChadliaJerad Mar 3, 2024
1795f80
Fix return void *
ChadliaJerad Mar 4, 2024
1682395
Fix the use of condition variabale updated_delayed_grants
ChadliaJerad Mar 4, 2024
5ad13a3
Add documentation to lf_delayed_grants_thread() and adjust the exit c…
ChadliaJerad Mar 4, 2024
508c484
Fix the segmentation fault hapening when a second hot swap mechanism …
ChadliaJerad Mar 11, 2024
aff416d
Improve memory management when dealing with transients
ChadliaJerad Mar 11, 2024
1ac4bbe
Make sure the transient federate interface did not change when a new …
ChadliaJerad Mar 11, 2024
42e00c8
Fix the segmentation fault error of the RTI
ChadliaJerad Mar 18, 2024
402c4af
Fix the exit of th thread that connects to transients
ChadliaJerad Mar 18, 2024
c1249e5
Logging of the delayed grants queue activity
ChadliaJerad Mar 18, 2024
8bc1f43
Consistent naming: use lf_tag_effective_start() instead of lf_get_eff…
ChadliaJerad Mar 18, 2024
34e820e
Fix log message
ChadliaJerad Mar 18, 2024
548adf0
Attempt to solve another segmentation fault
ChadliaJerad Mar 18, 2024
7d75f20
Fix implicit declaration error by moving lf_stop(), lf_get_federates_…
ChadliaJerad Mar 18, 2024
9487891
Fix merge
ChadliaJerad Apr 12, 2024
dbf6bf7
Fix warnings (turned as errors)
ChadliaJerad Apr 15, 2024
0175324
Fix variable name
ChadliaJerad Apr 15, 2024
69d8ef7
Fix the documentation of MSG_TYPE_FED_IDS to describe the federate ty…
ChadliaJerad Apr 24, 2024
16cf120
Augment the documentation of receive_connection_information() to desc…
ChadliaJerad Apr 24, 2024
8d2d6a5
Invalidate upstream delays when a transient leaves the federation
ChadliaJerad Apr 24, 2024
0ba3d61
Fix the invalidation
ChadliaJerad Apr 25, 2024
033e99b
Upadte the computatio of the effective start tag to account for upstr…
ChadliaJerad May 8, 2024
4cbe5b8
Get the max of the TAG of the upstreams only if the queue is not empty
ChadliaJerad Jun 19, 2024
1a7fba6
Fix return value of lf_get_federates_bin_directory()
ChadliaJerad Jun 19, 2024
7d85d0f
Another attempt to fix return value of lf_get_federates_bin_directory()
ChadliaJerad Jun 19, 2024
c6e43ee
Another attempt to fix return value of lf_get_federates_bin_directory()
ChadliaJerad Jun 20, 2024
5949b75
Start on adding federate type (transient or not)
ChadliaJerad Feb 1, 2024
9d92dec
Add cmdline argument -nt to RTI and add nbr_transient_federates attri…
ChadliaJerad Feb 1, 2024
29ca14b
Differentiate between connecting to persistent federates and transien…
ChadliaJerad Feb 1, 2024
fad4dcc
Add support of the effective_start_tag cont.
ChadliaJerad Feb 1, 2024
d28bd54
Federate shares its type (persistent or transient)
ChadliaJerad Feb 1, 2024
f19ac22
Granting TAG or PTAGs can be delayed if one of the upstream federates…
ChadliaJerad Feb 15, 2024
97b3812
Start on enabling the hot swap mechanism
ChadliaJerad Feb 15, 2024
275a0c6
More on the hot swap mechanism + various fixes
ChadliaJerad Feb 15, 2024
148d84d
RTI can sent a request for immediate stop. This is required by the ho…
ChadliaJerad Feb 15, 2024
03705b3
A federate can get its id, its effective_start_time, and the start_ti…
ChadliaJerad Feb 16, 2024
1dafa30
Fix the use of lf_stop()
ChadliaJerad Feb 19, 2024
070302b
Attemp to fix the hot swap mechanism
ChadliaJerad Feb 20, 2024
9429cf7
Code review: remove redundancy and add has_transient_upstream_federats
ChadliaJerad Feb 29, 2024
7a9c8c1
Add comments and more formatting
ChadliaJerad Mar 14, 2024
c51bbe0
Fix bugs due to rebase + Tracepoint lf_stop()
ChadliaJerad Mar 14, 2024
9461e8f
Use a tag queue to manage delayed grants
ChadliaJerad Mar 3, 2024
04c614a
Fix missing code from the previous commit
ChadliaJerad Mar 15, 2024
cd6807f
Fix implicit declaration error by moving lf_stop(), lf_get_federates_…
ChadliaJerad Mar 18, 2024
f512a97
Fix merge
ChadliaJerad Apr 12, 2024
f042571
Support zero-delay cycles
edwardalee Jul 15, 2024
cf003cb
Fix the type of _lf_zero_delay_cycle_action_table_size iterator to be…
ChadliaJerad Jul 15, 2024
1fde08f
Removed unnecessary parens
edwardalee Jul 15, 2024
6aeb52a
Run clang formatter
ChadliaJerad Jul 17, 2024
4ed301b
Fixed thread interactions
edwardalee Jul 17, 2024
5d2d472
Format
edwardalee Jul 17, 2024
3554de7
Fix mutex access in lf_delayed_grants()
ChadliaJerad Jul 18, 2024
00f8a30
Made functions static and use free function for queue
edwardalee Jul 18, 2024
db1c7a2
Added max function
edwardalee Jul 19, 2024
76b9e2e
Revert to holding mutex plus general cleanups
edwardalee Jul 19, 2024
5a3cf7c
Hold mutex and notify downstream not upstream
edwardalee Jul 19, 2024
2117bd8
Fix the pqueue tag iterator type
ChadliaJerad Jul 24, 2024
b7544b3
Fix condition 2 for computing the effective start time of a transient…
ChadliaJerad Jul 24, 2024
38c571a
Update lingua-franca-ref.txt
ChadliaJerad Jul 24, 2024
755f8fa
Revert to 0 microstep
edwardalee Jul 27, 2024
7d97331
Fix lf_get_federates_bin_directory() + Fix its scope, as well as lf_g…
ChadliaJerad Aug 7, 2024
f4e9623
Remove no more needed LF_FEDERATED_BIN_DIRECTORY
ChadliaJerad Aug 7, 2024
d6d1d0e
Run Clang formatter
ChadliaJerad Aug 7, 2024
09e1f87
Remove overlooked code when merging
ChadliaJerad Aug 14, 2024
23b714c
Handle corner cases where connection messages about transients are re…
ChadliaJerad Aug 21, 2024
d14f811
Reset timing info from previous runs
ChadliaJerad Aug 21, 2024
35e7bc7
Skip checking the satet in the first call of _update_min_delays_upsteam
ChadliaJerad Aug 21, 2024
0dbe9f6
Invalidate min delays of all federates once a tansient joins
ChadliaJerad Aug 28, 2024
00de25c
Do not skip the node itself in _updat_min_delays
ChadliaJerad Aug 28, 2024
58eecb1
Removed duplicated function
ChadliaJerad Dec 2, 2024
4d6587b
Formatting
ChadliaJerad Dec 2, 2024
6e9b2a6
Attempt to pass tests by manually adding prototypes to lf code
ChadliaJerad Dec 2, 2024
96efa72
Removed lf_get_federates_bin_directory. Use LF_FED_PACKAGE_DIRECTORY
edwardalee Dec 2, 2024
98032c1
Do not account for absent trnsients when calculating efimt
ChadliaJerad Dec 4, 2024
666bc1f
Restored declaration of lf_get_federation_id
edwardalee Dec 8, 2024
832c831
Attempt to make sure a persistent knows that a transient joined
ChadliaJerad Dec 9, 2024
b85bcac
Fix send_start_tag() function name, comments, and actions ordering
ChadliaJerad Dec 10, 2024
de5a81b
Fix message ordering in send_start_tag_locked() + apply suggestions t…
ChadliaJerad Dec 11, 2024
09deeff
Allow federate to handle that an upstream has connected or disconnect…
ChadliaJerad Dec 11, 2024
c465bc7
Format?!
ChadliaJerad Dec 11, 2024
fd5fe06
Formatting using clang-format-19
ChadliaJerad Dec 11, 2024
c4c2b35
Fix dropping the message when a transient's effective start tag is no…
ChadliaJerad Dec 11, 2024
b942c88
Simplify the code of message dropping in the remote RTI.
ChadliaJerad Dec 13, 2024
c6712c6
Account for delay when dropping a message to be forwarded to a transi…
ChadliaJerad Dec 16, 2024
4c1e9c8
Cleanup after rebase
ChadliaJerad Jan 3, 2025
b11ce38
Fix segmentation fault and use accept_ocket() when connecting to trab…
ChadliaJerad Jan 3, 2025
bbba285
Fix lingua-franca-ref.txt
ChadliaJerad Jan 4, 2025
98ccd3b
Merge branch 'main' into transient-fed
ChadliaJerad Jan 4, 2025
95e67b6
Fix the waiting time to start in decentralized coordination
ChadliaJerad Jan 4, 2025
7727215
Small fix to pqueue_delayed_grants_find_by_fed_id()
ChadliaJerad Jan 4, 2025
fd60396
Cleanup
ChadliaJerad Jan 4, 2025
9be3596
Support backward compatibility when sending the IDS
ChadliaJerad Jan 4, 2025
8d9f15f
Fix types when reading from and writing to a socket
ChadliaJerad Jan 4, 2025
e106ea1
Support backward compatibility when sending the timestamp (and tag)
ChadliaJerad Jan 5, 2025
ea2c3ab
Fix tracing the start time in the RTI
ChadliaJerad Jan 13, 2025
cc6590b
Merge branch 'main' into transient-fed
ChadliaJerad Jan 23, 2025
7dbd42e
Do not overwrite lft files, but find a name that does not exist
ChadliaJerad Jan 24, 2025
cfcf681
Merge branch 'main' into transient-fed
ChadliaJerad Jan 24, 2025
a85af56
Run clang-format
ChadliaJerad Jan 24, 2025
c022317
Merge branch 'main' into transient-fed
ChadliaJerad Jan 28, 2025
57ba24d
Fix merge issues
ChadliaJerad Jan 31, 2025
7e2971b
Apply formatter
ChadliaJerad Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions core/federated/RTI/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ void usage(int argc, const char* argv[]) {
lf_print(" The ID of the federation that this RTI will control.\n");
lf_print(" -n, --number_of_federates <n>");
lf_print(" The number of federates in the federation that this RTI will control.\n");
lf_print(" -nt, --number_of_transient_federates <n>");
lf_print(" The number of transient federates in the federation that this RTI will control.\n");
lf_print(" -p, --port <n>");
lf_print(" The port number to use for the RTI. Must be larger than 0 and smaller than %d. Default is %d.\n",
UINT16_MAX, DEFAULT_PORT);
Expand Down Expand Up @@ -233,6 +235,21 @@ int process_args(int argc, const char* argv[]) {
}
rti.base.number_of_scheduling_nodes = (int32_t)num_federates; // FIXME: Loses numbers on 64-bit machines
lf_print("RTI: Number of federates: %d", rti.base.number_of_scheduling_nodes);
} else if (strcmp(argv[i], "-nt") == 0 || strcmp(argv[i], "--number_of_transient_federates") == 0) {
if (argc < i + 2) {
lf_print_error("--number_of_transient_federates needs a valid positive argument.");
usage(argc, argv);
return 0;
}
i++;
long num_transient_federates = strtol(argv[i], NULL, 10);
if (num_transient_federates == LONG_MAX || num_transient_federates == LONG_MIN) {
lf_print_error("--number_of_transient_federates needs a valid positive or null integer argument.");
usage(argc, argv);
return 0;
}
rti.number_of_transient_federates = (int32_t)num_transient_federates; // FIXME: Loses numbers on 64-bit machines
lf_print("RTI: Number of transient federates: %d", rti.number_of_transient_federates);
} else if (strcmp(argv[i], "-p") == 0 || strcmp(argv[i], "--port") == 0) {
if (argc < i + 2) {
lf_print_error("--port needs a short unsigned integer argument ( > 0 and < %d).", UINT16_MAX);
Expand Down Expand Up @@ -275,6 +292,16 @@ int process_args(int argc, const char* argv[]) {
return 0;
}
}
if (rti.base.number_of_scheduling_nodes == 0) {
lf_print_error("--number_of_federates needs a valid positive integer argument.");
usage(argc, argv);
return 0;
}
if (rti.number_of_transient_federates > rti.base.number_of_scheduling_nodes) {
lf_print_error("--number_of_transient_federates cannot be higher than the number of federates.");
usage(argc, argv);
return 0;
}
return 1;
}
int main(int argc, const char* argv[]) {
Expand Down Expand Up @@ -314,8 +341,8 @@ int main(int argc, const char* argv[]) {
lf_print("Tracing the RTI execution in %s file.", rti_trace_file_name);
}

lf_print("Starting RTI for %d federates in federation ID %s.", rti.base.number_of_scheduling_nodes,
rti.federation_id);
lf_print("Starting RTI for a total of %d federates, with %d being transient, in federation ID %s",
rti.base.number_of_scheduling_nodes, rti.number_of_transient_federates, rti.federation_id);
assert(rti.base.number_of_scheduling_nodes < UINT16_MAX);

// Allocate memory for the federates
Expand Down
18 changes: 16 additions & 2 deletions core/federated/RTI/rti_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void invalidate_min_delays() {
node->flags = 0; // All flags cleared because they get set lazily.
}
free(rti_common->min_delays);
rti_common->min_delays = NULL;
}
}

Expand Down Expand Up @@ -101,6 +102,8 @@ tag_t earliest_future_incoming_message_tag(scheduling_node_t* e) {
if (lf_tag_compare(rti_common->min_delays[i * n + e->id], FOREVER_TAG) != 0) {
// Node i is upstream of e with min delay rti_common->min_delays[i * n + e->id]
scheduling_node_t* upstream = rti_common->scheduling_nodes[i];
if (upstream->state == NOT_CONNECTED)
continue;
// If we haven't heard from the upstream node, then assume it can send an event at the start time.
if (lf_tag_compare(upstream->next_event, NEVER_TAG) == 0) {
tag_t start_tag = {.time = start_time, .microstep = 0};
Expand Down Expand Up @@ -163,6 +166,9 @@ tag_t eimt_strict(scheduling_node_t* e) {
tag_advance_grant_t tag_advance_grant_if_safe(scheduling_node_t* e) {
tag_advance_grant_t result = {.tag = NEVER_TAG, .is_provisional = false};

// Check how many upstream federates are connected
int num_connected_upstream = 0;

// Find the earliest LTC of upstream scheduling_nodes (M).
tag_t min_upstream_completed = FOREVER_TAG;

Expand All @@ -172,6 +178,7 @@ tag_advance_grant_t tag_advance_grant_if_safe(scheduling_node_t* e) {
// Ignore this enclave/federate if it is not connected.
if (upstream->state == NOT_CONNECTED)
continue;
num_connected_upstream++;

// Adjust by the "after" delay.
// Note that "no delay" is encoded as NEVER,
Expand All @@ -184,8 +191,15 @@ tag_advance_grant_t tag_advance_grant_if_safe(scheduling_node_t* e) {
}
LF_PRINT_LOG("RTI: Minimum upstream LTC for federate/enclave %d is " PRINTF_TAG "(adjusted by after delay).", e->id,
min_upstream_completed.time - start_time, min_upstream_completed.microstep);
if (lf_tag_compare(min_upstream_completed, e->last_granted) > 0 &&
lf_tag_compare(min_upstream_completed, e->next_event) >= 0 // The enclave has to advance its tag

if (num_connected_upstream == 0) {
// When none of the upstream federates is connected (case of transients),
if (lf_tag_compare(e->next_event, FOREVER_TAG) != 0) {
result.tag = e->next_event;
return result;
}
} else if (lf_tag_compare(min_upstream_completed, e->last_granted) > 0 &&
lf_tag_compare(min_upstream_completed, e->next_event) >= 0 // The enclave has to advance its tag
) {
result.tag = min_upstream_completed;
return result;
Expand Down
Loading
Loading