mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
fix for ACK2 sending, output prettier stats
This commit is contained in:
parent
ed614521fd
commit
d420bca88e
4 changed files with 37 additions and 15 deletions
|
@ -192,6 +192,9 @@ void Connection::sendACK2(SequenceNumber currentACKSubSequenceNumber) {
|
|||
// write the sub sequence number for this ACK2
|
||||
ack2Packet->writePrimitive(currentACKSubSequenceNumber);
|
||||
|
||||
// send the ACK2 packet
|
||||
_parentSocket->writeBasePacket(*ack2Packet, _destination);
|
||||
|
||||
// update the last sent ACK2 and the last ACK2 send time
|
||||
_lastSentACK2 = currentACKSubSequenceNumber;
|
||||
|
||||
|
|
|
@ -215,19 +215,15 @@ void Socket::setCongestionControlFactory(std::unique_ptr<CongestionControlVirtua
|
|||
_synInterval = _ccFactory->synInterval();
|
||||
}
|
||||
|
||||
void Socket::sampleAndPrintConnectionStats() {
|
||||
if (thread() != QThread::currentThread()) {
|
||||
QMetaObject::invokeMethod(this, "sampleAndPrintConnectionStats");
|
||||
return;
|
||||
}
|
||||
ConnectionStats::Stats Socket::sampleStatsForConnection(const HifiSockAddr& destination) {
|
||||
Q_ASSERT_X(thread() == QThread::currentThread(),
|
||||
"Socket::sampleStatsForConnection",
|
||||
"Stats sampling for connection must be on socket thread");
|
||||
|
||||
for(auto& connection : _connectionsHash) {
|
||||
ConnectionStats::Stats sampleStats = connection.second->sampleStats();
|
||||
|
||||
qDebug() << connection.first
|
||||
<< sampleStats.receiveRate << sampleStats.rtt
|
||||
<< sampleStats.congestionWindowSize << sampleStats.packetSendPeriod
|
||||
<< sampleStats.sentPackets
|
||||
<< sampleStats.receivedACKs << sampleStats.receivedLightACKs << sampleStats.receivedNAKs;
|
||||
auto it = _connectionsHash.find(destination);
|
||||
if (it != _connectionsHash.end()) {
|
||||
return it->second->sampleStats();
|
||||
} else {
|
||||
return ConnectionStats::Stats();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
|
||||
void connectToSendSignal(const HifiSockAddr& destinationAddr, QObject* receiver, const char* slot);
|
||||
|
||||
void sampleAndPrintConnectionStats();
|
||||
ConnectionStats::Stats sampleStatsForConnection(const HifiSockAddr& destination);
|
||||
|
||||
private slots:
|
||||
void readPendingDatagrams();
|
||||
|
|
|
@ -41,6 +41,10 @@ const QCommandLineOption UNRELIABLE_PACKETS {
|
|||
"unreliable", "send unreliable packets (default is reliable)"
|
||||
};
|
||||
|
||||
const QStringList STATS_TABLE_HEADERS {
|
||||
"Send Rate (P/s)", "RTT(ms)", "CW (P)", "Send Period (us)", "Received ACK", "Received NAK", "Sent ACK2"
|
||||
};
|
||||
|
||||
UDTTest::UDTTest(int& argc, char** argv) :
|
||||
QCoreApplication(argc, argv)
|
||||
{
|
||||
|
@ -123,6 +127,9 @@ UDTTest::UDTTest(int& argc, char** argv) :
|
|||
QTimer* statsTimer = new QTimer(this);
|
||||
connect(statsTimer, &QTimer::timeout, this, &UDTTest::sampleStats);
|
||||
statsTimer->start(STATS_SAMPLE_INTERVAL);
|
||||
|
||||
// output the headers for stats for our table
|
||||
qDebug() << qPrintable(STATS_TABLE_HEADERS.join(" | "));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,5 +214,21 @@ void UDTTest::sendPacket() {
|
|||
}
|
||||
|
||||
void UDTTest::sampleStats() {
|
||||
_socket.sampleAndPrintConnectionStats();
|
||||
udt::ConnectionStats::Stats stats = _socket.sampleStatsForConnection(_target);
|
||||
|
||||
int headerIndex = -1;
|
||||
|
||||
// setup a list of left justified values
|
||||
QStringList values {
|
||||
QString::number(stats.receiveRate).leftJustified(STATS_TABLE_HEADERS[++headerIndex].size()),
|
||||
QString::number(stats.rtt).leftJustified(STATS_TABLE_HEADERS[++headerIndex].size()),
|
||||
QString::number(stats.congestionWindowSize).leftJustified(STATS_TABLE_HEADERS[++headerIndex].size()),
|
||||
QString::number(stats.packetSendPeriod).leftJustified(STATS_TABLE_HEADERS[++headerIndex].size()),
|
||||
QString::number(stats.receivedACKs).leftJustified(STATS_TABLE_HEADERS[++headerIndex].size()),
|
||||
QString::number(stats.receivedNAKs).leftJustified(STATS_TABLE_HEADERS[++headerIndex].size()),
|
||||
QString::number(stats.sentACK2s).leftJustified(STATS_TABLE_HEADERS[++headerIndex].size())
|
||||
};
|
||||
|
||||
// output this line of values
|
||||
qDebug() << qPrintable(values.join(" | "));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue