mirror of
https://github.com/lubosz/overte.git
synced 2025-04-09 00:02:39 +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,16 +72,18 @@ void Connection::sendReliablePacket(unique_ptr<Packet> packet) {
|
|||
}
|
||||
|
||||
void Connection::sync() {
|
||||
// we send out a periodic ACK every rate control interval
|
||||
sendACK();
|
||||
|
||||
// check if we need to re-transmit a loss list
|
||||
// we do this if it has been longer than the current nakInterval since we last sent
|
||||
auto now = high_resolution_clock::now();
|
||||
|
||||
if (duration_cast<microseconds>(now - _lastNAKTime).count() >= _nakInterval) {
|
||||
// Send a timeout NAK packet
|
||||
sendTimeoutNAK();
|
||||
if (_hasReceivedFirstPacket) {
|
||||
// we send out a periodic ACK every rate control interval
|
||||
sendACK();
|
||||
|
||||
// check if we need to re-transmit a loss list
|
||||
// we do this if it has been longer than the current nakInterval since we last sent
|
||||
auto now = high_resolution_clock::now();
|
||||
|
||||
if (duration_cast<microseconds>(now - _lastNAKTime).count() >= _nakInterval) {
|
||||
// Send a timeout NAK packet
|
||||
sendTimeoutNAK();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,6 +267,9 @@ SequenceNumber Connection::nextACK() const {
|
|||
}
|
||||
|
||||
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
|
||||
if (((uint32_t) sequenceNumber & 0xF) == 0) {
|
||||
_receiveWindow.onProbePair1Arrival();
|
||||
|
@ -424,7 +429,7 @@ void Connection::processACK(std::unique_ptr<ControlPacket> controlPacket) {
|
|||
static const int EMWA_ALPHA_NUMERATOR = 8;
|
||||
|
||||
// record these samples in connection stats
|
||||
_stats.recordReceiveRate(receiveRate);
|
||||
_stats.recordSendRate(receiveRate);
|
||||
_stats.recordEstimatedBandwidth(bandwidth);
|
||||
|
||||
_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
|
||||
std::chrono::high_resolution_clock::time_point _lastNAKTime;
|
||||
|
||||
bool _hasReceivedFirstPacket { false };
|
||||
|
||||
LossList _lossList; // List of all missing packets
|
||||
SequenceNumber _lastReceivedSequenceNumber; // The largest sequence number received from the peer
|
||||
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_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) {
|
||||
_currentSample.receiveRate = sample;
|
||||
_total.receiveRate = (_total.receiveRate * EWMA_PREVIOUS_SAMPLES_WEIGHT) + (sample * EWMA_CURRENT_SAMPLE_WEIGHT);
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
int duplicates { 0 };
|
||||
|
||||
// the following stats are trailing averages in the result, not totals
|
||||
int sendRate { 0 };
|
||||
int receiveRate { 0 };
|
||||
int estimatedBandwith { 0 };
|
||||
int rtt { 0 };
|
||||
|
@ -84,6 +85,7 @@ public:
|
|||
void recordRetransmission();
|
||||
void recordDuplicates();
|
||||
|
||||
void recordSendRate(int sample);
|
||||
void recordReceiveRate(int sample);
|
||||
void recordEstimatedBandwidth(int sample);
|
||||
void recordRTT(int sample);
|
||||
|
|
|
@ -108,6 +108,8 @@ void SendQueue::overrideNAKListFromPacket(ControlPacket& packet) {
|
|||
packet.readPrimitive(&first);
|
||||
packet.readPrimitive(&second);
|
||||
|
||||
qDebug() << "NAK" << (uint32_t) first << (uint32_t) second;
|
||||
|
||||
if (first == second) {
|
||||
_naks.append(first);
|
||||
} else {
|
||||
|
|
|
@ -222,7 +222,7 @@ void UDTTest::sampleStats() {
|
|||
|
||||
// setup a list of left justified 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.congestionWindowSize).leftJustified(STATS_TABLE_HEADERS[++headerIndex].size()),
|
||||
QString::number(stats.packetSendPeriod).leftJustified(STATS_TABLE_HEADERS[++headerIndex].size()),
|
||||
|
|
Loading…
Reference in a new issue