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
/// Association statistics
#[derive(Default, Debug, Copy, Clone)]
pub struct AssociationStats {
n_datas: u64,
n_sacks: u64,
n_t3timeouts: u64,
n_ack_timeouts: u64,
n_fast_retrans: u64,
n_retransmissions: u64,
n_partially_reliable_retransmissions: u64,
n_abandoned_messages: u64,
n_forward_tsns: u64,
n_fast_retrans_abandoned: u64,
t3_wait_ms: u64,
n_sack_losses: u64,
n_reneged: u64,
}
impl AssociationStats {
/// Counts one DATA chunk received.
pub fn inc_datas(&mut self) {
self.n_datas += 1;
}
/// The number of DATA chunks received.
pub fn get_num_datas(&mut self) -> u64 {
self.n_datas
}
/// Counts one SACK chunk received.
pub fn inc_sacks(&mut self) {
self.n_sacks += 1;
}
/// The number of SACK chunks received.
pub fn get_num_sacks(&mut self) -> u64 {
self.n_sacks
}
/// Counts one T3-rtx retransmission timeout.
pub fn inc_t3timeouts(&mut self) {
self.n_t3timeouts += 1;
}
/// The number of T3-rtx retransmission timeouts, a signal of loss or a stalled path.
pub fn get_num_t3timeouts(&mut self) -> u64 {
self.n_t3timeouts
}
/// Counts one delayed-acknowledgement timeout.
pub fn inc_ack_timeouts(&mut self) {
self.n_ack_timeouts += 1;
}
/// The number of delayed-acknowledgement timeouts.
pub fn get_num_ack_timeouts(&mut self) -> u64 {
self.n_ack_timeouts
}
/// Counts one fast retransmission.
pub fn inc_fast_retrans(&mut self) {
self.n_fast_retrans += 1;
}
/// The number of fast retransmissions, triggered by SACK gap reports rather than a timeout.
pub fn get_num_fast_retrans(&mut self) -> u64 {
self.n_fast_retrans
}
/// Counts one DATA chunk sent again (by T3-rtx, Fast Retransmit or with a repeated COOKIE
/// ACK).
pub fn inc_retransmissions(&mut self) {
self.n_retransmissions += 1;
}
/// The number of DATA chunks sent again, whatever made them go again.
pub fn get_num_retransmissions(&mut self) -> u64 {
self.n_retransmissions
}
/// Counts one DATA chunk of a partially reliable message (RFC 3758: a lifetime or a
/// retransmission limit, RFC 7496) sent again.
pub fn inc_partially_reliable_retransmissions(&mut self) {
self.n_partially_reliable_retransmissions += 1;
}
/// Of [`Self::get_num_retransmissions`], the DATA chunks of partially reliable messages
/// (RFC 3758, RFC 7496: sent with a lifetime or a retransmission limit) sent again; the rest
/// are reliable messages (on a WebRTC association, the DCEP messages, RFC 8832 section 5,
/// beside the reliable channels). With a limit of zero retransmissions (RFC 8831 section
/// 6.6, `maxRetransmits` 0) and the peer's support for partial reliability, a message's
/// chunks are never counted here. Without that support (RFC 3758 3.3) partially reliable
/// messages are retransmitted as reliable ones, and counted here.
pub fn get_num_partially_reliable_retransmissions(&mut self) -> u64 {
self.n_partially_reliable_retransmissions
}
/// Counts one message abandoned (RFC 3758 3.5 A2): sent in part or whole and never to be
/// sent again, or dropped before it was sent.
pub fn inc_abandoned_messages(&mut self) {
self.n_abandoned_messages += 1;
}
/// The number of messages abandoned under their partial reliability policy.
pub fn get_num_abandoned_messages(&mut self) -> u64 {
self.n_abandoned_messages
}
/// Counts one FORWARD TSN (or I-FORWARD TSN) chunk sent.
pub fn inc_forward_tsns(&mut self) {
self.n_forward_tsns += 1;
}
/// The number of FORWARD TSN (or I-FORWARD TSN) chunks sent (RFC 3758 3.5 C3, A5).
pub fn get_num_forward_tsns(&mut self) -> u64 {
self.n_forward_tsns
}
/// Counts one chunk that Fast Retransmit would have sent again and abandoned instead: its
/// message's retransmission budget was spent (RFC 3758 3.5 A2, RFC 7496).
pub fn inc_fast_retrans_abandoned(&mut self) {
self.n_fast_retrans_abandoned += 1;
}
/// The number of losses Fast Retransmit found in partially reliable messages whose budget
/// was spent, so that they were abandoned (and skipped by FORWARD TSN) without waiting for
/// T3-rtx.
pub fn get_num_fast_retrans_abandoned(&mut self) -> u64 {
self.n_fast_retrans_abandoned
}
/// Adds the RTO, in milliseconds, that a T3-rtx expiry waited out.
pub fn add_t3_wait(&mut self, rto_ms: u64) {
self.t3_wait_ms = self.t3_wait_ms.saturating_add(rto_ms);
}
/// The sum of the RTOs the T3-rtx expiries waited out (each the RTO in force when the
/// timer expired, before the back-off of RFC 9260 6.3.3 E2): how much of a transfer's time
/// the retransmission timer accounts for.
pub fn get_t3_wait(&mut self) -> std::time::Duration {
std::time::Duration::from_millis(self.t3_wait_ms)
}
/// Counts one SACK loss found from a Duplicate TSN report (RFC 9260 6.2).
pub fn inc_sack_losses(&mut self) {
self.n_sack_losses += 1;
}
/// The SACKs found lost (RFC 9260 6.2: the sender "MAY use the duplicate TSN information
/// to determine if SACK chunk loss is occurring"): DATA this side sent again on a
/// retransmission timeout that the peer then reported as a duplicate, which it had
/// received before, so the SACK that acknowledged it did not arrive in time.
pub fn get_num_sack_losses(&mut self) -> u64 {
self.n_sack_losses
}
/// Counts one DATA chunk this receiver dropped from those it held above its cumulative TSN.
pub fn inc_reneged(&mut self) {
self.n_reneged += 1;
}
/// The DATA chunks this receiver reneged on (RFC 9260 6.2.1): held above its cumulative TSN,
/// which a SACK reports in a Gap Ack Block, and dropped, so the peer has to send them again.
/// Only
/// `TransportConfig::with_zero_window_renege` does so (RFC 9260 6.2: a chunk filling a
/// gap through a closed window takes the place of the largest TSN held for reordering).
pub fn get_num_reneged(&mut self) -> u64 {
self.n_reneged
}
/// Zeroes every counter.
pub fn reset(&mut self) {
self.n_datas = 0;
self.n_sacks = 0;
self.n_t3timeouts = 0;
self.n_ack_timeouts = 0;
self.n_fast_retrans = 0;
self.n_retransmissions = 0;
self.n_partially_reliable_retransmissions = 0;
self.n_abandoned_messages = 0;
self.n_forward_tsns = 0;
self.n_fast_retrans_abandoned = 0;
self.t3_wait_ms = 0;
self.n_sack_losses = 0;
self.n_reneged = 0;
}
}