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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
//! BBRv3 configuration and constants.
//!
//! This module contains the configuration struct and tuning constants for the
//! BBRv3 congestion control algorithm, based on the IETF draft:
//! https://datatracker.ietf.org/doc/html/draft-cardwell-iccrg-bbr-congestion-control
use Duration;
use crateMAX_DATA_SIZE;
/// Maximum segment size (actual packet data capacity)
pub const MSS: usize = MAX_DATA_SIZE;
// =============================================================================
// BBRv3 Pacing and CWND Gains
// =============================================================================
/// Startup pacing gain: 2/ln(2) ≈ 2.77
/// This allows BBR to double its sending rate each round trip during Startup.
pub const STARTUP_PACING_GAIN: f64 = 2.77;
/// Default minimum pacing rate during Startup: 25 MB/s.
///
/// This floor prevents the "bootstrap death spiral" where:
/// 1. Low pacing_rate limits how fast we send
/// 2. BBR measures bandwidth from our limited sends
/// 3. Low measured bandwidth → lower pacing_rate → stuck
///
/// By maintaining a high floor during Startup, we can discover the actual
/// available bandwidth. Once BBR exits Startup (via bandwidth plateau or loss),
/// it uses the measured bandwidth without this floor.
///
/// 25 MB/s handles high-bandwidth links while congestion triggers loss-based
/// exit from Startup on constrained paths. Can be lowered via BbrConfig for
/// testing or constrained environments.
pub const DEFAULT_STARTUP_MIN_PACING_RATE: u64 = 25_000_000;
/// Startup cwnd gain: 2.0
/// Provides headroom for ACK aggregation during startup.
pub const STARTUP_CWND_GAIN: f64 = 2.0;
/// Drain pacing gain: 1/2.77 ≈ 0.36
/// Drains the queue built during Startup by pacing below estimated bandwidth.
pub const DRAIN_PACING_GAIN: f64 = 0.36;
/// ProbeBW UP phase pacing gain: probe for more bandwidth.
pub const PROBE_BW_UP_PACING_GAIN: f64 = 1.25;
/// ProbeBW DOWN phase pacing gain: drain any queue.
pub const PROBE_BW_DOWN_PACING_GAIN: f64 = 0.9;
/// ProbeBW CRUISE/REFILL phase pacing gain: maintain steady state.
pub const PROBE_BW_CRUISE_PACING_GAIN: f64 = 1.0;
/// ProbeRTT cwnd gain: reduce cwnd to measure true min_rtt.
pub const PROBE_RTT_CWND_GAIN: f64 = 0.5;
/// ProbeRTT minimum cwnd: 4 packets per BBRv3 spec.
/// This ensures we can still make forward progress during RTT probing.
pub const PROBE_RTT_MIN_CWND: usize = 4 * MSS;
/// Default cwnd gain for ProbeBW phases.
pub const PROBE_BW_CWND_GAIN: f64 = 2.0;
// =============================================================================
// BBRv3 Timing Parameters
// =============================================================================
/// Minimum RTT filter window: 10 seconds.
/// BBR tracks min_rtt over this window to estimate path propagation delay.
pub const MIN_RTT_FILTER_WINDOW: Duration = from_secs;
/// ProbeRTT interval: how often to enter ProbeRTT to refresh min_rtt.
/// BBRv3 uses ~5 seconds (2.5s-7.5s range with randomization).
pub const PROBE_RTT_INTERVAL: Duration = from_secs;
/// ProbeRTT duration: how long to stay in ProbeRTT.
/// 200ms is enough to drain queues and get a clean RTT sample.
pub const PROBE_RTT_DURATION: Duration = from_millis;
/// Bandwidth filter window size (number of max_bw samples to track).
/// BBRv3 typically uses 2 round trips worth of samples.
pub const BW_FILTER_SIZE: usize = 10;
// =============================================================================
// BBRv3 Startup Exit Detection
// =============================================================================
/// Number of rounds without bandwidth growth to exit Startup.
/// BBR exits Startup when max_bw hasn't grown by more than 25% for 3 rounds.
pub const STARTUP_FULL_BW_ROUNDS: u32 = 3;
/// Bandwidth growth threshold for Startup exit (25% growth).
/// If max_bw doesn't grow by at least this factor, count as a "full bandwidth" round.
pub const STARTUP_FULL_BW_THRESHOLD: f64 = 1.25;
// =============================================================================
// BBRv3 Loss Response
// =============================================================================
/// Loss threshold for Startup exit: 2% packet loss indicates buffer overflow.
pub const STARTUP_LOSS_THRESHOLD: f64 = 0.02;
/// Beta: multiplicative decrease factor for loss response.
/// BBRv3 uses 0.7 (reduce by 30% on loss).
pub const BETA: f64 = 0.7;
// =============================================================================
// ProbeBW Cycle Parameters
// =============================================================================
/// Number of rounds in ProbeBW cycle before probing up.
/// Typically 6-8 rounds of Cruise before attempting Up.
pub const PROBE_BW_CRUISE_ROUNDS_MIN: u32 = 6;
/// Duration of Down phase in ProbeBW (in round trips).
pub const PROBE_BW_DOWN_ROUNDS: u32 = 1;
/// Duration of Refill phase in ProbeBW (in round trips).
pub const PROBE_BW_REFILL_ROUNDS: u32 = 1;
/// Duration of Up phase in ProbeBW (in round trips).
pub const PROBE_BW_UP_ROUNDS: u32 = 1;
// =============================================================================
// Configuration Struct
// =============================================================================
/// Configuration for BBRv3 congestion control.