onPacketLost method
Called when a packet is considered lost.
Implementation
void onPacketLost(int bytes, List<UDXPacket> lostPackets) {
_inflight -= bytes;
if (_inflight < 0) _inflight = 0;
_checkPersistentCongestion(lostPackets);
// Don't reduce CWND if we are already in a recovery period.
if (_inRecovery) {
return;
}
_epochStart = DateTime.now(); // Start of a new recovery epoch
_inRecovery = true;
_recoveryEndPacketNumber = packetManager.lastSentPacketNumber;
// CUBIC's W_max calculation and window reduction
_wMax = _cwnd; // Store the window size at the point of congestion.
_ssthresh = (_wMax * betaCubic).round();
if (_ssthresh < minCwnd) {
_ssthresh = minCwnd;
}
// Pre-calculate K
final wMaxInMss = _wMax / maxDatagramSize;
final diff = wMaxInMss * (1 - betaCubic) / c;
_k = pow(diff, 1/3).toDouble();
_cwnd = _ssthresh; // Reduce the window
_dupAcks = 0;
pacingController.updateRate(_cwnd, _minRtt);
}