From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Thu, 15 Sep 2022 13:27:57 +0000 (+0100) Subject: Only try to start a silent clock if no follow_ups have _ever_ been seen since it... X-Git-Tag: 1.2~1^2~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=264805dc7ca63316b745409febd62a0d77bf650c;p=thirdparty%2Fnqptp.git Only try to start a silent clock if no follow_ups have _ever_ been seen since it became master. --- diff --git a/nqptp-message-handlers.c b/nqptp-message-handlers.c index 9420baf..75708b4 100644 --- a/nqptp-message-handlers.c +++ b/nqptp-message-handlers.c @@ -64,6 +64,7 @@ void handle_control_port_messages(char *buf, ssize_t recv_len, if ((command == NULL) || ((strcmp(command, "T") == 0) && (ip_list == NULL))) { // clear all the flags + debug(2, "Stop monitoring."); int client_id = get_client_id(smi_name); // create the record if it doesn't exist if (client_id != -1) { /* @@ -121,12 +122,11 @@ void handle_control_port_messages(char *buf, ssize_t recv_len, if (t == -1) t = create_clock_source_record(new_ip, clock_private_info); if (t != -1) { // if the clock table is not full, show it's a timing peer + debug(2, "Monitor clock at %s.", new_ip); clock_private_info[t].client_flags[client_id] |= (1 << clock_is_master); } // otherwise, drop it } - - } @@ -396,15 +396,16 @@ void handle_follow_up(char *buf, ssize_t recv_len, clock_source_private_data *cl if ((clock_private_info->previous_offset_time != 0) && (jitter > -10000000)) { if (jitter < 0) { - if (mastership_time < 1000000000) // at the beginning + if (mastership_time < 1000000000) // at the beginning, if jitter is negative smoothed_offset = clock_private_info->previous_offset + jitter / 16; else - smoothed_offset = clock_private_info->previous_offset + jitter / 64; - } else if (mastership_time < 1000000000) // at the beginning + smoothed_offset = clock_private_info->previous_offset + jitter / 64; // later, if jitter is negative + } else if (mastership_time < 1000000000) { // at the beginning smoothed_offset = - clock_private_info->previous_offset + jitter / 1; // accept positive changes quickly - else - smoothed_offset = clock_private_info->previous_offset + jitter / 64; + clock_private_info->previous_offset + jitter / 1; // at the beginning, if jitter is positive -- accept positive changes quickly + } else { + smoothed_offset = clock_private_info->previous_offset + jitter / 64; // later, if jitter is positive + } } else { // allow samples to disappear for up to a second if ((time_since_previous_offset != 0) && (time_since_previous_offset < 1000000000) && diff --git a/nqptp.c b/nqptp.c index 4f8e50b..6e89252 100644 --- a/nqptp.c +++ b/nqptp.c @@ -520,6 +520,7 @@ uint64_t broadcasting_task(uint64_t call_time, __attribute__((unused)) void *pri // only process it if it's a master somewhere... if ((is_a_master != 0) && (clocks_private[i].announcements_without_followups == 3)) { + if (clocks_private[i].follow_up_number == 0) { debug(1, "Attempt to awaken a silent clock %" PRIx64 ", index %u, at follow_up_number %u at IP %s.", @@ -534,6 +535,13 @@ uint64_t broadcasting_task(uint64_t call_time, __attribute__((unused)) void *pri send_awakening_announcement_sequence( clocks_private[i].clock_id, clocks_private[i].ip, clocks_private[i].family, clocks_private[i].grandmasterPriority1, clocks_private[i].grandmasterPriority2); + } else { + debug(1, + "Silent clock %" PRIx64 + " detected, index %u, at follow_up_number %u at IP %s. No attempt to awaken it.", + clocks_private[i].clock_id, i, clocks_private[i].follow_up_number, + clocks_private[i].ip); + } } }