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
use crate::{GenericCongAvoidAlg, GenericCongAvoidFlow, GenericCongAvoidMeasurements};
#[derive(Default)]
pub struct Reno {
mss: u32,
init_cwnd: f64,
cwnd: f64,
}
impl GenericCongAvoidAlg for Reno {
type Flow = Self;
fn name() -> &'static str {
"reno"
}
fn with_args(_: clap::ArgMatches) -> Self {
Default::default()
}
fn new_flow(&self, init_cwnd: u32, mss: u32) -> Self::Flow {
Reno {
mss,
init_cwnd: f64::from(init_cwnd),
cwnd: f64::from(init_cwnd),
}
}
}
impl GenericCongAvoidFlow for Reno {
fn curr_cwnd(&self) -> u32 {
self.cwnd as u32
}
fn set_cwnd(&mut self, cwnd: u32) {
self.cwnd = f64::from(cwnd);
}
fn increase(&mut self, m: &GenericCongAvoidMeasurements) {
self.cwnd += f64::from(self.mss) * (f64::from(m.acked) / self.cwnd);
}
fn reduction(&mut self, _m: &GenericCongAvoidMeasurements) {
self.cwnd /= 2.0;
if self.cwnd <= self.init_cwnd {
self.cwnd = self.init_cwnd;
}
}
}