Compare commits
2 Commits
404669eb7e
...
35a82cd67f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35a82cd67f | ||
|
|
308790dc3a |
@@ -69,7 +69,8 @@ struct CCAI {
|
||||
virtual void onAck(std::vector<SeqIDType> seqs) = 0;
|
||||
|
||||
// if discard, not resent, not inflight
|
||||
virtual void onLoss(SeqIDType seq, bool discard) = 0;
|
||||
// return if found
|
||||
virtual bool onLoss(SeqIDType seq, bool discard) = 0;
|
||||
|
||||
// signal congestion externally (eg. send queue is full)
|
||||
virtual void onCongestion(void) {};
|
||||
|
||||
@@ -102,6 +102,8 @@ int64_t CUBIC::canSend(float time_delta) {
|
||||
// this is mostly to prevent spikes on empty windows
|
||||
const auto rate = window / getCurrentDelay();
|
||||
|
||||
// TODO: time slicing alla flow
|
||||
|
||||
// we dont want this limit to fall below atleast 1 segment
|
||||
const int64_t max_bytes_per_tick = std::max<int64_t>(rate * time_delta + 0.5f, MAXIMUM_SEGMENT_SIZE);
|
||||
cspace_bytes = std::min<int64_t>(cspace_bytes, max_bytes_per_tick);
|
||||
|
||||
@@ -80,7 +80,15 @@ int64_t FlowOnly::canSend(float time_delta) {
|
||||
|
||||
// also limit to max sendrate per tick, which is usually smaller than window
|
||||
// this is mostly to prevent spikes on empty windows
|
||||
fspace = std::min<int64_t>(fspace, max_byterate_allowed * time_delta + 0.5f);
|
||||
fspace = std::min<int64_t>({
|
||||
fspace,
|
||||
|
||||
// slice window into time time_delta sized chunks and only allow 1.5 chunks sized per tick
|
||||
int64_t((1.5f * _fwnd) / time_delta + 0.5f),
|
||||
|
||||
// similar, but without current delay in the equation (fallback)
|
||||
int64_t(1.2f * max_byterate_allowed * time_delta + 0.5f),
|
||||
});
|
||||
|
||||
// limit to whole packets
|
||||
return (fspace / MAXIMUM_SEGMENT_DATA_SIZE) * MAXIMUM_SEGMENT_DATA_SIZE;
|
||||
@@ -203,15 +211,18 @@ void FlowOnly::onAck(std::vector<SeqIDType> seqs) {
|
||||
}
|
||||
}
|
||||
|
||||
void FlowOnly::onLoss(SeqIDType seq, bool discard) {
|
||||
bool FlowOnly::onLoss(SeqIDType seq, bool discard) {
|
||||
auto it = std::find_if(_in_flight.begin(), _in_flight.end(), [seq](const auto& v) -> bool {
|
||||
assert(!std::isnan(v.timestamp));
|
||||
return v.id == seq;
|
||||
});
|
||||
|
||||
// we care about it still being there, when we do not discard
|
||||
if (it == _in_flight.end()) {
|
||||
// error
|
||||
return; // not found, ignore ??
|
||||
if (!discard) {
|
||||
std::cerr << "FLOW seq not found!\n";
|
||||
}
|
||||
return false; // not found, ignore ??
|
||||
}
|
||||
|
||||
//std::cerr << "FLOW loss\n";
|
||||
@@ -241,5 +252,7 @@ void FlowOnly::onLoss(SeqIDType seq, bool discard) {
|
||||
// this is usually a safe indicator for congestion/maxed connection
|
||||
onCongestion();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,6 @@ struct FlowOnly : public CCAI {
|
||||
void onAck(std::vector<SeqIDType> seqs) override;
|
||||
|
||||
// if discard, not resent, not inflight
|
||||
void onLoss(SeqIDType seq, bool discard) override;
|
||||
bool onLoss(SeqIDType seq, bool discard) override;
|
||||
};
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ void LEDBAT::onAck(std::vector<SeqIDType> seqs) {
|
||||
updateWindows();
|
||||
}
|
||||
|
||||
void LEDBAT::onLoss(SeqIDType seq, bool discard) {
|
||||
bool LEDBAT::onLoss(SeqIDType seq, bool discard) {
|
||||
auto it = std::find_if(_in_flight.begin(), _in_flight.end(), [seq](const auto& v) -> bool {
|
||||
assert(!std::isnan(std::get<1>(v)));
|
||||
return std::get<0>(v) == seq;
|
||||
@@ -139,7 +139,7 @@ void LEDBAT::onLoss(SeqIDType seq, bool discard) {
|
||||
|
||||
if (it == _in_flight.end()) {
|
||||
// error
|
||||
return; // not found, ignore ??
|
||||
return false; // not found, ignore ??
|
||||
}
|
||||
|
||||
if (PLOTTING) {
|
||||
@@ -165,6 +165,8 @@ void LEDBAT::onLoss(SeqIDType seq, bool discard) {
|
||||
#endif
|
||||
|
||||
updateWindows();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
float LEDBAT::getCurrentDelay(void) const {
|
||||
|
||||
@@ -72,7 +72,7 @@ struct LEDBAT : public CCAI {
|
||||
void onAck(std::vector<SeqIDType> seqs) override;
|
||||
|
||||
// if discard, not resent, not inflight
|
||||
void onLoss(SeqIDType seq, bool discard) override;
|
||||
bool onLoss(SeqIDType seq, bool discard) override;
|
||||
|
||||
private:
|
||||
using clock = std::chrono::steady_clock;
|
||||
|
||||
Reference in New Issue
Block a user