Add asymmetry correction.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Acked-by: Jacob Keller <Jacob.e.keller@intel.com>
master
Richard Cochran 2012-12-10 14:39:08 +01:00
parent 39e8ee0642
commit b810153ed5
6 changed files with 19 additions and 5 deletions

View File

@ -61,7 +61,12 @@ static enum parser_result parse_pod_setting(const char *option,
Integer8 i8;
UInteger8 u8;
if (!strcmp(option, "logAnnounceInterval")) {
if (!strcmp(option, "delayAsymmetry")) {
if (1 != sscanf(value, "%d", &val))
return BAD_VALUE;
pod->asymmetry = (Integer64) val << 16;
} else if (!strcmp(option, "logAnnounceInterval")) {
if (1 != sscanf(value, "%hhd", &i8))
return BAD_VALUE;
pod->logAnnounceInterval = i8;

View File

@ -20,6 +20,7 @@ logSyncInterval 0
logMinDelayReqInterval 0
logMinPdelayReqInterval 0
announceReceiptTimeout 3
delayAsymmetry 0
#
# Run time options
#

1
ds.h
View File

@ -102,6 +102,7 @@ struct portDS {
} PACKED;
struct port_defaults {
Integer64 asymmetry;
Integer8 logAnnounceInterval;
Integer8 logSyncInterval;
Integer8 logMinDelayReqInterval;

View File

@ -19,6 +19,7 @@ logAnnounceInterval 1
logSyncInterval -3
logMinPdelayReqInterval 0
announceReceiptTimeout 3
delayAsymmetry 0
#
# Run time options
#

8
port.c
View File

@ -588,6 +588,7 @@ static int port_pdelay_request(struct port *p)
msg->header.ver = PTP_VERSION;
msg->header.messageLength = pdulen;
msg->header.domainNumber = clock_domain_number(p->clock);
msg->header.correction = -p->pod.asymmetry;
msg->header.sourcePortIdentity = p->portIdentity;
msg->header.sequenceId = p->seqnum.delayreq++;
msg->header.control = CTL_OTHER;
@ -636,6 +637,7 @@ static int port_delay_request(struct port *p)
msg->header.ver = PTP_VERSION;
msg->header.messageLength = pdulen;
msg->header.domainNumber = clock_domain_number(p->clock);
msg->header.correction = -p->pod.asymmetry;
msg->header.sourcePortIdentity = p->portIdentity;
msg->header.sequenceId = p->seqnum.delayreq++;
msg->header.control = CTL_DELAY_REQ;
@ -1226,11 +1228,9 @@ static void port_peer_delay(struct port *p)
if (rsp->header.sequenceId != ntohs(req->header.sequenceId))
return;
// TODO - add asymmetry value to correctionField.
t1 = timespec_to_tmv(req->hwts.ts);
t4 = timespec_to_tmv(rsp->hwts.ts);
c1 = correction_to_tmv(rsp->header.correction);
c1 = correction_to_tmv(rsp->header.correction + p->pod.asymmetry);
/* Process one-step response immediately. */
if (one_step(rsp)) {
@ -1339,7 +1339,7 @@ static void process_sync(struct port *p, struct ptp_message *m)
clock_sync_interval(p->clock, p->log_sync_interval);
}
// TODO - add asymmetry value to correctionField.
m->header.correction += p->pod.asymmetry;
if (one_step(m)) {
port_synchronize(p, m->hwts.ts, m->ts.pdu,

View File

@ -134,6 +134,12 @@ option. An empty port section can be used to replace the command line option.
.SH PORT OPTIONS
.TP
.B delayAsymmetry
The time difference in nanoseconds of the transmit and receive
paths. This value should be positive when the master-to-slave
propagation time is longer and negative when the slave-to-master time
is longer. The default is 0 nanoseconds.
.TP
.B logAnnounceInterval
The mean time interval between Announce messages. A shorter interval makes