Skip to content

Commit

Permalink
config: Add min_neighbor_prop_delay configuration variable
Browse files Browse the repository at this point in the history
When peer delay is < min_neighbor_prop_delay the port is flagged
as non 802.1AS capable. min_neighbor_prop_delay defaults to -20ms.

Signed-off-by: Delio Brignoli <[email protected]>
  • Loading branch information
dbrignoli authored and richardcochran committed Feb 25, 2014
1 parent bd001fd commit b2bde6f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ static enum parser_result parse_pod_setting(const char *option,
return r;
pod->neighborPropDelayThresh = uval;

} else if (!strcmp(option, "min_neighbor_prop_delay")) {
r = get_ranged_int(value, &val, INT_MIN, -1);
if (r != PARSED_OK)
return r;
pod->min_neighbor_prop_delay = val;

} else if (!strcmp(option, "fault_badpeernet_interval")) {
pod->flt_interval_pertype[FT_BAD_PEER_NETWORK].type = FTMO_LINEAR_SECONDS;
if (!strcasecmp("ASAP", value)) {
Expand Down
1 change: 1 addition & 0 deletions ds.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ struct port_defaults {
int freq_est_interval; /*log seconds*/
struct fault_interval flt_interval_pertype[FT_CNT];
UInteger32 neighborPropDelayThresh; /*nanoseconds*/
int min_neighbor_prop_delay; /*nanoseconds*/
};

#endif
1 change: 1 addition & 0 deletions gPTP.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ syncReceiptTimeout 3
delayAsymmetry 0
fault_reset_interval 4
neighborPropDelayThresh 800
min_neighbor_prop_delay -20000000
#
# Run time options
#
Expand Down
11 changes: 11 additions & 0 deletions port.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ struct port {
Enumeration8 delayMechanism;
Integer8 logMinPdelayReqInterval;
UInteger32 neighborPropDelayThresh;
int min_neighbor_prop_delay;
enum fault_type last_fault_type;
unsigned int versionNumber; /*UInteger4*/
/* foreignMasterDS */
Expand Down Expand Up @@ -475,6 +476,15 @@ static int port_capable(struct port *p)
goto not_capable;
}

if (tmv_to_nanoseconds(p->peer_delay) < p->min_neighbor_prop_delay) {
if (p->asCapable)
pr_debug("port %hu: peer_delay (%" PRId64 ") < min_neighbor_prop_delay "
"(%" PRId32 "), resetting asCapable", portnum(p),
tmv_to_nanoseconds(p->peer_delay),
p->min_neighbor_prop_delay);
goto not_capable;
}

if (p->pdr_missing > ALLOWED_LOST_RESPONSES) {
if (p->asCapable)
pr_debug("port %hu: missed %d peer delay resp, "
Expand Down Expand Up @@ -1378,6 +1388,7 @@ static int port_initialize(struct port *p)
p->logSyncInterval = p->pod.logSyncInterval;
p->logMinPdelayReqInterval = p->pod.logMinPdelayReqInterval;
p->neighborPropDelayThresh = p->pod.neighborPropDelayThresh;
p->min_neighbor_prop_delay = p->pod.min_neighbor_prop_delay;

for (i = 0; i < N_TIMER_FDS; i++) {
fd[i] = -1;
Expand Down
4 changes: 4 additions & 0 deletions ptp4l.8
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ The default is UDPv4.
Upper limit for peer delay in nanoseconds. If the estimated peer delay is
greater than this value the port is marked as not 802.1AS capable.
.TP
.B min_neighbor_prop_delay
Lower limit for peer delay in nanoseconds. If the estimated peer delay is
smaller than this value the port is marked as not 802.1AS capable.
.TP
.B delay_filter
Select the algorithm used to filter the measured delay and peer delay. Possible
values are moving_average and moving_median.
Expand Down
2 changes: 2 additions & 0 deletions ptp4l.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -90,6 +91,7 @@ static struct config cfg_settings = {
.freq_est_interval = 1,
/* Default to very a large neighborPropDelay threshold */
.neighborPropDelayThresh = 20000000,
.min_neighbor_prop_delay = -20000000,
},

.timestamping = TS_HARDWARE,
Expand Down

0 comments on commit b2bde6f

Please sign in to comment.