Skip to main content

rtc_sctp/association/
stats.rs

1/// Association statistics
2#[derive(Default, Debug, Copy, Clone)]
3pub struct AssociationStats {
4    n_datas: u64,
5    n_sacks: u64,
6    n_t3timeouts: u64,
7    n_ack_timeouts: u64,
8    n_fast_retrans: u64,
9}
10
11impl AssociationStats {
12    /// Counts one DATA chunk sent.
13    pub fn inc_datas(&mut self) {
14        self.n_datas += 1;
15    }
16
17    /// The number of DATA chunks sent.
18    pub fn get_num_datas(&mut self) -> u64 {
19        self.n_datas
20    }
21
22    /// Counts one SACK chunk received.
23    pub fn inc_sacks(&mut self) {
24        self.n_sacks += 1;
25    }
26
27    /// The number of SACK chunks received.
28    pub fn get_num_sacks(&mut self) -> u64 {
29        self.n_sacks
30    }
31
32    /// Counts one T3-rtx retransmission timeout.
33    pub fn inc_t3timeouts(&mut self) {
34        self.n_t3timeouts += 1;
35    }
36
37    /// The number of T3-rtx retransmission timeouts, a signal of loss or a stalled path.
38    pub fn get_num_t3timeouts(&mut self) -> u64 {
39        self.n_t3timeouts
40    }
41
42    /// Counts one delayed-acknowledgement timeout.
43    pub fn inc_ack_timeouts(&mut self) {
44        self.n_ack_timeouts += 1;
45    }
46
47    /// The number of delayed-acknowledgement timeouts.
48    pub fn get_num_ack_timeouts(&mut self) -> u64 {
49        self.n_ack_timeouts
50    }
51
52    /// Counts one fast retransmission.
53    pub fn inc_fast_retrans(&mut self) {
54        self.n_fast_retrans += 1;
55    }
56
57    /// The number of fast retransmissions, triggered by SACK gap reports rather than a timeout.
58    pub fn get_num_fast_retrans(&mut self) -> u64 {
59        self.n_fast_retrans
60    }
61
62    /// Zeroes every counter.
63    pub fn reset(&mut self) {
64        self.n_datas = 0;
65        self.n_sacks = 0;
66        self.n_t3timeouts = 0;
67        self.n_ack_timeouts = 0;
68        self.n_fast_retrans = 0;
69    }
70}