Discussion:
[Linuxptp-devel] [PATCH 3/3] port: Prevent erroneous neighbor rate calculations.
Erik Hons
2017-06-01 16:07:41 UTC
Permalink
port: Prevent erroneous neighbor rate calculations.

When a connected peer introduces a time discontinuities in between
consecutive peer-delay measurements (i.e. a jump in time in
consecutive PDelay response), an erroneous neighbor rate ratio is
calculated. This change disqualifies any neighbor rate ratio that
exceeds +/- 100 ppm, as required by IEEE 802.1AS-2011 Anex B.1.1.

Signed-off-by: Rodney Greenstreet <***@ni.com>
---
port.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/port.c b/port.c
index 1b4e18c..051dd4d 100644
--- a/port.c
+++ b/port.c
@@ -42,6 +42,9 @@
#define ALLOWED_LOST_RESPONSES 3
#define ANNOUNCE_SPAN 1
+/* TODO: Allow the frequency range to be configurable */
+#define MAX_PDELAY_FREQ_OFFSET 0.0002
+
enum syfu_state {
SF_EMPTY,
SF_HAVE_SYNC,
@@ -925,6 +928,7 @@ static int port_management_set(struct port *target,
static void port_nrate_calculate(struct port *p, tmv_t origin, tmv_t ingress)
{
struct nrate_estimator *n = &p->nrate;
+ double ratio = 0.0;
/*
* We experienced a successful exchanges of peer delay request
@@ -945,9 +949,16 @@ static void port_nrate_calculate(struct port *p, tmv_t origin, tmv_t ingress)
pr_warning("bad timestamps in nrate calculation");
return;
}
- n->ratio =
+
+ ratio =
tmv_dbl(tmv_sub(origin, n->origin1)) /
tmv_dbl(tmv_sub(ingress, n->ingress1));
+
+ if ((ratio <= (1.0 + MAX_PDELAY_FREQ_OFFSET)) &&
+ (ratio >= (1.0 - MAX_PDELAY_FREQ_OFFSET))) {
+ n->ratio = ratio;
+ }
+
n->ingress1 = ingress;
n->origin1 = origin;
n->count = 0;
--
2.7.4
Richard Cochran
2017-06-06 20:13:40 UTC
Permalink
Post by Erik Hons
port: Prevent erroneous neighbor rate calculations.
When a connected peer introduces a time discontinuities in between
consecutive peer-delay measurements (i.e. a jump in time in
consecutive PDelay response), an erroneous neighbor rate ratio is
calculated. This change disqualifies any neighbor rate ratio that
exceeds +/- 100 ppm, as required by IEEE 802.1AS-2011 Anex B.1.1.
In contrast to the first two patches, this is small, clear, and has a
proper explanation in the change log. If it weren't white space
damaged, then I probably would have been applied it.

Thanks,
Richard

Loading...