Merge branch 'atp' of https://github.com/birarda/hifi into protocol

This commit is contained in:
Atlante45 2015-07-29 11:37:30 -07:00
commit 3704740227
2 changed files with 13 additions and 4 deletions

View file

@ -346,13 +346,19 @@ void Connection::processACK(std::unique_ptr<ControlPacket> controlPacket) {
_congestionControl->setRTT(_rtt);
if (controlPacket->getPayloadSize() > (qint64) (sizeof(SequenceNumber) + sizeof(SequenceNumber) + sizeof(rtt))) {
int32_t deliveryRate, bandwidth;
controlPacket->readPrimitive(&deliveryRate);
int32_t receiveRate, bandwidth;
controlPacket->readPrimitive(&receiveRate);
controlPacket->readPrimitive(&bandwidth);
// set the delivery rate and bandwidth for congestion control
_congestionControl->setReceiveRate(deliveryRate);
_congestionControl->setBandwidth(bandwidth);
// these are calculated using an EWMA
static const int EMWA_ALPHA_NUMERATOR = 8;
_deliveryRate = (_deliveryRate * (EMWA_ALPHA_NUMERATOR - 1) + _deliveryRate) / EMWA_ALPHA_NUMERATOR;
_bandwidth = (_bandwidth * (EMWA_ALPHA_NUMERATOR - 1) + _bandwidth) / EMWA_ALPHA_NUMERATOR;
_congestionControl->setReceiveRate(_deliveryRate);
_congestionControl->setBandwidth(_bandwidth);
}
// fire the onACK callback for congestion control

View file

@ -81,6 +81,9 @@ private:
int32_t _rttVariance; // RTT variance
int _flowWindowSize; // 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
SentACKMap _sentACKs; // Map of ACK sub-sequence numbers to ACKed sequence number and sent time
Socket* _parentSocket { nullptr };