private void UpdateRoundTripTime(int roundTripTime) { //Calc average round trip time _rtt += roundTripTime; _rttCount++; _avgRtt = _rtt / _rttCount; //flowmode 0 = fastest //flowmode max = lowest if (_avgRtt < _peerListener.GetStartRtt(_currentFlowMode - 1)) { if (_currentFlowMode <= 0) { //Already maxed return; } _goodRttCount++; if (_goodRttCount > NetConstants.FlowIncreaseThreshold) { _goodRttCount = 0; _currentFlowMode--; NetUtils.DebugWrite("[PA]Increased flow speed, RTT: {0}, PPS: {1}", _avgRtt, _peerListener.GetPacketsPerSecond(_currentFlowMode)); } } else if (_avgRtt > _peerListener.GetStartRtt(_currentFlowMode)) { _goodRttCount = 0; if (_currentFlowMode < _peerListener.GetMaxFlowMode()) { _currentFlowMode++; NetUtils.DebugWrite("[PA]Decreased flow speed, RTT: {0}, PPS: {1}", _avgRtt, _peerListener.GetPacketsPerSecond(_currentFlowMode)); } } //recalc resend delay double avgRtt = _avgRtt; if (avgRtt <= 0.0) { avgRtt = 0.1; } _resendDelay = 25 + (avgRtt * 2.1); // 25 ms + double rtt }