mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-26 23:10:19 +02:00
make send rate actually send rate, don't sync as sender
This commit is contained in:
parent
74a2d985eb
commit
7f8c993bd7
6 changed files with 28 additions and 12 deletions
|
@ -72,6 +72,7 @@ void Connection::sendReliablePacket(unique_ptr<Packet> packet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::sync() {
|
void Connection::sync() {
|
||||||
|
if (_hasReceivedFirstPacket) {
|
||||||
// we send out a periodic ACK every rate control interval
|
// we send out a periodic ACK every rate control interval
|
||||||
sendACK();
|
sendACK();
|
||||||
|
|
||||||
|
@ -84,6 +85,7 @@ void Connection::sync() {
|
||||||
sendTimeoutNAK();
|
sendTimeoutNAK();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Connection::recordSentPackets(int dataSize, int payloadSize) {
|
void Connection::recordSentPackets(int dataSize, int payloadSize) {
|
||||||
_stats.recordSentPackets(payloadSize, dataSize);
|
_stats.recordSentPackets(payloadSize, dataSize);
|
||||||
|
@ -265,6 +267,9 @@ SequenceNumber Connection::nextACK() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Connection::processReceivedSequenceNumber(SequenceNumber sequenceNumber, int packetSize, int payloadSize) {
|
bool Connection::processReceivedSequenceNumber(SequenceNumber sequenceNumber, int packetSize, int payloadSize) {
|
||||||
|
|
||||||
|
_hasReceivedFirstPacket = true;
|
||||||
|
|
||||||
// check if this is a packet pair we should estimate bandwidth from, or just a regular packet
|
// check if this is a packet pair we should estimate bandwidth from, or just a regular packet
|
||||||
if (((uint32_t) sequenceNumber & 0xF) == 0) {
|
if (((uint32_t) sequenceNumber & 0xF) == 0) {
|
||||||
_receiveWindow.onProbePair1Arrival();
|
_receiveWindow.onProbePair1Arrival();
|
||||||
|
@ -424,7 +429,7 @@ void Connection::processACK(std::unique_ptr<ControlPacket> controlPacket) {
|
||||||
static const int EMWA_ALPHA_NUMERATOR = 8;
|
static const int EMWA_ALPHA_NUMERATOR = 8;
|
||||||
|
|
||||||
// record these samples in connection stats
|
// record these samples in connection stats
|
||||||
_stats.recordReceiveRate(receiveRate);
|
_stats.recordSendRate(receiveRate);
|
||||||
_stats.recordEstimatedBandwidth(bandwidth);
|
_stats.recordEstimatedBandwidth(bandwidth);
|
||||||
|
|
||||||
_deliveryRate = (_deliveryRate * (EMWA_ALPHA_NUMERATOR - 1) + receiveRate) / EMWA_ALPHA_NUMERATOR;
|
_deliveryRate = (_deliveryRate * (EMWA_ALPHA_NUMERATOR - 1) + receiveRate) / EMWA_ALPHA_NUMERATOR;
|
||||||
|
|
|
@ -86,6 +86,8 @@ private:
|
||||||
int _minNAKInterval { 100000 }; // NAK timeout interval lower bound, default of 100ms
|
int _minNAKInterval { 100000 }; // NAK timeout interval lower bound, default of 100ms
|
||||||
std::chrono::high_resolution_clock::time_point _lastNAKTime;
|
std::chrono::high_resolution_clock::time_point _lastNAKTime;
|
||||||
|
|
||||||
|
bool _hasReceivedFirstPacket { false };
|
||||||
|
|
||||||
LossList _lossList; // List of all missing packets
|
LossList _lossList; // List of all missing packets
|
||||||
SequenceNumber _lastReceivedSequenceNumber; // The largest sequence number received from the peer
|
SequenceNumber _lastReceivedSequenceNumber; // The largest sequence number received from the peer
|
||||||
SequenceNumber _lastReceivedACK; // The last ACK received
|
SequenceNumber _lastReceivedACK; // The last ACK received
|
||||||
|
|
|
@ -139,6 +139,11 @@ void ConnectionStats::recordDuplicates() {
|
||||||
static const double EWMA_CURRENT_SAMPLE_WEIGHT = 0.125;
|
static const double EWMA_CURRENT_SAMPLE_WEIGHT = 0.125;
|
||||||
static const double EWMA_PREVIOUS_SAMPLES_WEIGHT = 1 - 0.125;
|
static const double EWMA_PREVIOUS_SAMPLES_WEIGHT = 1 - 0.125;
|
||||||
|
|
||||||
|
void ConnectionStats::recordSendRate(int sample) {
|
||||||
|
_currentSample.sendRate = sample;
|
||||||
|
_total.sendRate = (_total.sendRate * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
void ConnectionStats::recordReceiveRate(int sample) {
|
void ConnectionStats::recordReceiveRate(int sample) {
|
||||||
_currentSample.receiveRate = sample;
|
_currentSample.receiveRate = sample;
|
||||||
_total.receiveRate = (_total.receiveRate * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT);
|
_total.receiveRate = (_total.receiveRate * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT);
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
int duplicates { 0 };
|
int duplicates { 0 };
|
||||||
|
|
||||||
// the following stats are trailing averages in the result, not totals
|
// the following stats are trailing averages in the result, not totals
|
||||||
|
int sendRate { 0 };
|
||||||
int receiveRate { 0 };
|
int receiveRate { 0 };
|
||||||
int estimatedBandwith { 0 };
|
int estimatedBandwith { 0 };
|
||||||
int rtt { 0 };
|
int rtt { 0 };
|
||||||
|
@ -84,6 +85,7 @@ public:
|
||||||
void recordRetransmission();
|
void recordRetransmission();
|
||||||
void recordDuplicates();
|
void recordDuplicates();
|
||||||
|
|
||||||
|
void recordSendRate(int sample);
|
||||||
void recordReceiveRate(int sample);
|
void recordReceiveRate(int sample);
|
||||||
void recordEstimatedBandwidth(int sample);
|
void recordEstimatedBandwidth(int sample);
|
||||||
void recordRTT(int sample);
|
void recordRTT(int sample);
|
||||||
|
|
|
@ -108,6 +108,8 @@ void SendQueue::overrideNAKListFromPacket(ControlPacket& packet) {
|
||||||
packet.readPrimitive(&first);
|
packet.readPrimitive(&first);
|
||||||
packet.readPrimitive(&second);
|
packet.readPrimitive(&second);
|
||||||
|
|
||||||
|
qDebug() << "NAK" << (uint32_t) first << (uint32_t) second;
|
||||||
|
|
||||||
if (first == second) {
|
if (first == second) {
|
||||||
_naks.append(first);
|
_naks.append(first);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -222,7 +222,7 @@ void UDTTest::sampleStats() {
|
||||||
|
|
||||||
// setup a list of left justified values
|
// setup a list of left justified values
|
||||||
QStringList values {
|
QStringList values {
|
||||||
QString::number(stats.receiveRate).leftJustified(STATS_TABLE_HEADERS[++headerIndex].size()),
|
QString::number(stats.sendRate).leftJustified(STATS_TABLE_HEADERS[++headerIndex].size()),
|
||||||
QString::number(stats.rtt / USECS_PER_MSEC).leftJustified(STATS_TABLE_HEADERS[++headerIndex].size()),
|
QString::number(stats.rtt / USECS_PER_MSEC).leftJustified(STATS_TABLE_HEADERS[++headerIndex].size()),
|
||||||
QString::number(stats.congestionWindowSize).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.packetSendPeriod).leftJustified(STATS_TABLE_HEADERS[++headerIndex].size()),
|
||||||
|
|
Loading…
Reference in a new issue