fixed beacon detect logic does not detect reconnected servers
This commit is contained in:
@@ -89,7 +89,7 @@ void bhe::beaconAnomalyNotify ()
|
||||
* updates beacon period, and looks for beacon anomalies
|
||||
*/
|
||||
bool bhe::updatePeriod ( const epicsTime & programBeginTime,
|
||||
const epicsTime & currentTime, unsigned beaconNumber,
|
||||
const epicsTime & currentTime, ca_uint32_t beaconNumber,
|
||||
unsigned protocolRevision )
|
||||
{
|
||||
//
|
||||
@@ -115,11 +115,28 @@ bool bhe::updatePeriod ( const epicsTime & programBeginTime,
|
||||
return false;
|
||||
}
|
||||
|
||||
// detect beacon duplications due to IP redundant packet routes
|
||||
// 1) detect beacon duplications due to redundant routes
|
||||
// 2) detect lost beacons due to input queue overrun or damage
|
||||
if ( CA_V410 ( protocolRevision ) ) {
|
||||
unsigned lastBeaconNumberSave = this->lastBeaconNumber;
|
||||
unsigned beaconSeqAdvance;
|
||||
if ( beaconNumber > this->lastBeaconNumber ) {
|
||||
beaconSeqAdvance = beaconNumber - this->lastBeaconNumber;
|
||||
}
|
||||
else {
|
||||
beaconSeqAdvance = ( ca_uint32_max - this->lastBeaconNumber ) + beaconNumber;
|
||||
}
|
||||
this->lastBeaconNumber = beaconNumber;
|
||||
if ( beaconNumber != lastBeaconNumberSave + 1 ) {
|
||||
|
||||
// throw out sequence numbers just prior to, or the same as, the last one received
|
||||
// (this situation is probably caused by a temporary duplicate route )
|
||||
if ( beaconSeqAdvance == 0 || beaconSeqAdvance > ca_uint32_max - 256 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// throw out sequence numbers that jump forward by only a few numbers
|
||||
// (this situation is probably caused by a duplicate route
|
||||
// or a beacon due to input queue overun)
|
||||
if ( beaconSeqAdvance > 1 && beaconSeqAdvance < 4 ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#endif
|
||||
|
||||
#include "inetAddrID.h"
|
||||
|
||||
#include "caProto.h"
|
||||
|
||||
class tcpiiu;
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
epicsShareFunc ~bhe ();
|
||||
epicsShareFunc void destroy ();
|
||||
epicsShareFunc bool updatePeriod ( const epicsTime & programBeginTime,
|
||||
const epicsTime & currentTime, unsigned beaconNumber,
|
||||
const epicsTime & currentTime, ca_uint32_t beaconNumber,
|
||||
unsigned protocolRevision );
|
||||
epicsShareFunc double period () const;
|
||||
epicsShareFunc epicsTime updateTime () const;
|
||||
@@ -63,7 +63,7 @@ private:
|
||||
tsDLList < tcpiiu > iiuList;
|
||||
epicsTime timeStamp;
|
||||
double averagePeriod;
|
||||
unsigned lastBeaconNumber;
|
||||
ca_uint32_t lastBeaconNumber;
|
||||
void beaconAnomalyNotify ();
|
||||
static epicsSingleton < tsFreeList < class bhe, 1024 > > pFreeList;
|
||||
bhe ( const bhe & );
|
||||
|
||||
@@ -101,6 +101,8 @@ typedef unsigned int ca_uint32_t;
|
||||
typedef float ca_float32_t;
|
||||
typedef ca_uint32_t caResId;
|
||||
|
||||
#define ca_uint32_max 0xffffffff
|
||||
|
||||
/* values for m_cmmd */
|
||||
#define CA_PROTO_VERSION 0u /* set minor version and priority (used to be NOOP cmd) */
|
||||
#define CA_PROTO_EVENT_ADD 1u /* add an event */
|
||||
|
||||
@@ -372,7 +372,7 @@ void cac::show ( unsigned level ) const
|
||||
* cac::beaconNotify
|
||||
*/
|
||||
void cac::beaconNotify ( const inetAddrID & addr, const epicsTime & currentTime,
|
||||
unsigned beaconNumber, unsigned protocolRevision )
|
||||
ca_uint32_t beaconNumber, unsigned protocolRevision )
|
||||
{
|
||||
epicsGuard < cacMutex > guard ( this->mutex );
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
|
||||
// beacon management
|
||||
void beaconNotify ( const inetAddrID & addr, const epicsTime & currentTime,
|
||||
unsigned beaconNumber, unsigned protocolRevision );
|
||||
ca_uint32_t beaconNumber, unsigned protocolRevision );
|
||||
void repeaterSubscribeConfirmNotify ();
|
||||
|
||||
// IO management
|
||||
|
||||
@@ -195,7 +195,7 @@ int main ( int argc, char ** argv )
|
||||
ina.sin_port = epicsNTOH16 ( serverPort );
|
||||
}
|
||||
|
||||
unsigned beaconNumber = ntohl ( pCurMsg->m_cid );
|
||||
ca_uint32_t beaconNumber = ntohl ( pCurMsg->m_cid );
|
||||
unsigned protocolRevision = ntohs ( pCurMsg->m_dataType );
|
||||
|
||||
epicsTime currentTime = epicsTime::getCurrent();
|
||||
|
||||
@@ -684,7 +684,7 @@ bool udpiiu::beaconAction ( epicsGuard < callbackMutex > &, const caHdr &msg,
|
||||
ina.sin_port = epicsHTON16 ( this->serverPort );
|
||||
}
|
||||
unsigned protocolRevision = msg.m_dataType;
|
||||
unsigned beaconNumber = msg.m_cid;
|
||||
ca_uint32_t beaconNumber = msg.m_cid;
|
||||
|
||||
this->cacRef.beaconNotify ( ina, currentTime,
|
||||
beaconNumber, protocolRevision );
|
||||
|
||||
Reference in New Issue
Block a user