From 93a00c3d5d94d1203f566045dff453edf2f73501 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 18 Mar 2016 14:03:56 -0700 Subject: [PATCH] don't perform a decrease during single packet loss events --- .../networking/src/udt/CongestionControl.cpp | 19 +++++++++++++------ .../networking/src/udt/CongestionControl.h | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/libraries/networking/src/udt/CongestionControl.cpp b/libraries/networking/src/udt/CongestionControl.cpp index 0f8a9f24f6..76ac93781b 100644 --- a/libraries/networking/src/udt/CongestionControl.cpp +++ b/libraries/networking/src/udt/CongestionControl.cpp @@ -138,18 +138,23 @@ void DefaultCC::onLoss(SequenceNumber rangeStart, SequenceNumber rangeEnd) { } } - _loss = true; - static const double INTER_PACKET_ARRIVAL_INCREASE = 1.125; static const int MAX_DECREASES_PER_CONGESTION_EPOCH = 5; - + // check if this NAK starts a new congestion period - this will be the case if the // NAK received occured for a packet sent after the last decrease if (rangeStart > _lastDecreaseMaxSeq) { + + // check if we should skip handling of this loss event + // we do this if this congestion event represents only a single packet loss + if (rangeStart == rangeEnd) { + return; + } + _lastDecreasePeriod = _packetSendPeriod; - + _packetSendPeriod = ceil(_packetSendPeriod * INTER_PACKET_ARRIVAL_INCREASE); - + // use EWMA to update the average number of NAKs per congestion static const double NAK_EWMA_ALPHA = 0.125; _avgNAKNum = (int)ceil(_avgNAKNum * (1 - NAK_EWMA_ALPHA) + _nakCount * NAK_EWMA_ALPHA); @@ -159,7 +164,7 @@ void DefaultCC::onLoss(SequenceNumber rangeStart, SequenceNumber rangeEnd) { _decreaseCount = 1; _lastDecreaseMaxSeq = _sendCurrSeqNum; - + if (_avgNAKNum < 1) { _randomDecreaseThreshold = 1; } else { @@ -177,6 +182,8 @@ void DefaultCC::onLoss(SequenceNumber rangeStart, SequenceNumber rangeEnd) { _packetSendPeriod = ceil(_packetSendPeriod * INTER_PACKET_ARRIVAL_INCREASE); _lastDecreaseMaxSeq = _sendCurrSeqNum; } + + _loss = true; } // Note: This isn't currently being called by anything since we, unlike UDT, don't have TTL on our packets diff --git a/libraries/networking/src/udt/CongestionControl.h b/libraries/networking/src/udt/CongestionControl.h index 69b7a32d2d..e3990f511a 100644 --- a/libraries/networking/src/udt/CongestionControl.h +++ b/libraries/networking/src/udt/CongestionControl.h @@ -118,6 +118,7 @@ private: SequenceNumber _slowStartLastACK; // last ACKed seq num from previous slow start check bool _loss { false }; // if loss happened since last rate increase SequenceNumber _lastDecreaseMaxSeq; // max pkt seq num sent out when last decrease happened + SequenceNumber _firstLossFromEvent; // sequence number of first packet ignored for last congestion event double _lastDecreasePeriod { 1 }; // value of _packetSendPeriod when last decrease happened int _nakCount { 0 }; // number of NAKs in congestion epoch int _randomDecreaseThreshold { 1 }; // random threshold on decrease by number of loss events