Skip to content

Commit

Permalink
Send NET every time when DNET is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
byeonggiljun committed Jan 7, 2025
1 parent 25a32c9 commit 05f5acc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/federated/federate.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ federate_instance_t _fed = {.socket_TCP_RTI = -1,
.is_last_TAG_provisional = false,
.has_upstream = false,
.has_downstream = false,
.received_any_DNET = false,
.last_DNET = {.time = NEVER, .microstep = 0u},
.received_stop_request_from_rti = false,
.last_sent_LTC = {.time = NEVER, .microstep = 0u},
Expand Down Expand Up @@ -1471,6 +1472,7 @@ static void handle_downstream_next_event_tag() {
tracepoint_federate_from_rti(receive_DNET, _lf_my_fed_id, &DNET);

LF_PRINT_LOG("Received Downstream Next Event Tag (DNET): " PRINTF_TAG ".", DNET.time - start_time, DNET.microstep);
_fed.received_any_DNET = true;

environment_t* env;
_lf_get_environments(&env);
Expand Down Expand Up @@ -2264,8 +2266,9 @@ tag_t lf_send_next_event_tag(environment_t* env, tag_t tag, bool wait_for_reply)
LF_PRINT_DEBUG("Granted tag " PRINTF_TAG " because TAG or PTAG has been received.",
_fed.last_TAG.time - start_time, _fed.last_TAG.microstep);

// In case a downstream federate needs the NET of this tag, send NET.
if (lf_tag_compare(_fed.last_DNET, tag) < 0 && lf_tag_compare(_fed.last_DNET, _fed.last_sent_NET) >= 0) {
// In case a downstream federate needs the NET of this tag or has not received any DNET, send NET.
if (!_fed.received_any_DNET ||
(lf_tag_compare(_fed.last_DNET, tag) < 0 && lf_tag_compare(_fed.last_DNET, _fed.last_sent_NET) >= 0)) {
send_tag(MSG_TYPE_NEXT_EVENT_TAG, tag);
_fed.last_sent_NET = tag;
_fed.last_skipped_NET = NEVER_TAG;
Expand Down
5 changes: 5 additions & 0 deletions include/core/federated/federate.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ typedef struct federate_instance_t {
*/
tag_t last_skipped_NET;

/**
* Indicator of whether this federate has received any DNET (downstream next event tag) signal.
*/
bool received_any_DNET;

/**
* A record of the most recent DNET (downstream next event tag) signal.
*/
Expand Down

0 comments on commit 05f5acc

Please sign in to comment.