Merge pull request #2743 from Atlante45/clockSkew_win_bug

Clock skew win bug
This commit is contained in:
Brad Hefta-Gaub 2014-04-29 14:15:59 -07:00
commit 8a823ee4c4
4 changed files with 163 additions and 139 deletions

View file

@ -62,6 +62,8 @@ PacketVersion versionForPacketType(PacketType type) {
case PacketTypeVoxelSet:
case PacketTypeVoxelSetDestructive:
return 1;
case PacketTypeOctreeStats:
return 1;
default:
return 0;
}

View file

@ -646,70 +646,70 @@ int OctreeSceneStats::unpackFromMessage(const unsigned char* sourceBuffer, int a
void OctreeSceneStats::printDebugDetails() {
qDebug("\n------------------------------");
qDebug("OctreeSceneStats:");
qDebug(" start : %llu", (long long unsigned int)_start);
qDebug(" end : %llu", (long long unsigned int)_end);
qDebug(" elapsed : %llu", (long long unsigned int)_elapsed);
qDebug(" encoding : %llu", (long long unsigned int)_totalEncodeTime);
qDebug() << "\n------------------------------";
qDebug() << "OctreeSceneStats:";
qDebug() << "start: " << _start;
qDebug() << "end: " << _end;
qDebug() << "elapsed: " << _elapsed;
qDebug() << "encoding: " << _totalEncodeTime;
qDebug();
qDebug(" full scene: %s", debug::valueOf(_isFullScene));
qDebug(" moving: %s", debug::valueOf(_isMoving));
qDebug() << "full scene: " << debug::valueOf(_isFullScene);
qDebug() << "moving: " << debug::valueOf(_isMoving);
qDebug();
qDebug(" packets: %d", _packets);
qDebug(" bytes : %ld", _bytes);
qDebug() << "packets: " << _packets;
qDebug() << "bytes: " << _bytes;
qDebug();
qDebug(" total elements : %lu", _totalElements );
qDebug(" internal : %lu", _totalInternal );
qDebug(" leaves : %lu", _totalLeaves );
qDebug(" traversed : %lu", _traversed );
qDebug(" internal : %lu", _internal );
qDebug(" leaves : %lu", _leaves );
qDebug(" skipped distance : %lu", _skippedDistance );
qDebug(" internal : %lu", _internalSkippedDistance );
qDebug(" leaves : %lu", _leavesSkippedDistance );
qDebug(" skipped out of view : %lu", _skippedOutOfView );
qDebug(" internal : %lu", _internalSkippedOutOfView );
qDebug(" leaves : %lu", _leavesSkippedOutOfView );
qDebug(" skipped was in view : %lu", _skippedWasInView );
qDebug(" internal : %lu", _internalSkippedWasInView );
qDebug(" leaves : %lu", _leavesSkippedWasInView );
qDebug(" skipped no change : %lu", _skippedNoChange );
qDebug(" internal : %lu", _internalSkippedNoChange );
qDebug(" leaves : %lu", _leavesSkippedNoChange );
qDebug(" skipped occluded : %lu", _skippedOccluded );
qDebug(" internal : %lu", _internalSkippedOccluded );
qDebug(" leaves : %lu", _leavesSkippedOccluded );
qDebug() << "total elements: " << _totalElements;
qDebug() << "internal: " << _totalInternal;
qDebug() << "leaves: " << _totalLeaves;
qDebug() << "traversed: " << _traversed;
qDebug() << "internal: " << _internal;
qDebug() << "leaves: " << _leaves;
qDebug() << "skipped distance: " << _skippedDistance;
qDebug() << "internal: " << _internalSkippedDistance;
qDebug() << "leaves: " << _leavesSkippedDistance;
qDebug() << "skipped out of view: " << _skippedOutOfView;
qDebug() << "internal: " << _internalSkippedOutOfView;
qDebug() << "leaves: " << _leavesSkippedOutOfView;
qDebug() << "skipped was in view: " << _skippedWasInView;
qDebug() << "internal: " << _internalSkippedWasInView;
qDebug() << "leaves: " << _leavesSkippedWasInView;
qDebug() << "skipped no change: " << _skippedNoChange;
qDebug() << "internal: " << _internalSkippedNoChange;
qDebug() << "leaves: " << _leavesSkippedNoChange;
qDebug() << "skipped occluded: " << _skippedOccluded;
qDebug() << "internal: " << _internalSkippedOccluded;
qDebug() << "leaves: " << _leavesSkippedOccluded;
qDebug();
qDebug(" color sent : %lu", _colorSent );
qDebug(" internal : %lu", _internalColorSent );
qDebug(" leaves : %lu", _leavesColorSent );
qDebug(" Didn't Fit : %lu", _didntFit );
qDebug(" internal : %lu", _internalDidntFit );
qDebug(" leaves : %lu", _leavesDidntFit );
qDebug(" color bits : %lu", _colorBitsWritten );
qDebug(" exists bits : %lu", _existsBitsWritten );
qDebug(" in packet bit : %lu", _existsInPacketBitsWritten);
qDebug(" trees removed : %lu", _treesRemoved );
qDebug() << "color sent: " << _colorSent;
qDebug() << "internal: " << _internalColorSent;
qDebug() << "leaves: " << _leavesColorSent;
qDebug() << "Didn't Fit: " << _didntFit;
qDebug() << "internal: " << _internalDidntFit;
qDebug() << "leaves: " << _leavesDidntFit;
qDebug() << "color bits: " << _colorBitsWritten;
qDebug() << "exists bits: " << _existsBitsWritten;
qDebug() << "in packet bit: " << _existsInPacketBitsWritten;
qDebug() << "trees removed: " << _treesRemoved;
}
OctreeSceneStats::ItemInfo OctreeSceneStats::_ITEMS[] = {
{ "Elapsed" , GREENISH , 2 , "Elapsed,fps" },
{ "Encode" , YELLOWISH , 2 , "Time,fps" },
{ "Network" , GREYISH , 3 , "Packets,Bytes,KBPS" },
{ "Octrees on Server" , GREENISH , 3 , "Total,Internal,Leaves" },
{ "Octrees Sent" , YELLOWISH , 5 , "Total,Bits/Octree,Avg Bits/Octree,Internal,Leaves" },
{ "Colors Sent" , GREYISH , 3 , "Total,Internal,Leaves" },
{ "Bitmasks Sent" , GREENISH , 3 , "Colors,Exists,In Packets" },
{ "Traversed" , YELLOWISH , 3 , "Total,Internal,Leaves" },
{ "Skipped - Total" , GREYISH , 3 , "Total,Internal,Leaves" },
{ "Skipped - Distance" , GREENISH , 3 , "Total,Internal,Leaves" },
{ "Skipped - Out of View", YELLOWISH , 3 , "Total,Internal,Leaves" },
{ "Skipped - Was in View", GREYISH , 3 , "Total,Internal,Leaves" },
{ "Skipped - No Change" , GREENISH , 3 , "Total,Internal,Leaves" },
{ "Skipped - Occluded" , YELLOWISH , 3 , "Total,Internal,Leaves" },
{ "Didn't fit in packet" , GREYISH , 4 , "Total,Internal,Leaves,Removed" },
{ "Mode" , GREENISH , 4 , "Moving,Stationary,Partial,Full" },
{ "Elapsed", GREENISH, 2, "Elapsed,fps" },
{ "Encode", YELLOWISH, 2, "Time,fps" },
{ "Network", GREYISH, 3, "Packets,Bytes,KBPS" },
{ "Octrees on Server", GREENISH, 3, "Total,Internal,Leaves" },
{ "Octrees Sent", YELLOWISH, 5, "Total,Bits/Octree,Avg Bits/Octree,Internal,Leaves" },
{ "Colors Sent", GREYISH, 3, "Total,Internal,Leaves" },
{ "Bitmasks Sent", GREENISH, 3, "Colors,Exists,In Packets" },
{ "Traversed", YELLOWISH, 3, "Total,Internal,Leaves" },
{ "Skipped - Total", GREYISH, 3, "Total,Internal,Leaves" },
{ "Skipped - Distance", GREENISH, 3, "Total,Internal,Leaves" },
{ "Skipped - Out of View", YELLOWISH, 3, "Total,Internal,Leaves" },
{ "Skipped - Was in View", GREYISH, 3, "Total,Internal,Leaves" },
{ "Skipped - No Change", GREENISH, 3, "Total,Internal,Leaves" },
{ "Skipped - Occluded", YELLOWISH, 3, "Total,Internal,Leaves" },
{ "Didn't fit in packet", GREYISH, 4, "Total,Internal,Leaves,Removed" },
{ "Mode", GREENISH, 4, "Moving,Stationary,Partial,Full" },
};
const char* OctreeSceneStats::getItemValue(Item item) {
@ -732,12 +732,14 @@ const char* OctreeSceneStats::getItemValue(Item item) {
case ITEM_PACKETS: {
float elapsedSecs = ((float)_elapsed / (float)USECS_PER_SECOND);
calculatedKBPS = elapsedSecs == 0 ? 0 : ((_bytes * 8) / elapsedSecs) / 1000;
sprintf(_itemValueBuffer, "%d packets %lu bytes (%d kbps)", _packets, _bytes, calculatedKBPS);
sprintf(_itemValueBuffer, "%d packets %lu bytes (%d kbps)", _packets, (long unsigned int)_bytes, calculatedKBPS);
break;
}
case ITEM_VOXELS_SERVER: {
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
_totalElements, _totalInternal, _totalLeaves);
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
(long unsigned int)_totalElements,
(long unsigned int)_totalInternal,
(long unsigned int)_totalLeaves);
break;
}
case ITEM_VOXELS: {
@ -745,12 +747,14 @@ const char* OctreeSceneStats::getItemValue(Item item) {
float calculatedBPV = total == 0 ? 0 : (_bytes * 8) / total;
float averageBPV = _bitsPerOctreeAverage.getAverage();
sprintf(_itemValueBuffer, "%lu (%.2f bits/octree Average: %.2f bits/octree) %lu internal %lu leaves",
total, calculatedBPV, averageBPV, _existsInPacketBitsWritten, _colorSent);
total, calculatedBPV, averageBPV,
(long unsigned int)_existsInPacketBitsWritten,
(long unsigned int)_colorSent);
break;
}
case ITEM_TRAVERSED: {
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
_traversed, _internal, _leaves);
(long unsigned int)_traversed, (long unsigned int)_internal, (long unsigned int)_leaves);
break;
}
case ITEM_SKIPPED: {
@ -769,42 +773,59 @@ const char* OctreeSceneStats::getItemValue(Item item) {
}
case ITEM_SKIPPED_DISTANCE: {
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
_skippedDistance, _internalSkippedDistance, _leavesSkippedDistance);
(long unsigned int)_skippedDistance,
(long unsigned int)_internalSkippedDistance,
(long unsigned int)_leavesSkippedDistance);
break;
}
case ITEM_SKIPPED_OUT_OF_VIEW: {
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
_skippedOutOfView, _internalSkippedOutOfView, _leavesSkippedOutOfView);
(long unsigned int)_skippedOutOfView,
(long unsigned int)_internalSkippedOutOfView,
(long unsigned int)_leavesSkippedOutOfView);
break;
}
case ITEM_SKIPPED_WAS_IN_VIEW: {
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
_skippedWasInView, _internalSkippedWasInView, _leavesSkippedWasInView);
(long unsigned int)_skippedWasInView,
(long unsigned int)_internalSkippedWasInView,
(long unsigned int)_leavesSkippedWasInView);
break;
}
case ITEM_SKIPPED_NO_CHANGE: {
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
_skippedNoChange, _internalSkippedNoChange, _leavesSkippedNoChange);
(long unsigned int)_skippedNoChange,
(long unsigned int)_internalSkippedNoChange,
(long unsigned int)_leavesSkippedNoChange);
break;
}
case ITEM_SKIPPED_OCCLUDED: {
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
_skippedOccluded, _internalSkippedOccluded, _leavesSkippedOccluded);
(long unsigned int)_skippedOccluded,
(long unsigned int)_internalSkippedOccluded,
(long unsigned int)_leavesSkippedOccluded);
break;
}
case ITEM_COLORS: {
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves",
_colorSent, _internalColorSent, _leavesColorSent);
(long unsigned int)_colorSent,
(long unsigned int)_internalColorSent,
(long unsigned int)_leavesColorSent);
break;
}
case ITEM_DIDNT_FIT: {
sprintf(_itemValueBuffer, "%lu total %lu internal %lu leaves (removed: %lu)",
_didntFit, _internalDidntFit, _leavesDidntFit, _treesRemoved);
(long unsigned int)_didntFit,
(long unsigned int)_internalDidntFit,
(long unsigned int)_leavesDidntFit,
(long unsigned int)_treesRemoved);
break;
}
case ITEM_BITS: {
sprintf(_itemValueBuffer, "colors: %lu, exists: %lu, in packets: %lu",
_colorBitsWritten, _existsBitsWritten, _existsInPacketBitsWritten);
(long unsigned int)_colorBitsWritten,
(long unsigned int)_existsBitsWritten,
(long unsigned int)_existsInPacketBitsWritten);
break;
}
case ITEM_MODE: {

View file

@ -146,30 +146,30 @@ public:
const std::vector<unsigned char*>& getJurisdictionEndNodes() const { return _jurisdictionEndNodes; }
bool isMoving() const { return _isMoving; };
unsigned long getTotalElements() const { return _totalElements; }
unsigned long getTotalInternal() const { return _totalInternal; }
unsigned long getTotalLeaves() const { return _totalLeaves; }
unsigned long getTotalEncodeTime() const { return _totalEncodeTime; }
unsigned long getElapsedTime() const { return _elapsed; }
quint64 getTotalElements() const { return _totalElements; }
quint64 getTotalInternal() const { return _totalInternal; }
quint64 getTotalLeaves() const { return _totalLeaves; }
quint64 getTotalEncodeTime() const { return _totalEncodeTime; }
quint64 getElapsedTime() const { return _elapsed; }
unsigned long getLastFullElapsedTime() const { return _lastFullElapsed; }
unsigned long getLastFullTotalEncodeTime() const { return _lastFullTotalEncodeTime; }
unsigned int getLastFullTotalPackets() const { return _lastFullTotalPackets; }
unsigned long getLastFullTotalBytes() const { return _lastFullTotalBytes; }
quint64 getLastFullElapsedTime() const { return _lastFullElapsed; }
quint64 getLastFullTotalEncodeTime() const { return _lastFullTotalEncodeTime; }
quint32 getLastFullTotalPackets() const { return _lastFullTotalPackets; }
quint64 getLastFullTotalBytes() const { return _lastFullTotalBytes; }
// Used in client implementations to track individual octree packets
void trackIncomingOctreePacket(const QByteArray& packet, bool wasStatsPacket, int nodeClockSkewUsec);
unsigned int getIncomingPackets() const { return _incomingPacket; }
unsigned long getIncomingBytes() const { return _incomingBytes; }
unsigned long getIncomingWastedBytes() const { return _incomingWastedBytes; }
unsigned int getIncomingOutOfOrder() const { return _incomingLate + _incomingEarly; }
unsigned int getIncomingLikelyLost() const { return _incomingLikelyLost; }
unsigned int getIncomingRecovered() const { return _incomingRecovered; }
unsigned int getIncomingEarly() const { return _incomingEarly; }
unsigned int getIncomingLate() const { return _incomingLate; }
unsigned int getIncomingReallyLate() const { return _incomingReallyLate; }
unsigned int getIncomingPossibleDuplicate() const { return _incomingPossibleDuplicate; }
quint32 getIncomingPackets() const { return _incomingPacket; }
quint64 getIncomingBytes() const { return _incomingBytes; }
quint64 getIncomingWastedBytes() const { return _incomingWastedBytes; }
quint32 getIncomingOutOfOrder() const { return _incomingLate + _incomingEarly; }
quint32 getIncomingLikelyLost() const { return _incomingLikelyLost; }
quint32 getIncomingRecovered() const { return _incomingRecovered; }
quint32 getIncomingEarly() const { return _incomingEarly; }
quint32 getIncomingLate() const { return _incomingLate; }
quint32 getIncomingReallyLate() const { return _incomingReallyLate; }
quint32 getIncomingPossibleDuplicate() const { return _incomingPossibleDuplicate; }
float getIncomingFlightTimeAverage() { return _incomingFlightTimeAverage.getAverage(); }
private:
@ -178,7 +178,8 @@ private:
bool _isReadyToSend;
unsigned char _statsMessage[MAX_PACKET_SIZE];
int _statsMessageLength;
qint32 _statsMessageLength;
// scene timing data in usecs
bool _isStarted;
@ -188,8 +189,8 @@ private:
quint64 _lastFullElapsed;
quint64 _lastFullTotalEncodeTime;
unsigned int _lastFullTotalPackets;
unsigned long _lastFullTotalBytes;
quint32 _lastFullTotalPackets;
quint64 _lastFullTotalBytes;
SimpleMovingAverage _elapsedAverage;
SimpleMovingAverage _bitsPerOctreeAverage;
@ -198,46 +199,46 @@ private:
quint64 _encodeStart;
// scene octree related data
unsigned long _totalElements;
unsigned long _totalInternal;
unsigned long _totalLeaves;
quint64 _totalElements;
quint64 _totalInternal;
quint64 _totalLeaves;
unsigned long _traversed;
unsigned long _internal;
unsigned long _leaves;
quint64 _traversed;
quint64 _internal;
quint64 _leaves;
unsigned long _skippedDistance;
unsigned long _internalSkippedDistance;
unsigned long _leavesSkippedDistance;
quint64 _skippedDistance;
quint64 _internalSkippedDistance;
quint64 _leavesSkippedDistance;
unsigned long _skippedOutOfView;
unsigned long _internalSkippedOutOfView;
unsigned long _leavesSkippedOutOfView;
quint64 _skippedOutOfView;
quint64 _internalSkippedOutOfView;
quint64 _leavesSkippedOutOfView;
unsigned long _skippedWasInView;
unsigned long _internalSkippedWasInView;
unsigned long _leavesSkippedWasInView;
quint64 _skippedWasInView;
quint64 _internalSkippedWasInView;
quint64 _leavesSkippedWasInView;
unsigned long _skippedNoChange;
unsigned long _internalSkippedNoChange;
unsigned long _leavesSkippedNoChange;
quint64 _skippedNoChange;
quint64 _internalSkippedNoChange;
quint64 _leavesSkippedNoChange;
unsigned long _skippedOccluded;
unsigned long _internalSkippedOccluded;
unsigned long _leavesSkippedOccluded;
quint64 _skippedOccluded;
quint64 _internalSkippedOccluded;
quint64 _leavesSkippedOccluded;
unsigned long _colorSent;
unsigned long _internalColorSent;
unsigned long _leavesColorSent;
quint64 _colorSent;
quint64 _internalColorSent;
quint64 _leavesColorSent;
unsigned long _didntFit;
unsigned long _internalDidntFit;
unsigned long _leavesDidntFit;
quint64 _didntFit;
quint64 _internalDidntFit;
quint64 _leavesDidntFit;
unsigned long _colorBitsWritten;
unsigned long _existsBitsWritten;
unsigned long _existsInPacketBitsWritten;
unsigned long _treesRemoved;
quint64 _colorBitsWritten;
quint64 _existsBitsWritten;
quint64 _existsInPacketBitsWritten;
quint64 _treesRemoved;
// Accounting Notes:
//
@ -255,22 +256,22 @@ private:
//
// scene network related data
unsigned int _packets;
unsigned long _bytes;
unsigned int _passes;
quint32 _packets;
quint64 _bytes;
quint32 _passes;
// incoming packets stats
unsigned int _incomingPacket;
unsigned long _incomingBytes;
unsigned long _incomingWastedBytes;
quint32 _incomingPacket;
quint64 _incomingBytes;
quint64 _incomingWastedBytes;
uint16_t _incomingLastSequence; /// last incoming sequence number
unsigned int _incomingLikelyLost; /// count of packets likely lost, may be off by _incomingReallyLate count
unsigned int _incomingRecovered; /// packets that were late, and we had in our missing list, we consider recovered
unsigned int _incomingEarly; /// out of order earlier than expected
unsigned int _incomingLate; /// out of order later than expected
unsigned int _incomingReallyLate; /// out of order and later than MAX_MISSING_SEQUENCE_OLD_AGE late
unsigned int _incomingPossibleDuplicate; /// out of order possibly a duplicate
quint16 _incomingLastSequence; /// last incoming sequence number
quint32 _incomingLikelyLost; /// count of packets likely lost, may be off by _incomingReallyLate count
quint32 _incomingRecovered; /// packets that were late, and we had in our missing list, we consider recovered
quint32 _incomingEarly; /// out of order earlier than expected
quint32 _incomingLate; /// out of order later than expected
quint32 _incomingReallyLate; /// out of order and later than MAX_MISSING_SEQUENCE_OLD_AGE late
quint32 _incomingPossibleDuplicate; /// out of order possibly a duplicate
QSet<uint16_t> _missingSequenceNumbers;
SimpleMovingAverage _incomingFlightTimeAverage;
@ -280,7 +281,7 @@ private:
static ItemInfo _ITEMS[];
static int const MAX_ITEM_VALUE_LENGTH = 128;
static const int MAX_ITEM_VALUE_LENGTH = 128;
char _itemValueBuffer[MAX_ITEM_VALUE_LENGTH];
unsigned char* _jurisdictionRoot;

View file

@ -615,7 +615,7 @@ int unpackClipValueFromTwoByte(const unsigned char* buffer, float& clipValue) {
}
int packFloatToByte(unsigned char* buffer, float value, float scaleBy) {
unsigned char holder;
quint8 holder;
const float CONVERSION_RATIO = (255 / scaleBy);
holder = floorf(value * CONVERSION_RATIO);
memcpy(buffer, &holder, sizeof(holder));
@ -623,7 +623,7 @@ int packFloatToByte(unsigned char* buffer, float value, float scaleBy) {
}
int unpackFloatFromByte(const unsigned char* buffer, float& value, float scaleBy) {
unsigned char holder;
quint8 holder;
memcpy(&holder, buffer, sizeof(holder));
value = ((float)holder / (float) 255) * scaleBy;
return sizeof(holder);