blob: c18aba631e29cf5180832aba73d51d39ca9f9169 (
plain)
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
|
//! Test helpers.
#[cfg(test)]
use super::{rtt::RoundtripTimeEstimator, CongestionWindow};
// Make a new RTT estimator.
#[cfg(test)]
pub(crate) fn new_rtt_estimator() -> RoundtripTimeEstimator {
RoundtripTimeEstimator::new(¶ms::build_rtt_params())
}
// Make a new congestion window.
#[cfg(test)]
pub(crate) fn new_cwnd() -> CongestionWindow {
CongestionWindow::new(¶ms::build_cwnd_params())
}
#[cfg(test)]
pub(crate) mod params {
use tor_units::Percentage;
use crate::ccparams::{
Algorithm, CongestionControlParams, CongestionControlParamsBuilder, CongestionWindowParams,
CongestionWindowParamsBuilder, FixedWindowParamsBuilder, RoundTripEstimatorParams,
RoundTripEstimatorParamsBuilder,
};
pub(crate) fn build_cc_fixed_params() -> CongestionControlParams {
let params = FixedWindowParamsBuilder::default()
.circ_window_start(1000)
.circ_window_min(100)
.circ_window_max(1000)
.build()
.expect("Unable to build fixed window params");
CongestionControlParamsBuilder::default()
.rtt_params(build_rtt_params())
.cwnd_params(build_cwnd_params())
.alg(Algorithm::FixedWindow(params))
.build()
.expect("Unable to build CC params")
}
// Build the round trip estimator parameters. with good enough values for tests.
pub(crate) fn build_rtt_params() -> RoundTripEstimatorParams {
RoundTripEstimatorParamsBuilder::default()
.ewma_cwnd_pct(Percentage::new(50))
.ewma_max(10)
.ewma_ss_max(2)
.rtt_reset_pct(Percentage::new(100))
.build()
.expect("Unable to build RTT parameters")
}
// Build the congestion window parameters. with good enough values for tests.
pub(crate) fn build_cwnd_params() -> CongestionWindowParams {
// Values taken from the prop324.
CongestionWindowParamsBuilder::default()
.cwnd_init(124)
.cwnd_inc_pct_ss(Percentage::new(100))
.cwnd_inc(1)
.cwnd_inc_rate(31)
.cwnd_min(124)
.cwnd_max(u32::MAX)
.sendme_inc(31)
.build()
.expect("Unable to build congestion window parameters")
}
}
|