diff --git a/libraries/networking/src/udt/CongestionControl.h b/libraries/networking/src/udt/CongestionControl.h index 81de761632..e56dd253db 100644 --- a/libraries/networking/src/udt/CongestionControl.h +++ b/libraries/networking/src/udt/CongestionControl.h @@ -46,6 +46,7 @@ public: virtual bool shouldNAK() { return true; } virtual bool shouldACK2() { return true; } + virtual bool shouldProbe() { return true; } virtual void onPacketSent(int packetSize, SequenceNumber seqNum, p_high_resolution_clock::time_point timePoint) {} protected: diff --git a/libraries/networking/src/udt/Connection.cpp b/libraries/networking/src/udt/Connection.cpp index 764511408c..45ecf11e50 100644 --- a/libraries/networking/src/udt/Connection.cpp +++ b/libraries/networking/src/udt/Connection.cpp @@ -125,6 +125,7 @@ SendQueue& Connection::getSendQueue() { _sendQueue->setSyncInterval(_synInterval); _sendQueue->setEstimatedTimeout(estimatedTimeout()); _sendQueue->setFlowWindowSize(std::min(_flowWindowSize, (int) _congestionControl->_congestionWindowSize)); + _sendQueue->setProbePacketEnabled(_congestionControl->shouldProbe()); // give the randomized sequence number to the congestion control object _congestionControl->setInitialSendSequenceNumber(_sendQueue->getCurrentSequenceNumber()); diff --git a/libraries/networking/src/udt/SendQueue.cpp b/libraries/networking/src/udt/SendQueue.cpp index e8f3375ba6..537f5c9215 100644 --- a/libraries/networking/src/udt/SendQueue.cpp +++ b/libraries/networking/src/udt/SendQueue.cpp @@ -396,6 +396,10 @@ void SendQueue::run() { } } +void SendQueue::setProbePacketEnabled(bool enabled) { + _shouldSendProbes = enabled; +} + int SendQueue::maybeSendNewPacket() { if (!isFlowWindowFull()) { // we didn't re-send a packet, so time to send a new one @@ -413,7 +417,7 @@ int SendQueue::maybeSendNewPacket() { std::unique_ptr secondPacket; bool shouldSendPairTail = false; - if (((uint32_t) nextNumber & 0xF) == 0) { + if (_shouldSendProbes && ((uint32_t) nextNumber & 0xF) == 0) { // the first packet is the first in a probe pair - every 16 (rightmost 16 bits = 0) packets // pull off a second packet if we can before we unlock shouldSendPairTail = true; diff --git a/libraries/networking/src/udt/SendQueue.h b/libraries/networking/src/udt/SendQueue.h index c7110d4044..e7651dd934 100644 --- a/libraries/networking/src/udt/SendQueue.h +++ b/libraries/networking/src/udt/SendQueue.h @@ -64,6 +64,8 @@ public: void setEstimatedTimeout(int estimatedTimeout) { _estimatedTimeout = estimatedTimeout; } void setSyncInterval(int syncInterval) { _syncInterval = syncInterval; } + + void setProbePacketEnabled(bool enabled); public slots: void stop(); @@ -140,6 +142,9 @@ private: std::condition_variable _handshakeACKCondition; std::condition_variable_any _emptyCondition; + + + std::atomic _shouldSendProbes { true }; }; } diff --git a/libraries/networking/src/udt/TCPVegasCC.cpp b/libraries/networking/src/udt/TCPVegasCC.cpp index c27b82f485..15f3863b54 100644 --- a/libraries/networking/src/udt/TCPVegasCC.cpp +++ b/libraries/networking/src/udt/TCPVegasCC.cpp @@ -52,8 +52,6 @@ bool TCPVegasCC::onACK(SequenceNumber ack, p_high_resolution_clock::time_point r + abs(lastRTT - _ewmaRTT)) / RTT_ESTIMATION_VARIANCE_ALPHA_NUMERATOR; } - - // keep track of the lowest RTT during connection _baseRTT = std::min(_baseRTT, lastRTT); diff --git a/libraries/networking/src/udt/TCPVegasCC.h b/libraries/networking/src/udt/TCPVegasCC.h index 7dffc18702..4f538cd5a4 100644 --- a/libraries/networking/src/udt/TCPVegasCC.h +++ b/libraries/networking/src/udt/TCPVegasCC.h @@ -33,6 +33,7 @@ public: virtual bool shouldNAK() override { return false; } virtual bool shouldACK2() override { return false; } + virtual bool shouldProbe() override { return false; } virtual void onPacketSent(int packetSize, SequenceNumber seqNum, p_high_resolution_clock::time_point timePoint) override;