mirror of
https://github.com/lubosz/overte.git
synced 2025-08-15 04:39:30 +02:00
Move node received bandwidth tracking to LimitedNodeList
This commit is contained in:
parent
473a7e9593
commit
b5e2913eb9
5 changed files with 12 additions and 25 deletions
|
@ -845,7 +845,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
||||||
QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>();
|
QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>();
|
||||||
connect(nodeList.data(), &LimitedNodeList::dataSent,
|
connect(nodeList.data(), &LimitedNodeList::dataSent,
|
||||||
bandwidthRecorder.data(), &BandwidthRecorder::updateOutboundData);
|
bandwidthRecorder.data(), &BandwidthRecorder::updateOutboundData);
|
||||||
connect(&nodeList->getPacketReceiver(), &PacketReceiver::dataReceived,
|
connect(nodeList.data(), &LimitedNodeList::dataReceived,
|
||||||
bandwidthRecorder.data(), &BandwidthRecorder::updateInboundData);
|
bandwidthRecorder.data(), &BandwidthRecorder::updateInboundData);
|
||||||
|
|
||||||
// FIXME -- I'm a little concerned about this.
|
// FIXME -- I'm a little concerned about this.
|
||||||
|
|
|
@ -175,7 +175,11 @@ QUdpSocket& LimitedNodeList::getDTLSSocket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LimitedNodeList::isPacketVerified(const udt::Packet& packet) {
|
bool LimitedNodeList::isPacketVerified(const udt::Packet& packet) {
|
||||||
return packetVersionMatch(packet) && packetSourceAndHashMatch(packet);
|
// We track bandwidth when doing packet verification to avoid needing to do a node lookup
|
||||||
|
// later when we already do it in packetSourceAndHashMatchAndTrackBandwidth. A node lookup
|
||||||
|
// incurs a lock, so it is ideal to avoid needing to do it 2+ times for each packet
|
||||||
|
// received.
|
||||||
|
return packetVersionMatch(packet) && packetSourceAndHashMatchAndTrackBandwidth(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LimitedNodeList::packetVersionMatch(const udt::Packet& packet) {
|
bool LimitedNodeList::packetVersionMatch(const udt::Packet& packet) {
|
||||||
|
@ -224,11 +228,12 @@ bool LimitedNodeList::packetVersionMatch(const udt::Packet& packet) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LimitedNodeList::packetSourceAndHashMatch(const udt::Packet& packet) {
|
bool LimitedNodeList::packetSourceAndHashMatchAndTrackBandwidth(const udt::Packet& packet) {
|
||||||
|
|
||||||
PacketType headerType = NLPacket::typeInHeader(packet);
|
PacketType headerType = NLPacket::typeInHeader(packet);
|
||||||
|
|
||||||
if (NON_SOURCED_PACKETS.contains(headerType)) {
|
if (NON_SOURCED_PACKETS.contains(headerType)) {
|
||||||
|
emit dataReceived(NodeType::Unassigned, packet.getPayloadSize());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
QUuid sourceID = NLPacket::sourceIDInHeader(packet);
|
QUuid sourceID = NLPacket::sourceIDInHeader(packet);
|
||||||
|
@ -260,6 +265,8 @@ bool LimitedNodeList::packetSourceAndHashMatch(const udt::Packet& packet) {
|
||||||
// from this sending node
|
// from this sending node
|
||||||
matchingNode->setLastHeardMicrostamp(usecTimestampNow());
|
matchingNode->setLastHeardMicrostamp(usecTimestampNow());
|
||||||
|
|
||||||
|
emit dataReceived(matchingNode->getType(), packet.getPayloadSize());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -243,6 +243,7 @@ public slots:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataSent(quint8 channelType, int bytes);
|
void dataSent(quint8 channelType, int bytes);
|
||||||
|
void dataReceived(quint8 channelType, int bytes);
|
||||||
|
|
||||||
// QUuid might be zero for non-sourced packet types.
|
// QUuid might be zero for non-sourced packet types.
|
||||||
void packetVersionMismatch(PacketType type, const HifiSockAddr& senderSockAddr, const QUuid& senderUUID);
|
void packetVersionMismatch(PacketType type, const HifiSockAddr& senderSockAddr, const QUuid& senderUUID);
|
||||||
|
@ -279,7 +280,7 @@ protected:
|
||||||
|
|
||||||
void setLocalSocket(const HifiSockAddr& sockAddr);
|
void setLocalSocket(const HifiSockAddr& sockAddr);
|
||||||
|
|
||||||
bool packetSourceAndHashMatch(const udt::Packet& packet);
|
bool packetSourceAndHashMatchAndTrackBandwidth(const udt::Packet& packet);
|
||||||
void processSTUNResponse(std::unique_ptr<udt::BasePacket> packet);
|
void processSTUNResponse(std::unique_ptr<udt::BasePacket> packet);
|
||||||
|
|
||||||
void handleNodeKill(const SharedNodePointer& node);
|
void handleNodeKill(const SharedNodePointer& node);
|
||||||
|
|
|
@ -215,15 +215,6 @@ void PacketReceiver::handleVerifiedPacket(std::unique_ptr<udt::Packet> packet) {
|
||||||
_inPacketCount += 1;
|
_inPacketCount += 1;
|
||||||
_inByteCount += nlPacket->size();
|
_inByteCount += nlPacket->size();
|
||||||
|
|
||||||
SharedNodePointer matchingNode;
|
|
||||||
NodeType_t nodeType = NodeType::Unassigned;
|
|
||||||
if (!nlPacket->getSourceID().isNull()) {
|
|
||||||
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
|
||||||
matchingNode = nodeList->nodeWithUUID(nlPacket->getSourceID());
|
|
||||||
nodeType = matchingNode->getType();
|
|
||||||
}
|
|
||||||
emit dataReceived(nodeType, nlPacket->getPayloadSize());
|
|
||||||
|
|
||||||
handleVerifiedMessage(receivedMessage, true);
|
handleVerifiedMessage(receivedMessage, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,15 +224,6 @@ void PacketReceiver::handleVerifiedMessagePacket(std::unique_ptr<udt::Packet> pa
|
||||||
_inPacketCount += 1;
|
_inPacketCount += 1;
|
||||||
_inByteCount += nlPacket->size();
|
_inByteCount += nlPacket->size();
|
||||||
|
|
||||||
SharedNodePointer matchingNode;
|
|
||||||
NodeType_t nodeType = NodeType::Unassigned;
|
|
||||||
if (!nlPacket->getSourceID().isNull()) {
|
|
||||||
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
|
||||||
matchingNode = nodeList->nodeWithUUID(nlPacket->getSourceID());
|
|
||||||
nodeType = matchingNode->getType();
|
|
||||||
}
|
|
||||||
emit dataReceived(nodeType, nlPacket->getPayloadSize());
|
|
||||||
|
|
||||||
auto key = std::pair<HifiSockAddr, udt::Packet::MessageNumber>(nlPacket->getSenderSockAddr(), nlPacket->getMessageNumber());
|
auto key = std::pair<HifiSockAddr, udt::Packet::MessageNumber>(nlPacket->getSenderSockAddr(), nlPacket->getMessageNumber());
|
||||||
auto it = _pendingMessages.find(key);
|
auto it = _pendingMessages.find(key);
|
||||||
QSharedPointer<ReceivedMessage> message;
|
QSharedPointer<ReceivedMessage> message;
|
||||||
|
|
|
@ -67,9 +67,6 @@ public:
|
||||||
void handleVerifiedPacket(std::unique_ptr<udt::Packet> packet);
|
void handleVerifiedPacket(std::unique_ptr<udt::Packet> packet);
|
||||||
void handleVerifiedMessagePacket(std::unique_ptr<udt::Packet> message);
|
void handleVerifiedMessagePacket(std::unique_ptr<udt::Packet> message);
|
||||||
void handleMessageFailure(HifiSockAddr from, udt::Packet::MessageNumber messageNumber);
|
void handleMessageFailure(HifiSockAddr from, udt::Packet::MessageNumber messageNumber);
|
||||||
|
|
||||||
signals:
|
|
||||||
void dataReceived(quint8 channelType, int bytes);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Listener {
|
struct Listener {
|
||||||
|
|
Loading…
Reference in a new issue