strncpy((char *)&clocks_private_info[i].ip, sender_string,
FIELD_SIZEOF(clock_source_private_data, ip) - 1);
clocks_private_info[i].family = family;
+#ifdef MAX_TIMING_SAMPLES
clocks_private_info[i].vacant_samples = MAX_TIMING_SAMPLES;
+#endif
clocks_private_info[i].in_use = 1;
debug(2, "create record for ip: %s, family: %s.", &clocks_private_info[i].ip,
clocks_private_info[i].family == AF_INET6 ? "IPv6" : "IPv4");
// 8 samples per seconds
// #define MAX_TIMING_SAMPLES 47
-#define MAX_TIMING_SAMPLES 1
+// #define MAX_TIMING_SAMPLES 1
+
+#ifdef MAX_TIMING_SAMPLES
typedef struct {
uint64_t local_time, clock_time;
} timing_samples;
+#endif
// information about each clock source
typedef struct {
uint64_t announce_times[4]; // we'll check qualification and currency using these
int is_one_of_ours; // true if it is one of our own clocks
+#ifdef MAX_TIMING_SAMPLES
timing_samples samples[MAX_TIMING_SAMPLES];
int vacant_samples; // the number of elements in the timing_samples array that are not yet used
int next_sample_goes_here; // point to where in the timing samples array the next entries should
// go
+#endif
// these are for finding the best clock to use
// See Figure 27 and 27 pp 89 -- 90 for the Data set comparison algorithm
clock_private_info->announcements_without_followups = 0; // we've seen a followup
+#ifdef MAX_TIMING_SAMPLES
clock_private_info->samples[clock_private_info->next_sample_goes_here].local_time =
reception_time;
clock_private_info->samples[clock_private_info->next_sample_goes_here].clock_time =
// if we have need to wrap.
if (clock_private_info->next_sample_goes_here == MAX_TIMING_SAMPLES)
clock_private_info->next_sample_goes_here = 0;
+#endif
debug(2, "FOLLOWUP from %" PRIx64 ", %s.", clock_private_info->clock_id, &clock_private_info->ip);
uint64_t offset = preciseOriginTimestamp - reception_time;
// we definitely have at least one sample since the request was made to
// designate it a master, so we assume it is legitimate. That is, we assume
// that the clock originator knows that it a clock master by now.
+#ifdef MAX_TIMING_SAMPLES
uint64_t oldest_acceptable_master_clock_time =
clock_private_info->source_time + 1150000000; // ns.
clock_private_info->mastership_start_time = age_of_oldest_legitimate_sample;
int64_t offset_difference =
best_offset_so_far - clock_private_info->local_to_source_time_offset;
-
debug(2, "Lookback difference: %f ms with %d samples checked of %d samples total.",
0.000001 * offset_difference, samples_checked, number_of_samples);
clock_private_info->local_to_source_time_offset = best_offset_so_far;
-
debug(2, "Master sampling started %f ms before becoming master.",
0.000001 * (reception_time - age_of_oldest_legitimate_sample));
+#else
+ clock_private_info->mastership_start_time = clock_private_info->local_time;
+#endif
clock_private_info->flags &= ~(1 << clock_is_becoming_master);
clock_private_info->flags |= 1 << clock_is_master;
clock_private_info->previous_offset_time = 0;
clock_private_info->ip);
// leave the offset as it was coming in and take it as a sync time
clock_private_info->last_sync_time = reception_time;
+ clock_private_info->mastership_start_time = reception_time; // mastership is reset to this time...
+ clock_private_info->previous_offset_time = 0;
}
} else {
clock_private_info->last_sync_time = reception_time;
void update_master_clock_info(uint64_t master_clock_id, const char *ip, uint64_t local_time,
uint64_t local_to_master_offset, uint64_t mastership_start_time) {
-
+
//debug(1,"update_master_clock_info start");
if (shared_memory->master_clock_id != master_clock_id)
debug_log_nqptp_status(1);
FIELD_SIZEOF(struct shm_structure, master_clock_ip) - 1);
else
shared_memory->master_clock_ip[0] = '\0';
+ shared_memory->master_clock_start_time = mastership_start_time;
shared_memory->local_time = local_time;
shared_memory->local_to_master_time_offset = local_to_master_offset;
rc = pthread_mutex_unlock(&shared_memory->shm_mutex);