diff --git a/libraries/networking/src/udt/CongestionControl.h b/libraries/networking/src/udt/CongestionControl.h index c54405e73d..27c1c8e8fd 100644 --- a/libraries/networking/src/udt/CongestionControl.h +++ b/libraries/networking/src/udt/CongestionControl.h @@ -20,9 +20,11 @@ namespace udt { static const int32_t DEFAULT_SYN_INTERVAL = 10000; // 10 ms +class Connection; class Packet; class CongestionControl { + friend class Connection; public: CongestionControl() {}; @@ -35,8 +37,6 @@ public: virtual void close() {} virtual void onAck(SequenceNumber ackNum) {} virtual void onLoss(const std::vector& lossList) {} - virtual void onPacketSent(const Packet& packet) {} - virtual void onPacketReceived(const Packet& packet) {} protected: void setAckTimer(int period) { _ackPeriod = (period > _synInterval) ? _synInterval : period; } diff --git a/libraries/networking/src/udt/Connection.cpp b/libraries/networking/src/udt/Connection.cpp index 0f09e67a72..d4dd0be7bf 100644 --- a/libraries/networking/src/udt/Connection.cpp +++ b/libraries/networking/src/udt/Connection.cpp @@ -336,6 +336,7 @@ void Connection::processACK(std::unique_ptr controlPacket) { updateRTT(rtt); // set the RTT for congestion control + _congestionControl->setRtt(_rtt); if (controlPacket->getPayloadSize() > (qint64) (sizeof(SequenceNumber) + sizeof(SequenceNumber) + sizeof(rtt))) { int32_t deliveryRate, bandwidth; @@ -343,6 +344,8 @@ void Connection::processACK(std::unique_ptr controlPacket) { controlPacket->readPrimitive(&bandwidth); // set the delivery rate and bandwidth for congestion control + _congestionControl->setRcvRate(deliveryRate); + _congestionControl->setBandwidth(bandwidth); } // fire the onACK callback for congestion control @@ -387,6 +390,7 @@ void Connection::processACK2(std::unique_ptr controlPacket) { updateRTT(rtt); // set the RTT for congestion control + _congestionControl->setRtt(_rtt); // update the last ACKed ACK if (pair.first > _lastReceivedAcknowledgedACK) { @@ -401,10 +405,13 @@ void Connection::processNAK(std::unique_ptr controlPacket) { // read the loss report SequenceNumber start, end; controlPacket->readPrimitive(&start); + if (controlPacket->bytesLeftToRead() >= (qint64)sizeof(SequenceNumber)) { controlPacket->readPrimitive(&end); } + + ++_totalReceivedNAKs; }