mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
Merge branch 'packet-tests' of github.com:birarda/hifi into receive_packets
Conflicts: libraries/networking/src/udt/Packet.h
This commit is contained in:
commit
12d5ec89d1
28 changed files with 145 additions and 81 deletions
|
@ -65,9 +65,9 @@ void Agent::handleOctreePacket(QSharedPointer<NLPacket> packet, SharedNodePointe
|
||||||
if (packetType == PacketType::OctreeStats) {
|
if (packetType == PacketType::OctreeStats) {
|
||||||
|
|
||||||
int statsMessageLength = OctreeHeadlessViewer::parseOctreeStats(packet, senderNode);
|
int statsMessageLength = OctreeHeadlessViewer::parseOctreeStats(packet, senderNode);
|
||||||
if (packet->getSizeUsed() > statsMessageLength) {
|
if (packet->getPayloadSize() > statsMessageLength) {
|
||||||
// pull out the piggybacked packet and create a new QSharedPointer<NLPacket> for it
|
// pull out the piggybacked packet and create a new QSharedPointer<NLPacket> for it
|
||||||
int piggyBackedSizeWithHeader = packet->getSizeUsed() - statsMessageLength;
|
int piggyBackedSizeWithHeader = packet->getPayloadSize() - statsMessageLength;
|
||||||
|
|
||||||
std::unique_ptr<char> buffer = std::unique_ptr<char>(new char[piggyBackedSizeWithHeader]);
|
std::unique_ptr<char> buffer = std::unique_ptr<char>(new char[piggyBackedSizeWithHeader]);
|
||||||
memcpy(buffer.get(), packet->getPayload() + statsMessageLength, piggyBackedSizeWithHeader);
|
memcpy(buffer.get(), packet->getPayload() + statsMessageLength, piggyBackedSizeWithHeader);
|
||||||
|
|
|
@ -552,9 +552,9 @@ void AudioMixer::handleMuteEnvironmentPacket(QSharedPointer<NLPacket> packet, Sh
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
|
||||||
if (sendingNode->getCanAdjustLocks()) {
|
if (sendingNode->getCanAdjustLocks()) {
|
||||||
auto newPacket = NLPacket::create(PacketType::MuteEnvironment, packet->getSizeUsed());
|
auto newPacket = NLPacket::create(PacketType::MuteEnvironment, packet->getPayloadSize());
|
||||||
// Copy payload
|
// Copy payload
|
||||||
newPacket->write(packet->getPayload(), packet->getSizeUsed());
|
newPacket->write(packet->getPayload(), packet->getPayloadSize());
|
||||||
|
|
||||||
nodeList->eachNode([&](const SharedNodePointer& node){
|
nodeList->eachNode([&](const SharedNodePointer& node){
|
||||||
if (node->getType() == NodeType::Agent && node->getActiveSocket() &&
|
if (node->getType() == NodeType::Agent && node->getActiveSocket() &&
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
int AvatarMixerClientData::parseData(NLPacket& packet) {
|
int AvatarMixerClientData::parseData(NLPacket& packet) {
|
||||||
// compute the offset to the data payload
|
// compute the offset to the data payload
|
||||||
return _avatar.parseDataFromBuffer(QByteArray::fromRawData(packet.getPayload(), packet.getSizeUsed()));
|
return _avatar.parseDataFromBuffer(QByteArray::fromRawData(packet.getPayload(), packet.getPayloadSize()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AvatarMixerClientData::checkAndSetHasReceivedFirstPackets() {
|
bool AvatarMixerClientData::checkAndSetHasReceivedFirstPackets() {
|
||||||
|
|
|
@ -108,7 +108,7 @@ int EntityServer::sendSpecialPackets(const SharedNodePointer& node, OctreeQueryN
|
||||||
|
|
||||||
queryNode->packetSent(*specialPacket);
|
queryNode->packetSent(*specialPacket);
|
||||||
|
|
||||||
totalBytes += specialPacket->getSizeWithHeader();
|
totalBytes += specialPacket->getDataSize();
|
||||||
packetsSent++;
|
packetsSent++;
|
||||||
|
|
||||||
DependencyManager::get<NodeList>()->sendPacket(std::move(specialPacket), *node);
|
DependencyManager::get<NodeList>()->sendPacket(std::move(specialPacket), *node);
|
||||||
|
|
|
@ -85,7 +85,7 @@ void OctreeInboundPacketProcessor::processPacket(QSharedPointer<NLPacket> packet
|
||||||
if (debugProcessPacket) {
|
if (debugProcessPacket) {
|
||||||
qDebug("OctreeInboundPacketProcessor::processPacket() payload=%p payloadLength=%lld",
|
qDebug("OctreeInboundPacketProcessor::processPacket() payload=%p payloadLength=%lld",
|
||||||
packet->getPayload(),
|
packet->getPayload(),
|
||||||
packet->getSizeUsed());
|
packet->getPayloadSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ask our tree subclass if it can handle the incoming packet...
|
// Ask our tree subclass if it can handle the incoming packet...
|
||||||
|
@ -117,7 +117,7 @@ void OctreeInboundPacketProcessor::processPacket(QSharedPointer<NLPacket> packet
|
||||||
|
|
||||||
if (debugProcessPacket || _myServer->wantsDebugReceiving()) {
|
if (debugProcessPacket || _myServer->wantsDebugReceiving()) {
|
||||||
qDebug() << "PROCESSING THREAD: got '" << packetType << "' packet - " << _receivedPacketCount << " command from client";
|
qDebug() << "PROCESSING THREAD: got '" << packetType << "' packet - " << _receivedPacketCount << " command from client";
|
||||||
qDebug() << " receivedBytes=" << packet->getSizeWithHeader();
|
qDebug() << " receivedBytes=" << packet->getDataSize();
|
||||||
qDebug() << " sequence=" << sequence;
|
qDebug() << " sequence=" << sequence;
|
||||||
qDebug() << " sentAt=" << sentAt << " usecs";
|
qDebug() << " sentAt=" << sentAt << " usecs";
|
||||||
qDebug() << " arrivedAt=" << arrivedAt << " usecs";
|
qDebug() << " arrivedAt=" << arrivedAt << " usecs";
|
||||||
|
@ -135,7 +135,8 @@ void OctreeInboundPacketProcessor::processPacket(QSharedPointer<NLPacket> packet
|
||||||
|
|
||||||
if (debugProcessPacket) {
|
if (debugProcessPacket) {
|
||||||
qDebug() << " atByte (in payload)=" << packet->pos();
|
qDebug() << " atByte (in payload)=" << packet->pos();
|
||||||
qDebug() << " payload size=" << packet->getSizeUsed();
|
qDebug() << " payload size=" << packet->getPayloadSize();
|
||||||
|
|
||||||
if (!packet->bytesLeftToRead()) {
|
if (!packet->bytesLeftToRead()) {
|
||||||
qDebug() << " ----- UNEXPECTED ---- got a packet without any edit details!!!! --------";
|
qDebug() << " ----- UNEXPECTED ---- got a packet without any edit details!!!! --------";
|
||||||
}
|
}
|
||||||
|
@ -154,7 +155,7 @@ void OctreeInboundPacketProcessor::processPacket(QSharedPointer<NLPacket> packet
|
||||||
qDebug() << " maxSize=" << maxSize;
|
qDebug() << " maxSize=" << maxSize;
|
||||||
qDebug("OctreeInboundPacketProcessor::processPacket() %c "
|
qDebug("OctreeInboundPacketProcessor::processPacket() %c "
|
||||||
"payload=%p payloadLength=%lld editData=%p payloadPosition=%lld maxSize=%d",
|
"payload=%p payloadLength=%lld editData=%p payloadPosition=%lld maxSize=%d",
|
||||||
packetType, packet->getPayload(), packet->getSizeUsed(), editData,
|
packetType, packet->getPayload(), packet->getPayloadSize(), editData,
|
||||||
packet->pos(), maxSize);
|
packet->pos(), maxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +185,7 @@ void OctreeInboundPacketProcessor::processPacket(QSharedPointer<NLPacket> packet
|
||||||
if (debugProcessPacket) {
|
if (debugProcessPacket) {
|
||||||
qDebug() << " editDataBytesRead=" << editDataBytesRead;
|
qDebug() << " editDataBytesRead=" << editDataBytesRead;
|
||||||
qDebug() << " AFTER processEditPacketData payload position=" << packet->pos();
|
qDebug() << " AFTER processEditPacketData payload position=" << packet->pos();
|
||||||
qDebug() << " AFTER processEditPacketData payload size=" << packet->getSizeUsed();
|
qDebug() << " AFTER processEditPacketData payload size=" << packet->getPayloadSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -192,7 +193,7 @@ void OctreeInboundPacketProcessor::processPacket(QSharedPointer<NLPacket> packet
|
||||||
if (debugProcessPacket) {
|
if (debugProcessPacket) {
|
||||||
qDebug("OctreeInboundPacketProcessor::processPacket() DONE LOOPING FOR %c "
|
qDebug("OctreeInboundPacketProcessor::processPacket() DONE LOOPING FOR %c "
|
||||||
"payload=%p payloadLength=%lld editData=%p payloadPosition=%lld",
|
"payload=%p payloadLength=%lld editData=%p payloadPosition=%lld",
|
||||||
packetType, packet->getPayload(), packet->getSizeUsed(), editData, packet->pos());
|
packetType, packet->getPayload(), packet->getPayloadSize(), editData, packet->pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure our Node and NodeList knows we've heard from this node.
|
// Make sure our Node and NodeList knows we've heard from this node.
|
||||||
|
|
|
@ -108,10 +108,10 @@ bool OctreeQueryNode::packetIsDuplicate() const {
|
||||||
// since our packets now include header information, like sequence number, and createTime, we can't just do a memcmp
|
// since our packets now include header information, like sequence number, and createTime, we can't just do a memcmp
|
||||||
// of the entire packet, we need to compare only the packet content...
|
// of the entire packet, we need to compare only the packet content...
|
||||||
|
|
||||||
if (_lastOctreePacketLength == _octreePacket->getSizeUsed()) {
|
if (_lastOctreePacketLength == _octreePacket->getPayloadSize()) {
|
||||||
if (memcmp(_lastOctreePayload + OCTREE_PACKET_EXTRA_HEADERS_SIZE,
|
if (memcmp(_lastOctreePayload + OCTREE_PACKET_EXTRA_HEADERS_SIZE,
|
||||||
_octreePacket->getPayload() + OCTREE_PACKET_EXTRA_HEADERS_SIZE,
|
_octreePacket->getPayload() + OCTREE_PACKET_EXTRA_HEADERS_SIZE,
|
||||||
_octreePacket->getSizeUsed() - OCTREE_PACKET_EXTRA_HEADERS_SIZE) == 0) {
|
_octreePacket->getPayloadSize() - OCTREE_PACKET_EXTRA_HEADERS_SIZE) == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ void OctreeQueryNode::resetOctreePacket() {
|
||||||
// changed since we last reset it. Since we know that no two packets can ever be identical without being the same
|
// changed since we last reset it. Since we know that no two packets can ever be identical without being the same
|
||||||
// scene information, (e.g. the root node packet of a static scene), we can use this as a strategy for reducing
|
// scene information, (e.g. the root node packet of a static scene), we can use this as a strategy for reducing
|
||||||
// packet send rate.
|
// packet send rate.
|
||||||
_lastOctreePacketLength = _octreePacket->getSizeUsed();
|
_lastOctreePacketLength = _octreePacket->getPayloadSize();
|
||||||
memcpy(_lastOctreePayload, _octreePacket->getPayload(), _lastOctreePacketLength);
|
memcpy(_lastOctreePayload, _octreePacket->getPayload(), _lastOctreePacketLength);
|
||||||
|
|
||||||
// If we're moving, and the client asked for low res, then we force monochrome, otherwise, use
|
// If we're moving, and the client asked for low res, then we force monochrome, otherwise, use
|
||||||
|
|
|
@ -147,16 +147,16 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
|
||||||
NLPacket& statsPacket = nodeData->stats.getStatsMessage();
|
NLPacket& statsPacket = nodeData->stats.getStatsMessage();
|
||||||
|
|
||||||
// If the size of the stats message and the octree message will fit in a packet, then piggyback them
|
// If the size of the stats message and the octree message will fit in a packet, then piggyback them
|
||||||
if (nodeData->getPacket().getSizeWithHeader() <= statsPacket.bytesAvailableForWrite()) {
|
if (nodeData->getPacket().getDataSize() <= statsPacket.bytesAvailableForWrite()) {
|
||||||
|
|
||||||
// copy octree message to back of stats message
|
// copy octree message to back of stats message
|
||||||
statsPacket.write(nodeData->getPacket().getData(), nodeData->getPacket().getSizeWithHeader());
|
statsPacket.write(nodeData->getPacket().getData(), nodeData->getPacket().getDataSize());
|
||||||
|
|
||||||
// since a stats message is only included on end of scene, don't consider any of these bytes "wasted", since
|
// since a stats message is only included on end of scene, don't consider any of these bytes "wasted", since
|
||||||
// there was nothing else to send.
|
// there was nothing else to send.
|
||||||
int thisWastedBytes = 0;
|
int thisWastedBytes = 0;
|
||||||
_totalWastedBytes += thisWastedBytes;
|
_totalWastedBytes += thisWastedBytes;
|
||||||
_totalBytes += statsPacket.getSizeWithHeader();
|
_totalBytes += statsPacket.getDataSize();
|
||||||
_totalPackets++;
|
_totalPackets++;
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
|
@ -172,8 +172,8 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
|
||||||
|
|
||||||
qDebug() << "Adding stats to packet at " << now << " [" << _totalPackets <<"]: sequence: " << sequence <<
|
qDebug() << "Adding stats to packet at " << now << " [" << _totalPackets <<"]: sequence: " << sequence <<
|
||||||
" timestamp: " << timestamp <<
|
" timestamp: " << timestamp <<
|
||||||
" statsMessageLength: " << statsPacket.getSizeWithHeader() <<
|
" statsMessageLength: " << statsPacket.getDataSize() <<
|
||||||
" original size: " << nodeData->getPacket().getSizeWithHeader() << " [" << _totalBytes <<
|
" original size: " << nodeData->getPacket().getDataSize() << " [" << _totalBytes <<
|
||||||
"] wasted bytes:" << thisWastedBytes << " [" << _totalWastedBytes << "]";
|
"] wasted bytes:" << thisWastedBytes << " [" << _totalWastedBytes << "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
|
||||||
// there was nothing else to send.
|
// there was nothing else to send.
|
||||||
int thisWastedBytes = 0;
|
int thisWastedBytes = 0;
|
||||||
_totalWastedBytes += thisWastedBytes;
|
_totalWastedBytes += thisWastedBytes;
|
||||||
_totalBytes += statsPacket.getSizeWithHeader();
|
_totalBytes += statsPacket.getDataSize();
|
||||||
_totalPackets++;
|
_totalPackets++;
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
|
@ -206,11 +206,11 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
|
||||||
|
|
||||||
qDebug() << "Sending separate stats packet at " << now << " [" << _totalPackets <<"]: sequence: " << sequence <<
|
qDebug() << "Sending separate stats packet at " << now << " [" << _totalPackets <<"]: sequence: " << sequence <<
|
||||||
" timestamp: " << timestamp <<
|
" timestamp: " << timestamp <<
|
||||||
" size: " << statsPacket.getSizeWithHeader() << " [" << _totalBytes <<
|
" size: " << statsPacket.getDataSize() << " [" << _totalBytes <<
|
||||||
"] wasted bytes:" << thisWastedBytes << " [" << _totalWastedBytes << "]";
|
"] wasted bytes:" << thisWastedBytes << " [" << _totalWastedBytes << "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
trueBytesSent += statsPacket.getSizeWithHeader();
|
trueBytesSent += statsPacket.getDataSize();
|
||||||
truePacketsSent++;
|
truePacketsSent++;
|
||||||
packetsSent++;
|
packetsSent++;
|
||||||
|
|
||||||
|
@ -218,10 +218,10 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
|
||||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(nodeData->getPacket(), *_node);
|
DependencyManager::get<NodeList>()->sendUnreliablePacket(nodeData->getPacket(), *_node);
|
||||||
packetSent = true;
|
packetSent = true;
|
||||||
|
|
||||||
int packetSizeWithHeader = nodeData->getPacket().getSizeWithHeader();
|
int packetSizeWithHeader = nodeData->getPacket().getDataSize();
|
||||||
thisWastedBytes = MAX_PACKET_SIZE - packetSizeWithHeader;
|
thisWastedBytes = MAX_PACKET_SIZE - packetSizeWithHeader;
|
||||||
_totalWastedBytes += thisWastedBytes;
|
_totalWastedBytes += thisWastedBytes;
|
||||||
_totalBytes += nodeData->getPacket().getSizeWithHeader();
|
_totalBytes += nodeData->getPacket().getDataSize();
|
||||||
_totalPackets++;
|
_totalPackets++;
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
|
@ -237,7 +237,7 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
|
||||||
|
|
||||||
qDebug() << "Sending packet at " << now << " [" << _totalPackets <<"]: sequence: " << sequence <<
|
qDebug() << "Sending packet at " << now << " [" << _totalPackets <<"]: sequence: " << sequence <<
|
||||||
" timestamp: " << timestamp <<
|
" timestamp: " << timestamp <<
|
||||||
" size: " << nodeData->getPacket().getSizeWithHeader() << " [" << _totalBytes <<
|
" size: " << nodeData->getPacket().getDataSize() << " [" << _totalBytes <<
|
||||||
"] wasted bytes:" << thisWastedBytes << " [" << _totalWastedBytes << "]";
|
"] wasted bytes:" << thisWastedBytes << " [" << _totalWastedBytes << "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
|
||||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(nodeData->getPacket(), *_node);
|
DependencyManager::get<NodeList>()->sendUnreliablePacket(nodeData->getPacket(), *_node);
|
||||||
packetSent = true;
|
packetSent = true;
|
||||||
|
|
||||||
int packetSizeWithHeader = nodeData->getPacket().getSizeWithHeader();
|
int packetSizeWithHeader = nodeData->getPacket().getDataSize();
|
||||||
int thisWastedBytes = MAX_PACKET_SIZE - packetSizeWithHeader;
|
int thisWastedBytes = MAX_PACKET_SIZE - packetSizeWithHeader;
|
||||||
_totalWastedBytes += thisWastedBytes;
|
_totalWastedBytes += thisWastedBytes;
|
||||||
_totalBytes += packetSizeWithHeader;
|
_totalBytes += packetSizeWithHeader;
|
||||||
|
@ -277,8 +277,8 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
|
||||||
|
|
||||||
// remember to track our stats
|
// remember to track our stats
|
||||||
if (packetSent) {
|
if (packetSent) {
|
||||||
nodeData->stats.packetSent(nodeData->getPacket().getSizeUsed());
|
nodeData->stats.packetSent(nodeData->getPacket().getPayloadSize());
|
||||||
trueBytesSent += nodeData->getPacket().getSizeUsed();
|
trueBytesSent += nodeData->getPacket().getPayloadSize();
|
||||||
truePacketsSent++;
|
truePacketsSent++;
|
||||||
packetsSent++;
|
packetsSent++;
|
||||||
nodeData->octreePacketSent();
|
nodeData->octreePacketSent();
|
||||||
|
@ -596,9 +596,9 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus
|
||||||
truePacketsSent++;
|
truePacketsSent++;
|
||||||
packetsSentThisInterval++;
|
packetsSentThisInterval++;
|
||||||
|
|
||||||
_totalBytes += packet->getSizeWithHeader();
|
_totalBytes += packet->getDataSize();
|
||||||
_totalPackets++;
|
_totalPackets++;
|
||||||
_totalWastedBytes += MAX_PACKET_SIZE - packet->getSizeWithHeader();
|
_totalWastedBytes += MAX_PACKET_SIZE - packet->getDataSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -579,7 +579,7 @@ void DomainServer::processConnectRequestPacket(QSharedPointer<NLPacket> packet)
|
||||||
NodeType_t nodeType;
|
NodeType_t nodeType;
|
||||||
HifiSockAddr publicSockAddr, localSockAddr;
|
HifiSockAddr publicSockAddr, localSockAddr;
|
||||||
|
|
||||||
if (packet->getSizeUsed() == 0) {
|
if (packet->getPayloadSize() == 0) {
|
||||||
// TODO: We know what size the connect packet should be (minimally) - check for that here
|
// TODO: We know what size the connect packet should be (minimally) - check for that here
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ void IceServer::sendPeerInformationPacket(const NetworkPeer& peer, const HifiSoc
|
||||||
peerPacket->write(peer.toByteArray());
|
peerPacket->write(peer.toByteArray());
|
||||||
|
|
||||||
// write the current packet
|
// write the current packet
|
||||||
_serverSocket.writeDatagram(peerPacket->getData(), peerPacket->getSizeWithHeader(),
|
_serverSocket.writeDatagram(peerPacket->getData(), peerPacket->getDataSize(),
|
||||||
destinationSockAddr->getAddress(), destinationSockAddr->getPort());
|
destinationSockAddr->getAddress(), destinationSockAddr->getPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2899,7 +2899,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType::Value packetTyp
|
||||||
|
|
||||||
// encode the query data
|
// encode the query data
|
||||||
int packetSize = _octreeQuery.getBroadcastData(reinterpret_cast<unsigned char*>(queryPacket->getPayload()));
|
int packetSize = _octreeQuery.getBroadcastData(reinterpret_cast<unsigned char*>(queryPacket->getPayload()));
|
||||||
queryPacket->setSizeUsed(packetSize);
|
queryPacket->setPayloadSize(packetSize);
|
||||||
|
|
||||||
// make sure we still have an active socket
|
// make sure we still have an active socket
|
||||||
nodeList->sendUnreliablePacket(*queryPacket, *node);
|
nodeList->sendUnreliablePacket(*queryPacket, *node);
|
||||||
|
|
|
@ -57,7 +57,7 @@ void OctreePacketProcessor::processPacket(QSharedPointer<NLPacket> packet, Share
|
||||||
int statsMessageLength = app->processOctreeStats(*packet, sendingNode);
|
int statsMessageLength = app->processOctreeStats(*packet, sendingNode);
|
||||||
|
|
||||||
wasStatsPacket = true;
|
wasStatsPacket = true;
|
||||||
int piggybackBytes = packet->getSizeUsed() - statsMessageLength;
|
int piggybackBytes = packet->getPayloadSize() - statsMessageLength;
|
||||||
|
|
||||||
if (piggybackBytes) {
|
if (piggybackBytes) {
|
||||||
// construct a new packet from the piggybacked one
|
// construct a new packet from the piggybacked one
|
||||||
|
|
|
@ -937,7 +937,7 @@ void AudioClient::handleAudioInput() {
|
||||||
|
|
||||||
if (_audioPacket->getType() != PacketType::SilentAudioFrame) {
|
if (_audioPacket->getType() != PacketType::SilentAudioFrame) {
|
||||||
// audio samples have already been packed (written to networkAudioSamples)
|
// audio samples have already been packed (written to networkAudioSamples)
|
||||||
_audioPacket->setSizeUsed(_audioPacket->getSizeUsed() + numNetworkBytes);
|
_audioPacket->setPayloadSize(_audioPacket->getPayloadSize() + numNetworkBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
_stats.sentPacket();
|
_stats.sentPacket();
|
||||||
|
|
|
@ -232,7 +232,7 @@ void AudioInjector::injectToMixer() {
|
||||||
audioPacket->write(_audioData.data() + _currentSendPosition, bytesToCopy);
|
audioPacket->write(_audioData.data() + _currentSendPosition, bytesToCopy);
|
||||||
|
|
||||||
// set the correct size used for this packet
|
// set the correct size used for this packet
|
||||||
audioPacket->setSizeUsed(audioPacket->pos());
|
audioPacket->setPayloadSize(audioPacket->pos());
|
||||||
|
|
||||||
// grab our audio mixer from the NodeList, if it exists
|
// grab our audio mixer from the NodeList, if it exists
|
||||||
SharedNodePointer audioMixer = nodeList->soloNodeOfType(NodeType::AudioMixer);
|
SharedNodePointer audioMixer = nodeList->soloNodeOfType(NodeType::AudioMixer);
|
||||||
|
|
|
@ -24,7 +24,7 @@ EntityEditPacketSender::EntityEditPacketSender() {
|
||||||
|
|
||||||
void EntityEditPacketSender::processEntityEditNackPacket(QSharedPointer<NLPacket> packet) {
|
void EntityEditPacketSender::processEntityEditNackPacket(QSharedPointer<NLPacket> packet) {
|
||||||
if (_shouldNack) {
|
if (_shouldNack) {
|
||||||
processNackPacket(QByteArray::fromRawData(packet->getData(), packet->getSizeWithHeader()));
|
processNackPacket(QByteArray::fromRawData(packet->getData(), packet->getDataSize()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -907,7 +907,7 @@ bool EntityItemProperties::decodeEntityEditPacket(NLPacket& packet, int& process
|
||||||
const unsigned char* data = reinterpret_cast<const unsigned char*>(packet.getPayload());
|
const unsigned char* data = reinterpret_cast<const unsigned char*>(packet.getPayload());
|
||||||
const unsigned char* dataAt = data;
|
const unsigned char* dataAt = data;
|
||||||
|
|
||||||
int bytesToRead = packet.getSizeUsed();
|
int bytesToRead = packet.getPayloadSize();
|
||||||
processedBytes = 0;
|
processedBytes = 0;
|
||||||
|
|
||||||
// the first part of the data is an octcode, this is a required element of the edit packet format, but we don't
|
// the first part of the data is an octcode, this is a required element of the edit packet format, but we don't
|
||||||
|
|
|
@ -215,7 +215,7 @@ bool LimitedNodeList::packetSourceAndHashMatch(const NLPacket& packet, SharedNod
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 LimitedNodeList::writeDatagram(const NLPacket& packet, const HifiSockAddr& destinationSockAddr) {
|
qint64 LimitedNodeList::writeDatagram(const NLPacket& packet, const HifiSockAddr& destinationSockAddr) {
|
||||||
return writeDatagram({packet.getData(), static_cast<int>(packet.getSizeWithHeader())}, destinationSockAddr);
|
return writeDatagram({packet.getData(), static_cast<int>(packet.getDataSize())}, destinationSockAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr) {
|
qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr) {
|
||||||
|
@ -598,7 +598,7 @@ bool LimitedNodeList::processSTUNResponse(QSharedPointer<NLPacket> packet) {
|
||||||
sizeof(RFC_5389_MAGIC_COOKIE_NETWORK_ORDER)) == 0) {
|
sizeof(RFC_5389_MAGIC_COOKIE_NETWORK_ORDER)) == 0) {
|
||||||
|
|
||||||
// enumerate the attributes to find XOR_MAPPED_ADDRESS_TYPE
|
// enumerate the attributes to find XOR_MAPPED_ADDRESS_TYPE
|
||||||
while (attributeStartIndex < packet->getSizeWithHeader()) {
|
while (attributeStartIndex < packet->getDataSize()) {
|
||||||
if (memcmp(packet->getData() + attributeStartIndex, &XOR_MAPPED_ADDRESS_TYPE, sizeof(XOR_MAPPED_ADDRESS_TYPE)) == 0) {
|
if (memcmp(packet->getData() + attributeStartIndex, &XOR_MAPPED_ADDRESS_TYPE, sizeof(XOR_MAPPED_ADDRESS_TYPE)) == 0) {
|
||||||
const int NUM_BYTES_STUN_ATTR_TYPE_AND_LENGTH = 4;
|
const int NUM_BYTES_STUN_ATTR_TYPE_AND_LENGTH = 4;
|
||||||
const int NUM_BYTES_FAMILY_ALIGN = 1;
|
const int NUM_BYTES_FAMILY_ALIGN = 1;
|
||||||
|
|
|
@ -80,7 +80,7 @@ NLPacket::NLPacket(PacketType::Value type, qint64 size) :
|
||||||
|
|
||||||
qint64 headerSize = localHeaderSize(type);
|
qint64 headerSize = localHeaderSize(type);
|
||||||
_payloadStart += headerSize;
|
_payloadStart += headerSize;
|
||||||
_capacity -= headerSize;
|
_payloadCapacity -= headerSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
NLPacket::NLPacket(PacketType::Value type) :
|
NLPacket::NLPacket(PacketType::Value type) :
|
||||||
|
@ -88,7 +88,7 @@ NLPacket::NLPacket(PacketType::Value type) :
|
||||||
{
|
{
|
||||||
qint64 headerSize = localHeaderSize(type);
|
qint64 headerSize = localHeaderSize(type);
|
||||||
_payloadStart += headerSize;
|
_payloadStart += headerSize;
|
||||||
_capacity -= headerSize;
|
_payloadCapacity -= headerSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
NLPacket::NLPacket(const NLPacket& other) : Packet(other) {
|
NLPacket::NLPacket(const NLPacket& other) : Packet(other) {
|
||||||
|
@ -137,7 +137,7 @@ QByteArray NLPacket::payloadHashWithConnectionUUID(const QUuid& connectionUUID)
|
||||||
QCryptographicHash hash(QCryptographicHash::Md5);
|
QCryptographicHash hash(QCryptographicHash::Md5);
|
||||||
|
|
||||||
// add the packet payload and the connection UUID
|
// add the packet payload and the connection UUID
|
||||||
hash.addData(_payloadStart, _sizeUsed);
|
hash.addData(_payloadStart, _payloadSize);
|
||||||
hash.addData(connectionUUID.toRfc4122());
|
hash.addData(connectionUUID.toRfc4122());
|
||||||
|
|
||||||
// return the hash
|
// return the hash
|
||||||
|
|
|
@ -475,7 +475,7 @@ void NodeList::processDomainServerList(QSharedPointer<NLPacket> packet) {
|
||||||
setThisNodeCanRez((bool) thisNodeCanRez);
|
setThisNodeCanRez((bool) thisNodeCanRez);
|
||||||
|
|
||||||
// pull each node in the packet
|
// pull each node in the packet
|
||||||
while (packetStream.device()->pos() < packet->getSizeUsed()) {
|
while (packetStream.device()->pos() < packet->getPayloadSize()) {
|
||||||
parseNodeFromPacketStream(packetStream);
|
parseNodeFromPacketStream(packetStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,20 +236,18 @@ void PacketReceiver::processDatagrams() {
|
||||||
matchingNode->setLastSequenceNumberForPacketType(packet->readSequenceNumber(), packet->getType());
|
matchingNode->setLastSequenceNumberForPacketType(packet->readSequenceNumber(), packet->getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
emit dataReceived(matchingNode->getType(), packet->getSizeWithHeader());
|
emit dataReceived(matchingNode->getType(), packet->getDataSize());
|
||||||
QMetaMethod metaMethod = listener.second;
|
QMetaMethod metaMethod = listener.second;
|
||||||
|
|
||||||
static const QByteArray QSHAREDPOINTER_NODE_NORMALIZED = QMetaObject::normalizedType("QSharedPointer<Node>");
|
static const QByteArray QSHAREDPOINTER_NODE_NORMALIZED = QMetaObject::normalizedType("QSharedPointer<Node>");
|
||||||
static const QByteArray SHARED_NODE_NORMALIZED = QMetaObject::normalizedType("SharedNodePointer");
|
static const QByteArray SHARED_NODE_NORMALIZED = QMetaObject::normalizedType("SharedNodePointer");
|
||||||
|
|
||||||
if (metaMethod.parameterTypes().contains(SHARED_NODE_NORMALIZED)) {
|
if (metaMethod.parameterTypes().contains(SHARED_NODE_NORMALIZED)) {
|
||||||
qDebug() << "invoking with matchingNode" << matchingNode;
|
|
||||||
success = metaMethod.invoke(listener.first,
|
success = metaMethod.invoke(listener.first,
|
||||||
Q_ARG(QSharedPointer<NLPacket>, QSharedPointer<NLPacket>(packet.release())),
|
Q_ARG(QSharedPointer<NLPacket>, QSharedPointer<NLPacket>(packet.release())),
|
||||||
Q_ARG(SharedNodePointer, matchingNode));
|
Q_ARG(SharedNodePointer, matchingNode));
|
||||||
|
|
||||||
} else if (metaMethod.parameterTypes().contains(QSHAREDPOINTER_NODE_NORMALIZED)) {
|
} else if (metaMethod.parameterTypes().contains(QSHAREDPOINTER_NODE_NORMALIZED)) {
|
||||||
qDebug() << "invoking with matchingNode" << matchingNode;
|
|
||||||
success = metaMethod.invoke(listener.first,
|
success = metaMethod.invoke(listener.first,
|
||||||
Q_ARG(QSharedPointer<NLPacket>, QSharedPointer<NLPacket>(packet.release())),
|
Q_ARG(QSharedPointer<NLPacket>, QSharedPointer<NLPacket>(packet.release())),
|
||||||
Q_ARG(QSharedPointer<Node>, matchingNode));
|
Q_ARG(QSharedPointer<Node>, matchingNode));
|
||||||
|
@ -259,7 +257,7 @@ void PacketReceiver::processDatagrams() {
|
||||||
Q_ARG(QSharedPointer<NLPacket>, QSharedPointer<NLPacket>(packet.release())));
|
Q_ARG(QSharedPointer<NLPacket>, QSharedPointer<NLPacket>(packet.release())));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit dataReceived(NodeType::Unassigned, packet->getSizeWithHeader());
|
emit dataReceived(NodeType::Unassigned, packet->getDataSize());
|
||||||
|
|
||||||
success = listener.second.invoke(listener.first,
|
success = listener.second.invoke(listener.first,
|
||||||
Q_ARG(QSharedPointer<NLPacket>, QSharedPointer<NLPacket>(packet.release())));
|
Q_ARG(QSharedPointer<NLPacket>, QSharedPointer<NLPacket>(packet.release())));
|
||||||
|
|
|
@ -54,7 +54,7 @@ void PacketSender::queuePacketForSending(const SharedNodePointer& destinationNod
|
||||||
unlock();
|
unlock();
|
||||||
|
|
||||||
_totalPacketsQueued++;
|
_totalPacketsQueued++;
|
||||||
_totalBytesQueued += packet->getSizeWithHeader();
|
_totalBytesQueued += packet->getDataSize();
|
||||||
|
|
||||||
// Make sure to wake our actual processing thread because we now have packets for it to process.
|
// Make sure to wake our actual processing thread because we now have packets for it to process.
|
||||||
_hasPackets.wakeAll();
|
_hasPackets.wakeAll();
|
||||||
|
@ -278,7 +278,7 @@ bool PacketSender::nonThreadedProcess() {
|
||||||
_packetsOverCheckInterval++;
|
_packetsOverCheckInterval++;
|
||||||
_totalPacketsSent++;
|
_totalPacketsSent++;
|
||||||
|
|
||||||
int packetSize = packetPair.second->getSizeWithHeader();
|
int packetSize = packetPair.second->getDataSize();
|
||||||
|
|
||||||
_totalBytesSent += packetSize;
|
_totalBytesSent += packetSize;
|
||||||
emit packetSent(packetSize);
|
emit packetSent(packetSize);
|
||||||
|
|
|
@ -71,8 +71,8 @@ Packet::Packet(PacketType::Value type, qint64 size) :
|
||||||
|
|
||||||
_packetSize = localHeaderSize(type) + size;
|
_packetSize = localHeaderSize(type) + size;
|
||||||
_packet.reset(new char[_packetSize]);
|
_packet.reset(new char[_packetSize]);
|
||||||
_capacity = size;
|
_payloadCapacity = size;
|
||||||
_payloadStart = _packet.get() + (_packetSize - _capacity);
|
_payloadStart = _packet.get() + (_packetSize - _payloadCapacity);
|
||||||
|
|
||||||
// Sanity check
|
// Sanity check
|
||||||
Q_ASSERT(size >= 0 || size < maxPayload);
|
Q_ASSERT(size >= 0 || size < maxPayload);
|
||||||
|
@ -93,9 +93,9 @@ Packet::Packet(std::unique_ptr<char> data, qint64 size, const HifiSockAddr& send
|
||||||
{
|
{
|
||||||
_type = readType();
|
_type = readType();
|
||||||
_version = readVersion();
|
_version = readVersion();
|
||||||
_capacity = _packetSize - localHeaderSize(_type);
|
_payloadCapacity = _packetSize - localHeaderSize(_type);
|
||||||
_sizeUsed = _capacity;
|
_payloadSize = _payloadCapacity;
|
||||||
_payloadStart = _packet.get() + (_packetSize - _capacity);
|
_payloadStart = _packet.get() + (_packetSize - _payloadCapacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
Packet::Packet(const Packet& other) {
|
Packet::Packet(const Packet& other) {
|
||||||
|
@ -110,9 +110,9 @@ Packet& Packet::operator=(const Packet& other) {
|
||||||
memcpy(_packet.get(), other._packet.get(), _packetSize);
|
memcpy(_packet.get(), other._packet.get(), _packetSize);
|
||||||
|
|
||||||
_payloadStart = _packet.get() + (other._payloadStart - other._packet.get());
|
_payloadStart = _packet.get() + (other._payloadStart - other._packet.get());
|
||||||
_capacity = other._capacity;
|
_payloadCapacity = other._payloadCapacity;
|
||||||
|
|
||||||
_sizeUsed = other._sizeUsed;
|
_payloadSize = other._payloadSize;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -128,13 +128,31 @@ Packet& Packet::operator=(Packet&& other) {
|
||||||
_packet = std::move(other._packet);
|
_packet = std::move(other._packet);
|
||||||
|
|
||||||
_payloadStart = other._payloadStart;
|
_payloadStart = other._payloadStart;
|
||||||
_capacity = other._capacity;
|
_payloadCapacity = other._payloadCapacity;
|
||||||
|
|
||||||
_sizeUsed = other._sizeUsed;
|
_payloadSize = other._payloadSize;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Packet::setPayloadSize(qint64 payloadSize) {
|
||||||
|
if (isWritable()) {
|
||||||
|
Q_ASSERT(payloadSize > _payloadCapacity);
|
||||||
|
_payloadSize = std::max(payloadSize, _payloadCapacity);
|
||||||
|
} else {
|
||||||
|
qDebug() << "You can not call setPayloadSize for a non-writeable Packet.";
|
||||||
|
Q_ASSERT(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Packet::reset() {
|
||||||
|
if (isWritable()) {
|
||||||
|
setPayloadSize(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return QIODevice::reset();
|
||||||
|
}
|
||||||
|
|
||||||
void Packet::setType(PacketType::Value type) {
|
void Packet::setType(PacketType::Value type) {
|
||||||
auto currentHeaderSize = totalHeadersSize();
|
auto currentHeaderSize = totalHeadersSize();
|
||||||
_type = type;
|
_type = type;
|
||||||
|
@ -197,13 +215,13 @@ qint64 Packet::writeData(const char* data, qint64 maxSize) {
|
||||||
if (maxSize <= bytesAvailableForWrite()) {
|
if (maxSize <= bytesAvailableForWrite()) {
|
||||||
qint64 currentPos = pos();
|
qint64 currentPos = pos();
|
||||||
|
|
||||||
Q_ASSERT(currentPos < _capacity);
|
Q_ASSERT(currentPos < _payloadCapacity);
|
||||||
|
|
||||||
// good to go - write the data
|
// good to go - write the data
|
||||||
memcpy(_payloadStart + currentPos, data, maxSize);
|
memcpy(_payloadStart + currentPos, data, maxSize);
|
||||||
|
|
||||||
// keep track of _sizeUsed so we can just write the actual data when packet is about to be sent
|
// keep track of _payloadSize so we can just write the actual data when packet is about to be sent
|
||||||
_sizeUsed = std::max(currentPos + maxSize, _sizeUsed);
|
_payloadSize = std::max(currentPos + maxSize, _payloadSize);
|
||||||
|
|
||||||
// return the number of bytes written
|
// return the number of bytes written
|
||||||
return maxSize;
|
return maxSize;
|
||||||
|
|
|
@ -49,12 +49,20 @@ public:
|
||||||
|
|
||||||
PacketVersion getVersion() const { return _version; }
|
PacketVersion getVersion() const { return _version; }
|
||||||
|
|
||||||
qint64 getSizeWithHeader() const { return totalHeadersSize() + getSizeUsed(); }
|
// Returns the size of the packet, including the header
|
||||||
qint64 getSizeUsed() const { return _sizeUsed; }
|
qint64 getDataSize() const { return totalHeadersSize() + getPayloadSize(); }
|
||||||
void setSizeUsed(qint64 sizeUsed) { _sizeUsed = sizeUsed; }
|
|
||||||
|
// Returns the size of the payload only
|
||||||
|
qint64 getPayloadSize() const { return _payloadSize; }
|
||||||
|
|
||||||
|
// Allows a writer to change the size of the payload used when writing directly
|
||||||
|
void setPayloadSize(qint64 payloadSize);
|
||||||
|
|
||||||
|
// Returns the number of bytes allocated for the payload
|
||||||
|
qint64 getPayloadCapacity() const { return _payloadCapacity; }
|
||||||
|
|
||||||
qint64 bytesLeftToRead() const { return _capacity - pos(); }
|
qint64 bytesLeftToRead() const { return _payloadCapacity - pos(); }
|
||||||
qint64 bytesAvailableForWrite() const { return _capacity - pos(); }
|
qint64 bytesAvailableForWrite() const { return _payloadCapacity - pos(); }
|
||||||
|
|
||||||
HifiSockAddr& getSenderSockAddr() { return _senderSockAddr; }
|
HifiSockAddr& getSenderSockAddr() { return _senderSockAddr; }
|
||||||
const HifiSockAddr& getSenderSockAddr() const { return _senderSockAddr; }
|
const HifiSockAddr& getSenderSockAddr() const { return _senderSockAddr; }
|
||||||
|
@ -65,8 +73,8 @@ public:
|
||||||
// QIODevice virtual functions
|
// QIODevice virtual functions
|
||||||
// WARNING: Those methods all refer to the payload ONLY and NOT the entire packet
|
// WARNING: Those methods all refer to the payload ONLY and NOT the entire packet
|
||||||
virtual bool isSequential() const { return false; }
|
virtual bool isSequential() const { return false; }
|
||||||
virtual bool reset() { setSizeUsed(0); return QIODevice::reset(); }
|
virtual bool reset();
|
||||||
virtual qint64 size() const { return _capacity; }
|
virtual qint64 size() const { return _payloadCapacity; }
|
||||||
|
|
||||||
template<typename T> qint64 peekPrimitive(T* data);
|
template<typename T> qint64 peekPrimitive(T* data);
|
||||||
template<typename T> qint64 readPrimitive(T* data);
|
template<typename T> qint64 readPrimitive(T* data);
|
||||||
|
@ -99,9 +107,9 @@ protected:
|
||||||
std::unique_ptr<char> _packet; // Allocated memory
|
std::unique_ptr<char> _packet; // Allocated memory
|
||||||
|
|
||||||
char* _payloadStart = nullptr; // Start of the payload
|
char* _payloadStart = nullptr; // Start of the payload
|
||||||
qint64 _capacity = 0; // Total capacity of the payload
|
qint64 _payloadCapacity = 0; // Total capacity of the payload
|
||||||
|
|
||||||
qint64 _sizeUsed = 0; // How much of the payload is actually used
|
qint64 _payloadSize = 0; // How much of the payload is actually used
|
||||||
|
|
||||||
HifiSockAddr _senderSockAddr; // sender address for packet (only used on receiving end)
|
HifiSockAddr _senderSockAddr; // sender address for packet (only used on receiving end)
|
||||||
};
|
};
|
||||||
|
|
|
@ -90,7 +90,7 @@ qint64 PacketList::writeData(const char* data, qint64 maxSize) {
|
||||||
_segmentStartIndex = 0;
|
_segmentStartIndex = 0;
|
||||||
|
|
||||||
// shrink the current payload to the actual size of the packet
|
// shrink the current payload to the actual size of the packet
|
||||||
_currentPacket->setSizeUsed(_segmentStartIndex);
|
_currentPacket->setPayloadSize(_segmentStartIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// move the current packet to our list of packets
|
// move the current packet to our list of packets
|
||||||
|
|
|
@ -103,7 +103,7 @@ void OctreeEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, std::uniqu
|
||||||
quint64 transitTime = queuedAt - createdAt;
|
quint64 transitTime = queuedAt - createdAt;
|
||||||
|
|
||||||
qCDebug(octree) << "OctreeEditPacketSender::queuePacketToNode() queued " << packet->getType()
|
qCDebug(octree) << "OctreeEditPacketSender::queuePacketToNode() queued " << packet->getType()
|
||||||
<< " - command to node bytes=" << packet->getSizeWithHeader()
|
<< " - command to node bytes=" << packet->getDataSize()
|
||||||
<< " sequence=" << sequence << " transitTimeSoFar=" << transitTime << " usecs";
|
<< " sequence=" << sequence << " transitTimeSoFar=" << transitTime << " usecs";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ void OctreeEditPacketSender::queueOctreeEditMessage(PacketType::Value type, QByt
|
||||||
bufferedPacket = NLPacket::create(type);
|
bufferedPacket = NLPacket::create(type);
|
||||||
} else {
|
} else {
|
||||||
// If we're switching type, then we send the last one and start over
|
// If we're switching type, then we send the last one and start over
|
||||||
if ((type != bufferedPacket->getType() && bufferedPacket->getSizeUsed() > 0) ||
|
if ((type != bufferedPacket->getType() && bufferedPacket->getPayloadSize() > 0) ||
|
||||||
(editMessage.size() >= bufferedPacket->bytesAvailableForWrite())) {
|
(editMessage.size() >= bufferedPacket->bytesAvailableForWrite())) {
|
||||||
|
|
||||||
// create the new packet and swap it with the packet in _pendingEditPackets
|
// create the new packet and swap it with the packet in _pendingEditPackets
|
||||||
|
@ -307,7 +307,7 @@ void OctreeEditPacketSender::releaseQueuedMessages() {
|
||||||
|
|
||||||
void OctreeEditPacketSender::releaseQueuedPacket(const QUuid& nodeID, std::unique_ptr<NLPacket> packet) {
|
void OctreeEditPacketSender::releaseQueuedPacket(const QUuid& nodeID, std::unique_ptr<NLPacket> packet) {
|
||||||
_releaseQueuedPacketMutex.lock();
|
_releaseQueuedPacketMutex.lock();
|
||||||
if (packet->getSizeUsed() > 0 && packet->getType() != PacketType::Unknown) {
|
if (packet->getPayloadSize() > 0 && packet->getType() != PacketType::Unknown) {
|
||||||
queuePacketToNode(nodeID, std::move(packet));
|
queuePacketToNode(nodeID, std::move(packet));
|
||||||
}
|
}
|
||||||
_releaseQueuedPacketMutex.unlock();
|
_releaseQueuedPacketMutex.unlock();
|
||||||
|
|
|
@ -90,7 +90,7 @@ void OctreeRenderer::processDatagram(NLPacket& packet, SharedNodePointer sourceN
|
||||||
qCDebug(octree, "OctreeRenderer::processDatagram() ... Got Packet Section"
|
qCDebug(octree, "OctreeRenderer::processDatagram() ... Got Packet Section"
|
||||||
" color:%s compressed:%s sequence: %u flight:%d usec size:%lld data:%lld",
|
" color:%s compressed:%s sequence: %u flight:%d usec size:%lld data:%lld",
|
||||||
debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed),
|
debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed),
|
||||||
sequence, flightTime, packet.getSizeWithHeader(), packet.bytesLeftToRead());
|
sequence, flightTime, packet.getDataSize(), packet.bytesLeftToRead());
|
||||||
}
|
}
|
||||||
|
|
||||||
_packetsInLastWindow++;
|
_packetsInLastWindow++;
|
||||||
|
@ -139,7 +139,7 @@ void OctreeRenderer::processDatagram(NLPacket& packet, SharedNodePointer sourceN
|
||||||
" color:%s compressed:%s sequence: %u flight:%d usec size:%lld data:%lld"
|
" color:%s compressed:%s sequence: %u flight:%d usec size:%lld data:%lld"
|
||||||
" subsection:%d sectionLength:%d uncompressed:%d",
|
" subsection:%d sectionLength:%d uncompressed:%d",
|
||||||
debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed),
|
debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed),
|
||||||
sequence, flightTime, packet.getSizeWithHeader(), packet.bytesLeftToRead(), subsection, sectionLength,
|
sequence, flightTime, packet.getDataSize(), packet.bytesLeftToRead(), subsection, sectionLength,
|
||||||
packetData.getUncompressedSize());
|
packetData.getUncompressedSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -439,7 +439,7 @@ int OctreeSceneStats::packIntoPacket() {
|
||||||
_statsPacket->writePrimitive(bytes);
|
_statsPacket->writePrimitive(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _statsPacket->getSizeUsed();
|
return _statsPacket->getPayloadSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
int OctreeSceneStats::unpackFromPacket(NLPacket& packet) {
|
int OctreeSceneStats::unpackFromPacket(NLPacket& packet) {
|
||||||
|
@ -789,8 +789,8 @@ void OctreeSceneStats::trackIncomingOctreePacket(NLPacket& packet, bool wasStats
|
||||||
|
|
||||||
// track packets here...
|
// track packets here...
|
||||||
_incomingPacket++;
|
_incomingPacket++;
|
||||||
_incomingBytes += packet.getSizeWithHeader();
|
_incomingBytes += packet.getDataSize();
|
||||||
if (!wasStatsPacket) {
|
if (!wasStatsPacket) {
|
||||||
_incomingWastedBytes += (MAX_PACKET_SIZE - packet.getSizeWithHeader());
|
_incomingWastedBytes += (MAX_PACKET_SIZE - packet.getDataSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
tests/networking/src/PacketTests.cpp
Normal file
14
tests/networking/src/PacketTests.cpp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
//
|
||||||
|
// PacketTests.cpp
|
||||||
|
// tests/networking/src
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 07/14/15.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "PacketTests.h"
|
||||||
|
|
||||||
|
QTEST_MAIN(PacketTests)
|
25
tests/networking/src/PacketTests.h
Normal file
25
tests/networking/src/PacketTests.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
//
|
||||||
|
// PacketTests.h
|
||||||
|
// tests/networking/src
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 07/14/15.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_PacketTests_h
|
||||||
|
#define hifi_PacketTests_h
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
class PacketTests : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
private slots:
|
||||||
|
void readTest();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_PacketTests_h
|
Loading…
Reference in a new issue