use a double USECS_PER_SECOND in CongestionControl

This commit is contained in:
Stephen Birarda 2015-07-29 11:14:03 -07:00
parent 89e32e4a6b
commit f65472cbc7
2 changed files with 7 additions and 7 deletions

View file

@ -11,11 +11,11 @@
#include "CongestionControl.h"
#include <NumericalConstants.h>
using namespace udt;
using namespace std::chrono;
static const double USECS_PER_SECOND = 1000000.0;
void DefaultCC::init() {
_lastRCTime = high_resolution_clock::now();
setAckTimer(synInterval());
@ -69,7 +69,7 @@ void DefaultCC::onACK(SequenceNumber ackNum) {
return;
}
B = (int64_t)(_bandwidth - 1000000.0 / _packetSendPeriod);
B = (int64_t)(_bandwidth - USECS_PER_SECOND/ _packetSendPeriod);
if ((_packetSendPeriod > _lastDecreasePeriod) && ((_bandwidth / 9) < B)) {
B = _bandwidth / 9;
}
@ -121,7 +121,7 @@ void DefaultCC::onLoss(SequenceNumber rangeStart, SequenceNumber rangeEnd) {
_decRandom = (int)ceil(_avgNAKNum * (double(rand()) / RAND_MAX));
if (_decRandom < 1)
_decRandom = 1;
} else if ((_decCount++ < 5) && (0 == (++_nakCount % _decRandom))) {
} else if ((_decCount ++ < 5) && (0 == (++ _nakCount % _decRandom))) {
// 0.875^5 = 0.51, rate should not be decreased by more than half within a congestion period
_packetSendPeriod = ceil(_packetSendPeriod * 1.125);
_lastDecreaseMaxSeq = _sendCurrSeqNum;

View file

@ -343,7 +343,7 @@ void Connection::processACK(std::unique_ptr<ControlPacket> controlPacket) {
updateRTT(rtt);
// set the RTT for congestion control
_congestionControl->setRtt(_rtt);
_congestionControl->setRTT(_rtt);
if (controlPacket->getPayloadSize() > (qint64) (sizeof(SequenceNumber) + sizeof(SequenceNumber) + sizeof(rtt))) {
int32_t deliveryRate, bandwidth;
@ -351,7 +351,7 @@ void Connection::processACK(std::unique_ptr<ControlPacket> controlPacket) {
controlPacket->readPrimitive(&bandwidth);
// set the delivery rate and bandwidth for congestion control
_congestionControl->setRcvRate(deliveryRate);
_congestionControl->setReceiveRate(deliveryRate);
_congestionControl->setBandwidth(bandwidth);
}
@ -397,7 +397,7 @@ void Connection::processACK2(std::unique_ptr<ControlPacket> controlPacket) {
updateRTT(rtt);
// set the RTT for congestion control
_congestionControl->setRtt(_rtt);
_congestionControl->setRTT(_rtt);
// update the last ACKed ACK
if (pair.first > _lastReceivedAcknowledgedACK) {