Fix SequenceNumberStats, misc. clean-up

This commit is contained in:
Simon Walton 2018-03-29 10:47:11 -07:00
parent b409e04734
commit 1b0b280f3a
7 changed files with 15 additions and 15 deletions

View file

@ -1021,7 +1021,7 @@ void DomainGatekeeper::refreshGroupsCache() {
void DomainGatekeeper::initLocalIDManagement() { void DomainGatekeeper::initLocalIDManagement() {
std::uniform_int_distribution<quint16> sixteenBitRand; std::uniform_int_distribution<quint16> sixteenBitRand;
std::random_device randomDevice; std::random_device randomDevice;
std::default_random_engine engine {randomDevice()}; std::default_random_engine engine { randomDevice() };
_currentLocalID = sixteenBitRand(engine); _currentLocalID = sixteenBitRand(engine);
// Ensure increment is odd. // Ensure increment is odd.
_idIncrement = sixteenBitRand(engine) | 1; _idIncrement = sixteenBitRand(engine) | 1;

View file

@ -135,7 +135,7 @@ private:
UUIDToLocalID _uuidToLocalID; UUIDToLocalID _uuidToLocalID;
Node::LocalID _currentLocalID; Node::LocalID _currentLocalID;
quint16 _idIncrement; Node::LocalID _idIncrement;
}; };

View file

@ -1159,7 +1159,7 @@ void DomainServer::handleConnectedNode(SharedNodePointer newNode) {
void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const HifiSockAddr &senderSockAddr) { void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const HifiSockAddr &senderSockAddr) {
const int NUM_DOMAIN_LIST_EXTENDED_HEADER_BYTES = NUM_BYTES_RFC4122_UUID + NLPacket::NUM_BYTES_LOCALID + const int NUM_DOMAIN_LIST_EXTENDED_HEADER_BYTES = NUM_BYTES_RFC4122_UUID + NLPacket::NUM_BYTES_LOCALID +
NUM_BYTES_RFC4122_UUID + NLPacket::NUM_BYTES_LOCALID + 2; NUM_BYTES_RFC4122_UUID + NLPacket::NUM_BYTES_LOCALID + 4;
// setup the extended header for the domain list packets // setup the extended header for the domain list packets
// this data is at the beginning of each of the domain list packets // this data is at the beginning of each of the domain list packets

View file

@ -120,8 +120,8 @@ int InboundAudioStream::parseData(ReceivedMessage& message) {
// parse sequence number and track it // parse sequence number and track it
quint16 sequence; quint16 sequence;
message.readPrimitive(&sequence); message.readPrimitive(&sequence);
SequenceNumberStats::ArrivalInfo arrivalInfo = _incomingSequenceNumberStats.sequenceNumberReceived(sequence, QUuid() // TBD SequenceNumberStats::ArrivalInfo arrivalInfo =
/*message.getSourceID()*/); _incomingSequenceNumberStats.sequenceNumberReceived(sequence, message.getSourceID());
QString codecInPacket = message.readString(); QString codecInPacket = message.readString();
packetReceivedUpdateTimingStats(); packetReceivedUpdateTimingStats();

View file

@ -136,7 +136,7 @@ Node::LocalID LimitedNodeList::getSessionLocalID() const {
} }
void LimitedNodeList::setSessionLocalID(Node::LocalID sessionLocalID) { void LimitedNodeList::setSessionLocalID(Node::LocalID sessionLocalID) {
QWriteLocker lock { &_sessionUUIDLock }; // Necessary? QWriteLocker lock { &_sessionUUIDLock };
_sessionLocalID = sessionLocalID; _sessionLocalID = sessionLocalID;
} }

View file

@ -25,7 +25,7 @@ SequenceNumberStats::SequenceNumberStats(int statsHistoryLength, bool canDetectO
: _lastReceivedSequence(0), : _lastReceivedSequence(0),
_missingSet(), _missingSet(),
_stats(), _stats(),
_lastSenderUUID(), _lastSenderID(0),
_statsHistory(statsHistoryLength), _statsHistory(statsHistoryLength),
_lastUnreasonableSequence(0), _lastUnreasonableSequence(0),
_consecutiveUnreasonableOnTime(0) _consecutiveUnreasonableOnTime(0)
@ -35,7 +35,7 @@ SequenceNumberStats::SequenceNumberStats(int statsHistoryLength, bool canDetectO
void SequenceNumberStats::reset() { void SequenceNumberStats::reset() {
_missingSet.clear(); _missingSet.clear();
_stats = PacketStreamStats(); _stats = PacketStreamStats();
_lastSenderUUID = QUuid(); _lastSenderID = 0;
_statsHistory.clear(); _statsHistory.clear();
_lastUnreasonableSequence = 0; _lastUnreasonableSequence = 0;
_consecutiveUnreasonableOnTime = 0; _consecutiveUnreasonableOnTime = 0;
@ -43,18 +43,18 @@ void SequenceNumberStats::reset() {
static const int UINT16_RANGE = std::numeric_limits<uint16_t>::max() + 1; static const int UINT16_RANGE = std::numeric_limits<uint16_t>::max() + 1;
SequenceNumberStats::ArrivalInfo SequenceNumberStats::sequenceNumberReceived(quint16 incoming, QUuid senderUUID, const bool wantExtraDebugging) { SequenceNumberStats::ArrivalInfo SequenceNumberStats::sequenceNumberReceived(quint16 incoming, NetworkLocalID senderID, const bool wantExtraDebugging) {
SequenceNumberStats::ArrivalInfo arrivalInfo; SequenceNumberStats::ArrivalInfo arrivalInfo;
// if the sender node has changed, reset all stats // if the sender node has changed, reset all stats
if (senderUUID != _lastSenderUUID) { if (senderID != _lastSenderID) {
if (_stats._received > 0) { if (_stats._received > 0) {
qCDebug(networking) << "sequence number stats was reset due to new sender node"; qCDebug(networking) << "sequence number stats was reset due to new sender node";
qCDebug(networking) << "previous:" << _lastSenderUUID << "current:" << senderUUID; qCDebug(networking) << "previous:" << _lastSenderID << "current:" << senderID;
reset(); reset();
} }
_lastSenderUUID = senderUUID; _lastSenderID = senderID;
} }
// determine our expected sequence number... handle rollover appropriately // determine our expected sequence number... handle rollover appropriately

View file

@ -14,7 +14,7 @@
#include "SharedUtil.h" #include "SharedUtil.h"
#include "RingBufferHistory.h" #include "RingBufferHistory.h"
#include <quuid.h> #include "UUID.h"
const int MAX_REASONABLE_SEQUENCE_GAP = 1000; const int MAX_REASONABLE_SEQUENCE_GAP = 1000;
@ -73,7 +73,7 @@ public:
SequenceNumberStats(int statsHistoryLength = 0, bool canDetectOutOfSync = true); SequenceNumberStats(int statsHistoryLength = 0, bool canDetectOutOfSync = true);
void reset(); void reset();
ArrivalInfo sequenceNumberReceived(quint16 incoming, QUuid senderUUID = QUuid(), const bool wantExtraDebugging = false); ArrivalInfo sequenceNumberReceived(quint16 incoming, NetworkLocalID senderID = 0, const bool wantExtraDebugging = false);
void pruneMissingSet(const bool wantExtraDebugging = false); void pruneMissingSet(const bool wantExtraDebugging = false);
void pushStatsToHistory() { _statsHistory.insert(_stats); } void pushStatsToHistory() { _statsHistory.insert(_stats); }
@ -100,7 +100,7 @@ private:
PacketStreamStats _stats; PacketStreamStats _stats;
QUuid _lastSenderUUID; NetworkLocalID _lastSenderID;
RingBufferHistory<PacketStreamStats> _statsHistory; RingBufferHistory<PacketStreamStats> _statsHistory;