removed debug code

This commit is contained in:
wangyix 2014-06-09 12:35:26 -07:00
parent f13ae84da6
commit aa694d6967
14 changed files with 64 additions and 122 deletions

View file

@ -388,3 +388,23 @@ const QByteArray* OctreeQueryNode::getNextNackedPacket() {
} }
return NULL; return NULL;
} }
void OctreeQueryNode::parseNackPacket(QByteArray& packet) {
int numBytesPacketHeader = numBytesForPacketHeader(packet);
const unsigned char* dataAt = reinterpret_cast<const unsigned char*>(packet.data()) + numBytesPacketHeader;
uint16_t numSequenceNumbers = (*(uint16_t*)dataAt);
dataAt += sizeof(uint16_t);
printf("\t received nack packet containing %d seq nums\n", numSequenceNumbers);
// read sequence numbers
for (int i = 0; i < numSequenceNumbers; i++) {
OCTREE_PACKET_SEQUENCE sequenceNumber = (*(OCTREE_PACKET_SEQUENCE*)dataAt);
_nackedSequenceNumbers.enqueue(sequenceNumber);
dataAt += sizeof(OCTREE_PACKET_SEQUENCE);
printf("\t seq = %d\n", sequenceNumber);
}
}

View file

@ -24,8 +24,7 @@
#include <OctreeSceneStats.h> #include <OctreeSceneStats.h>
#include <ThreadedAssignment.h> // for SharedAssignmentPointer #include <ThreadedAssignment.h> // for SharedAssignmentPointer
#include "SentPacketHistory.h" #include "SentPacketHistory.h"
#include <qqueue.h>
#include <qqueue.h> // i added dis
class OctreeSendThread; class OctreeSendThread;
@ -109,9 +108,7 @@ public:
OCTREE_PACKET_SEQUENCE getSequenceNumber() const { return _sequenceNumber; } OCTREE_PACKET_SEQUENCE getSequenceNumber() const { return _sequenceNumber; }
void addNackedSequenceNumber(OCTREE_PACKET_SEQUENCE sequenceNumber) { void parseNackPacket(QByteArray& packet);
_nackedSequenceNumbers.append(sequenceNumber);
}
bool hasNextNackedPacket() const; bool hasNextNackedPacket() const;
const QByteArray* getNextNackedPacket(); const QByteArray* getNextNackedPacket();
@ -158,8 +155,8 @@ private:
PacketType _myPacketType; PacketType _myPacketType;
bool _isShuttingDown; bool _isShuttingDown;
SentPacketHistory _sentPacketHistory; SentPacketHistory _sentPacketHistory;
QQueue<OCTREE_PACKET_SEQUENCE> _nackedSequenceNumbers; QQueue<OCTREE_PACKET_SEQUENCE> _nackedSequenceNumbers;
}; };
#endif // hifi_OctreeQueryNode_h #endif // hifi_OctreeQueryNode_h

View file

@ -85,7 +85,7 @@ bool OctreeSendThread::process() {
if (nodeData && !nodeData->isShuttingDown()) { if (nodeData && !nodeData->isShuttingDown()) {
bool viewFrustumChanged = nodeData->updateCurrentViewFrustum(); bool viewFrustumChanged = nodeData->updateCurrentViewFrustum();
packetDistributor(nodeData, viewFrustumChanged); packetDistributor(nodeData, viewFrustumChanged);
resendNackedPackets(nodeData); resendNackedPackets(nodeData);
} }
} }
} }
@ -181,7 +181,7 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
// actually send it // actually send it
OctreeServer::didCallWriteDatagram(this); OctreeServer::didCallWriteDatagram(this);
NodeList::getInstance()->writeDatagram2(nodeData->getSequenceNumber(), (char*) statsMessage, statsMessageLength, _node); NodeList::getInstance()->writeDatagram((char*) statsMessage, statsMessageLength, _node);
packetSent = true; packetSent = true;
} else { } else {
// not enough room in the packet, send two packets // not enough room in the packet, send two packets
@ -215,7 +215,7 @@ NodeList::getInstance()->writeDatagram2(nodeData->getSequenceNumber(), (char*) s
packetsSent++; packetsSent++;
OctreeServer::didCallWriteDatagram(this); OctreeServer::didCallWriteDatagram(this);
NodeList::getInstance()->writeDatagram2(nodeData->getSequenceNumber(), (char*)nodeData->getPacket(), nodeData->getPacketLength(), _node); NodeList::getInstance()->writeDatagram((char*)nodeData->getPacket(), nodeData->getPacketLength(), _node);
packetSent = true; packetSent = true;
thisWastedBytes = MAX_PACKET_SIZE - nodeData->getPacketLength(); thisWastedBytes = MAX_PACKET_SIZE - nodeData->getPacketLength();
@ -244,7 +244,7 @@ NodeList::getInstance()->writeDatagram2(nodeData->getSequenceNumber(), (char*)no
if (nodeData->isPacketWaiting() && !nodeData->isShuttingDown()) { if (nodeData->isPacketWaiting() && !nodeData->isShuttingDown()) {
// just send the voxel packet // just send the voxel packet
OctreeServer::didCallWriteDatagram(this); OctreeServer::didCallWriteDatagram(this);
NodeList::getInstance()->writeDatagram2(nodeData->getSequenceNumber(), (char*)nodeData->getPacket(), nodeData->getPacketLength(), _node); NodeList::getInstance()->writeDatagram((char*)nodeData->getPacket(), nodeData->getPacketLength(), _node);
packetSent = true; packetSent = true;
int thisWastedBytes = MAX_PACKET_SIZE - nodeData->getPacketLength(); int thisWastedBytes = MAX_PACKET_SIZE - nodeData->getPacketLength();
@ -281,10 +281,6 @@ NodeList::getInstance()->writeDatagram2(nodeData->getSequenceNumber(), (char*)no
return packetsSent; return packetsSent;
} }
int OctreeSendThread::resendNackedPackets(OctreeQueryNode* nodeData) { int OctreeSendThread::resendNackedPackets(OctreeQueryNode* nodeData) {
const int MAX_PACKETS_RESEND = 10; const int MAX_PACKETS_RESEND = 10;
@ -299,20 +295,12 @@ int OctreeSendThread::resendNackedPackets(OctreeQueryNode* nodeData) {
_totalBytes += packet->size(); _totalBytes += packet->size();
_totalPackets++; _totalPackets++;
_totalWastedBytes += MAX_PACKET_SIZE - packet->size(); // ??? _totalWastedBytes += MAX_PACKET_SIZE - packet->size();
} }
} }
if (packetsSent > 0)
printf("\t\t re-sent %d packets!\n", packetsSent);
return packetsSent; return packetsSent;
} }
/// Version of voxel distributor that sends the deepest LOD level at once /// Version of voxel distributor that sends the deepest LOD level at once
int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrustumChanged) { int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrustumChanged) {

View file

@ -56,7 +56,7 @@ private:
int _nodeMissingCount; int _nodeMissingCount;
bool _isShuttingDown; bool _isShuttingDown;
int resendNackedPackets(OctreeQueryNode* nodeData); int resendNackedPackets(OctreeQueryNode* nodeData);
}; };

View file

@ -849,33 +849,15 @@ void OctreeServer::readPendingDatagrams() {
} }
} else if (packetType == PacketTypeOctreeDataNack) { } else if (packetType == PacketTypeOctreeDataNack) {
// If we got a nack packet, then we're talking to an agent, and we
// parse packet for sequence numbers that need to be resent // need to make sure we have it in our nodeList.
if (matchingNode) {
if (matchingNode) { nodeList->updateNodeWithDataFromPacket(matchingNode, receivedPacket);
OctreeQueryNode* nodeData = (OctreeQueryNode*)matchingNode->getLinkedData();
OctreeQueryNode* nodeData = (OctreeQueryNode*)matchingNode->getLinkedData(); if (nodeData) {
nodeData->parseNackPacket(receivedPacket);
int numBytesPacketHeader = numBytesForPacketHeader(receivedPacket); }
const unsigned char* dataAt = reinterpret_cast<const unsigned char*>(receivedPacket.data()) + numBytesPacketHeader; }
uint16_t numSequenceNumbers = (*(uint16_t*)dataAt);
dataAt += sizeof(uint16_t);
printf("\t received nack packet containing %d seq nums\n", numSequenceNumbers);
// read sequence numbers
for (int i = 0; i < numSequenceNumbers; i++) {
OCTREE_PACKET_SEQUENCE sequenceNumber = (*(OCTREE_PACKET_SEQUENCE*)dataAt);
nodeData->addNackedSequenceNumber(sequenceNumber);
dataAt += sizeof(OCTREE_PACKET_SEQUENCE);
printf("\t seq = %d\n", sequenceNumber);
}
}
} else if (packetType == PacketTypeJurisdictionRequest) { } else if (packetType == PacketTypeJurisdictionRequest) {
_jurisdictionSender->queueReceivedPacket(matchingNode, receivedPacket); _jurisdictionSender->queueReceivedPacket(matchingNode, receivedPacket);
} else if (_octreeInboundPacketProcessor && getOctree()->handlesEditPacketType(packetType)) { } else if (_octreeInboundPacketProcessor && getOctree()->handlesEditPacketType(packetType)) {

View file

@ -21,7 +21,8 @@ SentPacketHistory::SentPacketHistory(int size)
void SentPacketHistory::packetSent(OCTREE_PACKET_SEQUENCE sequenceNumber, const QByteArray& packet) { void SentPacketHistory::packetSent(OCTREE_PACKET_SEQUENCE sequenceNumber, const QByteArray& packet) {
_newestSequenceNumber = sequenceNumber; _newestSequenceNumber = sequenceNumber;
// increment _newestPacketAt cyclically, insert new packet there // increment _newestPacketAt cyclically, insert new packet there.
// this will overwrite the oldest packet in the buffer
_newestPacketAt = (_newestPacketAt == _sentPackets.size() - 1) ? 0 : _newestPacketAt + 1; _newestPacketAt = (_newestPacketAt == _sentPackets.size() - 1) ? 0 : _newestPacketAt + 1;
_sentPackets[_newestPacketAt] = packet; _sentPackets[_newestPacketAt] = packet;
@ -42,4 +43,4 @@ const QByteArray* SentPacketHistory::getPacket(OCTREE_PACKET_SEQUENCE sequenceNu
if (packetAt < 0) { packetAt += _sentPackets.size(); } if (packetAt < 0) { packetAt += _sentPackets.size(); }
return &_sentPackets.at(packetAt); return &_sentPackets.at(packetAt);
} }

View file

@ -25,7 +25,6 @@ public:
const QByteArray* getPacket(OCTREE_PACKET_SEQUENCE sequenceNumber) const; const QByteArray* getPacket(OCTREE_PACKET_SEQUENCE sequenceNumber) const;
private: private:
QVector<QByteArray> _sentPackets; // circular buffer QVector<QByteArray> _sentPackets; // circular buffer
int _newestPacketAt; int _newestPacketAt;
int _numExistingPackets; int _numExistingPackets;

View file

@ -2095,33 +2095,17 @@ void Application::updateMyAvatar(float deltaTime) {
} }
} }
// sent a nack packet containing missing sequence numbers of received packets // sent a nack packet containing missing sequence numbers of received packets
{ {
quint64 now = usecTimestampNow(); quint64 now = usecTimestampNow();
quint64 sinceLastNack = now - _lastNackTime; quint64 sinceLastNack = now - _lastNackTime;
const quint64 TOO_LONG_SINCE_LAST_NACK = 250 * MSECS_PER_SECOND; const quint64 TOO_LONG_SINCE_LAST_NACK = 250 * MSECS_PER_SECOND;
if (sinceLastNack > TOO_LONG_SINCE_LAST_NACK) { if (sinceLastNack > TOO_LONG_SINCE_LAST_NACK) {
_lastNackTime = now; _lastNackTime = now;
sendNack(); sendNack();
}
}
}
/*/ Attempt to identify the sender from it's address.
if (sendingNode) {
QUuid nodeUUID = sendingNode->getUUID();
// now that we know the node ID, let's add these stats to the stats for that node...
_octreeSceneStatsLock.lockForWrite();
if (_octreeServerSceneStats.find(nodeUUID) != _octreeServerSceneStats.end()) {
OctreeSceneStats& stats = _octreeServerSceneStats[nodeUUID];
stats.trackIncomingOctreePacket(packet, wasStatsPacket, sendingNode->getClockSkewUsec());
} }
_octreeSceneStatsLock.unlock();
} }
*/ }
void Application::sendNack() { void Application::sendNack() {
@ -2139,7 +2123,6 @@ void Application::sendNack() {
QUuid nodeUUID = node->getUUID(); QUuid nodeUUID = node->getUUID();
_octreeSceneStatsLock.lockForWrite(); _octreeSceneStatsLock.lockForWrite();
// retreive octree scene stats of this node // retreive octree scene stats of this node
@ -2172,15 +2155,11 @@ void Application::sendNack() {
dataAt += sizeof(uint16_t); dataAt += sizeof(uint16_t);
// pack sequence numbers // pack sequence numbers
//printf("\n\t sending nack...\n");
//printf("\t\t packed %d seq #s:", numSequenceNumbers);
for (int i = 0; i < numSequenceNumbers; i++) { for (int i = 0; i < numSequenceNumbers; i++) {
OCTREE_PACKET_SEQUENCE* sequenceNumberAt = (OCTREE_PACKET_SEQUENCE*)dataAt; OCTREE_PACKET_SEQUENCE* sequenceNumberAt = (OCTREE_PACKET_SEQUENCE*)dataAt;
*sequenceNumberAt = stats.getNextSequenceNumberToNack(); *sequenceNumberAt = stats.getNextSequenceNumberToNack();
dataAt += sizeof(OCTREE_PACKET_SEQUENCE); dataAt += sizeof(OCTREE_PACKET_SEQUENCE);
//printf(" %d,", *sequenceNumberAt);
} }
//printf("\n");
_octreeSceneStatsLock.unlock(); _octreeSceneStatsLock.unlock();
@ -2189,9 +2168,6 @@ void Application::sendNack() {
} }
} }
void Application::queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions) { void Application::queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions) {
// if voxels are disabled, then don't send this at all... // if voxels are disabled, then don't send this at all...

View file

@ -413,8 +413,6 @@ private:
void sendNack(); void sendNack();
MainWindow* _window; MainWindow* _window;
GLCanvas* _glWidget; // our GLCanvas has a couple extra features GLCanvas* _glWidget; // our GLCanvas has a couple extra features
@ -585,7 +583,7 @@ private:
QSystemTrayIcon* _trayIcon; QSystemTrayIcon* _trayIcon;
quint64 _lastNackTime; quint64 _lastNackTime;
}; };
#endif // hifi_Application_h #endif // hifi_Application_h

View file

@ -271,23 +271,6 @@ qint64 LimitedNodeList::writeDatagram(const char* data, qint64 size, const Share
return writeDatagram(QByteArray(data, size), destinationNode, overridenSockAddr); return writeDatagram(QByteArray(data, size), destinationNode, overridenSockAddr);
} }
qint64 LimitedNodeList::writeDatagram2(int seq, const char* data, qint64 size, const SharedNodePointer& destinationNode,
const HifiSockAddr& overridenSockAddr) {
qint64 ret = -1;
if (randFloat() < 0.8f) {
ret = writeDatagram(QByteArray(data, size), destinationNode, overridenSockAddr);
}
else {
printf("dropped packet seq = %d --------------------------\n", seq);
}
return ret;
}
qint64 LimitedNodeList::writeUnverifiedDatagram(const char* data, qint64 size, const SharedNodePointer& destinationNode, qint64 LimitedNodeList::writeUnverifiedDatagram(const char* data, qint64 size, const SharedNodePointer& destinationNode,
const HifiSockAddr& overridenSockAddr) { const HifiSockAddr& overridenSockAddr) {
return writeUnverifiedDatagram(QByteArray(data, size), destinationNode, overridenSockAddr); return writeUnverifiedDatagram(QByteArray(data, size), destinationNode, overridenSockAddr);

View file

@ -72,9 +72,6 @@ public:
qint64 writeDatagram(const char* data, qint64 size, const SharedNodePointer& destinationNode, qint64 writeDatagram(const char* data, qint64 size, const SharedNodePointer& destinationNode,
const HifiSockAddr& overridenSockAddr = HifiSockAddr()); const HifiSockAddr& overridenSockAddr = HifiSockAddr());
qint64 writeDatagram2(int seq, const char* data, qint64 size, const SharedNodePointer& destinationNode,
const HifiSockAddr& overridenSockAddr = HifiSockAddr());
qint64 writeUnverifiedDatagram(const char* data, qint64 size, const SharedNodePointer& destinationNode, qint64 writeUnverifiedDatagram(const char* data, qint64 size, const SharedNodePointer& destinationNode,
const HifiSockAddr& overridenSockAddr = HifiSockAddr()); const HifiSockAddr& overridenSockAddr = HifiSockAddr());

View file

@ -76,7 +76,7 @@ const QSet<PacketType> NON_VERIFIED_PACKETS = QSet<PacketType>()
<< PacketTypeDomainList << PacketTypeDomainListRequest << PacketTypeDomainOAuthRequest << PacketTypeDomainList << PacketTypeDomainListRequest << PacketTypeDomainOAuthRequest
<< PacketTypeCreateAssignment << PacketTypeRequestAssignment << PacketTypeStunResponse << PacketTypeCreateAssignment << PacketTypeRequestAssignment << PacketTypeStunResponse
<< PacketTypeNodeJsonStats << PacketTypeVoxelQuery << PacketTypeParticleQuery << PacketTypeModelQuery << PacketTypeNodeJsonStats << PacketTypeVoxelQuery << PacketTypeParticleQuery << PacketTypeModelQuery
<< PacketTypeOctreeDataNack; << PacketTypeOctreeDataNack;
const int NUM_BYTES_MD5_HASH = 16; const int NUM_BYTES_MD5_HASH = 16;
const int NUM_STATIC_HEADER_BYTES = sizeof(PacketVersion) + NUM_BYTES_RFC4122_UUID; const int NUM_STATIC_HEADER_BYTES = sizeof(PacketVersion) + NUM_BYTES_RFC4122_UUID;

View file

@ -46,7 +46,7 @@ OctreeSceneStats::OctreeSceneStats() :
_incomingReallyLate(0), _incomingReallyLate(0),
_incomingPossibleDuplicate(0), _incomingPossibleDuplicate(0),
_missingSequenceNumbers(), _missingSequenceNumbers(),
_sequenceNumbersToNack(), _sequenceNumbersToNack(),
_incomingFlightTimeAverage(samples), _incomingFlightTimeAverage(samples),
_jurisdictionRoot(NULL) _jurisdictionRoot(NULL)
{ {
@ -159,7 +159,7 @@ void OctreeSceneStats::copyFromOther(const OctreeSceneStats& other) {
_incomingPossibleDuplicate = other._incomingPossibleDuplicate; _incomingPossibleDuplicate = other._incomingPossibleDuplicate;
_missingSequenceNumbers = other._missingSequenceNumbers; _missingSequenceNumbers = other._missingSequenceNumbers;
_sequenceNumbersToNack = other._sequenceNumbersToNack; _sequenceNumbersToNack = other._sequenceNumbersToNack;
} }
@ -928,7 +928,7 @@ void OctreeSceneStats::trackIncomingOctreePacket(const QByteArray& packet,
qDebug() << "found it in _missingSequenceNumbers"; qDebug() << "found it in _missingSequenceNumbers";
} }
_missingSequenceNumbers.remove(sequence); _missingSequenceNumbers.remove(sequence);
_sequenceNumbersToNack.remove(sequence); _sequenceNumbersToNack.remove(sequence);
_incomingLikelyLost--; _incomingLikelyLost--;
_incomingRecovered++; _incomingRecovered++;
} else { } else {
@ -958,7 +958,7 @@ _sequenceNumbersToNack.remove(sequence);
_incomingLikelyLost += missing; _incomingLikelyLost += missing;
for(unsigned int missingSequence = expected; missingSequence < sequence; missingSequence++) { for(unsigned int missingSequence = expected; missingSequence < sequence; missingSequence++) {
_missingSequenceNumbers << missingSequence; _missingSequenceNumbers << missingSequence;
_sequenceNumbersToNack << missingSequence; _sequenceNumbersToNack << missingSequence;
} }
} }
} }
@ -986,7 +986,7 @@ _sequenceNumbersToNack << missingSequence;
qDebug() << "pruning really old missing sequence:" << missingItem; qDebug() << "pruning really old missing sequence:" << missingItem;
} }
_missingSequenceNumbers.remove(missingItem); _missingSequenceNumbers.remove(missingItem);
_sequenceNumbersToNack.remove(missingItem); _sequenceNumbersToNack.remove(missingItem);
} }
} }
} }
@ -1002,4 +1002,4 @@ uint16_t OctreeSceneStats::getNextSequenceNumberToNack() {
uint16_t sequenceNumber = *it; uint16_t sequenceNumber = *it;
_sequenceNumbersToNack.remove(sequenceNumber); _sequenceNumbersToNack.remove(sequenceNumber);
return sequenceNumber; return sequenceNumber;
} }

View file

@ -16,6 +16,7 @@
#include <NodeList.h> #include <NodeList.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include "JurisdictionMap.h" #include "JurisdictionMap.h"
#include "OctreePacketData.h"
#define GREENISH 0x40ff40d0 #define GREENISH 0x40ff40d0
#define YELLOWISH 0xffef40c0 #define YELLOWISH 0xffef40c0
@ -172,8 +173,8 @@ public:
quint32 getIncomingPossibleDuplicate() const { return _incomingPossibleDuplicate; } quint32 getIncomingPossibleDuplicate() const { return _incomingPossibleDuplicate; }
float getIncomingFlightTimeAverage() { return _incomingFlightTimeAverage.getAverage(); } float getIncomingFlightTimeAverage() { return _incomingFlightTimeAverage.getAverage(); }
int getNumSequenceNumbersToNack() const; int getNumSequenceNumbersToNack() const;
uint16_t getNextSequenceNumberToNack(); OCTREE_PACKET_SEQUENCE getNextSequenceNumberToNack();
private: private:
@ -275,8 +276,8 @@ private:
quint32 _incomingLate; /// out of order later 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 _incomingReallyLate; /// out of order and later than MAX_MISSING_SEQUENCE_OLD_AGE late
quint32 _incomingPossibleDuplicate; /// out of order possibly a duplicate quint32 _incomingPossibleDuplicate; /// out of order possibly a duplicate
QSet<uint16_t> _missingSequenceNumbers; QSet<OCTREE_PACKET_SEQUENCE> _missingSequenceNumbers;
QSet<uint16_t> _sequenceNumbersToNack; QSet<OCTREE_PACKET_SEQUENCE> _sequenceNumbersToNack;
SimpleMovingAverage _incomingFlightTimeAverage; SimpleMovingAverage _incomingFlightTimeAverage;
// features related items // features related items