1 use crate::candidate::*; 2 use crate::network_type::*; 3 4 use tokio::time::Instant; 5 6 // CandidatePairStats contains ICE candidate pair statistics 7 #[derive(Debug, Clone)] 8 pub struct CandidatePairStats { 9 // timestamp is the timestamp associated with this object. 10 pub timestamp: Instant, 11 12 // local_candidate_id is the id of the local candidate 13 pub local_candidate_id: String, 14 15 // remote_candidate_id is the id of the remote candidate 16 pub remote_candidate_id: String, 17 18 // state represents the state of the checklist for the local and remote 19 // candidates in a pair. 20 pub state: CandidatePairState, 21 22 // nominated is 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 // packets_sent represents the total number of packets sent on this candidate pair. 27 pub packets_sent: u32, 28 29 // packets_received represents the total number of packets received on this candidate pair. 30 pub packets_received: u32, 31 32 // bytes_sent represents the total number of payload bytes sent on this candidate pair 33 // not including headers or padding. 34 pub bytes_sent: u64, 35 36 // bytes_received represents the total number of payload bytes received on this candidate pair 37 // not including headers or padding. 38 pub bytes_received: u64, 39 40 // last_packet_sent_timestamp represents 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 // last_packet_received_timestamp represents 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 // first_request_timestamp represents the timestamp at which the first STUN request 49 // was sent on this particular candidate pair. 50 pub first_request_timestamp: Instant, 51 52 // last_request_timestamp represents 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 // last_response_timestamp represents the timestamp at which the last STUN response 59 // was received on this particular candidate pair. 60 pub last_response_timestamp: Instant, 61 62 // total_round_trip_time represents 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 // current_round_trip_time represents 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 // available_outgoing_bitrate is 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 // available_incoming_bitrate is 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 // circuit_breaker_trigger_count represents 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 // requests_received represents 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 // requests_sent represents the total number of connectivity check requests 101 // sent (not including retransmissions). 102 pub requests_sent: u64, 103 104 // responses_received represents 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 // retransmissions_received represents the total number of connectivity check 113 // request retransmissions received. 114 pub retransmissions_received: u64, 115 116 // retransmissions_sent represents the total number of connectivity check 117 // request retransmissions sent. 118 pub retransmissions_sent: u64, 119 120 // consent_requests_sent represents the total number of consent requests sent. 121 pub consent_requests_sent: u64, 122 123 // consent_expired_timestamp represents 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)] 130 pub struct CandidateStats { 131 // timestamp is the timestamp associated with this object. 132 pub timestamp: Instant, 133 134 // id is the candidate id 135 pub id: String, 136 137 // network_type represents the type of network interface used by the base of a 138 // local candidate (the address the ICE agent sends from). Only present for 139 // local candidates; it's not possible to know what type of network interface 140 // a remote candidate is using. 141 // 142 // Note: 143 // This stat only tells you about the network interface used by the first "hop"; 144 // it's possible that a connection will be bottlenecked by another type of network. 145 // For example, when using Wi-Fi tethering, the networkType of the relevant candidate 146 // would be "wifi", even when the next hop is over a cellular connection. 147 pub network_type: NetworkType, 148 149 // ip is the ip address of the candidate, allowing for IPv4 addresses and 150 // IPv6 addresses, but fully qualified domain names (FQDNs) are not allowed. 151 pub ip: String, 152 153 // port is the port number of the candidate. 154 pub port: u16, 155 156 // candidate_type is the "Type" field of the ICECandidate. 157 pub candidate_type: CandidateType, 158 159 // priority is the "priority" field of the ICECandidate. 160 pub priority: u32, 161 162 // url is the url of the TURN or STUN server indicated in the that translated 163 // this ip address. It is the url address surfaced in an PeerConnectionICEEvent. 164 pub url: String, 165 166 // relay_protocol is the protocol used by the endpoint to communicate with the 167 // TURN server. This is only present for local candidates. Valid values for 168 // the TURN url protocol is one of udp, tcp, or tls. 169 pub relay_protocol: String, 170 171 // deleted is true if the candidate has been deleted/freed. For host candidates, 172 // this means that any network resources (typically a socket) associated with the 173 // candidate have been released. For TURN candidates, this means the TURN allocation 174 // is no longer active. 175 // 176 // Only defined for local candidates. For remote candidates, this property is not applicable. 177 pub deleted: bool, 178 } 179