From: Delio Brignoli <dbrign...@audioscience.com>

Previouly the peer delay was not taking into account the
frequency offset between the local clock and the peer's clock.
Reset neighborRateRatio to 1.0 in port_nrate_initialize().

Signed-off-by: Delio Brignoli <dbrign...@audioscience.com>
---

Changes since v1:
 * Add dbl_tmv() to tmv.h
 * Update calculation of peer delay to use dbl_tmv()

 port.c |    5 ++++-
 tmv.h  |    5 +++++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/port.c b/port.c
index 523970e..7e7b2c1 100644
--- a/port.c
+++ b/port.c
@@ -855,6 +855,7 @@ static void port_nrate_initialize(struct port *p)
        p->nrate.ingress1 = tmv_zero();
        p->nrate.max_count = (1 << shift);
        p->nrate.count = 0;
+       p->nrate.ratio = 1.0;
        p->nrate.ratio_valid = 0;
 }
 
@@ -1739,6 +1740,7 @@ static void port_peer_delay(struct port *p)
        struct ptp_message *req = p->peer_delay_req;
        struct ptp_message *rsp = p->peer_delay_resp;
        struct ptp_message *fup = p->peer_delay_fup;
+       double adj_t41;
 
        /* Check for response, validate port and sequence number. */
 
@@ -1782,7 +1784,8 @@ static void port_peer_delay(struct port *p)
        t3 = timestamp_to_tmv(fup->ts.pdu);
        c2 = correction_to_tmv(fup->header.correction);
 calc:
-       pd = tmv_sub(tmv_sub(t4, t1), tmv_sub(t3, t2));
+       adj_t41 = p->nrate.ratio * tmv_dbl(tmv_sub(t4, t1));
+       pd = tmv_sub(dbl_tmv(adj_t41), tmv_sub(t3, t2));
        pd = tmv_sub(pd, c1);
        pd = tmv_sub(pd, c2);
        pd = tmv_div(pd, 2);
diff --git a/tmv.h b/tmv.h
index 16a0772..30b41ee 100644
--- a/tmv.h
+++ b/tmv.h
@@ -81,6 +81,11 @@ static inline double tmv_dbl(tmv_t x)
        return (double) x;
 }
 
+static inline tmv_t dbl_tmv(double x)
+{
+       return (tmv_t) x;
+}
+
 static inline int64_t tmv_to_nanoseconds(tmv_t x)
 {
        return x;
-- 
1.7.0.4




------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to