mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 09:18:45 +02:00
give CongestionControl timeout event from SendQueue
This commit is contained in:
parent
8e97a50957
commit
0956649cdb
6 changed files with 24 additions and 10 deletions
|
@ -62,10 +62,10 @@ void DefaultCC::onACK(SequenceNumber ackNum) {
|
||||||
|
|
||||||
if (_slowStart) {
|
if (_slowStart) {
|
||||||
// we are in slow start phase - increase the congestion window size by the number of packets just ACKed
|
// we are in slow start phase - increase the congestion window size by the number of packets just ACKed
|
||||||
_congestionWindowSize += seqlen(_slowStartLastACK, ackNum);
|
_congestionWindowSize += seqlen(_lastACK, ackNum);
|
||||||
|
|
||||||
// update the last ACK
|
// update the last ACK
|
||||||
_slowStartLastACK = ackNum;
|
_lastACK = ackNum;
|
||||||
|
|
||||||
// check if we can get out of slow start (is our new congestion window size bigger than the max)
|
// check if we can get out of slow start (is our new congestion window size bigger than the max)
|
||||||
if (_congestionWindowSize > _maxCongestionWindowSize) {
|
if (_congestionWindowSize > _maxCongestionWindowSize) {
|
||||||
|
@ -186,11 +186,11 @@ void DefaultCC::onTimeout() {
|
||||||
stopSlowStart();
|
stopSlowStart();
|
||||||
} else {
|
} else {
|
||||||
// UDT used to do the following on timeout if not in slow start - we should check if it could be helpful
|
// UDT used to do the following on timeout if not in slow start - we should check if it could be helpful
|
||||||
// _lastDecreasePeriod = _packetSendPeriod;
|
_lastDecreasePeriod = _packetSendPeriod;
|
||||||
// _packetSendPeriod = ceil(_packetSendPeriod * 2);
|
_packetSendPeriod = ceil(_packetSendPeriod * 2);
|
||||||
|
|
||||||
// this seems odd - the last ack they were setting _lastDecreaseMaxSeq to only applies to slow start
|
// this seems odd - the last ack they were setting _lastDecreaseMaxSeq to only applies to slow start
|
||||||
// _lastDecreaseMaxSeq = _slowStartLastAck;
|
_lastDecreaseMaxSeq = _lastACK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,6 +209,5 @@ void DefaultCC::stopSlowStart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultCC::setInitialSendSequenceNumber(udt::SequenceNumber seqNum) {
|
void DefaultCC::setInitialSendSequenceNumber(udt::SequenceNumber seqNum) {
|
||||||
_slowStartLastACK = seqNum;
|
_lastACK = _lastDecreaseMaxSeq = seqNum - 1;
|
||||||
_lastDecreaseMaxSeq = seqNum - 1;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
virtual void init() {}
|
virtual void init() {}
|
||||||
virtual void onACK(SequenceNumber ackNum) {}
|
virtual void onACK(SequenceNumber ackNum) {}
|
||||||
virtual void onLoss(SequenceNumber rangeStart, SequenceNumber rangeEnd) {}
|
virtual void onLoss(SequenceNumber rangeStart, SequenceNumber rangeEnd) {}
|
||||||
|
virtual void onTimeout() {}
|
||||||
protected:
|
protected:
|
||||||
void setAckInterval(int ackInterval) { _ackInterval = ackInterval; }
|
void setAckInterval(int ackInterval) { _ackInterval = ackInterval; }
|
||||||
void setRTO(int rto) { _userDefinedRTO = true; _rto = rto; }
|
void setRTO(int rto) { _userDefinedRTO = true; _rto = rto; }
|
||||||
|
@ -115,7 +115,7 @@ private:
|
||||||
p_high_resolution_clock::time_point _lastRCTime = p_high_resolution_clock::now(); // last rate increase time
|
p_high_resolution_clock::time_point _lastRCTime = p_high_resolution_clock::now(); // last rate increase time
|
||||||
|
|
||||||
bool _slowStart { true }; // if in slow start phase
|
bool _slowStart { true }; // if in slow start phase
|
||||||
SequenceNumber _slowStartLastACK; // last ACKed seq num from previous slow start check
|
SequenceNumber _lastACK; // last ACKed sequence number from previous
|
||||||
bool _loss { false }; // if loss happened since last rate increase
|
bool _loss { false }; // if loss happened since last rate increase
|
||||||
SequenceNumber _lastDecreaseMaxSeq; // max pkt seq num sent out when last decrease happened
|
SequenceNumber _lastDecreaseMaxSeq; // max pkt seq num sent out when last decrease happened
|
||||||
double _lastDecreasePeriod { 1 }; // value of _packetSendPeriod when last decrease happened
|
double _lastDecreasePeriod { 1 }; // value of _packetSendPeriod when last decrease happened
|
||||||
|
|
|
@ -98,6 +98,7 @@ SendQueue& Connection::getSendQueue() {
|
||||||
QObject::connect(_sendQueue.get(), &SendQueue::packetSent, this, &Connection::recordSentPackets);
|
QObject::connect(_sendQueue.get(), &SendQueue::packetSent, this, &Connection::recordSentPackets);
|
||||||
QObject::connect(_sendQueue.get(), &SendQueue::packetRetransmitted, this, &Connection::recordRetransmission);
|
QObject::connect(_sendQueue.get(), &SendQueue::packetRetransmitted, this, &Connection::recordRetransmission);
|
||||||
QObject::connect(_sendQueue.get(), &SendQueue::queueInactive, this, &Connection::queueInactive);
|
QObject::connect(_sendQueue.get(), &SendQueue::queueInactive, this, &Connection::queueInactive);
|
||||||
|
QObject::connect(_sendQueue.get(), &SendQueue::timeout, this, &Connection::queueTimeout);
|
||||||
|
|
||||||
// set defaults on the send queue from our congestion control object and estimatedTimeout()
|
// set defaults on the send queue from our congestion control object and estimatedTimeout()
|
||||||
_sendQueue->setPacketSendPeriod(_congestionControl->_packetSendPeriod);
|
_sendQueue->setPacketSendPeriod(_congestionControl->_packetSendPeriod);
|
||||||
|
@ -129,6 +130,12 @@ void Connection::queueInactive() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Connection::queueTimeout() {
|
||||||
|
updateCongestionControlAndSendQueue([this]{
|
||||||
|
_congestionControl->onTimeout();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void Connection::sendReliablePacket(std::unique_ptr<Packet> packet) {
|
void Connection::sendReliablePacket(std::unique_ptr<Packet> packet) {
|
||||||
Q_ASSERT_X(packet->isReliable(), "Connection::send", "Trying to send an unreliable packet reliably.");
|
Q_ASSERT_X(packet->isReliable(), "Connection::send", "Trying to send an unreliable packet reliably.");
|
||||||
getSendQueue().queuePacket(std::move(packet));
|
getSendQueue().queuePacket(std::move(packet));
|
||||||
|
|
|
@ -84,6 +84,7 @@ private slots:
|
||||||
void recordSentPackets(int payload, int total);
|
void recordSentPackets(int payload, int total);
|
||||||
void recordRetransmission();
|
void recordRetransmission();
|
||||||
void queueInactive();
|
void queueInactive();
|
||||||
|
void queueTimeout();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void sendACK(bool wasCausedBySyncTimeout = true);
|
void sendACK(bool wasCausedBySyncTimeout = true);
|
||||||
|
|
|
@ -514,6 +514,11 @@ bool SendQueue::isInactive(bool sentAPacket) {
|
||||||
|
|
||||||
// Note that thanks to the DoubleLock we have the _naksLock right now
|
// Note that thanks to the DoubleLock we have the _naksLock right now
|
||||||
_naks.append(SequenceNumber(_lastACKSequenceNumber) + 1, _currentSequenceNumber);
|
_naks.append(SequenceNumber(_lastACKSequenceNumber) + 1, _currentSequenceNumber);
|
||||||
|
|
||||||
|
// we have the lock again - time to unlock it
|
||||||
|
locker.unlock();
|
||||||
|
|
||||||
|
emit timeout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,8 @@ signals:
|
||||||
void packetRetransmitted();
|
void packetRetransmitted();
|
||||||
|
|
||||||
void queueInactive();
|
void queueInactive();
|
||||||
|
|
||||||
|
void timeout();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void run();
|
void run();
|
||||||
|
|
Loading…
Reference in a new issue