mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 06:37:27 +02:00
Short local source IDs - checkpoint
DS assigns 16-bit IDs as well as UUIDs; ACs track mappings; nodes use short IDs in packets. Initial setup works; then fails prob. due to DS UUID.
This commit is contained in:
parent
4ec77e3af6
commit
d3464378b7
16 changed files with 91 additions and 58 deletions
|
@ -842,7 +842,7 @@ void AssetServer::handleAssetUpload(QSharedPointer<ReceivedMessage> message, Sha
|
||||||
|
|
||||||
|
|
||||||
if (canWriteToAssetServer) {
|
if (canWriteToAssetServer) {
|
||||||
qCDebug(asset_server) << "Starting an UploadAssetTask for upload from" << uuidStringWithoutCurlyBraces(message->getSourceID());
|
qCDebug(asset_server) << "Starting an UploadAssetTask for upload from" << message->getSourceID();
|
||||||
|
|
||||||
auto task = new UploadAssetTask(message, senderNode, _filesDirectory, _filesizeLimit);
|
auto task = new UploadAssetTask(message, senderNode, _filesDirectory, _filesizeLimit);
|
||||||
_transferTaskPool.start(task);
|
_transferTaskPool.start(task);
|
||||||
|
|
|
@ -118,7 +118,11 @@ void AudioMixer::queueReplicatedAudioPacket(QSharedPointer<ReceivedMessage> mess
|
||||||
// make sure we have a replicated node for the original sender of the packet
|
// make sure we have a replicated node for the original sender of the packet
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
|
||||||
QUuid nodeID = QUuid::fromRfc4122(message->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
|
QUuid nodeID;
|
||||||
|
SharedNodePointer sourceNode = nodeList->nodeWithLocalID(message->getSourceID());
|
||||||
|
if (sourceNode) {
|
||||||
|
nodeID = sourceNode->getUUID();
|
||||||
|
}
|
||||||
|
|
||||||
auto replicatedNode = nodeList->addOrUpdateNode(nodeID, NodeType::Agent,
|
auto replicatedNode = nodeList->addOrUpdateNode(nodeID, NodeType::Agent,
|
||||||
message->getSenderSockAddr(), message->getSenderSockAddr(),
|
message->getSenderSockAddr(), message->getSenderSockAddr(),
|
||||||
|
@ -136,7 +140,7 @@ void AudioMixer::queueReplicatedAudioPacket(QSharedPointer<ReceivedMessage> mess
|
||||||
|
|
||||||
auto replicatedMessage = QSharedPointer<ReceivedMessage>::create(audioData, rewrittenType,
|
auto replicatedMessage = QSharedPointer<ReceivedMessage>::create(audioData, rewrittenType,
|
||||||
versionForPacketType(rewrittenType),
|
versionForPacketType(rewrittenType),
|
||||||
message->getSenderSockAddr(), nodeID);
|
message->getSenderSockAddr(), message->getSourceID());
|
||||||
|
|
||||||
getOrCreateClientData(replicatedNode.data())->queuePacket(replicatedMessage, replicatedNode);
|
getOrCreateClientData(replicatedNode.data())->queuePacket(replicatedMessage, replicatedNode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,8 +112,12 @@ void AvatarMixer::handleReplicatedPacket(QSharedPointer<ReceivedMessage> message
|
||||||
void AvatarMixer::handleReplicatedBulkAvatarPacket(QSharedPointer<ReceivedMessage> message) {
|
void AvatarMixer::handleReplicatedBulkAvatarPacket(QSharedPointer<ReceivedMessage> message) {
|
||||||
while (message->getBytesLeftToRead()) {
|
while (message->getBytesLeftToRead()) {
|
||||||
// first, grab the node ID for this replicated avatar
|
// first, grab the node ID for this replicated avatar
|
||||||
auto nodeID = QUuid::fromRfc4122(message->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
|
QUuid nodeID;
|
||||||
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
SharedNodePointer sourceNode = nodeList->nodeWithLocalID(message->getSourceID());
|
||||||
|
if (sourceNode) {
|
||||||
|
nodeID = sourceNode->getUUID();
|
||||||
|
}
|
||||||
// make sure we have an upstream replicated node that matches
|
// make sure we have an upstream replicated node that matches
|
||||||
auto replicatedNode = addOrUpdateReplicatedNode(nodeID, message->getSenderSockAddr());
|
auto replicatedNode = addOrUpdateReplicatedNode(nodeID, message->getSenderSockAddr());
|
||||||
|
|
||||||
|
@ -127,7 +131,7 @@ void AvatarMixer::handleReplicatedBulkAvatarPacket(QSharedPointer<ReceivedMessag
|
||||||
// construct a "fake" avatar data received message from the byte array and packet list information
|
// construct a "fake" avatar data received message from the byte array and packet list information
|
||||||
auto replicatedMessage = QSharedPointer<ReceivedMessage>::create(avatarByteArray, PacketType::AvatarData,
|
auto replicatedMessage = QSharedPointer<ReceivedMessage>::create(avatarByteArray, PacketType::AvatarData,
|
||||||
versionForPacketType(PacketType::AvatarData),
|
versionForPacketType(PacketType::AvatarData),
|
||||||
message->getSenderSockAddr(), nodeID);
|
message->getSenderSockAddr(), message->getSourceID());
|
||||||
|
|
||||||
// queue up the replicated avatar data with the client data for the replicated node
|
// queue up the replicated avatar data with the client data for the replicated node
|
||||||
auto start = usecTimestampNow();
|
auto start = usecTimestampNow();
|
||||||
|
|
|
@ -524,9 +524,10 @@ SharedNodePointer DomainGatekeeper::addVerifiedNodeFromConnectRequest(const Node
|
||||||
|
|
||||||
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
|
||||||
|
Node::LocalID newLocalID = findOrCreateLocalID(nodeID);
|
||||||
SharedNodePointer newNode = limitedNodeList->addOrUpdateNode(nodeID, nodeConnection.nodeType,
|
SharedNodePointer newNode = limitedNodeList->addOrUpdateNode(nodeID, nodeConnection.nodeType,
|
||||||
nodeConnection.publicSockAddr, nodeConnection.localSockAddr);
|
nodeConnection.publicSockAddr, nodeConnection.localSockAddr,
|
||||||
newNode->setLocalID(findOrCreateLocalID(nodeID));
|
newLocalID);
|
||||||
|
|
||||||
// So that we can send messages to this node at will - we need to activate the correct socket on this node now
|
// So that we can send messages to this node at will - we need to activate the correct socket on this node now
|
||||||
newNode->activateMatchingOrNewSymmetricSocket(discoveredSocket);
|
newNode->activateMatchingOrNewSymmetricSocket(discoveredSocket);
|
||||||
|
|
|
@ -593,8 +593,9 @@ bool DomainServer::isPacketVerified(const udt::Packet& packet) {
|
||||||
|
|
||||||
if (!PacketTypeEnum::getNonSourcedPackets().contains(headerType)) {
|
if (!PacketTypeEnum::getNonSourcedPackets().contains(headerType)) {
|
||||||
// this is a sourced packet - first check if we have a node that matches
|
// this is a sourced packet - first check if we have a node that matches
|
||||||
QUuid sourceID = NLPacket::sourceIDInHeader(packet);
|
//QUuid sourceID = NLPacket::sourceIDInHeader(packet);
|
||||||
SharedNodePointer sourceNode = nodeList->nodeWithUUID(sourceID);
|
Node::LocalID localSourceID = NLPacket::sourceIDInHeader(packet);
|
||||||
|
SharedNodePointer sourceNode = nodeList->nodeWithLocalID(localSourceID);
|
||||||
|
|
||||||
if (sourceNode) {
|
if (sourceNode) {
|
||||||
// unverified DS packets (due to a lack of connection secret between DS + node)
|
// unverified DS packets (due to a lack of connection secret between DS + node)
|
||||||
|
@ -616,17 +617,17 @@ bool DomainServer::isPacketVerified(const udt::Packet& packet) {
|
||||||
= LogHandler::getInstance().addRepeatedMessageRegex(UNKNOWN_REGEX);
|
= LogHandler::getInstance().addRepeatedMessageRegex(UNKNOWN_REGEX);
|
||||||
|
|
||||||
qDebug() << "Packet of type" << headerType
|
qDebug() << "Packet of type" << headerType
|
||||||
<< "received from unmatched IP for UUID" << uuidStringWithoutCurlyBraces(sourceID);
|
<< "received from unmatched IP for UUID" << uuidStringWithoutCurlyBraces(sourceNode->getUUID());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
static const QString UNKNOWN_REGEX = "Packet of type \\d+ \\([\\sa-zA-Z:]+\\) received from unknown node with UUID";
|
static const QString UNKNOWN_REGEX = "Packet of type \\d+ \\([\\sa-zA-Z:]+\\) received from unknown node with Local ID";
|
||||||
static QString repeatedMessage
|
static QString repeatedMessage
|
||||||
= LogHandler::getInstance().addRepeatedMessageRegex(UNKNOWN_REGEX);
|
= LogHandler::getInstance().addRepeatedMessageRegex(UNKNOWN_REGEX);
|
||||||
|
|
||||||
qDebug() << "Packet of type" << headerType
|
qDebug() << "Packet of type" << headerType
|
||||||
<< "received from unknown node with UUID" << uuidStringWithoutCurlyBraces(sourceID);
|
<< "received from unknown node with Local ID" << localSourceID;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3203,13 +3204,12 @@ void DomainServer::processNodeDisconnectRequestPacket(QSharedPointer<ReceivedMes
|
||||||
// This packet has been matched to a source node and they're asking not to be in the domain anymore
|
// This packet has been matched to a source node and they're asking not to be in the domain anymore
|
||||||
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
|
||||||
const QUuid& nodeUUID = message->getSourceID();
|
auto localID = message->getSourceID();
|
||||||
|
qDebug() << "Received a disconnect request from node with local ID" << localID;
|
||||||
qDebug() << "Received a disconnect request from node with UUID" << nodeUUID;
|
|
||||||
|
|
||||||
// we want to check what type this node was before going to kill it so that we can avoid sending the RemovedNode
|
// we want to check what type this node was before going to kill it so that we can avoid sending the RemovedNode
|
||||||
// packet to nodes that don't care about this type
|
// packet to nodes that don't care about this type
|
||||||
auto nodeToKill = limitedNodeList->nodeWithUUID(nodeUUID);
|
auto nodeToKill = limitedNodeList->nodeWithLocalID(localID);
|
||||||
|
|
||||||
if (nodeToKill) {
|
if (nodeToKill) {
|
||||||
handleKillNode(nodeToKill);
|
handleKillNode(nodeToKill);
|
||||||
|
@ -3477,7 +3477,7 @@ void DomainServer::handleDomainContentReplacementFromURLRequest(QSharedPointer<R
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainServer::handleOctreeFileReplacementRequest(QSharedPointer<ReceivedMessage> message) {
|
void DomainServer::handleOctreeFileReplacementRequest(QSharedPointer<ReceivedMessage> message) {
|
||||||
auto node = DependencyManager::get<NodeList>()->nodeWithUUID(message->getSourceID());
|
auto node = DependencyManager::get<NodeList>()->nodeWithLocalID(message->getSourceID());
|
||||||
if (node->getCanReplaceContent()) {
|
if (node->getCanReplaceContent()) {
|
||||||
handleOctreeFileReplacement(message->readAll());
|
handleOctreeFileReplacement(message->readAll());
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,8 +120,8 @@ int InboundAudioStream::parseData(ReceivedMessage& message) {
|
||||||
// parse sequence number and track it
|
// parse sequence number and track it
|
||||||
quint16 sequence;
|
quint16 sequence;
|
||||||
message.readPrimitive(&sequence);
|
message.readPrimitive(&sequence);
|
||||||
SequenceNumberStats::ArrivalInfo arrivalInfo = _incomingSequenceNumberStats.sequenceNumberReceived(sequence,
|
SequenceNumberStats::ArrivalInfo arrivalInfo = _incomingSequenceNumberStats.sequenceNumberReceived(sequence, QUuid() // TBD
|
||||||
message.getSourceID());
|
/*message.getSourceID()*/);
|
||||||
QString codecInPacket = message.readString();
|
QString codecInPacket = message.readString();
|
||||||
|
|
||||||
packetReceivedUpdateTimingStats();
|
packetReceivedUpdateTimingStats();
|
||||||
|
@ -186,7 +186,7 @@ int InboundAudioStream::parseData(ReceivedMessage& message) {
|
||||||
_mismatchedAudioCodecCount = 0;
|
_mismatchedAudioCodecCount = 0;
|
||||||
|
|
||||||
// inform others of the mismatch
|
// inform others of the mismatch
|
||||||
auto sendingNode = DependencyManager::get<NodeList>()->nodeWithUUID(message.getSourceID());
|
auto sendingNode = DependencyManager::get<NodeList>()->nodeWithLocalID(message.getSourceID());
|
||||||
if (sendingNode) {
|
if (sendingNode) {
|
||||||
emit mismatchedAudioCodec(sendingNode, _selectedCodecName, codecInPacket);
|
emit mismatchedAudioCodec(sendingNode, _selectedCodecName, codecInPacket);
|
||||||
qDebug(audio) << "Codec mismatch threshold exceeded, SelectedAudioFormat(" << _selectedCodecName << " ) sent";
|
qDebug(audio) << "Codec mismatch threshold exceeded, SelectedAudioFormat(" << _selectedCodecName << " ) sent";
|
||||||
|
|
|
@ -238,7 +238,9 @@ bool LimitedNodeList::packetVersionMatch(const udt::Packet& packet) {
|
||||||
senderString = QString("%1:%2").arg(senderSockAddr.getAddress().toString()).arg(senderSockAddr.getPort());
|
senderString = QString("%1:%2").arg(senderSockAddr.getAddress().toString()).arg(senderSockAddr.getPort());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sourceID = NLPacket::sourceIDInHeader(packet);
|
SharedNodePointer sourceNode = nodeWithLocalID(NLPacket::sourceIDInHeader(packet));
|
||||||
|
if (sourceNode) {
|
||||||
|
sourceID = sourceNode->getUUID();
|
||||||
|
|
||||||
hasBeenOutput = sourcedVersionDebugSuppressMap.contains(sourceID, headerType);
|
hasBeenOutput = sourcedVersionDebugSuppressMap.contains(sourceID, headerType);
|
||||||
|
|
||||||
|
@ -247,6 +249,7 @@ bool LimitedNodeList::packetVersionMatch(const udt::Packet& packet) {
|
||||||
senderString = uuidStringWithoutCurlyBraces(sourceID.toString());
|
senderString = uuidStringWithoutCurlyBraces(sourceID.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!hasBeenOutput) {
|
if (!hasBeenOutput) {
|
||||||
qCDebug(networking) << "Packet version mismatch on" << headerType << "- Sender"
|
qCDebug(networking) << "Packet version mismatch on" << headerType << "- Sender"
|
||||||
|
@ -302,15 +305,18 @@ bool LimitedNodeList::packetSourceAndHashMatchAndTrackBandwidth(const udt::Packe
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QUuid sourceID = NLPacket::sourceIDInHeader(packet);
|
|
||||||
|
|
||||||
// check if we were passed a sourceNode hint or if we need to look it up
|
// check if we were passed a sourceNode hint or if we need to look it up
|
||||||
if (!sourceNode) {
|
if (!sourceNode) {
|
||||||
// figure out which node this is from
|
// figure out which node this is from
|
||||||
SharedNodePointer matchingNode = nodeWithUUID(sourceID);
|
NLPacket::LocalID sourceLocalID = NLPacket::sourceIDInHeader(packet);
|
||||||
|
|
||||||
|
SharedNodePointer matchingNode = nodeWithLocalID(sourceLocalID);
|
||||||
sourceNode = matchingNode.data();
|
sourceNode = matchingNode.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUuid sourceID = sourceNode->getUUID();
|
||||||
|
|
||||||
if (!sourceNode &&
|
if (!sourceNode &&
|
||||||
sourceID == getDomainUUID() &&
|
sourceID == getDomainUUID() &&
|
||||||
packet.getSenderSockAddr() == getDomainSockAddr() &&
|
packet.getSenderSockAddr() == getDomainSockAddr() &&
|
||||||
|
@ -374,7 +380,7 @@ void LimitedNodeList::collectPacketStats(const NLPacket& packet) {
|
||||||
|
|
||||||
void LimitedNodeList::fillPacketHeader(const NLPacket& packet, const QUuid& connectionSecret) {
|
void LimitedNodeList::fillPacketHeader(const NLPacket& packet, const QUuid& connectionSecret) {
|
||||||
if (!PacketTypeEnum::getNonSourcedPackets().contains(packet.getType())) {
|
if (!PacketTypeEnum::getNonSourcedPackets().contains(packet.getType())) {
|
||||||
packet.writeSourceID(getSessionUUID());
|
packet.writeSourceID(getSessionLocalID());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connectionSecret.isNull()
|
if (!connectionSecret.isNull()
|
||||||
|
@ -557,6 +563,16 @@ SharedNodePointer LimitedNodeList::nodeWithUUID(const QUuid& nodeUUID) {
|
||||||
return it == _nodeHash.cend() ? SharedNodePointer() : it->second;
|
return it == _nodeHash.cend() ? SharedNodePointer() : it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SharedNodePointer LimitedNodeList::nodeWithLocalID(Node::LocalID localID) const {
|
||||||
|
QReadLocker readLocker(&_nodeMutex);
|
||||||
|
|
||||||
|
LocalIDMapping::const_iterator idIter = _localIDMap.find(localID);
|
||||||
|
if (idIter == _localIDMap.cend()) {
|
||||||
|
qCDebug(networking) << "No such Node with local ID " << localID;
|
||||||
|
}
|
||||||
|
return idIter == _localIDMap.cend() ? nullptr : idIter->second;
|
||||||
|
}
|
||||||
|
|
||||||
void LimitedNodeList::eraseAllNodes() {
|
void LimitedNodeList::eraseAllNodes() {
|
||||||
QSet<SharedNodePointer> killedNodes;
|
QSet<SharedNodePointer> killedNodes;
|
||||||
|
|
||||||
|
@ -565,6 +581,8 @@ void LimitedNodeList::eraseAllNodes() {
|
||||||
// and then remove them from the hash
|
// and then remove them from the hash
|
||||||
QWriteLocker writeLocker(&_nodeMutex);
|
QWriteLocker writeLocker(&_nodeMutex);
|
||||||
|
|
||||||
|
_localIDMap.erase(_localIDMap.begin(), _localIDMap.end());
|
||||||
|
|
||||||
if (_nodeHash.size() > 0) {
|
if (_nodeHash.size() > 0) {
|
||||||
qCDebug(networking) << "LimitedNodeList::eraseAllNodes() removing all nodes from NodeList.";
|
qCDebug(networking) << "LimitedNodeList::eraseAllNodes() removing all nodes from NodeList.";
|
||||||
|
|
||||||
|
@ -630,7 +648,7 @@ void LimitedNodeList::handleNodeKill(const SharedNodePointer& node) {
|
||||||
|
|
||||||
SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType,
|
SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType,
|
||||||
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
|
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
|
||||||
bool isReplicated, bool isUpstream,
|
Node::LocalID localID, bool isReplicated, bool isUpstream,
|
||||||
const QUuid& connectionSecret, const NodePermissions& permissions) {
|
const QUuid& connectionSecret, const NodePermissions& permissions) {
|
||||||
QReadLocker readLocker(&_nodeMutex);
|
QReadLocker readLocker(&_nodeMutex);
|
||||||
NodeHash::const_iterator it = _nodeHash.find(uuid);
|
NodeHash::const_iterator it = _nodeHash.find(uuid);
|
||||||
|
@ -644,6 +662,7 @@ SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t
|
||||||
matchingNode->setConnectionSecret(connectionSecret);
|
matchingNode->setConnectionSecret(connectionSecret);
|
||||||
matchingNode->setIsReplicated(isReplicated);
|
matchingNode->setIsReplicated(isReplicated);
|
||||||
matchingNode->setIsUpstream(isUpstream || NodeType::isUpstream(nodeType));
|
matchingNode->setIsUpstream(isUpstream || NodeType::isUpstream(nodeType));
|
||||||
|
matchingNode->setLocalID(localID);
|
||||||
|
|
||||||
return matchingNode;
|
return matchingNode;
|
||||||
} else {
|
} else {
|
||||||
|
@ -653,6 +672,7 @@ SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t
|
||||||
newNode->setIsUpstream(isUpstream || NodeType::isUpstream(nodeType));
|
newNode->setIsUpstream(isUpstream || NodeType::isUpstream(nodeType));
|
||||||
newNode->setConnectionSecret(connectionSecret);
|
newNode->setConnectionSecret(connectionSecret);
|
||||||
newNode->setPermissions(permissions);
|
newNode->setPermissions(permissions);
|
||||||
|
newNode->setLocalID(localID);
|
||||||
|
|
||||||
// move the newly constructed node to the LNL thread
|
// move the newly constructed node to the LNL thread
|
||||||
newNode->moveToThread(thread());
|
newNode->moveToThread(thread());
|
||||||
|
@ -693,6 +713,7 @@ SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t
|
||||||
#else
|
#else
|
||||||
_nodeHash.emplace(newNode->getUUID(), newNodePointer);
|
_nodeHash.emplace(newNode->getUUID(), newNodePointer);
|
||||||
#endif
|
#endif
|
||||||
|
_localIDMap.emplace(localID, newNodePointer);
|
||||||
readLocker.unlock();
|
readLocker.unlock();
|
||||||
|
|
||||||
qCDebug(networking) << "Added" << *newNode;
|
qCDebug(networking) << "Added" << *newNode;
|
||||||
|
|
|
@ -157,10 +157,11 @@ public:
|
||||||
size_t size() const { QReadLocker readLock(&_nodeMutex); return _nodeHash.size(); }
|
size_t size() const { QReadLocker readLock(&_nodeMutex); return _nodeHash.size(); }
|
||||||
|
|
||||||
SharedNodePointer nodeWithUUID(const QUuid& nodeUUID);
|
SharedNodePointer nodeWithUUID(const QUuid& nodeUUID);
|
||||||
|
SharedNodePointer nodeWithLocalID(Node::LocalID localID) const;
|
||||||
|
|
||||||
SharedNodePointer addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType,
|
SharedNodePointer addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType,
|
||||||
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
|
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
|
||||||
bool isReplicated = false, bool isUpstream = false,
|
Node::LocalID localID = 0, bool isReplicated = false, bool isUpstream = false,
|
||||||
const QUuid& connectionSecret = QUuid(),
|
const QUuid& connectionSecret = QUuid(),
|
||||||
const NodePermissions& permissions = DEFAULT_AGENT_PERMISSIONS);
|
const NodePermissions& permissions = DEFAULT_AGENT_PERMISSIONS);
|
||||||
|
|
||||||
|
@ -429,6 +430,8 @@ private slots:
|
||||||
private:
|
private:
|
||||||
mutable QReadWriteLock _sessionUUIDLock;
|
mutable QReadWriteLock _sessionUUIDLock;
|
||||||
QUuid _sessionUUID;
|
QUuid _sessionUUID;
|
||||||
|
using LocalIDMapping = std::unordered_map<Node::LocalID, SharedNodePointer>;
|
||||||
|
LocalIDMapping _localIDMap;
|
||||||
Node::LocalID _sessionLocalID { 0 };
|
Node::LocalID _sessionLocalID { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
int NLPacket::localHeaderSize(PacketType type) {
|
int NLPacket::localHeaderSize(PacketType type) {
|
||||||
bool nonSourced = PacketTypeEnum::getNonSourcedPackets().contains(type);
|
bool nonSourced = PacketTypeEnum::getNonSourcedPackets().contains(type);
|
||||||
bool nonVerified = PacketTypeEnum::getNonVerifiedPackets().contains(type);
|
bool nonVerified = PacketTypeEnum::getNonVerifiedPackets().contains(type);
|
||||||
qint64 optionalSize = (nonSourced ? 0 : NUM_BYTES_RFC4122_UUID) + ((nonSourced || nonVerified) ? 0 : NUM_BYTES_MD5_HASH);
|
qint64 optionalSize = (nonSourced ? 0 : NUM_BYTES_LOCALID) + ((nonSourced || nonVerified) ? 0 : NUM_BYTES_MD5_HASH);
|
||||||
return sizeof(PacketType) + sizeof(PacketVersion) + optionalSize;
|
return sizeof(PacketType) + sizeof(PacketVersion) + optionalSize;
|
||||||
}
|
}
|
||||||
int NLPacket::totalHeaderSize(PacketType type, bool isPartOfMessage) {
|
int NLPacket::totalHeaderSize(PacketType type, bool isPartOfMessage) {
|
||||||
|
@ -139,13 +139,14 @@ PacketVersion NLPacket::versionInHeader(const udt::Packet& packet) {
|
||||||
return *reinterpret_cast<const PacketVersion*>(packet.getData() + headerOffset + sizeof(PacketType));
|
return *reinterpret_cast<const PacketVersion*>(packet.getData() + headerOffset + sizeof(PacketType));
|
||||||
}
|
}
|
||||||
|
|
||||||
QUuid NLPacket::sourceIDInHeader(const udt::Packet& packet) {
|
NLPacket::LocalID NLPacket::sourceIDInHeader(const udt::Packet& packet) {
|
||||||
int offset = Packet::totalHeaderSize(packet.isPartOfMessage()) + sizeof(PacketType) + sizeof(PacketVersion);
|
int offset = Packet::totalHeaderSize(packet.isPartOfMessage()) + sizeof(PacketType) + sizeof(PacketVersion);
|
||||||
return QUuid::fromRfc4122(QByteArray::fromRawData(packet.getData() + offset, NUM_BYTES_RFC4122_UUID));
|
return *reinterpret_cast<const LocalID*>(packet.getData() + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray NLPacket::verificationHashInHeader(const udt::Packet& packet) {
|
QByteArray NLPacket::verificationHashInHeader(const udt::Packet& packet) {
|
||||||
int offset = Packet::totalHeaderSize(packet.isPartOfMessage()) + sizeof(PacketType) + sizeof(PacketVersion) + NUM_BYTES_RFC4122_UUID;
|
int offset = Packet::totalHeaderSize(packet.isPartOfMessage()) + sizeof(PacketType) +
|
||||||
|
sizeof(PacketVersion) + NUM_BYTES_LOCALID;
|
||||||
return QByteArray(packet.getData() + offset, NUM_BYTES_MD5_HASH);
|
return QByteArray(packet.getData() + offset, NUM_BYTES_MD5_HASH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +154,7 @@ QByteArray NLPacket::hashForPacketAndSecret(const udt::Packet& packet, const QUu
|
||||||
QCryptographicHash hash(QCryptographicHash::Md5);
|
QCryptographicHash hash(QCryptographicHash::Md5);
|
||||||
|
|
||||||
int offset = Packet::totalHeaderSize(packet.isPartOfMessage()) + sizeof(PacketType) + sizeof(PacketVersion)
|
int offset = Packet::totalHeaderSize(packet.isPartOfMessage()) + sizeof(PacketType) + sizeof(PacketVersion)
|
||||||
+ NUM_BYTES_RFC4122_UUID + NUM_BYTES_MD5_HASH;
|
+ NUM_BYTES_LOCALID + NUM_BYTES_MD5_HASH;
|
||||||
|
|
||||||
// add the packet payload and the connection UUID
|
// add the packet payload and the connection UUID
|
||||||
hash.addData(packet.getData() + offset, packet.getDataSize() - offset);
|
hash.addData(packet.getData() + offset, packet.getDataSize() - offset);
|
||||||
|
@ -203,11 +204,12 @@ void NLPacket::readSourceID() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NLPacket::writeSourceID(const QUuid& sourceID) const {
|
void NLPacket::writeSourceID(LocalID sourceID) const {
|
||||||
Q_ASSERT(!PacketTypeEnum::getNonSourcedPackets().contains(_type));
|
Q_ASSERT(!PacketTypeEnum::getNonSourcedPackets().contains(_type));
|
||||||
|
|
||||||
auto offset = Packet::totalHeaderSize(isPartOfMessage()) + sizeof(PacketType) + sizeof(PacketVersion);
|
auto offset = Packet::totalHeaderSize(isPartOfMessage()) + sizeof(PacketType) + sizeof(PacketVersion);
|
||||||
memcpy(_packet.get() + offset, sourceID.toRfc4122().constData(), NUM_BYTES_RFC4122_UUID);
|
|
||||||
|
memcpy(_packet.get() + offset, &sourceID, sizeof(sourceID));
|
||||||
|
|
||||||
_sourceID = sourceID;
|
_sourceID = sourceID;
|
||||||
}
|
}
|
||||||
|
@ -217,7 +219,7 @@ void NLPacket::writeVerificationHashGivenSecret(const QUuid& connectionSecret) c
|
||||||
!PacketTypeEnum::getNonVerifiedPackets().contains(_type));
|
!PacketTypeEnum::getNonVerifiedPackets().contains(_type));
|
||||||
|
|
||||||
auto offset = Packet::totalHeaderSize(isPartOfMessage()) + sizeof(PacketType) + sizeof(PacketVersion)
|
auto offset = Packet::totalHeaderSize(isPartOfMessage()) + sizeof(PacketType) + sizeof(PacketVersion)
|
||||||
+ NUM_BYTES_RFC4122_UUID;
|
+ NUM_BYTES_LOCALID;
|
||||||
QByteArray verificationHash = hashForPacketAndSecret(*this, connectionSecret);
|
QByteArray verificationHash = hashForPacketAndSecret(*this, connectionSecret);
|
||||||
|
|
||||||
memcpy(_packet.get() + offset, verificationHash.data(), verificationHash.size());
|
memcpy(_packet.get() + offset, verificationHash.data(), verificationHash.size());
|
||||||
|
|
|
@ -43,10 +43,12 @@ public:
|
||||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
||||||
// NLPacket Header Format
|
// NLPacket Header Format
|
||||||
|
|
||||||
|
using LocalID = qint16;
|
||||||
|
static const int NUM_BYTES_LOCALID = sizeof(LocalID);
|
||||||
// this is used by the Octree classes - must be known at compile time
|
// this is used by the Octree classes - must be known at compile time
|
||||||
static const int MAX_PACKET_HEADER_SIZE =
|
static const int MAX_PACKET_HEADER_SIZE =
|
||||||
sizeof(udt::Packet::SequenceNumberAndBitField) + sizeof(udt::Packet::MessageNumberAndBitField) +
|
sizeof(udt::Packet::SequenceNumberAndBitField) + sizeof(udt::Packet::MessageNumberAndBitField) +
|
||||||
sizeof(PacketType) + sizeof(PacketVersion) + NUM_BYTES_RFC4122_UUID + NUM_BYTES_MD5_HASH;
|
sizeof(PacketType) + sizeof(PacketVersion) + NUM_BYTES_LOCALID + NUM_BYTES_MD5_HASH;
|
||||||
|
|
||||||
static std::unique_ptr<NLPacket> create(PacketType type, qint64 size = -1,
|
static std::unique_ptr<NLPacket> create(PacketType type, qint64 size = -1,
|
||||||
bool isReliable = false, bool isPartOfMessage = false, PacketVersion version = 0);
|
bool isReliable = false, bool isPartOfMessage = false, PacketVersion version = 0);
|
||||||
|
@ -69,7 +71,7 @@ public:
|
||||||
static PacketType typeInHeader(const udt::Packet& packet);
|
static PacketType typeInHeader(const udt::Packet& packet);
|
||||||
static PacketVersion versionInHeader(const udt::Packet& packet);
|
static PacketVersion versionInHeader(const udt::Packet& packet);
|
||||||
|
|
||||||
static QUuid sourceIDInHeader(const udt::Packet& packet);
|
static LocalID sourceIDInHeader(const udt::Packet& packet);
|
||||||
static QByteArray verificationHashInHeader(const udt::Packet& packet);
|
static QByteArray verificationHashInHeader(const udt::Packet& packet);
|
||||||
static QByteArray hashForPacketAndSecret(const udt::Packet& packet, const QUuid& connectionSecret);
|
static QByteArray hashForPacketAndSecret(const udt::Packet& packet, const QUuid& connectionSecret);
|
||||||
|
|
||||||
|
@ -79,9 +81,9 @@ public:
|
||||||
PacketVersion getVersion() const { return _version; }
|
PacketVersion getVersion() const { return _version; }
|
||||||
void setVersion(PacketVersion version);
|
void setVersion(PacketVersion version);
|
||||||
|
|
||||||
const QUuid& getSourceID() const { return _sourceID; }
|
LocalID getSourceID() const { return _sourceID; }
|
||||||
|
|
||||||
void writeSourceID(const QUuid& sourceID) const;
|
void writeSourceID(qint16 sourceID) const;
|
||||||
void writeVerificationHashGivenSecret(const QUuid& connectionSecret) const;
|
void writeVerificationHashGivenSecret(const QUuid& connectionSecret) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -106,7 +108,7 @@ protected:
|
||||||
|
|
||||||
PacketType _type;
|
PacketType _type;
|
||||||
PacketVersion _version;
|
PacketVersion _version;
|
||||||
mutable QUuid _sourceID;
|
mutable LocalID _sourceID;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_NLPacket_h
|
#endif // hifi_NLPacket_h
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
bool isReliable = false, bool isOrdered = false);
|
bool isReliable = false, bool isOrdered = false);
|
||||||
|
|
||||||
PacketVersion getVersion() const { return _packetVersion; }
|
PacketVersion getVersion() const { return _packetVersion; }
|
||||||
const QUuid& getSourceID() const { return _sourceID; }
|
NLPacket::LocalID getSourceID() const { return _sourceID; }
|
||||||
|
|
||||||
qint64 getMaxSegmentSize() const override { return NLPacket::maxPayloadSize(_packetType, _isOrdered); }
|
qint64 getMaxSegmentSize() const override { return NLPacket::maxPayloadSize(_packetType, _isOrdered); }
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ private:
|
||||||
|
|
||||||
|
|
||||||
PacketVersion _packetVersion;
|
PacketVersion _packetVersion;
|
||||||
QUuid _sourceID;
|
NLPacket::LocalID _sourceID;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QSharedPointer<NLPacketList>)
|
Q_DECLARE_METATYPE(QSharedPointer<NLPacketList>)
|
||||||
|
|
|
@ -659,9 +659,8 @@ void NodeList::parseNodeFromPacketStream(QDataStream& packetStream) {
|
||||||
|
|
||||||
packetStream >> connectionSecretUUID;
|
packetStream >> connectionSecretUUID;
|
||||||
|
|
||||||
SharedNodePointer node = addOrUpdateNode(nodeUUID, nodeType, nodePublicSocket,
|
SharedNodePointer node = addOrUpdateNode(nodeUUID, nodeType, nodePublicSocket, nodeLocalSocket,
|
||||||
nodeLocalSocket, isReplicated, false, connectionSecretUUID, permissions);
|
sessionLocalID, isReplicated, false, connectionSecretUUID, permissions);
|
||||||
node->setLocalID(sessionLocalID);
|
|
||||||
|
|
||||||
// nodes that are downstream or upstream of our own type are kept alive when we hear about them from the domain server
|
// nodes that are downstream or upstream of our own type are kept alive when we hear about them from the domain server
|
||||||
// and always have their public socket as their active socket
|
// and always have their public socket as their active socket
|
||||||
|
|
|
@ -261,10 +261,7 @@ void PacketReceiver::handleVerifiedMessage(QSharedPointer<ReceivedMessage> recei
|
||||||
|
|
||||||
SharedNodePointer matchingNode;
|
SharedNodePointer matchingNode;
|
||||||
|
|
||||||
if (!receivedMessage->getSourceID().isNull()) {
|
matchingNode = nodeList->nodeWithLocalID(receivedMessage->getSourceID());
|
||||||
matchingNode = nodeList->nodeWithUUID(receivedMessage->getSourceID());
|
|
||||||
}
|
|
||||||
|
|
||||||
QMutexLocker packetListenerLocker(&_packetListenerLock);
|
QMutexLocker packetListenerLocker(&_packetListenerLock);
|
||||||
|
|
||||||
auto it = _messageListenerMap.find(receivedMessage->getType());
|
auto it = _messageListenerMap.find(receivedMessage->getType());
|
||||||
|
|
|
@ -43,7 +43,7 @@ ReceivedMessage::ReceivedMessage(NLPacket& packet)
|
||||||
}
|
}
|
||||||
|
|
||||||
ReceivedMessage::ReceivedMessage(QByteArray byteArray, PacketType packetType, PacketVersion packetVersion,
|
ReceivedMessage::ReceivedMessage(QByteArray byteArray, PacketType packetType, PacketVersion packetVersion,
|
||||||
const HifiSockAddr& senderSockAddr, QUuid sourceID) :
|
const HifiSockAddr& senderSockAddr, NLPacket::LocalID sourceID) :
|
||||||
_data(byteArray),
|
_data(byteArray),
|
||||||
_headData(_data.mid(0, HEAD_DATA_SIZE)),
|
_headData(_data.mid(0, HEAD_DATA_SIZE)),
|
||||||
_numPackets(1),
|
_numPackets(1),
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
ReceivedMessage(const NLPacketList& packetList);
|
ReceivedMessage(const NLPacketList& packetList);
|
||||||
ReceivedMessage(NLPacket& packet);
|
ReceivedMessage(NLPacket& packet);
|
||||||
ReceivedMessage(QByteArray byteArray, PacketType packetType, PacketVersion packetVersion,
|
ReceivedMessage(QByteArray byteArray, PacketType packetType, PacketVersion packetVersion,
|
||||||
const HifiSockAddr& senderSockAddr, QUuid sourceID = QUuid());
|
const HifiSockAddr& senderSockAddr, NLPacket::LocalID sourceID = 0);
|
||||||
|
|
||||||
QByteArray getMessage() const { return _data; }
|
QByteArray getMessage() const { return _data; }
|
||||||
const char* getRawMessage() const { return _data.constData(); }
|
const char* getRawMessage() const { return _data.constData(); }
|
||||||
|
@ -40,7 +40,7 @@ public:
|
||||||
bool failed() const { return _failed; }
|
bool failed() const { return _failed; }
|
||||||
bool isComplete() const { return _isComplete; }
|
bool isComplete() const { return _isComplete; }
|
||||||
|
|
||||||
const QUuid& getSourceID() const { return _sourceID; }
|
NLPacket::LocalID getSourceID() const { return _sourceID; }
|
||||||
const HifiSockAddr& getSenderSockAddr() { return _senderSockAddr; }
|
const HifiSockAddr& getSenderSockAddr() { return _senderSockAddr; }
|
||||||
|
|
||||||
qint64 getPosition() const { return _position; }
|
qint64 getPosition() const { return _position; }
|
||||||
|
@ -93,7 +93,7 @@ private:
|
||||||
std::atomic<qint64> _position { 0 };
|
std::atomic<qint64> _position { 0 };
|
||||||
std::atomic<qint64> _numPackets { 0 };
|
std::atomic<qint64> _numPackets { 0 };
|
||||||
|
|
||||||
QUuid _sourceID;
|
NLPacket::LocalID _sourceID;
|
||||||
PacketType _packetType;
|
PacketType _packetType;
|
||||||
PacketVersion _packetVersion;
|
PacketVersion _packetVersion;
|
||||||
HifiSockAddr _senderSockAddr;
|
HifiSockAddr _senderSockAddr;
|
||||||
|
|
|
@ -96,7 +96,7 @@ void OctreeProcessor::processDatagram(ReceivedMessage& message, SharedNodePointe
|
||||||
quint64 totalUncompress = 0;
|
quint64 totalUncompress = 0;
|
||||||
quint64 totalReadBitsteam = 0;
|
quint64 totalReadBitsteam = 0;
|
||||||
|
|
||||||
const QUuid& sourceUUID = message.getSourceID();
|
const QUuid& sourceUUID = sourceNode->getUUID();
|
||||||
|
|
||||||
int subsection = 1;
|
int subsection = 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue