cubic almost working, general fixes

This commit is contained in:
2023-08-30 13:45:09 +02:00
parent 0d49752c3e
commit 4ee5dd6ca5
3 changed files with 31 additions and 28 deletions

View File

@@ -8,7 +8,7 @@ float CUBIC::getCWnD(void) const {
(_window_max * (1. - BETA)) / SCALING_CONSTANT
);
const auto time_since_reduction = getTimeNow() - _time_point_reduction;
const double time_since_reduction = getTimeNow() - _time_point_reduction;
const double TK = time_since_reduction - K;
@@ -18,6 +18,7 @@ float CUBIC::getCWnD(void) const {
+ _window_max
;
#if 0
std::cout
<< "K:" << K
<< " ts:" << time_since_reduction
@@ -26,34 +27,36 @@ float CUBIC::getCWnD(void) const {
<< " rtt:" << getCurrentDelay()
<< "\n"
;
#endif
return std::max<float>(cwnd, 2.f * MAXIMUM_SEGMENT_SIZE);
}
void CUBIC::onCongestion(void) {
const auto current_cwnd = getCWnD();
_time_point_reduction = getTimeNow();
_window_max = current_cwnd;
if (getTimeNow() - _time_point_reduction >= getCurrentDelay()) {
const auto current_cwnd = getCWnD();
_time_point_reduction = getTimeNow();
_window_max = current_cwnd;
//std::cout << "CONGESTION!\n";
std::cout << "CONGESTION! cwnd:" << current_cwnd << "\n";
}
}
size_t CUBIC::canSend(void) {
const auto flow_space = FlowOnly::canSend();
const auto fspace_pkgs = FlowOnly::canSend();
if (flow_space == 0) {
return 0;
if (fspace_pkgs == 0u) {
return 0u;
}
const int64_t cspace = getCWnD() - _in_flight_bytes;
if (cspace < MAXIMUM_SEGMENT_DATA_SIZE) {
const int64_t cspace_bytes = getCWnD() - _in_flight_bytes;
if (cspace_bytes < MAXIMUM_SEGMENT_DATA_SIZE) {
return 0u;
}
// limit to whole packets
size_t space = std::ceil(cspace / MAXIMUM_SEGMENT_DATA_SIZE)
* MAXIMUM_SEGMENT_DATA_SIZE;
size_t cspace_pkgs = std::floor(cspace_bytes / MAXIMUM_SEGMENT_DATA_SIZE) * MAXIMUM_SEGMENT_DATA_SIZE;
return std::min(space, flow_space);
return std::min(cspace_pkgs, fspace_pkgs);
}