From 039e6121bc9c5c6b68f5c5e2b66ef094c1fac534 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 20 Aug 2015 12:44:10 -0700 Subject: [PATCH 1/5] add randomization of data for ordered test --- tools/udt-test/src/UDTTest.cpp | 82 +++++++++++++++++++++++++++------- tools/udt-test/src/UDTTest.h | 2 + 2 files changed, 67 insertions(+), 17 deletions(-) diff --git a/tools/udt-test/src/UDTTest.cpp b/tools/udt-test/src/UDTTest.cpp index 0b65907e29..4455ac586e 100644 --- a/tools/udt-test/src/UDTTest.cpp +++ b/tools/udt-test/src/UDTTest.cpp @@ -11,6 +11,8 @@ #include "UDTTest.h" +#include + #include #include @@ -29,16 +31,16 @@ const QCommandLineOption PACKET_SIZE { QString(udt::MAX_PACKET_SIZE_WITH_UDP_HEADER) }; const QCommandLineOption MIN_PACKET_SIZE { - "min-packet-size", "min size for sent packets in bytes", "min-bytes" + "min-packet-size", "min size for sent packets in bytes", "min bytes" }; const QCommandLineOption MAX_PACKET_SIZE { - "max-packet-size", "max size for sent packets in bytes", "max-bytes" + "max-packet-size", "max size for sent packets in bytes", "max bytes" }; const QCommandLineOption MAX_SEND_BYTES { - "max-send-bytes", "number of bytes to send before stopping (default is infinite)", "max-bytes" + "max-send-bytes", "number of bytes to send before stopping (default is infinite)", "max bytes" }; const QCommandLineOption MAX_SEND_PACKETS { - "max-send-packets", "number of packets to send before stopping (default is infinite)", "max-packets" + "max-send-packets", "number of packets to send before stopping (default is infinite)", "max packets" }; const QCommandLineOption UNRELIABLE_PACKETS { "unreliable", "send unreliable packets (default is reliable)" @@ -46,6 +48,9 @@ const QCommandLineOption UNRELIABLE_PACKETS { const QCommandLineOption ORDERED_PACKETS { "ordered", "send ordered packets (default is unordered)" }; +const QCommandLineOption MESSAGE_SIZE { + "message-size", "megabytes per message payload for ordered sending (default is 100)", "megabytes" +}; const QStringList CLIENT_STATS_TABLE_HEADERS { "Send Rate (P/s)", "Bandwidth (P/s)", "RTT(ms)", "CW (P)", "Send Period (us)", @@ -138,6 +143,17 @@ UDTTest::UDTTest(int& argc, char** argv) : _sendOrdered = true; } + if (_argumentParser.isSet(MESSAGE_SIZE)) { + if (_argumentParser.isSet(ORDERED_PACKETS)) { + static const double BYTES_PER_MEGABYTE = 1000000; + _messageSize = (int) _argumentParser.value(MESSAGE_SIZE).toInt() * BYTES_PER_MEGABYTE; + + qDebug() << "Message size for ordered packet sending is" << QString("%1MB").arg(_messageSize / BYTES_PER_MEGABYTE); + } else { + qWarning() << "message-size has no effect if not sending ordered - it will be ignored"; + } + } + if (!_target.isNull()) { sendInitialPackets(); } @@ -159,7 +175,8 @@ void UDTTest::parseArguments() { _argumentParser.addOptions({ PORT_OPTION, TARGET_OPTION, PACKET_SIZE, MIN_PACKET_SIZE, MAX_PACKET_SIZE, - MAX_SEND_BYTES, MAX_SEND_PACKETS, UNRELIABLE_PACKETS, ORDERED_PACKETS + MAX_SEND_BYTES, MAX_SEND_PACKETS, UNRELIABLE_PACKETS, ORDERED_PACKETS, + MESSAGE_SIZE }); if (!_argumentParser.parse(arguments())) { @@ -189,6 +206,8 @@ void UDTTest::sendInitialPackets() { } } +static const int FIRST_MESSAGE_SEED = 742272; + void UDTTest::sendPacket() { if (_maxSendPackets != -1 && _totalQueuedPackets > _maxSendPackets) { @@ -216,22 +235,51 @@ void UDTTest::sendPacket() { } if (_sendOrdered) { + // check if it is time to add another message - we do this every time 95% of the message size has been sent static int call = 0; - call = (call + 1) % 4; - if (call == 0) { - auto packetList = std::unique_ptr(new udt::PacketList(PacketType::BulkAvatarData, QByteArray(), true, true)); - for (int i = 0; i < 4; i++) { - packetList->writePrimitive(0x1); - packetList->writePrimitive(0x2); - packetList->writePrimitive(0x3); - packetList->writePrimitive(0x4); - packetList->closeCurrentPacket(false); + static int packetSize = udt::Packet::maxPayloadSize(true); + static int messageSizePackets = (int) ceil(_messageSize / udt::Packet::maxPayloadSize()); + + static int refillCount = (int) (messageSizePackets * 0.95); + + if (call++ % refillCount == 0) { + // construct a reliable and ordered packet list + auto packetList = std::unique_ptr({ + new udt::PacketList(PacketType::BulkAvatarData, QByteArray(), true, true) + }); + + static int currentSeed = FIRST_MESSAGE_SEED; + + std::random_device rd; + std::mt19937 generator(rd()); + + // seed the generator with a value that the receiver will also use when verifying the ordered message + generator.seed(currentSeed++); + + // setup a distribution for integer values + std::uniform_int_distribution<> dis(1, UINT64_MAX); + + // fill the packet list with random data according to the constant seed (so receiver can verify) + for (int i = 0; i < messageSizePackets; ++i) { + // setup a QByteArray full of zeros for our random padded data + QByteArray randomPaddedData { packetSize, 0 }; + + // generate a random integer for the first 8 bytes of the random data + uint64_t randomInt = dis(generator); + randomPaddedData.replace(0, sizeof(randomInt), reinterpret_cast(&randomInt)); + + // write this data to the PacketList + packetList->write(randomPaddedData); } + + packetList->closeCurrentPacket(false); + _totalQueuedBytes += packetList->getDataSize(); - + _totalQueuedPackets += packetList->getNumPackets(); + _socket.writePacketList(std::move(packetList), _target); } - _totalQueuedPackets += 4; + } else { auto newPacket = udt::Packet::create(packetPayloadSize, _sendReliable); newPacket->setPayloadSize(packetPayloadSize); @@ -239,12 +287,12 @@ void UDTTest::sendPacket() { _totalQueuedBytes += newPacket->getDataSize(); // queue or send this packet by calling write packet on the socket for our target - // if ( if (_sendReliable) { _socket.writePacket(std::move(newPacket), _target); } else { _socket.writePacket(*newPacket, _target); } + ++_totalQueuedPackets; } diff --git a/tools/udt-test/src/UDTTest.h b/tools/udt-test/src/UDTTest.h index 28aa3d340e..652a721cbc 100644 --- a/tools/udt-test/src/UDTTest.h +++ b/tools/udt-test/src/UDTTest.h @@ -48,6 +48,8 @@ private: bool _sendReliable { true }; // whether packets are sent reliably or unreliably bool _sendOrdered { false }; // whether to send ordered packets + int _messageSize { 10000000 }; // number of bytes per message while sending ordered + int _totalQueuedPackets { 0 }; // keeps track of the number of packets we have already queued int _totalQueuedBytes { 0 }; // keeps track of the number of bytes we have already queued }; From 1756e606477b64dd8922eaa04c2817d4cbc27a7f Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 20 Aug 2015 14:22:05 -0700 Subject: [PATCH 2/5] complete test for ordered packets in udt-test target --- libraries/networking/src/udt/PacketList.cpp | 13 ++++ libraries/networking/src/udt/PacketList.h | 1 + tools/udt-test/src/UDTTest.cpp | 72 +++++++++++++++------ tools/udt-test/src/UDTTest.h | 8 +++ 4 files changed, 74 insertions(+), 20 deletions(-) diff --git a/libraries/networking/src/udt/PacketList.cpp b/libraries/networking/src/udt/PacketList.cpp index 2e9bef09e1..b135788985 100644 --- a/libraries/networking/src/udt/PacketList.cpp +++ b/libraries/networking/src/udt/PacketList.cpp @@ -52,6 +52,19 @@ size_t PacketList::getDataSize() const { return totalBytes; } +size_t PacketList::getMessageSize() const { + size_t totalBytes = 0; + for (const auto& packet: _packets) { + totalBytes += packet->getPayloadSize(); + } + + if (_currentPacket) { + totalBytes += _currentPacket->getPayloadSize(); + } + + return totalBytes; +} + std::unique_ptr PacketList::fromReceivedPackets(std::list>&& packets) { auto packetList = std::unique_ptr(new PacketList(PacketType::Unknown, QByteArray(), true, true)); packetList->_packets = std::move(packets); diff --git a/libraries/networking/src/udt/PacketList.h b/libraries/networking/src/udt/PacketList.h index 37c253ac08..05800a1b26 100644 --- a/libraries/networking/src/udt/PacketList.h +++ b/libraries/networking/src/udt/PacketList.h @@ -47,6 +47,7 @@ public: QByteArray getExtendedHeader() const { return _extendedHeader; } size_t getDataSize() const; + size_t getMessageSize() const; void closeCurrentPacket(bool shouldSendEmpty = false); diff --git a/tools/udt-test/src/UDTTest.cpp b/tools/udt-test/src/UDTTest.cpp index 4455ac586e..234ae1e93e 100644 --- a/tools/udt-test/src/UDTTest.cpp +++ b/tools/udt-test/src/UDTTest.cpp @@ -11,8 +11,6 @@ #include "UDTTest.h" -#include - #include #include @@ -49,7 +47,10 @@ const QCommandLineOption ORDERED_PACKETS { "ordered", "send ordered packets (default is unordered)" }; const QCommandLineOption MESSAGE_SIZE { - "message-size", "megabytes per message payload for ordered sending (default is 100)", "megabytes" + "message-size", "megabytes per message payload for ordered sending (default is 20)", "megabytes" +}; +const QCommandLineOption MESSAGE_SEED { + "message-seed", "seed used for random number generation to match ordered messages (default is 742272)", "integer" }; const QStringList CLIENT_STATS_TABLE_HEADERS { @@ -154,8 +155,26 @@ UDTTest::UDTTest(int& argc, char** argv) : } } + + // in case we're an ordered sender or receiver setup our random number generator now + static const int FIRST_MESSAGE_SEED = 742272; + + int messageSeed = FIRST_MESSAGE_SEED; + + if (_argumentParser.isSet(MESSAGE_SEED)) { + messageSeed = _argumentParser.value(MESSAGE_SEED).toInt(); + } + + // seed the generator with a value that the receiver will also use when verifying the ordered message + _generator.seed(messageSeed); + if (!_target.isNull()) { sendInitialPackets(); + } else { + // this is a receiver - in case there are ordered packets (messages) being sent to us make sure that we handle them + // so that they can be verified + using std::placeholders::_1; + _socket.setPacketListHandler(std::bind(&UDTTest::handlePacketList, this, _1)); } // the sender reports stats every 100 milliseconds @@ -176,7 +195,7 @@ void UDTTest::parseArguments() { _argumentParser.addOptions({ PORT_OPTION, TARGET_OPTION, PACKET_SIZE, MIN_PACKET_SIZE, MAX_PACKET_SIZE, MAX_SEND_BYTES, MAX_SEND_PACKETS, UNRELIABLE_PACKETS, ORDERED_PACKETS, - MESSAGE_SIZE + MESSAGE_SIZE, MESSAGE_SEED }); if (!_argumentParser.parse(arguments())) { @@ -206,8 +225,6 @@ void UDTTest::sendInitialPackets() { } } -static const int FIRST_MESSAGE_SEED = 742272; - void UDTTest::sendPacket() { if (_maxSendPackets != -1 && _totalQueuedPackets > _maxSendPackets) { @@ -238,7 +255,7 @@ void UDTTest::sendPacket() { // check if it is time to add another message - we do this every time 95% of the message size has been sent static int call = 0; static int packetSize = udt::Packet::maxPayloadSize(true); - static int messageSizePackets = (int) ceil(_messageSize / udt::Packet::maxPayloadSize()); + static int messageSizePackets = (int) ceil(_messageSize / udt::Packet::maxPayloadSize(true)); static int refillCount = (int) (messageSizePackets * 0.95); @@ -248,25 +265,14 @@ void UDTTest::sendPacket() { new udt::PacketList(PacketType::BulkAvatarData, QByteArray(), true, true) }); - static int currentSeed = FIRST_MESSAGE_SEED; - - std::random_device rd; - std::mt19937 generator(rd()); - - // seed the generator with a value that the receiver will also use when verifying the ordered message - generator.seed(currentSeed++); - - // setup a distribution for integer values - std::uniform_int_distribution<> dis(1, UINT64_MAX); - // fill the packet list with random data according to the constant seed (so receiver can verify) for (int i = 0; i < messageSizePackets; ++i) { // setup a QByteArray full of zeros for our random padded data QByteArray randomPaddedData { packetSize, 0 }; // generate a random integer for the first 8 bytes of the random data - uint64_t randomInt = dis(generator); - randomPaddedData.replace(0, sizeof(randomInt), reinterpret_cast(&randomInt)); + uint64_t randomInt = _distribution(_generator); + randomPaddedData.replace(0, sizeof(randomInt), reinterpret_cast(&randomInt), sizeof(randomInt)); // write this data to the PacketList packetList->write(randomPaddedData); @@ -298,6 +304,32 @@ void UDTTest::sendPacket() { } +void UDTTest::handlePacketList(std::unique_ptr packetList) { + // generate the byte array that should match this message - using the same seed the sender did + + int packetSize = udt::Packet::maxPayloadSize(true); + int messageSize = packetList->getMessageSize(); + + QByteArray messageData(messageSize, 0); + + for (int i = 0; i < messageSize; i += packetSize) { + // generate the random 64-bit unsigned integer that should lead this packet + uint64_t randomInt = _distribution(_generator); + + messageData.replace(i, sizeof(randomInt), reinterpret_cast(&randomInt), sizeof(randomInt)); + } + + bool dataMatch = messageData == packetList->getMessage(); + + Q_ASSERT_X(dataMatch, "UDTTest::handlePacketList", + "received message did not match expected message (from seeded random number generation)."); + + if (!dataMatch) { + qCritical() << "UDTTest::handlePacketList" << "received message did not match expected message" + << "(from seeded random number generation)."; + } +} + void UDTTest::sampleStats() { static bool first = true; static const double USECS_PER_MSEC = 1000.0; diff --git a/tools/udt-test/src/UDTTest.h b/tools/udt-test/src/UDTTest.h index 652a721cbc..376dc98bf6 100644 --- a/tools/udt-test/src/UDTTest.h +++ b/tools/udt-test/src/UDTTest.h @@ -14,6 +14,9 @@ #ifndef hifi_UDTTest_h #define hifi_UDTTest_h + +#include + #include #include @@ -31,6 +34,7 @@ public slots: private: void parseArguments(); + void handlePacketList(std::unique_ptr packetList); void sendInitialPackets(); // fills the queue with packets to start void sendPacket(); // constructs and sends a packet according to the test parameters @@ -50,6 +54,10 @@ private: int _messageSize { 10000000 }; // number of bytes per message while sending ordered + std::random_device _randomDevice; + std::mt19937 _generator { _randomDevice() }; // random number generator for ordered data testing + std::uniform_int_distribution _distribution { 1, UINT64_MAX }; // producer of random integer values + int _totalQueuedPackets { 0 }; // keeps track of the number of packets we have already queued int _totalQueuedBytes { 0 }; // keeps track of the number of bytes we have already queued }; From 92116dd6e7b66a903aa9a96dd7458dd480be6bc0 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 25 Aug 2015 11:04:24 -0700 Subject: [PATCH 3/5] added stats for receive rate in Mbits --- tools/udt-test/src/UDTTest.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/udt-test/src/UDTTest.cpp b/tools/udt-test/src/UDTTest.cpp index 234ae1e93e..d9cd9cc1b6 100644 --- a/tools/udt-test/src/UDTTest.cpp +++ b/tools/udt-test/src/UDTTest.cpp @@ -52,6 +52,9 @@ const QCommandLineOption MESSAGE_SIZE { const QCommandLineOption MESSAGE_SEED { "message-seed", "seed used for random number generation to match ordered messages (default is 742272)", "integer" }; +const QCommandLineOption STATS_INTERVAL { + "stats-interval", "stats output interval (default is 100ms)", "milliseconds" +}; const QStringList CLIENT_STATS_TABLE_HEADERS { "Send Rate (P/s)", "Bandwidth (P/s)", "RTT(ms)", "CW (P)", "Send Period (us)", @@ -60,7 +63,7 @@ const QStringList CLIENT_STATS_TABLE_HEADERS { }; const QStringList SERVER_STATS_TABLE_HEADERS { - "Receive Rate (P/s)", "Bandwidth (P/s)", "RTT(ms)", "CW (P)", + "Received Megabits", "Receive Rate (P/s)", "Bandwidth (P/s)", "RTT(ms)", "CW (P)", "Sent ACK", "Sent LACK", "Sent NAK", "Sent TNAK", "Recieved ACK2", "Duplicate Packets" }; @@ -180,9 +183,15 @@ UDTTest::UDTTest(int& argc, char** argv) : // the sender reports stats every 100 milliseconds static const int STATS_SAMPLE_INTERVAL = 100; + int statsInterval = STATS_SAMPLE_INTERVAL; + + if (_argumentParser.isSet(STATS_INTERVAL)) { + statsInterval = _argumentParser.value(STATS_INTERVAL).toInt(); + } + QTimer* statsTimer = new QTimer(this); connect(statsTimer, &QTimer::timeout, this, &UDTTest::sampleStats); - statsTimer->start(STATS_SAMPLE_INTERVAL); + statsTimer->start(statsInterval); } void UDTTest::parseArguments() { @@ -195,7 +204,7 @@ void UDTTest::parseArguments() { _argumentParser.addOptions({ PORT_OPTION, TARGET_OPTION, PACKET_SIZE, MIN_PACKET_SIZE, MAX_PACKET_SIZE, MAX_SEND_BYTES, MAX_SEND_PACKETS, UNRELIABLE_PACKETS, ORDERED_PACKETS, - MESSAGE_SIZE, MESSAGE_SEED + MESSAGE_SIZE, MESSAGE_SEED, STATS_INTERVAL }); if (!_argumentParser.parse(arguments())) { @@ -377,8 +386,11 @@ void UDTTest::sampleStats() { int headerIndex = -1; + static const double MEGABITS_PER_BYTE = 8.0 / 1000000.0; + // setup a list of left justified values QStringList values { + QString::number(stats.recievedBytes * MEGABITS_PER_BYTE).leftJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), QString::number(stats.receiveRate).leftJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), QString::number(stats.estimatedBandwith).leftJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), QString::number(stats.rtt / USECS_PER_MSEC).leftJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), From 9ff7bfd0b50d201293e32681346e63dfed1a9937 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 25 Aug 2015 11:21:04 -0700 Subject: [PATCH 4/5] some header cleanup in UDTTest output --- .../networking/src/udt/ConnectionStats.cpp | 22 ++++---- .../networking/src/udt/ConnectionStats.h | 12 ++-- tools/udt-test/src/UDTTest.cpp | 56 +++++++++---------- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/libraries/networking/src/udt/ConnectionStats.cpp b/libraries/networking/src/udt/ConnectionStats.cpp index 8c36750782..52188c29c3 100644 --- a/libraries/networking/src/udt/ConnectionStats.cpp +++ b/libraries/networking/src/udt/ConnectionStats.cpp @@ -48,14 +48,14 @@ void ConnectionStats::recordSentPackets(int payload, int total) { } void ConnectionStats::recordReceivedPackets(int payload, int total) { - ++_currentSample.recievedPackets; - ++_total.recievedPackets; + ++_currentSample.receivedPackets; + ++_total.receivedPackets; - _currentSample.recievedUtilBytes += payload; - _total.recievedUtilBytes += payload; + _currentSample.receivedUtilBytes += payload; + _total.receivedUtilBytes += payload; - _currentSample.recievedBytes += total; - _total.recievedBytes += total; + _currentSample.receivedBytes += total; + _total.receivedBytes += total; } void ConnectionStats::recordUnreliableSentPackets(int payload, int total) { @@ -70,14 +70,14 @@ void ConnectionStats::recordUnreliableSentPackets(int payload, int total) { } void ConnectionStats::recordUnreliableReceivedPackets(int payload, int total) { - ++_currentSample.recievedUnreliablePackets; - ++_total.recievedUnreliablePackets; + ++_currentSample.receivedUnreliablePackets; + ++_total.receivedUnreliablePackets; - _currentSample.recievedUnreliableUtilBytes += payload; - _total.recievedUnreliableUtilBytes += payload; + _currentSample.receivedUnreliableUtilBytes += payload; + _total.receivedUnreliableUtilBytes += payload; _currentSample.sentUnreliableBytes += total; - _total.recievedUnreliableBytes += total; + _total.receivedUnreliableBytes += total; } static const double EWMA_CURRENT_SAMPLE_WEIGHT = 0.125; diff --git a/libraries/networking/src/udt/ConnectionStats.h b/libraries/networking/src/udt/ConnectionStats.h index 2800db7720..494d433bca 100644 --- a/libraries/networking/src/udt/ConnectionStats.h +++ b/libraries/networking/src/udt/ConnectionStats.h @@ -44,18 +44,18 @@ public: // packet counts and sizes int sentPackets { 0 }; - int recievedPackets { 0 }; + int receivedPackets { 0 }; int sentUtilBytes { 0 }; - int recievedUtilBytes { 0 }; + int receivedUtilBytes { 0 }; int sentBytes { 0 }; - int recievedBytes { 0 }; + int receivedBytes { 0 }; int sentUnreliablePackets { 0 }; - int recievedUnreliablePackets { 0 }; + int receivedUnreliablePackets { 0 }; int sentUnreliableUtilBytes { 0 }; - int recievedUnreliableUtilBytes { 0 }; + int receivedUnreliableUtilBytes { 0 }; int sentUnreliableBytes { 0 }; - int recievedUnreliableBytes { 0 }; + int receivedUnreliableBytes { 0 }; // the following stats are trailing averages in the result, not totals int sendRate { 0 }; diff --git a/tools/udt-test/src/UDTTest.cpp b/tools/udt-test/src/UDTTest.cpp index d9cd9cc1b6..74d662287f 100644 --- a/tools/udt-test/src/UDTTest.cpp +++ b/tools/udt-test/src/UDTTest.cpp @@ -57,15 +57,15 @@ const QCommandLineOption STATS_INTERVAL { }; const QStringList CLIENT_STATS_TABLE_HEADERS { - "Send Rate (P/s)", "Bandwidth (P/s)", "RTT(ms)", "CW (P)", "Send Period (us)", - "Received ACK", "Processed ACK", "Received LACK", "Received NAK", "Received TNAK", + "Send (P/s)", "Est. Max (P/s)", "RTT (ms)", "CW (P)", "Period (us)", + "Recv ACK", "Procd ACK", "Recv LACK", "Recv NAK", "Recv TNAK", "Sent ACK2", "Sent Packets", "Re-sent Packets" }; const QStringList SERVER_STATS_TABLE_HEADERS { - "Received Megabits", "Receive Rate (P/s)", "Bandwidth (P/s)", "RTT(ms)", "CW (P)", + "Megabits", "Recv P/s", "Est. Max (P/s)", "RTT (ms)", "CW (P)", "Sent ACK", "Sent LACK", "Sent NAK", "Sent TNAK", - "Recieved ACK2", "Duplicate Packets" + "Recv ACK2", "Duplicates (P)" }; UDTTest::UDTTest(int& argc, char** argv) : @@ -356,19 +356,19 @@ void UDTTest::sampleStats() { // setup a list of left justified values QStringList values { - QString::number(stats.sendRate).leftJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.estimatedBandwith).leftJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.rtt / USECS_PER_MSEC).leftJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.congestionWindowSize).leftJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.packetSendPeriod).leftJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.events[udt::ConnectionStats::Stats::ReceivedACK]).leftJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.events[udt::ConnectionStats::Stats::ProcessedACK]).leftJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.events[udt::ConnectionStats::Stats::ReceivedLightACK]).leftJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.events[udt::ConnectionStats::Stats::ReceivedNAK]).leftJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.events[udt::ConnectionStats::Stats::ReceivedTimeoutNAK]).leftJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.events[udt::ConnectionStats::Stats::SentACK2]).leftJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.sentPackets).leftJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.events[udt::ConnectionStats::Stats::Retransmission]).leftJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()) + QString::number(stats.sendRate).rightJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.estimatedBandwith).rightJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.rtt / USECS_PER_MSEC, 'f', 2).rightJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.congestionWindowSize).rightJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.packetSendPeriod).rightJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.events[udt::ConnectionStats::Stats::ReceivedACK]).rightJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.events[udt::ConnectionStats::Stats::ProcessedACK]).rightJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.events[udt::ConnectionStats::Stats::ReceivedLightACK]).rightJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.events[udt::ConnectionStats::Stats::ReceivedNAK]).rightJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.events[udt::ConnectionStats::Stats::ReceivedTimeoutNAK]).rightJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.events[udt::ConnectionStats::Stats::SentACK2]).rightJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.sentPackets).rightJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.events[udt::ConnectionStats::Stats::Retransmission]).rightJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()) }; // output this line of values @@ -390,17 +390,17 @@ void UDTTest::sampleStats() { // setup a list of left justified values QStringList values { - QString::number(stats.recievedBytes * MEGABITS_PER_BYTE).leftJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.receiveRate).leftJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.estimatedBandwith).leftJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.rtt / USECS_PER_MSEC).leftJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.congestionWindowSize).leftJustified(CLIENT_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.events[udt::ConnectionStats::Stats::SentACK]).leftJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.events[udt::ConnectionStats::Stats::SentLightACK]).leftJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.events[udt::ConnectionStats::Stats::SentNAK]).leftJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.events[udt::ConnectionStats::Stats::SentTimeoutNAK]).leftJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.events[udt::ConnectionStats::Stats::ReceivedACK2]).leftJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), - QString::number(stats.events[udt::ConnectionStats::Stats::Duplicate]).leftJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()) + QString::number(stats.receivedBytes * MEGABITS_PER_BYTE, 'f', 2).rightJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.receiveRate).rightJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.estimatedBandwith).rightJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.rtt / USECS_PER_MSEC, 'f', 2).rightJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.congestionWindowSize).rightJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.events[udt::ConnectionStats::Stats::SentACK]).rightJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.events[udt::ConnectionStats::Stats::SentLightACK]).rightJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.events[udt::ConnectionStats::Stats::SentNAK]).rightJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.events[udt::ConnectionStats::Stats::SentTimeoutNAK]).rightJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.events[udt::ConnectionStats::Stats::ReceivedACK2]).rightJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()), + QString::number(stats.events[udt::ConnectionStats::Stats::Duplicate]).rightJustified(SERVER_STATS_TABLE_HEADERS[++headerIndex].size()) }; // output this line of values From 61507bde09ac5767a21e26421b433270b5bf5b13 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 25 Aug 2015 11:24:26 -0700 Subject: [PATCH 5/5] fix order of member initialization in PacketList --- libraries/networking/src/udt/PacketList.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/networking/src/udt/PacketList.cpp b/libraries/networking/src/udt/PacketList.cpp index b135788985..6dad7e9133 100644 --- a/libraries/networking/src/udt/PacketList.cpp +++ b/libraries/networking/src/udt/PacketList.cpp @@ -26,9 +26,10 @@ PacketList::PacketList(PacketType packetType, QByteArray extendedHeader, bool is } PacketList::PacketList(PacketList&& other) : - _packetType(other._packetType), - _packets(std::move(other._packets)) + _packets(std::move(other._packets)), + _packetType(other._packetType) { + } void PacketList::startSegment() {