Skip to main content

rtc_ice/stats/
mod.rs

1use std::time::Instant;
2
3use crate::candidate::candidate_pair::CandidatePairState;
4use crate::candidate::*;
5
6/// CandidatePairStats contains ICE candidate pair statistics.
7#[derive(Debug, Clone)]
8pub struct CandidatePairStats {
9    /// The timestamp associated with this object.
10    pub timestamp: Instant,
11
12    /// The id of the local candidate.
13    pub local_candidate_id: String,
14
15    /// The id of the remote candidate.
16    pub remote_candidate_id: String,
17
18    /// The state of the checklist for the local and remote
19    /// candidates in a pair.
20    pub state: CandidatePairState,
21
22    /// True when this valid pair that should be used for media
23    /// if it is the highest-priority one amongst those whose nominated flag is set.
24    pub nominated: bool,
25
26    /// The total number of packets sent on this candidate pair.
27    pub packets_sent: u32,
28
29    /// The total number of packets received on this candidate pair.
30    pub packets_received: u32,
31
32    /// The total number of payload bytes sent on this candidate pair
33    /// not including headers or padding.
34    pub bytes_sent: u64,
35
36    /// The total number of payload bytes received on this candidate pair
37    /// not including headers or padding.
38    pub bytes_received: u64,
39
40    /// The timestamp at which the last packet was
41    /// sent on this particular candidate pair, excluding STUN packets.
42    pub last_packet_sent_timestamp: Instant,
43
44    /// The timestamp at which the last packet
45    /// was received on this particular candidate pair, excluding STUN packets.
46    pub last_packet_received_timestamp: Instant,
47
48    /// The timestamp at which the first STUN request
49    /// was sent on this particular candidate pair.
50    pub first_request_timestamp: Instant,
51
52    /// The timestamp at which the last STUN request
53    /// was sent on this particular candidate pair. The average interval between two
54    /// consecutive connectivity checks sent can be calculated with
55    /// (last_request_timestamp - first_request_timestamp) / requests_sent.
56    pub last_request_timestamp: Instant,
57
58    /// The timestamp at which the last STUN response
59    /// was received on this particular candidate pair.
60    pub last_response_timestamp: Instant,
61
62    /// The sum of all round trip time measurements
63    /// in seconds since the beginning of the session, based on STUN connectivity
64    /// check responses (responses_received), including those that reply to requests
65    /// that are sent in order to verify consent. The average round trip time can
66    /// be computed from total_round_trip_time by dividing it by responses_received.
67    pub total_round_trip_time: f64,
68
69    /// The latest round trip time measured in seconds,
70    /// computed from both STUN connectivity checks, including those that are sent
71    /// for consent verification.
72    pub current_round_trip_time: f64,
73
74    /// Calculated by the underlying congestion control
75    /// by combining the available bitrate for all the outgoing RTP streams using
76    /// this candidate pair. The bitrate measurement does not count the size of the
77    /// ip or other transport layers like TCP or UDP. It is similar to the TIAS defined
78    /// in RFC 3890, i.e., it is measured in bits per second and the bitrate is calculated
79    /// over a 1 second window.
80    pub available_outgoing_bitrate: f64,
81
82    /// Calculated by the underlying congestion control
83    /// by combining the available bitrate for all the incoming RTP streams using
84    /// this candidate pair. The bitrate measurement does not count the size of the
85    /// ip or other transport layers like TCP or UDP. It is similar to the TIAS defined
86    /// in  RFC 3890, i.e., it is measured in bits per second and the bitrate is
87    /// calculated over a 1 second window.
88    pub available_incoming_bitrate: f64,
89
90    /// The number of times the circuit breaker
91    /// is triggered for this particular 5-tuple, ceasing transmission.
92    pub circuit_breaker_trigger_count: u32,
93
94    /// The total number of connectivity check requests
95    /// received (including retransmissions). It is impossible for the receiver to
96    /// tell whether the request was sent in order to check connectivity or check
97    /// consent, so all connectivity checks requests are counted here.
98    pub requests_received: u64,
99
100    /// The total number of connectivity check requests
101    /// sent (not including retransmissions).
102    pub requests_sent: u64,
103
104    /// The total number of connectivity check responses received.
105    pub responses_received: u64,
106
107    /// Responses_sent epresents the total number of connectivity check responses sent.
108    /// Since we cannot distinguish connectivity check requests and consent requests,
109    /// all responses are counted.
110    pub responses_sent: u64,
111
112    /// The total number of connectivity check
113    /// request retransmissions received.
114    pub retransmissions_received: u64,
115
116    /// The total number of connectivity check
117    /// request retransmissions sent.
118    pub retransmissions_sent: u64,
119
120    /// The total number of consent requests sent.
121    pub consent_requests_sent: u64,
122
123    /// The timestamp at which the latest valid.
124    /// STUN binding response expired.
125    pub consent_expired_timestamp: Instant,
126}
127
128/// CandidateStats contains ICE candidate statistics related to the ICETransport objects.
129#[derive(Debug, Clone)]
130pub struct CandidateStats {
131    /// The timestamp associated with this object.
132    pub timestamp: Instant,
133
134    /// The candidate id.
135    pub id: String,
136
137    /// The ip address of the candidate, allowing for IPv4 addresses and.
138    /// IPv6 addresses, but fully qualified domain names (FQDNs) are not allowed.
139    pub ip: String,
140
141    /// The port number of the candidate.
142    pub port: u16,
143
144    /// The "Type" field of the ICECandidate.
145    pub candidate_type: CandidateType,
146
147    /// The "priority" field of the ICECandidate.
148    pub priority: u32,
149
150    /// The url of the TURN or STUN server indicated in the that translated
151    /// this ip address. It is the url address surfaced in an PeerConnectionICEEvent.
152    pub url: String,
153
154    /// The protocol used by the endpoint to communicate with the.
155    /// TURN server. This is only present for local candidates. Valid values for
156    /// the TURN url protocol is one of udp, tcp, or tls.
157    pub relay_protocol: String,
158
159    // deleted is true if the candidate has been deleted/freed. For host candidates,
160    // this means that any network resources (typically a socket) associated with the
161    // candidate have been released. For TURN candidates, this means the TURN allocation
162    // is no longer active.
163    //
164    /// Only defined for local candidates. For remote candidates, this property is not applicable.
165    pub deleted: bool,
166}