summaryrefslogtreecommitdiff
path: root/libs/gst/net/gstptpclock.c
diff options
context:
space:
mode:
Diffstat (limited to 'libs/gst/net/gstptpclock.c')
-rw-r--r--libs/gst/net/gstptpclock.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/libs/gst/net/gstptpclock.c b/libs/gst/net/gstptpclock.c
index 41eb05d68b..28b49ee6a8 100644
--- a/libs/gst/net/gstptpclock.c
+++ b/libs/gst/net/gstptpclock.c
@@ -1092,14 +1092,18 @@ update_ptp_time (PtpDomainData * domain, PtpPendingSync * sync)
#ifdef USE_MEASUREMENT_FILTERING
/* We check this here and when updating the mean path delay, because
- * we can get here without a delay response too */
+ * we can get here without a delay response too. The tolerance on
+ * accepting follow-up after a sync is high, because a PTP server
+ * doesn't have to prioritise sending FOLLOW_UP - its purpose is
+ * just to give us the accurate timestamp of the preceding SYNC */
if (sync->follow_up_recv_time_local != GST_CLOCK_TIME_NONE
&& sync->follow_up_recv_time_local >
- sync->sync_recv_time_local + 2 * domain->mean_path_delay) {
- GST_WARNING ("Sync-follow-up delay for domain %u too big: %" GST_TIME_FORMAT
- " > 2 * %" GST_TIME_FORMAT, domain->domain,
- GST_TIME_ARGS (sync->follow_up_recv_time_local),
- GST_TIME_ARGS (domain->mean_path_delay));
+ sync->sync_recv_time_local + 20 * domain->mean_path_delay) {
+ GstClockTimeDiff delay =
+ sync->follow_up_recv_time_local - sync->sync_recv_time_local;
+ GST_WARNING ("Sync-follow-up delay for domain %u too big: %"
+ GST_STIME_FORMAT " > 20 * %" GST_TIME_FORMAT, domain->domain,
+ GST_STIME_ARGS (delay), GST_TIME_ARGS (domain->mean_path_delay));
synced = FALSE;
gst_clock_get_calibration (GST_CLOCK_CAST (domain->domain_clock),
&internal_time, &external_time, &rate_num, &rate_den);
@@ -1357,12 +1361,15 @@ update_mean_path_delay (PtpDomainData * domain, PtpPendingSync * sync)
#endif
#ifdef USE_MEASUREMENT_FILTERING
+ /* The tolerance on accepting follow-up after a sync is high, because
+ * a PTP server doesn't have to prioritise sending FOLLOW_UP - its purpose is
+ * just to give us the accurate timestamp of the preceding SYNC */
if (sync->follow_up_recv_time_local != GST_CLOCK_TIME_NONE &&
domain->mean_path_delay != 0
&& sync->follow_up_recv_time_local >
- sync->sync_recv_time_local + 2 * domain->mean_path_delay) {
+ sync->sync_recv_time_local + 20 * domain->mean_path_delay) {
GST_WARNING ("Sync-follow-up delay for domain %u too big: %" GST_TIME_FORMAT
- " > 2 * %" GST_TIME_FORMAT, domain->domain,
+ " > 20 * %" GST_TIME_FORMAT, domain->domain,
GST_TIME_ARGS (sync->follow_up_recv_time_local -
sync->sync_recv_time_local),
GST_TIME_ARGS (domain->mean_path_delay));
@@ -1384,10 +1391,14 @@ update_mean_path_delay (PtpDomainData * domain, PtpPendingSync * sync)
sync->delay_resp_recv_time_local - sync->delay_req_send_time_local;
#ifdef USE_MEASUREMENT_FILTERING
- /* delay_req_delay is a RTT, so 2 times the path delay */
- if (delay_req_delay > 4 * domain->mean_path_delay) {
+ /* delay_req_delay is a RTT, so 2 times the path delay is what we'd
+ * hope for, but some PTP systems don't prioritise sending DELAY_RESP,
+ * but they must still have placed an accurate reception timestamp.
+ * That means we should be quite tolerant about late DELAY_RESP, and
+ * mostly rely on filtering out jumps in the mean-path-delay elsewhere */
+ if (delay_req_delay > 20 * domain->mean_path_delay) {
GST_WARNING ("Delay-request-response delay for domain %u too big: %"
- GST_TIME_FORMAT " > 4 * %" GST_TIME_FORMAT, domain->domain,
+ GST_TIME_FORMAT " > 20 * %" GST_TIME_FORMAT, domain->domain,
GST_TIME_ARGS (delay_req_delay),
GST_TIME_ARGS (domain->mean_path_delay));
ret = FALSE;