-
Notifications
You must be signed in to change notification settings - Fork 1
/
bbr_probe_bw.h
123 lines (102 loc) · 3.61 KB
/
bbr_probe_bw.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef BBR_PROBE_BW_H_
#define BBR_PROBE_BW_H_
#include <vector>
#include <common/rate.h>
#include <time/timestamp.h>
#include <bbr_common.h>
#include <bbr_mode.h>
namespace bbr
{
class BbrAlgorithm;
class BbrModel;
struct BbrCongestionEvent;
class BbrProbeBandwidth
{
enum class CyclePhase : uint8_t {
kProbeNotStarted = 0,
kPorbeUp,
kPorbeDown,
kPorbeCruise,
kProbeRefill,
};
struct Cycle {
time::Timestamp cycle_start_time{0};
CyclePhase phase = CyclePhase::kProbeNotStarted;
uint64_t rounds_in_phase = 0;
time::Timestamp phase_start_time {0};
uint64_t rounds_since_probe = 0;
time::TimeDelta probe_wait_time{0};
uint64_t probe_up_rounds = 0;
size_t probe_up_bytes = std::numeric_limits<size_t>::max();
size_t probe_up_acked = 0;
// Whether max bandwidth filter window has advanced in this cycle.
// It is advanced once per cycle.
bool has_advanced_max_bw = false;
bool is_sample_from_probing = false; /* rate samples reflect bw probing? */
};
enum class AdaptUpperBoundsResult : uint8_t {
kOk,
kProbedTooHigh,
kInfilghtHighNotSet,
kInvalidSample
};
public:
BbrProbeBandwidth(BbrAlgorithm* bbr, BbrModel* model);
void enter(time::Timestamp now,
const BbrCongestionEvent* congestion_event);
void leave(time::Timestamp now,
const BbrCongestionEvent* congestion_event) {};
BbrMode on_congestion_event(
size_t prior_inflight,
time::Timestamp at_time,
const std::vector<AckedPacket>& acked_packets,
const std::vector<LostPacket>& lost_packets,
const BbrCongestionEvent& congestion_event);
BbrMode on_exit_quiescence(time::Timestamp quiescence_start_time,
time::Timestamp now);
bool is_probing() const {
return cycle_.phase == CyclePhase::kProbeRefill ||
cycle_.phase == CyclePhase::kPorbeUp;
}
size_t cwnd_upper_limit() const ;
private:
float pacing_gain(CyclePhase phase) const;
void enter_probe_down(bool probed_too_high,
bool stopped_risky_probe, time::Timestamp now);
void exist_probe_down();
void enter_probe_up(time::Timestamp now);
void enter_probe_cruise(time::Timestamp now);
void enter_probe_refill(uint64_t probe_up_rounds,
time::Timestamp now);
void update_probe_down(size_t prior_inflight,
const BbrCongestionEvent& congestion_event);
void update_probe_up(size_t prior_inflight,
const BbrCongestionEvent& congestion_event);
void update_probe_cruise(
const BbrCongestionEvent& congestion_event);
void update_probe_refill(
const BbrCongestionEvent& congestion_event);
private:
bool is_time_to_probe_bw(
const BbrCongestionEvent& congestion_event);
bool is_time_to_probe_for_reno_coexistence(
double probe_wait_fraction,
const BbrCongestionEvent& congestion_event);
bool has_stayed_long_enough_in_probe_down(
const BbrCongestionEvent& congestion_event);
void handle_inflight_too_high(
bool app_limited, size_t bytes_inflight);
AdaptUpperBoundsResult maybe_adapt_upper_bounds(
const BbrCongestionEvent& congestion_event);
void raise_inflight_hi();
void probe_inflight_high_upward(
const BbrCongestionEvent& congestion_event);
private:
BbrAlgorithm* bbr_;
BbrModel* model_;
Cycle cycle_;
bool last_cycle_probed_too_high_ = false;
bool last_cycle_stopped_risky_probe_ = false;
};
}
#endif