mirror of
https://github.com/JulianGro/overte.git
synced 2025-05-07 12:39:55 +02: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
|
// write the sub sequence number for this ACK2
|
||||||
ack2Packet->writePrimitive(currentACKSubSequenceNumber);
|
ack2Packet->writePrimitive(currentACKSubSequenceNumber);
|
||||||
|
|
||||||
|
// send the ACK2 packet
|
||||||
|
_parentSocket->writeBasePacket(*ack2Packet, _destination);
|
||||||
|
|
||||||
// update the last sent ACK2 and the last ACK2 send time
|
// update the last sent ACK2 and the last ACK2 send time
|
||||||
_lastSentACK2 = currentACKSubSequenceNumber;
|
_lastSentACK2 = currentACKSubSequenceNumber;
|
||||||
|
|
||||||
|
|
|
@ -215,19 +215,15 @@ void Socket::setCongestionControlFactory(std::unique_ptr<CongestionControlVirtua
|
||||||
_synInterval = _ccFactory->synInterval();
|
_synInterval = _ccFactory->synInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Socket::sampleAndPrintConnectionStats() {
|
ConnectionStats::Stats Socket::sampleStatsForConnection(const HifiSockAddr& destination) {
|
||||||
if (thread() != QThread::currentThread()) {
|
Q_ASSERT_X(thread() == QThread::currentThread(),
|
||||||
QMetaObject::invokeMethod(this, "sampleAndPrintConnectionStats");
|
"Socket::sampleStatsForConnection",
|
||||||
return;
|
"Stats sampling for connection must be on socket thread");
|
||||||
}
|
|
||||||
|
|
||||||
for(auto& connection : _connectionsHash) {
|
auto it = _connectionsHash.find(destination);
|
||||||
ConnectionStats::Stats sampleStats = connection.second->sampleStats();
|
if (it != _connectionsHash.end()) {
|
||||||
|
return it->second->sampleStats();
|
||||||
qDebug() << connection.first
|
} else {
|
||||||
<< sampleStats.receiveRate << sampleStats.rtt
|
return ConnectionStats::Stats();
|
||||||
<< sampleStats.congestionWindowSize << sampleStats.packetSendPeriod
|
|
||||||
<< sampleStats.sentPackets
|
|
||||||
<< sampleStats.receivedACKs << sampleStats.receivedLightACKs << sampleStats.receivedNAKs;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ public:
|
||||||
|
|
||||||
void connectToSendSignal(const HifiSockAddr& destinationAddr, QObject* receiver, const char* slot);
|
void connectToSendSignal(const HifiSockAddr& destinationAddr, QObject* receiver, const char* slot);
|
||||||
|
|
||||||
void sampleAndPrintConnectionStats();
|
ConnectionStats::Stats sampleStatsForConnection(const HifiSockAddr& destination);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void readPendingDatagrams();
|
void readPendingDatagrams();
|
||||||
|
|
|
@ -41,6 +41,10 @@ const QCommandLineOption UNRELIABLE_PACKETS {
|
||||||
"unreliable", "send unreliable packets (default is reliable)"
|
"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) :
|
UDTTest::UDTTest(int& argc, char** argv) :
|
||||||
QCoreApplication(argc, argv)
|
QCoreApplication(argc, argv)
|
||||||
{
|
{
|
||||||
|
@ -123,6 +127,9 @@ UDTTest::UDTTest(int& argc, char** argv) :
|
||||||
QTimer* statsTimer = new QTimer(this);
|
QTimer* statsTimer = new QTimer(this);
|
||||||
connect(statsTimer, &QTimer::timeout, this, &UDTTest::sampleStats);
|
connect(statsTimer, &QTimer::timeout, this, &UDTTest::sampleStats);
|
||||||
statsTimer->start(STATS_SAMPLE_INTERVAL);
|
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() {
|
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