mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 17:56:43 +02:00
Merge pull request #7354 from birarda/udt-slow-start
fix for UDT slow start phase with handshake changes
This commit is contained in:
commit
e54d5aa162
3 changed files with 14 additions and 8 deletions
|
@ -34,7 +34,6 @@ void CongestionControl::setPacketSendPeriod(double newSendPeriod) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultCC::DefaultCC() :
|
DefaultCC::DefaultCC() :
|
||||||
_slowStartLastAck(_sendCurrSeqNum),
|
|
||||||
_lastDecreaseMaxSeq(SequenceNumber {SequenceNumber::MAX })
|
_lastDecreaseMaxSeq(SequenceNumber {SequenceNumber::MAX })
|
||||||
{
|
{
|
||||||
_mss = udt::MAX_PACKET_SIZE_WITH_UDP_HEADER;
|
_mss = udt::MAX_PACKET_SIZE_WITH_UDP_HEADER;
|
||||||
|
@ -63,11 +62,11 @@ 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(_slowStartLastACK, ackNum);
|
||||||
|
|
||||||
// update the last ACK
|
// update the last ACK
|
||||||
_slowStartLastAck = ackNum;
|
_slowStartLastACK = 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) {
|
||||||
_slowStart = false;
|
_slowStart = false;
|
||||||
|
|
|
@ -50,6 +50,7 @@ protected:
|
||||||
void setMaxCongestionWindowSize(int window) { _maxCongestionWindowSize = window; }
|
void setMaxCongestionWindowSize(int window) { _maxCongestionWindowSize = window; }
|
||||||
void setBandwidth(int bandwidth) { _bandwidth = bandwidth; }
|
void setBandwidth(int bandwidth) { _bandwidth = bandwidth; }
|
||||||
void setMaxBandwidth(int maxBandwidth) { _maxBandwidth = maxBandwidth; }
|
void setMaxBandwidth(int maxBandwidth) { _maxBandwidth = maxBandwidth; }
|
||||||
|
virtual void setInitialSendSequenceNumber(SequenceNumber seqNum) = 0;
|
||||||
void setSendCurrentSequenceNumber(SequenceNumber seqNum) { _sendCurrSeqNum = seqNum; }
|
void setSendCurrentSequenceNumber(SequenceNumber seqNum) { _sendCurrSeqNum = seqNum; }
|
||||||
void setReceiveRate(int rate) { _receiveRate = rate; }
|
void setReceiveRate(int rate) { _receiveRate = rate; }
|
||||||
void setRTT(int rtt) { _rtt = rtt; }
|
void setRTT(int rtt) { _rtt = rtt; }
|
||||||
|
@ -104,14 +105,17 @@ public:
|
||||||
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();
|
virtual void onTimeout();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void setInitialSendSequenceNumber(SequenceNumber seqNum) { _slowStartLastACK = seqNum; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void stopSlowStart(); // stops the slow start on loss or timeout
|
void stopSlowStart(); // stops the slow start on loss or timeout
|
||||||
|
|
||||||
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
|
SequenceNumber _slowStartLastACK; // last ACKed seq num from previous slow start check
|
||||||
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
|
||||||
|
|
|
@ -104,6 +104,9 @@ SendQueue& Connection::getSendQueue() {
|
||||||
_sendQueue->setSyncInterval(_synInterval);
|
_sendQueue->setSyncInterval(_synInterval);
|
||||||
_sendQueue->setEstimatedTimeout(estimatedTimeout());
|
_sendQueue->setEstimatedTimeout(estimatedTimeout());
|
||||||
_sendQueue->setFlowWindowSize(std::min(_flowWindowSize, (int) _congestionControl->_congestionWindowSize));
|
_sendQueue->setFlowWindowSize(std::min(_flowWindowSize, (int) _congestionControl->_congestionWindowSize));
|
||||||
|
|
||||||
|
// give the randomized sequence number to the congestion control object
|
||||||
|
_congestionControl->setInitialSendSequenceNumber(_sendQueue->getCurrentSequenceNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
return *_sendQueue;
|
return *_sendQueue;
|
||||||
|
@ -282,7 +285,7 @@ void Connection::sendACK(bool wasCausedBySyncTimeout) {
|
||||||
// grab the up to date packet receive speed and estimated bandwidth
|
// grab the up to date packet receive speed and estimated bandwidth
|
||||||
int32_t packetReceiveSpeed = _receiveWindow.getPacketReceiveSpeed();
|
int32_t packetReceiveSpeed = _receiveWindow.getPacketReceiveSpeed();
|
||||||
int32_t estimatedBandwidth = _receiveWindow.getEstimatedBandwidth();
|
int32_t estimatedBandwidth = _receiveWindow.getEstimatedBandwidth();
|
||||||
|
|
||||||
// update those values in our connection stats
|
// update those values in our connection stats
|
||||||
_stats.recordReceiveRate(packetReceiveSpeed);
|
_stats.recordReceiveRate(packetReceiveSpeed);
|
||||||
_stats.recordEstimatedBandwidth(estimatedBandwidth);
|
_stats.recordEstimatedBandwidth(estimatedBandwidth);
|
||||||
|
@ -541,7 +544,7 @@ void Connection::processACK(std::unique_ptr<ControlPacket> controlPacket) {
|
||||||
// read the ACK sub-sequence number
|
// read the ACK sub-sequence number
|
||||||
SequenceNumber currentACKSubSequenceNumber;
|
SequenceNumber currentACKSubSequenceNumber;
|
||||||
controlPacket->readPrimitive(¤tACKSubSequenceNumber);
|
controlPacket->readPrimitive(¤tACKSubSequenceNumber);
|
||||||
|
|
||||||
// Check if we need send an ACK2 for this ACK
|
// Check if we need send an ACK2 for this ACK
|
||||||
// This will be the case if it has been longer than the sync interval OR
|
// This will be the case if it has been longer than the sync interval OR
|
||||||
// it looks like they haven't received our ACK2 for this ACK
|
// it looks like they haven't received our ACK2 for this ACK
|
||||||
|
|
Loading…
Reference in a new issue