mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 18:56:55 +02:00
started work on sending nack packets from client
This commit is contained in:
parent
5461a06e99
commit
8cd5ec3b54
5 changed files with 85 additions and 3 deletions
|
@ -288,12 +288,12 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
|
||||||
|
|
||||||
int OctreeSendThread::resendNackedPackets(OctreeQueryNode* nodeData) {
|
int OctreeSendThread::resendNackedPackets(OctreeQueryNode* nodeData) {
|
||||||
|
|
||||||
const int maxPacketsSent = 10;
|
const int MAX_PACKETS_RESEND = 10;
|
||||||
|
|
||||||
int packetsSent = 0;
|
int packetsSent = 0;
|
||||||
|
|
||||||
const QByteArray* packet;
|
const QByteArray* packet;
|
||||||
while (nodeData->hasNextNackedPacket() && packetsSent < maxPacketsSent) {
|
while (nodeData->hasNextNackedPacket() && packetsSent < MAX_PACKETS_RESEND) {
|
||||||
packet = nodeData->getNextNackedPacket();
|
packet = nodeData->getNextNackedPacket();
|
||||||
// packet will be NULL if it's not in nodeData's packet history
|
// packet will be NULL if it's not in nodeData's packet history
|
||||||
if (packet) {
|
if (packet) {
|
||||||
|
|
|
@ -167,7 +167,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
_applicationOverlay(),
|
_applicationOverlay(),
|
||||||
_runningScriptsWidget(new RunningScriptsWidget(_window)),
|
_runningScriptsWidget(new RunningScriptsWidget(_window)),
|
||||||
_runningScriptsWidgetWasVisible(false),
|
_runningScriptsWidgetWasVisible(false),
|
||||||
_trayIcon(new QSystemTrayIcon(_window))
|
_trayIcon(new QSystemTrayIcon(_window)),
|
||||||
|
_lastNackTime(usecTimestampNow())
|
||||||
{
|
{
|
||||||
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
||||||
QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
|
QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
|
||||||
|
@ -2091,7 +2092,63 @@ void Application::updateMyAvatar(float deltaTime) {
|
||||||
_lastQueriedViewFrustum = _viewFrustum;
|
_lastQueriedViewFrustum = _viewFrustum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sent a nack packet containing missing sequence numbers of received packets
|
||||||
|
{
|
||||||
|
quint64 now = usecTimestampNow();
|
||||||
|
quint64 sinceLastNack = now - _lastNackTime;
|
||||||
|
const quint64 TOO_LONG_SINCE_LAST_NACK = 100 * MSECS_PER_SECOND;
|
||||||
|
if (sinceLastNack > TOO_LONG_SINCE_LAST_NACK) {
|
||||||
|
_lastNackTime = now;
|
||||||
|
|
||||||
|
//_octreeServerSceneStats-
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Application::sendNack() {
|
||||||
|
/*
|
||||||
|
// 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();
|
||||||
|
*/
|
||||||
|
|
||||||
|
char packet[MAX_PACKET_SIZE];
|
||||||
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
|
// iterates thru all nodes in NodeList
|
||||||
|
foreach(const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
|
||||||
|
|
||||||
|
char* dataAt = packet;
|
||||||
|
int bytesRemaining = MAX_PACKET_SIZE;
|
||||||
|
|
||||||
|
int numBytesPacketHeader = populatePacketHeader(packet, PacketTypeOctreeDataNack, node->getUUID());
|
||||||
|
dataAt += numBytesPacketHeader;
|
||||||
|
bytesRemaining -= numBytesPacketHeader;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t numSequenceNumbers;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
OctreeSceneStats& stats = _octreeServerSceneStats[node->getUUID()];
|
||||||
|
int numSequenceNumbersAvailable = stats.getNumSequenceNumberToNack();
|
||||||
|
|
||||||
|
|
||||||
|
// make sure we still have an active socket
|
||||||
|
nodeList->writeUnverifiedDatagram(reinterpret_cast<const char*>(queryPacket), packetLength, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Application::queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions) {
|
void Application::queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions) {
|
||||||
|
|
||||||
|
|
|
@ -411,6 +411,10 @@ private:
|
||||||
static void attachNewHeadToNode(Node *newNode);
|
static void attachNewHeadToNode(Node *newNode);
|
||||||
static void* networkReceive(void* args); // network receive thread
|
static void* networkReceive(void* args); // network receive thread
|
||||||
|
|
||||||
|
void sendNack();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MainWindow* _window;
|
MainWindow* _window;
|
||||||
GLCanvas* _glWidget; // our GLCanvas has a couple extra features
|
GLCanvas* _glWidget; // our GLCanvas has a couple extra features
|
||||||
|
|
||||||
|
@ -580,6 +584,8 @@ private:
|
||||||
bool _runningScriptsWidgetWasVisible;
|
bool _runningScriptsWidgetWasVisible;
|
||||||
|
|
||||||
QSystemTrayIcon* _trayIcon;
|
QSystemTrayIcon* _trayIcon;
|
||||||
|
|
||||||
|
quint64 _lastNackTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Application_h
|
#endif // hifi_Application_h
|
||||||
|
|
|
@ -46,6 +46,7 @@ OctreeSceneStats::OctreeSceneStats() :
|
||||||
_incomingReallyLate(0),
|
_incomingReallyLate(0),
|
||||||
_incomingPossibleDuplicate(0),
|
_incomingPossibleDuplicate(0),
|
||||||
_missingSequenceNumbers(),
|
_missingSequenceNumbers(),
|
||||||
|
_sequenceNumbersToNack(),
|
||||||
_incomingFlightTimeAverage(samples),
|
_incomingFlightTimeAverage(samples),
|
||||||
_jurisdictionRoot(NULL)
|
_jurisdictionRoot(NULL)
|
||||||
{
|
{
|
||||||
|
@ -158,6 +159,7 @@ void OctreeSceneStats::copyFromOther(const OctreeSceneStats& other) {
|
||||||
_incomingPossibleDuplicate = other._incomingPossibleDuplicate;
|
_incomingPossibleDuplicate = other._incomingPossibleDuplicate;
|
||||||
|
|
||||||
_missingSequenceNumbers = other._missingSequenceNumbers;
|
_missingSequenceNumbers = other._missingSequenceNumbers;
|
||||||
|
_missingSequenceNumbersToNack = other._missingSequenceNumbersToNack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -926,6 +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);
|
||||||
_incomingLikelyLost--;
|
_incomingLikelyLost--;
|
||||||
_incomingRecovered++;
|
_incomingRecovered++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -955,6 +958,7 @@ void OctreeSceneStats::trackIncomingOctreePacket(const QByteArray& packet,
|
||||||
_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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -982,9 +986,20 @@ void OctreeSceneStats::trackIncomingOctreePacket(const QByteArray& packet,
|
||||||
qDebug() << "pruning really old missing sequence:" << missingItem;
|
qDebug() << "pruning really old missing sequence:" << missingItem;
|
||||||
}
|
}
|
||||||
_missingSequenceNumbers.remove(missingItem);
|
_missingSequenceNumbers.remove(missingItem);
|
||||||
|
_sequenceNumbersToNack.remove(missingItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OctreeSceneStats::getNumSequenceNumberToNack() const {
|
||||||
|
return _sequenceNumbersToNack.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t OctreeSceneStats::getNextSequenceNumberToNack() {
|
||||||
|
QSet<uint16_t>::Iterator it = _sequenceNumbersToNack.begin();
|
||||||
|
uint16_t sequenceNumber = *it;
|
||||||
|
_sequenceNumbersToNack.remove(sequenceNumber);
|
||||||
|
return sequenceNumber;
|
||||||
|
}
|
|
@ -172,6 +172,9 @@ public:
|
||||||
quint32 getIncomingPossibleDuplicate() const { return _incomingPossibleDuplicate; }
|
quint32 getIncomingPossibleDuplicate() const { return _incomingPossibleDuplicate; }
|
||||||
float getIncomingFlightTimeAverage() { return _incomingFlightTimeAverage.getAverage(); }
|
float getIncomingFlightTimeAverage() { return _incomingFlightTimeAverage.getAverage(); }
|
||||||
|
|
||||||
|
bool getNumSequenceNumberToNack() const;
|
||||||
|
uint16_t getNextSequenceNumberToNack();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void copyFromOther(const OctreeSceneStats& other);
|
void copyFromOther(const OctreeSceneStats& other);
|
||||||
|
@ -273,6 +276,7 @@ private:
|
||||||
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<uint16_t> _missingSequenceNumbers;
|
||||||
|
QSet<uint16_t> _sequenceNumbersToNack;
|
||||||
SimpleMovingAverage _incomingFlightTimeAverage;
|
SimpleMovingAverage _incomingFlightTimeAverage;
|
||||||
|
|
||||||
// features related items
|
// features related items
|
||||||
|
|
Loading…
Reference in a new issue