]> git.ipfire.org Git - thirdparty/nqptp.git/commitdiff
Only try to start a silent clock if no follow_ups have _ever_ been seen since it...
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Thu, 15 Sep 2022 13:27:57 +0000 (14:27 +0100)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Thu, 15 Sep 2022 13:27:57 +0000 (14:27 +0100)
nqptp-message-handlers.c
nqptp.c

index 9420baf5c1e4c42c560e8376b84c01a4993a8bf5..75708b4b6f4700ffcb8c2303b34e36192905b5b7 100644 (file)
@@ -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 4f8e50b97263bf003b97eab3aad4338894adb07d..6e892523ef1af18bc1eeb12402eaedbe9eb63fc6 100644 (file)
--- 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);
+      }
     }
   }