From 55555cf13e10579b800a7e26f1849ae9659b843c Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 29 Jul 2015 15:28:20 -0700 Subject: [PATCH] setup default for RTT, RTT variance, _synInterval --- libraries/networking/src/udt/CongestionControl.cpp | 2 +- libraries/networking/src/udt/Connection.cpp | 8 +++++++- libraries/networking/src/udt/Connection.h | 5 +++-- libraries/networking/src/udt/Constants.h | 4 +++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libraries/networking/src/udt/CongestionControl.cpp b/libraries/networking/src/udt/CongestionControl.cpp index 06b63ec60e..1450e60930 100644 --- a/libraries/networking/src/udt/CongestionControl.cpp +++ b/libraries/networking/src/udt/CongestionControl.cpp @@ -20,7 +20,7 @@ static const double USECS_PER_SECOND = 1000000.0; void DefaultCC::init() { _lastRCTime = high_resolution_clock::now(); - _mss = udt::MAX_PACKET_SIZE; + _mss = udt::MAX_PACKET_SIZE_WITH_UDP_HEADER; _slowStartLastAck = _sendCurrSeqNum; _lastDecreaseMaxSeq = SequenceNumber { SequenceNumber::MAX }; diff --git a/libraries/networking/src/udt/Connection.cpp b/libraries/networking/src/udt/Connection.cpp index 146714df10..39e4254895 100644 --- a/libraries/networking/src/udt/Connection.cpp +++ b/libraries/networking/src/udt/Connection.cpp @@ -30,6 +30,10 @@ Connection::Connection(Socket* parentSocket, HifiSockAddr destination, unique_pt _destination(destination), _congestionControl(move(congestionControl)) { + // setup default SYN, RTT and RTT Variance based on the SYN interval in CongestionControl object + _synInterval = _congestionControl->synInterval(); + _rtt = _synInterval * 10; + _rttVariance = _rtt / 2; } Connection::~Connection() { @@ -126,7 +130,9 @@ void Connection::sendACK(bool wasCausedBySyncTimeout) { // pack in the RTT and variance ackPacket->writePrimitive(_rtt); - // pack the available buffer size - must be a minimum of 2 + // pack the available buffer size, in packets + // in our implementation we have no hard limit on receive buffer size, send the default value + ackPacket->writePrimitive((int32_t) udt::CONNECTION_RECEIVE_BUFFER_SIZE_PACKETS); if (wasCausedBySyncTimeout) { // pack in the receive speed and estimatedBandwidth diff --git a/libraries/networking/src/udt/Connection.h b/libraries/networking/src/udt/Connection.h index b42ef0d8ea..d957339b9f 100644 --- a/libraries/networking/src/udt/Connection.h +++ b/libraries/networking/src/udt/Connection.h @@ -15,6 +15,7 @@ #include #include +#include "Constants.h" #include "LossList.h" #include "PacketTimeWindow.h" #include "SendQueue.h" @@ -61,7 +62,7 @@ private: int estimatedTimeout() const; - int _synInterval; // Periodical Rate Control Interval, in microseconds, defaults to 10ms + int _synInterval; // Periodical Rate Control Interval, in microseconds int _nakInterval; // NAK timeout interval, in microseconds int _minNAKInterval { 100000 }; // NAK timeout interval lower bound, default of 100ms @@ -79,7 +80,7 @@ private: int32_t _rtt; // RTT, in microseconds int32_t _rttVariance; // RTT variance - int _flowWindowSize; // Flow control window size + int _flowWindowSize { udt::MAX_PACKETS_IN_FLIGHT }; // Flow control window size int _bandwidth { 1 }; // Exponential moving average for estimated bandwidth, in packets per second int _deliveryRate { 16 }; // Exponential moving average for receiver's receive rate, in packets per second diff --git a/libraries/networking/src/udt/Constants.h b/libraries/networking/src/udt/Constants.h index 5c5ba392a1..e8a7658bf9 100644 --- a/libraries/networking/src/udt/Constants.h +++ b/libraries/networking/src/udt/Constants.h @@ -15,12 +15,14 @@ #define hifi_udt_Constants_h namespace udt { - static const int MAX_PACKET_SIZE = 1450; + static const int MAX_PACKET_SIZE_WITH_UDP_HEADER = 1500; + static const int MAX_PACKET_SIZE = MAX_PACKET_SIZE_WITH_UDP_HEADER - 28; static const int MAX_PACKETS_IN_FLIGHT = 25600; static const int CONNECTION_RECEIVE_BUFFER_SIZE_PACKETS = 8192; static const int CONNECTION_SEND_BUFFER_SIZE_PACKETS = 8192; static const int UDP_SEND_BUFFER_SIZE_BYTES = 1048576; static const int UDP_RECEIVE_BUFFER_SIZE_BYTES = 1048576; + static const int DEFAULT_SYN_INTERVAL_USECS = 10 * 1000; } #endif // hifi_udt_Constants_h