mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 00:08:53 +02:00
collect packet rate stats in NodeList
This commit is contained in:
parent
40fa4bfbd2
commit
8dbe4dfdde
3 changed files with 40 additions and 6 deletions
|
@ -369,12 +369,20 @@ void AudioMixer::sendStatsPacket() {
|
||||||
statsObject["average_mixes_per_listener"] = 0.0;
|
statsObject["average_mixes_per_listener"] = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
|
float packetsPerSecond, bytesPerSecond;
|
||||||
|
nodeList->getPacketStats(packetsPerSecond, bytesPerSecond);
|
||||||
|
nodeList->resetPacketStats();
|
||||||
|
|
||||||
|
statsObject["packets_per_second"] = packetsPerSecond;
|
||||||
|
statsObject["bytes_per_second"] = bytesPerSecond;
|
||||||
|
|
||||||
_sumListeners = 0;
|
_sumListeners = 0;
|
||||||
_sumMixes = 0;
|
_sumMixes = 0;
|
||||||
_numStatFrames = 0;
|
_numStatFrames = 0;
|
||||||
|
|
||||||
NodeList::getInstance()->sendStatsToDomainServer(statsObject);
|
nodeList->sendStatsToDomainServer(statsObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioMixer::run() {
|
void AudioMixer::run() {
|
||||||
|
|
|
@ -69,7 +69,10 @@ NodeList::NodeList(char newOwnerType, unsigned short int newSocketListenPort) :
|
||||||
_assignmentServerSocket(),
|
_assignmentServerSocket(),
|
||||||
_publicSockAddr(),
|
_publicSockAddr(),
|
||||||
_hasCompletedInitialSTUNFailure(false),
|
_hasCompletedInitialSTUNFailure(false),
|
||||||
_stunRequestsSinceSuccess(0)
|
_stunRequestsSinceSuccess(0),
|
||||||
|
_numCollectedPackets(0),
|
||||||
|
_numCollectedBytes(0),
|
||||||
|
_packetStatTimer()
|
||||||
{
|
{
|
||||||
_nodeSocket.bind(QHostAddress::AnyIPv4, newSocketListenPort);
|
_nodeSocket.bind(QHostAddress::AnyIPv4, newSocketListenPort);
|
||||||
qDebug() << "NodeList socket is listening on" << _nodeSocket.localPort();
|
qDebug() << "NodeList socket is listening on" << _nodeSocket.localPort();
|
||||||
|
@ -79,6 +82,8 @@ NodeList::NodeList(char newOwnerType, unsigned short int newSocketListenPort) :
|
||||||
|
|
||||||
// clear our NodeList when logout is requested
|
// clear our NodeList when logout is requested
|
||||||
connect(&AccountManager::getInstance(), &AccountManager::logoutComplete , this, &NodeList::reset);
|
connect(&AccountManager::getInstance(), &AccountManager::logoutComplete , this, &NodeList::reset);
|
||||||
|
|
||||||
|
_packetStatTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NodeList::packetVersionAndHashMatch(const QByteArray& packet) {
|
bool NodeList::packetVersionAndHashMatch(const QByteArray& packet) {
|
||||||
|
@ -161,7 +166,11 @@ qint64 NodeList::writeDatagram(const QByteArray& datagram, const HifiSockAddr& d
|
||||||
|
|
||||||
// setup the MD5 hash for source verification in the header
|
// setup the MD5 hash for source verification in the header
|
||||||
replaceHashInPacketGivenConnectionUUID(datagramCopy, connectionSecret);
|
replaceHashInPacketGivenConnectionUUID(datagramCopy, connectionSecret);
|
||||||
|
|
||||||
|
// stat collection for packets
|
||||||
|
++_numCollectedPackets;
|
||||||
|
_numCollectedBytes += datagram.size();
|
||||||
|
|
||||||
return _nodeSocket.writeDatagram(datagramCopy, destinationSockAddr.getAddress(), destinationSockAddr.getPort());
|
return _nodeSocket.writeDatagram(datagramCopy, destinationSockAddr.getAddress(), destinationSockAddr.getPort());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -854,6 +863,17 @@ SharedNodePointer NodeList::soloNodeOfType(char nodeType) {
|
||||||
return SharedNodePointer();
|
return SharedNodePointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodeList::getPacketStats(float& packetsPerSecond, float& bytesPerSecond) {
|
||||||
|
packetsPerSecond = _numCollectedPackets / (float) (_packetStatTimer.elapsed() / 1000.0f);
|
||||||
|
bytesPerSecond = _numCollectedBytes / (float) (_packetStatTimer.elapsed() / 1000.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeList::resetPacketStats() {
|
||||||
|
_numCollectedPackets = 0;
|
||||||
|
_numCollectedBytes = 0;
|
||||||
|
_packetStatTimer.restart();
|
||||||
|
}
|
||||||
|
|
||||||
void NodeList::removeSilentNodes() {
|
void NodeList::removeSilentNodes() {
|
||||||
|
|
||||||
_nodeHashMutex.lock();
|
_nodeHashMutex.lock();
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <unistd.h> // not on windows, not needed for mac or windows
|
#include <unistd.h> // not on windows, not needed for mac or windows
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QtCore/QElapsedTimer>
|
||||||
#include <QtCore/QMutex>
|
#include <QtCore/QMutex>
|
||||||
#include <QtCore/QSet>
|
#include <QtCore/QSet>
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
|
@ -120,6 +121,9 @@ public:
|
||||||
unsigned broadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes);
|
unsigned broadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes);
|
||||||
SharedNodePointer soloNodeOfType(char nodeType);
|
SharedNodePointer soloNodeOfType(char nodeType);
|
||||||
|
|
||||||
|
void getPacketStats(float &packetsPerSecond, float &bytesPerSecond);
|
||||||
|
void resetPacketStats();
|
||||||
|
|
||||||
void loadData(QSettings* settings);
|
void loadData(QSettings* settings);
|
||||||
void saveData(QSettings* settings);
|
void saveData(QSettings* settings);
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -155,6 +159,8 @@ private:
|
||||||
|
|
||||||
void processDomainServerAuthRequest(const QByteArray& packet);
|
void processDomainServerAuthRequest(const QByteArray& packet);
|
||||||
void requestAuthForDomainServer();
|
void requestAuthForDomainServer();
|
||||||
|
void activateSocketFromNodeCommunication(const QByteArray& packet, const SharedNodePointer& sendingNode);
|
||||||
|
void timePingReply(const QByteArray& packet, const SharedNodePointer& sendingNode);
|
||||||
|
|
||||||
NodeHash _nodeHash;
|
NodeHash _nodeHash;
|
||||||
QMutex _nodeHashMutex;
|
QMutex _nodeHashMutex;
|
||||||
|
@ -168,9 +174,9 @@ private:
|
||||||
HifiSockAddr _publicSockAddr;
|
HifiSockAddr _publicSockAddr;
|
||||||
bool _hasCompletedInitialSTUNFailure;
|
bool _hasCompletedInitialSTUNFailure;
|
||||||
unsigned int _stunRequestsSinceSuccess;
|
unsigned int _stunRequestsSinceSuccess;
|
||||||
|
int _numCollectedPackets;
|
||||||
void activateSocketFromNodeCommunication(const QByteArray& packet, const SharedNodePointer& sendingNode);
|
int _numCollectedBytes;
|
||||||
void timePingReply(const QByteArray& packet, const SharedNodePointer& sendingNode);
|
QElapsedTimer _packetStatTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__hifi__NodeList__) */
|
#endif /* defined(__hifi__NodeList__) */
|
||||||
|
|
Loading…
Reference in a new issue