Debian Codegraph @

third_party/rust/neqo-transport/src/cc/new_reno.rs

raw
1 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
2 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
4 // option. This file may not be copied, modified, or distributed
5 // except according to those terms.
6
7 // Congestion control
8
9 use std::{
10 fmt::{self, Display},
11 time::{Duration, Instant},
12 };
13
14 use crate::cc::classic_cc::WindowAdjustment;
15
16 #[derive(Debug, Default)]
17 pub struct NewReno {}
18
19 impl Display for NewReno {
20 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
21 write!(f, "NewReno")?;
22 Ok(())
23 }
24 }
25
26 impl WindowAdjustment for NewReno {
27 fn bytes_for_cwnd_increase(
28 &mut self,
29 curr_cwnd: usize,
30 _new_acked_bytes: usize,
31 _min_rtt: Duration,
32 _max_datagram_size: usize,
33
34 _now: Instant,
35 ) -> usize {
36 curr_cwnd
37 }
38
39 fn reduce_cwnd(
40 &mut self,
41 curr_cwnd: usize,
42 acked_bytes: usize,
43 _max_datagram_size: usize,
44 ) -> (usize, usize) {
45 (curr_cwnd / 2, acked_bytes / 2)
46 }
47
48 fn on_app_limited(&mut self) {}
49
50 #[cfg(test)]
51 fn last_max_cwnd(&self) -> f64 {
52 0.0
53 }
54
55 #[cfg(test)]
56 fn set_last_max_cwnd(&mut self, _last_max_cwnd: f64) {}
57 }