mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 02:36:54 +02:00
sensible defaults for other time_point uses
This commit is contained in:
parent
6a186ad1fe
commit
6756d5364b
6 changed files with 23 additions and 20 deletions
|
@ -34,7 +34,6 @@ void CongestionControl::setPacketSendPeriod(double newSendPeriod) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultCC::DefaultCC() :
|
DefaultCC::DefaultCC() :
|
||||||
_lastRCTime(p_high_resolution_clock::now()),
|
|
||||||
_slowStartLastAck(_sendCurrSeqNum),
|
_slowStartLastAck(_sendCurrSeqNum),
|
||||||
_lastDecreaseMaxSeq(SequenceNumber {SequenceNumber::MAX })
|
_lastDecreaseMaxSeq(SequenceNumber {SequenceNumber::MAX })
|
||||||
{
|
{
|
||||||
|
|
|
@ -108,7 +108,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void stopSlowStart(); // stops the slow start on loss or timeout
|
void stopSlowStart(); // stops the slow start on loss or timeout
|
||||||
|
|
||||||
p_high_resolution_clock::time_point _lastRCTime = p_high_resolution_clock::time_point().min(); // last rate increase time
|
p_high_resolution_clock::time_point _lastRCTime = p_high_resolution_clock::now(); // last rate increase time
|
||||||
|
|
||||||
bool _slowStart { true }; // if in slow start phase
|
bool _slowStart { true }; // if in slow start phase
|
||||||
SequenceNumber _slowStartLastAck; // last ACKed seq num
|
SequenceNumber _slowStartLastAck; // last ACKed seq num
|
||||||
|
|
|
@ -28,7 +28,6 @@ using namespace udt;
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
Connection::Connection(Socket* parentSocket, HifiSockAddr destination, std::unique_ptr<CongestionControl> congestionControl) :
|
Connection::Connection(Socket* parentSocket, HifiSockAddr destination, std::unique_ptr<CongestionControl> congestionControl) :
|
||||||
_connectionStart(p_high_resolution_clock::now()),
|
|
||||||
_parentSocket(parentSocket),
|
_parentSocket(parentSocket),
|
||||||
_destination(destination),
|
_destination(destination),
|
||||||
_congestionControl(move(congestionControl))
|
_congestionControl(move(congestionControl))
|
||||||
|
@ -222,7 +221,7 @@ void Connection::recordRetransmission() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::sendACK(bool wasCausedBySyncTimeout) {
|
void Connection::sendACK(bool wasCausedBySyncTimeout) {
|
||||||
static p_high_resolution_clock::time_point lastACKSendTime = p_high_resolution_clock::time_point().min();
|
static p_high_resolution_clock::time_point lastACKSendTime;
|
||||||
auto currentTime = p_high_resolution_clock::now();
|
auto currentTime = p_high_resolution_clock::now();
|
||||||
|
|
||||||
SequenceNumber nextACKNumber = nextACK();
|
SequenceNumber nextACKNumber = nextACK();
|
||||||
|
@ -278,11 +277,11 @@ void Connection::sendACK(bool wasCausedBySyncTimeout) {
|
||||||
// pack in the receive speed and estimatedBandwidth
|
// pack in the receive speed and estimatedBandwidth
|
||||||
ackPacket->writePrimitive(packetReceiveSpeed);
|
ackPacket->writePrimitive(packetReceiveSpeed);
|
||||||
ackPacket->writePrimitive(estimatedBandwidth);
|
ackPacket->writePrimitive(estimatedBandwidth);
|
||||||
|
|
||||||
// record this as the last ACK send time
|
|
||||||
lastACKSendTime = p_high_resolution_clock::now();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// record this as the last ACK send time
|
||||||
|
lastACKSendTime = p_high_resolution_clock::now();
|
||||||
|
|
||||||
// have the socket send off our packet
|
// have the socket send off our packet
|
||||||
_parentSocket->writeBasePacket(*ackPacket, _destination);
|
_parentSocket->writeBasePacket(*ackPacket, _destination);
|
||||||
|
|
||||||
|
@ -534,7 +533,8 @@ void Connection::processACK(std::unique_ptr<ControlPacket> controlPacket) {
|
||||||
// This will be the case if it has been longer than the sync interval OR
|
// This will be the case if it has been longer than the sync interval OR
|
||||||
// it looks like they haven't received our ACK2 for this ACK
|
// it looks like they haven't received our ACK2 for this ACK
|
||||||
auto currentTime = p_high_resolution_clock::now();
|
auto currentTime = p_high_resolution_clock::now();
|
||||||
static p_high_resolution_clock::time_point lastACK2SendTime = p_high_resolution_clock::time_point().min();
|
static p_high_resolution_clock::time_point lastACK2SendTime =
|
||||||
|
p_high_resolution_clock::now() - std::chrono::microseconds(_synInterval);
|
||||||
|
|
||||||
microseconds sinceLastACK2 = duration_cast<microseconds>(currentTime - lastACK2SendTime);
|
microseconds sinceLastACK2 = duration_cast<microseconds>(currentTime - lastACK2SendTime);
|
||||||
|
|
||||||
|
@ -779,7 +779,7 @@ void Connection::resetReceiveState() {
|
||||||
|
|
||||||
// clear the loss list and _lastNAKTime
|
// clear the loss list and _lastNAKTime
|
||||||
_lossList.clear();
|
_lossList.clear();
|
||||||
_lastNAKTime = p_high_resolution_clock::time_point().min();
|
_lastNAKTime = p_high_resolution_clock::now();
|
||||||
|
|
||||||
// the _nakInterval need not be reset, that will happen on loss
|
// the _nakInterval need not be reset, that will happen on loss
|
||||||
|
|
||||||
|
|
|
@ -114,13 +114,14 @@ private:
|
||||||
|
|
||||||
int _nakInterval { -1 }; // NAK timeout interval, in microseconds, set on loss
|
int _nakInterval { -1 }; // NAK timeout interval, in microseconds, set on loss
|
||||||
int _minNAKInterval { 100000 }; // NAK timeout interval lower bound, default of 100ms
|
int _minNAKInterval { 100000 }; // NAK timeout interval lower bound, default of 100ms
|
||||||
p_high_resolution_clock::time_point _lastNAKTime = p_high_resolution_clock::time_point().min();
|
p_high_resolution_clock::time_point _lastNAKTime = p_high_resolution_clock::now();
|
||||||
|
|
||||||
bool _hasReceivedHandshake { false }; // flag for receipt of handshake from server
|
bool _hasReceivedHandshake { false }; // flag for receipt of handshake from server
|
||||||
bool _hasReceivedHandshakeACK { false }; // flag for receipt of handshake ACK from client
|
bool _hasReceivedHandshakeACK { false }; // flag for receipt of handshake ACK from client
|
||||||
|
|
||||||
p_high_resolution_clock::time_point _connectionStart = p_high_resolution_clock::time_point().min(); // holds the time_point for creation of this connection
|
p_high_resolution_clock::time_point _connectionStart = p_high_resolution_clock::now(); // holds the time_point for creation of this connection
|
||||||
p_high_resolution_clock::time_point _lastReceiveTime = p_high_resolution_clock::time_point().min(); // holds the last time we received anything from sender
|
p_high_resolution_clock::time_point _lastReceiveTime; // holds the last time we received anything from sender
|
||||||
|
|
||||||
bool _isReceivingData { false }; // flag used for expiry of receipt portion of connection
|
bool _isReceivingData { false }; // flag used for expiry of receipt portion of connection
|
||||||
|
|
||||||
LossList _lossList; // List of all missing packets
|
LossList _lossList; // List of all missing packets
|
||||||
|
|
|
@ -93,15 +93,18 @@ int32_t PacketTimeWindow::getEstimatedBandwidth() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketTimeWindow::onPacketArrival() {
|
void PacketTimeWindow::onPacketArrival() {
|
||||||
|
|
||||||
// take the current time
|
// take the current time
|
||||||
auto now = p_high_resolution_clock::now();
|
auto now = p_high_resolution_clock::now();
|
||||||
|
|
||||||
// record the interval between this packet and the last one
|
if (_packetIntervals.size() > 0) {
|
||||||
_packetIntervals[_currentPacketInterval++] = duration_cast<microseconds>(now - _lastPacketTime).count();
|
// record the interval between this packet and the last one
|
||||||
|
_packetIntervals[_currentPacketInterval++] = duration_cast<microseconds>(now - _lastPacketTime).count();
|
||||||
// reset the currentPacketInterval index when it wraps
|
|
||||||
if (_currentPacketInterval == _numPacketIntervals) {
|
// reset the currentPacketInterval index when it wraps
|
||||||
_currentPacketInterval = 0;
|
if (_currentPacketInterval == _numPacketIntervals) {
|
||||||
|
_currentPacketInterval = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remember this as the last packet arrival time
|
// remember this as the last packet arrival time
|
||||||
|
|
|
@ -42,8 +42,8 @@ private:
|
||||||
std::vector<int> _packetIntervals; // vector of microsecond intervals between packet arrivals
|
std::vector<int> _packetIntervals; // vector of microsecond intervals between packet arrivals
|
||||||
std::vector<int> _probeIntervals; // vector of microsecond intervals between probe pair arrivals
|
std::vector<int> _probeIntervals; // vector of microsecond intervals between probe pair arrivals
|
||||||
|
|
||||||
p_high_resolution_clock::time_point _lastPacketTime = p_high_resolution_clock::time_point().min(); // the time_point when last packet arrived
|
p_high_resolution_clock::time_point _lastPacketTime = p_high_resolution_clock::now(); // the time_point when last packet arrived
|
||||||
p_high_resolution_clock::time_point _firstProbeTime = p_high_resolution_clock::time_point().min(); // the time_point when first probe in pair arrived
|
p_high_resolution_clock::time_point _firstProbeTime = p_high_resolution_clock::now(); // the time_point when first probe in pair arrived
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue