From ef4eb0af41e4660cea2480871df4777286821b96 Mon Sep 17 00:00:00 2001 From: Rune Magnussen Date: Thu, 13 Jul 2017 22:07:01 +0200 Subject: [PATCH 1/2] Turn hard coden values into parameters. Values affecting mode 1 and 2 of the standard PLL have been conveted to tunable parameters. The min and max values are far apart and may need to be tightened up. The scheduling delay in main_sim_client.c and the cut off for ancient packets in ntp_filter.c has veen turned into parameters too. --- main_sim_client.c | 2 +- ntp_filter.c | 3 +-- param_tbl.h | 40 ++++++++++++++++++++++++++++++++++++++-- pll_std.c | 7 ++++--- 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/main_sim_client.c b/main_sim_client.c index 4da8972..56e4259 100644 --- a/main_sim_client.c +++ b/main_sim_client.c @@ -139,7 +139,7 @@ simfile_readline(struct ocx *ocx, struct todolist *tdl, void *priv) u1 -= sf->t0; TS_Nanosec(&sf->when, u1, u2); dt = TS_Diff(&sf->when, &t0); - if (dt >= 1e-3) { + if (dt >= param_sim_min_sched) { TODO_ScheduleAbs(tdl, simfile_readline, priv, &sf->when, 0.0, "Readline"); return (TODO_OK); diff --git a/ntp_filter.c b/ntp_filter.c index bd9cb9e..7a5e5b3 100644 --- a/ntp_filter.c +++ b/ntp_filter.c @@ -115,8 +115,7 @@ nf_filter(struct ocx *ocx, const struct ntp_peer *np) } // This is almost never a good sign. - if (r > 2048) { - /* XXX: 2048 -> param */ + if (r > param_ntp_filter_ancient) { Put(ocx, OCX_TRACE, "NF ancient ref %.3e\n", r); return; } diff --git a/param_tbl.h b/param_tbl.h index cf2f7c4..14d2dd5 100644 --- a/param_tbl.h +++ b/param_tbl.h @@ -38,8 +38,10 @@ /* name, min, max, default, docs */ #ifdef PARAM_CLIENT -PARAM_CLIENT(poll_rate, 16.0, 4096.0, 64.0, "") -PARAM_CLIENT(foo, 16.0, 4096.0, 64.0, "") +PARAM_CLIENT(poll_rate, 16.0, 4096.0, 64.0, "Client poll rate") +PARAM_CLIENT(sim_min_sched, + 1e-6, 1e-2, 1e-3, + "Minimum delay before simulator scheduling") #endif #ifdef PARAM_NTP_FILTER @@ -60,6 +62,14 @@ PARAM_NTP_FILTER(ntp_filter_threshold, " Setting it too low throws away adequate timestamps." ) +PARAM_NTP_FILTER(ntp_filter_ancient, + 256, 4096, 2048, + "Packet delays exceeding the average by this amount are too old." + " Theese events are logged." + " Setting this too high and the clock man become eratic." + " Setting it too low throws away useful timestamps." +) + #endif /********************************************************************** @@ -109,6 +119,32 @@ PARAM_PLL_STD(pll_std_p_limit, " Increasing this makes the PLL more agile and prone to noise." ) +PARAM_PLL_STD(pll_std_mode1_step, + 1e-6, 3e2, 1e-3, + "Treshold for stepping clock at startup.\n\n" + "Reducing this will step the clock at smaller errors." + " Increasing this makes the PLL more tolerant and" + " reduce the chance that the clock is stepped." +) + +PARAM_PLL_STD(pll_std_mode1_rt, + 1e-3, 1e3, 2, + "Cut off value for internal offset in PLL-mode 1\n\n" + "Increasing this will delay the initial clock step." +) + +PARAM_PLL_STD(pll_std_mode1_weight, + 1e-3, 1e3, 3, + "Cut off value for weight in PLL-mode 1\n\n" + "Increasing this will delay the initial clock step." +) + +PARAM_PLL_STD(pll_std_mode2_rt, + 1e-3, 1e3, 6, + "Cut off value for internal offset in PLL-mode 2\n\n" + "Increasing this will delay the transition to mode 3." +) + #endif diff --git a/pll_std.c b/pll_std.c index 5223e31..5cd2438 100644 --- a/pll_std.c +++ b/pll_std.c @@ -77,8 +77,9 @@ pll_std(struct ocx *ocx, double offset, double weight) case 1: /* Wait until we have a good estimate, then step */ rt = TS_Diff(&t0, &pll_t0); - if (rt > 2.0 && weight > 3) { // XXX param - if (fabs(offset) > 1e-3) // XXX param + if (rt > param_pll_std_mode1_rt + && weight > param_pll_std_mode1_weight) { + if (fabs(offset) > param_pll_std_mode1_step) TB_Step(ocx, -offset); pll_mode = 2; pll_t0 = t0; @@ -88,7 +89,7 @@ pll_std(struct ocx *ocx, double offset, double weight) case 2: /* Wait for another good estimate, then PLL */ rt = TS_Diff(&t0, &pll_t0); - if (rt > 6.0) { + if (rt > param_pll_std_mode2_rt) { pll_b = pll_a / param_pll_std_i_init; pll_t0 = t0; pll_mode = 3; From 4d8f7308356cd467d5d5de0fef5aa994c2cac052 Mon Sep 17 00:00:00 2001 From: Rune Magnussen Date: Thu, 20 Jul 2017 16:42:28 +0200 Subject: [PATCH 2/2] Fix typos and spelling errors spotted by git user @rwarren . Fix spelling in param_tbl.h . --- param_tbl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/param_tbl.h b/param_tbl.h index 14d2dd5..abd43c2 100644 --- a/param_tbl.h +++ b/param_tbl.h @@ -65,8 +65,8 @@ PARAM_NTP_FILTER(ntp_filter_threshold, PARAM_NTP_FILTER(ntp_filter_ancient, 256, 4096, 2048, "Packet delays exceeding the average by this amount are too old." - " Theese events are logged." - " Setting this too high and the clock man become eratic." + " These events are logged." + " Setting this too high and the clock may become erratic." " Setting it too low throws away useful timestamps." ) @@ -124,7 +124,7 @@ PARAM_PLL_STD(pll_std_mode1_step, "Treshold for stepping clock at startup.\n\n" "Reducing this will step the clock at smaller errors." " Increasing this makes the PLL more tolerant and" - " reduce the chance that the clock is stepped." + " reduces the chance that the clock is stepped." ) PARAM_PLL_STD(pll_std_mode1_rt,