port: adjust peer delay calculation using neighborRateRatio

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 <dbrignoli@audioscience.com>
master
Delio Brignoli 2014-02-21 10:40:54 +01:00 committed by Richard Cochran
parent 54c9effeba
commit bd001fdec7
2 changed files with 9 additions and 1 deletions

5
port.c
View File

@ -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);

5
tmv.h
View File

@ -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;