Compare commits

..

2 Commits

4 changed files with 31 additions and 7 deletions

View File

@ -3,14 +3,25 @@
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
void CUBIC::updateReductionTimer(float time_delta) {
const auto now {getTimeNow()};
// only keep updating while the cca interaction is not too long ago
if (now - _time_point_last_update <= getCurrentDelay()*2.f) {
_time_since_reduction += time_delta;
}
}
void CUBIC::resetReductionTimer(void) {
_time_since_reduction = 0.f;
}
float CUBIC::getCWnD(void) const { float CUBIC::getCWnD(void) const {
const double K = cbrt( const double K = cbrt(
(_window_max * (1. - BETA)) / SCALING_CONSTANT (_window_max * (1. - BETA)) / SCALING_CONSTANT
); );
const double time_since_reduction = getTimeNow() - _time_point_reduction; const double TK = _time_since_reduction - K;
const double TK = time_since_reduction - K;
const double cwnd = const double cwnd =
SCALING_CONSTANT SCALING_CONSTANT
@ -34,13 +45,13 @@ float CUBIC::getCWnD(void) const {
void CUBIC::onCongestion(void) { void CUBIC::onCongestion(void) {
// 8 is probably too much (800ms for 100ms rtt) // 8 is probably too much (800ms for 100ms rtt)
if (getTimeNow() - _time_point_reduction >= getCurrentDelay()*4.f) { if (_time_since_reduction >= getCurrentDelay()*4.f) {
const auto tmp_old_tp = getTimeNow() - _time_point_reduction; const auto tmp_old_tp = _time_since_reduction;
const auto current_cwnd = getCWnD(); // TODO: remove, only used by logging? const auto current_cwnd = getCWnD(); // TODO: remove, only used by logging?
const auto current_wnd = getWindow(); // respects cwnd and fwnd const auto current_wnd = getWindow(); // respects cwnd and fwnd
_time_point_reduction = getTimeNow(); resetReductionTimer();
if (current_cwnd < _window_max) { if (current_cwnd < _window_max) {
// congestion before reaching the inflection point (prev window_max). // congestion before reaching the inflection point (prev window_max).
@ -72,6 +83,8 @@ float CUBIC::getWindow(void) {
int64_t CUBIC::canSend(float time_delta) { int64_t CUBIC::canSend(float time_delta) {
const auto fspace_pkgs = FlowOnly::canSend(time_delta); const auto fspace_pkgs = FlowOnly::canSend(time_delta);
updateReductionTimer(time_delta);
if (fspace_pkgs == 0u) { if (fspace_pkgs == 0u) {
return 0u; return 0u;
} }

View File

@ -17,9 +17,13 @@ struct CUBIC : public FlowOnly {
// window size before last reduciton // window size before last reduciton
double _window_max {2.f * MAXIMUM_SEGMENT_SIZE}; // start with mss*2 double _window_max {2.f * MAXIMUM_SEGMENT_SIZE}; // start with mss*2
//double _window_last_max {2.f * MAXIMUM_SEGMENT_SIZE}; //double _window_last_max {2.f * MAXIMUM_SEGMENT_SIZE};
double _time_point_reduction {getTimeNow()};
double _time_since_reduction {12.f}; // warm start
private: private:
void updateReductionTimer(float time_delta);
void resetReductionTimer(void);
float getCWnD(void) const; float getCWnD(void) const;
// moving avg over the last few delay samples // moving avg over the last few delay samples

View File

@ -114,6 +114,8 @@ void FlowOnly::onSent(SeqIDType seq, size_t data_size) {
); );
_in_flight_bytes += data_size + SEGMENT_OVERHEAD; _in_flight_bytes += data_size + SEGMENT_OVERHEAD;
//_recently_sent_bytes += data_size + SEGMENT_OVERHEAD; //_recently_sent_bytes += data_size + SEGMENT_OVERHEAD;
_time_point_last_update = getTimeNow();
} }
void FlowOnly::onAck(std::vector<SeqIDType> seqs) { void FlowOnly::onAck(std::vector<SeqIDType> seqs) {
@ -124,6 +126,8 @@ void FlowOnly::onAck(std::vector<SeqIDType> seqs) {
const auto now {getTimeNow()}; const auto now {getTimeNow()};
_time_point_last_update = now;
// first seq in seqs is the actual value, all extra are for redundency // first seq in seqs is the actual value, all extra are for redundency
{ // skip in ack is congestion event { // skip in ack is congestion event
// 1. look at primary ack of packet // 1. look at primary ack of packet

View File

@ -38,6 +38,9 @@ struct FlowOnly : public CCAI {
clock::time_point _time_start_offset; clock::time_point _time_start_offset;
// used to clamp growth rate in the void
double _time_point_last_update {getTimeNow()};
protected: protected:
// make values relative to algo start for readability (and precision) // make values relative to algo start for readability (and precision)
// get timestamp in seconds // get timestamp in seconds