summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandrew-elder <aelder@audioscience.com>2016-02-26 12:21:46 -0500
committerandrew-elder <aelder@audioscience.com>2016-02-26 12:21:46 -0500
commitda8467834cb159c1a662ce81f0c291ab62b3192f (patch)
tree984c001b8ae0a84f7d08ad6ba82105a73e6349f0
parent943f9e36c98df7852fadecdcfa88e2eb1feb4ce8 (diff)
parentdfd4ff4a7d439bd13a9dc5816273bda916ae239b (diff)
downloadOpen-AVB-da8467834cb159c1a662ce81f0c291ab62b3192f.tar.gz
Merge pull request #349 from davidcemin/task-gptpv3
Handles lost of Resp and Fup messages
-rw-r--r--daemons/gptp/common/avbts_message.hpp1
-rw-r--r--daemons/gptp/common/avbts_port.hpp112
-rw-r--r--daemons/gptp/common/gptp_cfg.hpp18
-rw-r--r--daemons/gptp/common/ieee1588port.cpp5
-rw-r--r--daemons/gptp/common/ptp_message.cpp45
-rw-r--r--daemons/gptp/gptp_cfg.ini12
-rw-r--r--daemons/gptp/linux/src/daemon_cl.cpp12
7 files changed, 25 insertions, 180 deletions
diff --git a/daemons/gptp/common/avbts_message.hpp b/daemons/gptp/common/avbts_message.hpp
index 68639e86..9aaf05a4 100644
--- a/daemons/gptp/common/avbts_message.hpp
+++ b/daemons/gptp/common/avbts_message.hpp
@@ -949,6 +949,7 @@ class PTPMessagePathDelayRespFollowUp:public PTPMessageCommon {
PortIdentity *requestingPortIdentity;
PTPMessagePathDelayRespFollowUp(void) { }
+
public:
/**
* Builds the PTPMessagePathDelayRespFollowUp object
diff --git a/daemons/gptp/common/avbts_port.hpp b/daemons/gptp/common/avbts_port.hpp
index a2230d4f..7e9d0cb3 100644
--- a/daemons/gptp/common/avbts_port.hpp
+++ b/daemons/gptp/common/avbts_port.hpp
@@ -234,8 +234,6 @@ class IEEE1588Port {
static const int64_t INVALID_LINKDELAY = 3600000000000;
static const int64_t NEIGHBOR_PROP_DELAY_THRESH = 800;
static const unsigned int DEFAULT_SYNC_RECEIPT_THRESH = 5;
- static const unsigned int DEFAULT_SEQID_ASCAPABLE_THRESHOLD = 5;
- static const uint16_t DEFAULT_LOSTPDELAY_RESP_THRESH = 3;
/* Signed value allows this to be negative result because of inaccurate
timestamp */
@@ -246,14 +244,6 @@ class IEEE1588Port {
unsigned int sync_receipt_thresh;
unsigned int wrongSeqIDCounter;
- /*SeqID threshold*/
- unsigned int seqIdAsCapableThresh;
- unsigned int seqIdAsCapableThreshCounter;
-
- /*Lost PDelayFUPs*/
- uint16_t lastSeqId;
- uint16_t lostPdelayRespThresh;
-
/* Implementation Specific data/methods */
IEEE1588Clock *clock;
@@ -409,7 +399,7 @@ class IEEE1588Port {
/**
* @brief Gets the asCapable flag
- * @return asCapable flag
+ * @return asCapable flag.
*/
bool getAsCapable() { return( asCapable ); }
@@ -947,42 +937,6 @@ class IEEE1588Port {
sync_receipt_thresh = th;
}
- /**
- * @brief Sets the seqIdAsCapableThresh value
- * @param th value to be set
- */
- void setSeqIdAsCapableThresh(unsigned int th)
- {
- seqIdAsCapableThresh = th;
- }
-
- /**
- * @brief Gets the seqIdAsCapableThresh value
- * @return seqIdAsCapableThresh content
- */
- unsigned int getSeqIdAsCapableThresh(void)
- {
- return seqIdAsCapableThresh;
- }
-
- /**
- * @brief Sets the lostPdelayRespThresh value
- * @param th value to be set
- */
- void setLostPdelayRespThresh(unsigned int th)
- {
- lostPdelayRespThresh = th;
- }
-
- /**
- * @brief Gets the lostPdelayRespThresh value
- * @return lostPdelayRespThresh content
- */
- uint16_t getLostPdelayRespThresh(void)
- {
- return lostPdelayRespThresh;
- }
-
/**
* @brief Gets the internal variabl sync_receipt_thresh, which is the
* flag that monitors the amount of wrong syncs enabled before switching
@@ -1025,67 +979,23 @@ class IEEE1588Port {
* @param [out] cnt Pointer to the counter value. Must be valid
* @return TRUE if incremented value is lower than the syncReceiptThreshold. FALSE otherwise.
*/
-
bool incWrongSeqIDCounter(unsigned int *cnt)
{
- if( cnt == NULL )
- {
- return false;
- }
- *cnt = ++wrongSeqIDCounter;
-
- return ( *cnt < getSyncReceiptThresh() );
- }
-
- /**
- * @brief Set the seqIdAsCapableThreshCounter value
- * @param c Value to be set to.
- * @return void
- */
- void setSeqIdAsCapableThreshCounter(unsigned int c)
- {
- seqIdAsCapableThreshCounter = c;
- }
+ if( getAsCapable() )
+ {
+ wrongSeqIDCounter++;
+ }
+ bool ret = wrongSeqIDCounter < getSyncReceiptThresh();
- /**
- * @brief Gets the content of seqIdAsCapableThreshCounter
- * @return seqIdAsCapableThreshCounter value
- */
- unsigned int getSeqIdAsCapableThreshCounter(void)
- {
- return seqIdAsCapableThreshCounter;
- }
+ if( cnt != NULL)
+ {
+ *cnt = wrongSeqIDCounter;
+ }
- /**
- * @brief Increments the seqIdAsCapableThreshCounter value
- * @param incSeqIdAsCapableThreshCounter
- * @return TRUE if incremented value is lower than the seqIdAsCapableThresh.
- * FALSE otherwise.
- */
- bool incSeqIdAsCapableThreshCounter(void)
- {
- return( ++seqIdAsCapableThreshCounter < getSeqIdAsCapableThresh() );
+ return ret;
}
/**
- * @brief Stores the last seqID on port object
- * @param seqid Value to be set
- */
- void setLastSeqID(uint16_t seqid)
- {
- lastSeqId = seqid;
- }
-
- /**
- * @brief Gets the last SeqID from Port object
- * @return lastSeqID
- */
- uint16_t getLastSeqId(void)
- {
- return lastSeqId;
- }
-
- /**
* @brief Sets the neighbor propagation delay threshold
* @param delay Delay in nanoseconds
* @return void
diff --git a/daemons/gptp/common/gptp_cfg.hpp b/daemons/gptp/common/gptp_cfg.hpp
index 4007fab9..50e509b2 100644
--- a/daemons/gptp/common/gptp_cfg.hpp
+++ b/daemons/gptp/common/gptp_cfg.hpp
@@ -169,24 +169,6 @@ class GptpIniParser
return _config.syncReceiptThresh;
}
- /**
- * @brief Gets the value from seqIdAsCapableThresh from the configuration file
- * @return seqIdAsCapableThresh content
- */
- unsigned int getSeqIdAsCapableThresh(void)
- {
- return _config.seqIdAsCapableThresh;
- }
-
- /**
- * @brief Reads the lostPdelayRespThresh from the configuration file
- * @return lostPdelayRespThresh value from the .ini file
- */
- uint16_t getLostPdelayRespThresh(void)
- {
- return _config.lostPdelayRespThresh;
- }
-
private:
int _error;
gptp_cfg_t _config;
diff --git a/daemons/gptp/common/ieee1588port.cpp b/daemons/gptp/common/ieee1588port.cpp
index d9b9b9b2..f1a6bb08 100644
--- a/daemons/gptp/common/ieee1588port.cpp
+++ b/daemons/gptp/common/ieee1588port.cpp
@@ -109,10 +109,7 @@ IEEE1588Port::IEEE1588Port
one_way_delay = ONE_WAY_DELAY_DEFAULT;
neighbor_prop_delay_thresh = NEIGHBOR_PROP_DELAY_THRESH;
sync_receipt_thresh = DEFAULT_SYNC_RECEIPT_THRESH;
- seqIdAsCapableThresh = DEFAULT_SEQID_ASCAPABLE_THRESHOLD;
wrongSeqIDCounter = 0;
- seqIdAsCapableThreshCounter = 0;
- lostPdelayRespThresh = DEFAULT_LOSTPDELAY_RESP_THRESH;
_peer_rate_offset = 1.0;
@@ -133,8 +130,6 @@ IEEE1588Port::IEEE1588Port
pdelay_count = 0;
sync_count = 0;
-
- lastSeqId = 0;
}
bool IEEE1588Port::init_port(int delay[4])
diff --git a/daemons/gptp/common/ptp_message.cpp b/daemons/gptp/common/ptp_message.cpp
index af4134ff..01dcb49f 100644
--- a/daemons/gptp/common/ptp_message.cpp
+++ b/daemons/gptp/common/ptp_message.cpp
@@ -1228,8 +1228,6 @@ void PTPMessagePathDelayResp::processMessage(IEEE1588Port * port)
return;
}
- port->getClock()->deleteEventTimerLocked
- (port, PDELAY_RESP_RECEIPT_TIMEOUT_EXPIRES);
PTPMessagePathDelayResp *old_pdelay_resp = port->getLastPDelayResp();
if (old_pdelay_resp != NULL) {
delete old_pdelay_resp;
@@ -1354,56 +1352,37 @@ void PTPMessagePathDelayRespFollowUp::processMessage(IEEE1588Port * port)
/* Probably shouldn't happen either */
XPTPD_ERROR
(">>> Received PDelay followup but no RESPONSE exists");
+
goto abort;
}
req->getPortIdentity(&req_id);
resp->getRequestingPortIdentity(&resp_id);
- /*We need to keep track of lost respFUPs. If we have more
- * than a certain number of lost FUPs we should set asCapable
- * to false
- */
- if( sequenceId != (port->getLastSeqId() + 1) )
- {
- XPTPD_ERROR("Current seqID: %d. %d are missing since the last one sent",
- sequenceId, sequenceId-port->getLastSeqId());
- if( (sequenceId - port->getLastSeqId() ) > port->getLostPdelayRespThresh() )
- {
- port->setAsCapable( false );
- }
+ if( req->getSequenceId() != sequenceId ) {
+ XPTPD_ERROR
+ (">>> Received PDelay FUP has different seqID than the PDelay request (%d/%d)",
+ sequenceId, req->getSequenceId() );
+ goto abort;
}
- port->setLastSeqID(sequenceId);
-
- // Check if we have received a response
- /* Count wrong seqIDs and after a threshold (from .ini), mark
- * gPTP as not asCapable
- */
- if (resp->getSequenceId() != sequenceId
- || resp_id != *requestingPortIdentity) {
+ if (resp->getSequenceId() != sequenceId) {
uint16_t resp_port_number;
uint16_t req_port_number;
resp_id.getPortNumber(&resp_port_number);
requestingPortIdentity->getPortNumber(&req_port_number);
- if( !port->incSeqIdAsCapableThreshCounter() )
- {
- port->setAsCapable( false );
- }
+
XPTPD_ERROR
("Received PDelay Response Follow Up but cannot find "
"corresponding response");
XPTPD_ERROR("%hu, %hu, %hu, %hu", resp->getSequenceId(),
sequenceId, resp_port_number, req_port_number);
- XPTPD_ERROR("Counter: %d Threshold: %d", port->getSeqIdAsCapableThreshCounter(),
- port->getSeqIdAsCapableThresh());
goto abort;
}
- else
- {
- port->setSeqIdAsCapableThreshCounter(0);
- }
+
+ port->getClock()->deleteEventTimerLocked
+ (port, PDELAY_RESP_RECEIPT_TIMEOUT_EXPIRES);
XPTPD_INFO("Request Sequence Id: %u", req->getSequenceId());
XPTPD_INFO("Response Sequence Id: %u", resp->getSequenceId());
@@ -1467,6 +1446,8 @@ void PTPMessagePathDelayRespFollowUp::processMessage(IEEE1588Port * port)
remote_req_rx_timestamp.nanoseconds);
// Adjust turn-around time for peer to local clock rate difference
+ // TODO: Are these .998 and 1.002 specifically defined in the standard?
+ // Should we create a define for them ?
if
( port->getPeerRateOffset() > .998 &&
port->getPeerRateOffset() < 1.002 ) {
diff --git a/daemons/gptp/gptp_cfg.ini b/daemons/gptp/gptp_cfg.ini
index dd89ea9b..35a00848 100644
--- a/daemons/gptp/gptp_cfg.ini
+++ b/daemons/gptp/gptp_cfg.ini
@@ -29,18 +29,6 @@ neighborPropDelayThresh = 800
# up to 1 second of wrong messages before switching
syncReceiptThresh = 8
-# Sequence ID AS Capable threshold
-# This flag is the the amount of wrong seqID messages that gPTP
-# is allowed to receive before it is considered not AS Capable.
-seqIdAsCapableThresh = 5
-
-# Lost PDelay response threshold
-# A gPTP device must keep count of consecutively lost responses to Pdelay_Req
-# frames. A lost response is considered any late or invalid Pdelay_Resp or
-# Pdelay_Resp_Follow_Up. If more than 3 consecutive responses are lost,
-# then both isMeasuringDelay and asCapable must be set to FALSE.
-lostPdelayRespThresh = 3
-
[eth]
# PHY delay GB TX in nanoseconds
diff --git a/daemons/gptp/linux/src/daemon_cl.cpp b/daemons/gptp/linux/src/daemon_cl.cpp
index 6c9ee9ba..41d7ae4b 100644
--- a/daemons/gptp/linux/src/daemon_cl.cpp
+++ b/daemons/gptp/linux/src/daemon_cl.cpp
@@ -320,8 +320,6 @@ int main(int argc, char **argv)
fprintf(stdout, "phy_delay_mb_rx: %d\n", iniParser.getPhyDelayMbRx());
fprintf(stdout, "neighborPropDelayThresh: %ld\n", iniParser.getNeighborPropDelayThresh());
fprintf(stdout, "syncReceiptThreshold: %d\n", iniParser.getSyncReceiptThresh());
- fprintf(stdout, "seqIdAsCapableThresh: %d\n", iniParser.getSeqIdAsCapableThresh());
- fprintf(stdout, "lostPdelayRespThresh %d\n", iniParser.getLostPdelayRespThresh());
/* If using config file, set the neighborPropDelayThresh.
* Otherwise it will use its default value (800ns) */
@@ -332,16 +330,6 @@ int main(int argc, char **argv)
*/
port->setSyncReceiptThresh(iniParser.getSyncReceiptThresh());
- /* If using config file, set the seqIdAsCapableThresh, otherwise
- * it will use the default value (SEQID_ASCAPABLE_THRESHOLD)
- */
- port->setSeqIdAsCapableThresh(iniParser.getSeqIdAsCapableThresh());
-
- /* If using config file, set the lostPdelayRespThresh, otherwise
- * it will use the default value (LOSTPDELAY_RESP_THRESH)
- */
- port->setLostPdelayRespThresh(iniParser.getLostPdelayRespThresh());
-
/*Only overwrites phy_delay default values if not input_delay switch enabled*/
if(!input_delay)
{