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

This commit is contained in:
Atlante45 2015-07-29 16:25:26 -07:00
commit 313fcea9fb
2 changed files with 22 additions and 18 deletions

View file

@ -385,15 +385,10 @@ void Connection::processACK(std::unique_ptr<ControlPacket> controlPacket) {
_congestionControl->setBandwidth(_bandwidth);
}
// update the last sent sequence number in congestion control
_congestionControl->setSendCurrentSequenceNumber(_sendQueue->getCurrentSequenceNumber());
// fire the onACK callback for congestion control
_congestionControl->onAck(ack);
// now that we've updated the congestion control, update the packet send period and flow window size
_sendQueue->setPacketSendPeriod(_congestionControl->_packetSendPeriod);
_sendQueue->setFlowWindowSize(std::min(_flowWindowSize, (int) _congestionControl->_congestionWindowSize));
// give this ACK to the congestion control and update the send queue parameters
updateCongestionControlAndSendQueue([this, ack](){
_congestionControl->onAck(ack);
});
// update the total count of received ACKs
_stats.recordReceivedACK();
@ -459,15 +454,10 @@ void Connection::processNAK(std::unique_ptr<ControlPacket> controlPacket) {
// send that off to the send queue so it knows there was loss
_sendQueue->nak(start, end);
// update the last sent sequence number in congestion control
_congestionControl->setSendCurrentSequenceNumber(_sendQueue->getCurrentSequenceNumber());
// give the loss to the congestion control object
_congestionControl->onLoss(start, end);
// now that we've updated the congestion control, update the packet send period and flow window size
_sendQueue->setPacketSendPeriod(_congestionControl->_packetSendPeriod);
_sendQueue->setFlowWindowSize(std::min(_flowWindowSize, (int) _congestionControl->_congestionWindowSize));
// give the loss to the congestion control object and update the send queue parameters
updateCongestionControlAndSendQueue([this, start, end](){
_congestionControl->onLoss(start, end);
});
_stats.recordReceivedNAK();
}
@ -505,3 +495,15 @@ void Connection::updateRTT(int rtt) {
int Connection::estimatedTimeout() const {
return _congestionControl->_userDefinedRto ? _rtt + _rttVariance * 4 : _congestionControl->_rto;
}
void Connection::updateCongestionControlAndSendQueue(std::function<void ()> congestionCallback) {
// update the last sent sequence number in congestion control
_congestionControl->setSendCurrentSequenceNumber(_sendQueue->getCurrentSequenceNumber());
// fire congestion control callback
congestionCallback();
// now that we've update the congestion control, update the packet send period and flow window size
_sendQueue->setPacketSendPeriod(_congestionControl->_packetSendPeriod);
_sendQueue->setFlowWindowSize(std::min(_flowWindowSize, (int) _congestionControl->_congestionWindowSize));
}

View file

@ -64,6 +64,8 @@ private:
int estimatedTimeout() const;
void updateCongestionControlAndSendQueue(std::function<void()> congestionCallback);
int _synInterval; // Periodical Rate Control Interval, in microseconds
int _nakInterval; // NAK timeout interval, in microseconds