Skip to content

Commit

Permalink
port: adjust peer delay calculation using neighborRateRatio
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dbrignoli authored and richardcochran committed Feb 25, 2014
1 parent 54c9eff commit bd001fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion port.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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. */

Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions tmv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bd001fd

Please sign in to comment.