From 1e5e441e10771b03a95efa0effad1389e0253445 Mon Sep 17 00:00:00 2001 From: Chadlia Jerad Date: Mon, 16 Dec 2024 11:52:36 +0100 Subject: [PATCH] Account for delay when dropping a message to be forwarded to a transient federate --- core/federated/RTI/rti_remote.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/core/federated/RTI/rti_remote.c b/core/federated/RTI/rti_remote.c index c1f8dfada..0153a0c72 100644 --- a/core/federated/RTI/rti_remote.c +++ b/core/federated/RTI/rti_remote.c @@ -664,10 +664,18 @@ void handle_timed_message(federate_info_t* sending_federate, unsigned char* buff LF_MUTEX_LOCK(&rti_mutex); // If the destination federate is no longer connected, or it is a transient that has not started executing yet - // (the intended tag is less than the effective start tag of the destination), issue a warning, remove the message - // from the socket, and return. + // (the delayed intended tag is less than the effective start tag of the destination), issue a warning, remove the + // message from the socket, and return. federate_info_t* fed = GET_FED_INFO(federate_id); - if (fed->enclave.state == NOT_CONNECTED || lf_tag_compare(intended_tag, fed->effective_start_tag) < 0) { + interval_t delay = NEVER; + for (int i = 0; i < fed->enclave.num_upstream; i++) { + if (fed->enclave.upstream[i] == sending_federate->enclave.id) { + delay = fed->enclave.upstream_delay[i]; + break; + } + } + if (fed->enclave.state == NOT_CONNECTED || + lf_tag_compare(lf_delay_tag(intended_tag, delay), fed->effective_start_tag) < 0) { lf_print_warning("RTI: Destination federate %d is not connected at logical time (" PRINTF_TAG "). Dropping message.", federate_id, intended_tag.time - start_time, intended_tag.microstep);