xref: /aosp_15_r20/external/webrtc/p2p/base/connection_info.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker  *  Copyright 2019 The WebRTC Project Authors. All rights reserved.
3*d9f75844SAndroid Build Coastguard Worker  *
4*d9f75844SAndroid Build Coastguard Worker  *  Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker  *  that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker  *  tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker  *  in the file PATENTS.  All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker  *  be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker  */
10*d9f75844SAndroid Build Coastguard Worker 
11*d9f75844SAndroid Build Coastguard Worker #ifndef P2P_BASE_CONNECTION_INFO_H_
12*d9f75844SAndroid Build Coastguard Worker #define P2P_BASE_CONNECTION_INFO_H_
13*d9f75844SAndroid Build Coastguard Worker 
14*d9f75844SAndroid Build Coastguard Worker #include <vector>
15*d9f75844SAndroid Build Coastguard Worker 
16*d9f75844SAndroid Build Coastguard Worker #include "absl/types/optional.h"
17*d9f75844SAndroid Build Coastguard Worker #include "api/candidate.h"
18*d9f75844SAndroid Build Coastguard Worker #include "api/units/timestamp.h"
19*d9f75844SAndroid Build Coastguard Worker 
20*d9f75844SAndroid Build Coastguard Worker namespace cricket {
21*d9f75844SAndroid Build Coastguard Worker 
22*d9f75844SAndroid Build Coastguard Worker // States are from RFC 5245. http://tools.ietf.org/html/rfc5245#section-5.7.4
23*d9f75844SAndroid Build Coastguard Worker enum class IceCandidatePairState {
24*d9f75844SAndroid Build Coastguard Worker   WAITING = 0,  // Check has not been performed, Waiting pair on CL.
25*d9f75844SAndroid Build Coastguard Worker   IN_PROGRESS,  // Check has been sent, transaction is in progress.
26*d9f75844SAndroid Build Coastguard Worker   SUCCEEDED,    // Check already done, produced a successful result.
27*d9f75844SAndroid Build Coastguard Worker   FAILED,       // Check for this connection failed.
28*d9f75844SAndroid Build Coastguard Worker   // According to spec there should also be a frozen state, but nothing is ever
29*d9f75844SAndroid Build Coastguard Worker   // frozen because we have not implemented ICE freezing logic.
30*d9f75844SAndroid Build Coastguard Worker };
31*d9f75844SAndroid Build Coastguard Worker 
32*d9f75844SAndroid Build Coastguard Worker // Stats that we can return about the connections for a transport channel.
33*d9f75844SAndroid Build Coastguard Worker // TODO(hta): Rename to ConnectionStats
34*d9f75844SAndroid Build Coastguard Worker struct ConnectionInfo {
35*d9f75844SAndroid Build Coastguard Worker   ConnectionInfo();
36*d9f75844SAndroid Build Coastguard Worker   ConnectionInfo(const ConnectionInfo&);
37*d9f75844SAndroid Build Coastguard Worker   ~ConnectionInfo();
38*d9f75844SAndroid Build Coastguard Worker 
39*d9f75844SAndroid Build Coastguard Worker   bool best_connection;      // Is this the best connection we have?
40*d9f75844SAndroid Build Coastguard Worker   bool writable;             // Has this connection received a STUN response?
41*d9f75844SAndroid Build Coastguard Worker   bool receiving;            // Has this connection received anything?
42*d9f75844SAndroid Build Coastguard Worker   bool timeout;              // Has this connection timed out?
43*d9f75844SAndroid Build Coastguard Worker   size_t rtt;                // The STUN RTT for this connection.
44*d9f75844SAndroid Build Coastguard Worker   size_t sent_discarded_bytes;  // Number of outgoing bytes discarded due to
45*d9f75844SAndroid Build Coastguard Worker                                 // socket errors.
46*d9f75844SAndroid Build Coastguard Worker   size_t sent_total_bytes;      // Total bytes sent on this connection. Does not
47*d9f75844SAndroid Build Coastguard Worker                                 // include discarded bytes.
48*d9f75844SAndroid Build Coastguard Worker   size_t sent_bytes_second;  // Bps over the last measurement interval.
49*d9f75844SAndroid Build Coastguard Worker   size_t sent_discarded_packets;  // Number of outgoing packets discarded due to
50*d9f75844SAndroid Build Coastguard Worker                                   // socket errors.
51*d9f75844SAndroid Build Coastguard Worker   size_t sent_total_packets;  // Number of total outgoing packets attempted for
52*d9f75844SAndroid Build Coastguard Worker                               // sending, including discarded packets.
53*d9f75844SAndroid Build Coastguard Worker   size_t sent_ping_requests_total;  // Number of STUN ping request sent.
54*d9f75844SAndroid Build Coastguard Worker   size_t sent_ping_requests_before_first_response;  // Number of STUN ping
55*d9f75844SAndroid Build Coastguard Worker   // sent before receiving the first response.
56*d9f75844SAndroid Build Coastguard Worker   size_t sent_ping_responses;  // Number of STUN ping response sent.
57*d9f75844SAndroid Build Coastguard Worker 
58*d9f75844SAndroid Build Coastguard Worker   size_t recv_total_bytes;     // Total bytes received on this connection.
59*d9f75844SAndroid Build Coastguard Worker   size_t recv_bytes_second;    // Bps over the last measurement interval.
60*d9f75844SAndroid Build Coastguard Worker   size_t packets_received;     // Number of packets that were received.
61*d9f75844SAndroid Build Coastguard Worker   size_t recv_ping_requests;   // Number of STUN ping request received.
62*d9f75844SAndroid Build Coastguard Worker   size_t recv_ping_responses;  // Number of STUN ping response received.
63*d9f75844SAndroid Build Coastguard Worker   Candidate local_candidate;   // The local candidate for this connection.
64*d9f75844SAndroid Build Coastguard Worker   Candidate remote_candidate;  // The remote candidate for this connection.
65*d9f75844SAndroid Build Coastguard Worker   void* key;                   // A static value that identifies this conn.
66*d9f75844SAndroid Build Coastguard Worker   // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-state
67*d9f75844SAndroid Build Coastguard Worker   IceCandidatePairState state;
68*d9f75844SAndroid Build Coastguard Worker   // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-priority
69*d9f75844SAndroid Build Coastguard Worker   uint64_t priority;
70*d9f75844SAndroid Build Coastguard Worker   // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-nominated
71*d9f75844SAndroid Build Coastguard Worker   bool nominated;
72*d9f75844SAndroid Build Coastguard Worker   // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-totalroundtriptime
73*d9f75844SAndroid Build Coastguard Worker   uint64_t total_round_trip_time_ms;
74*d9f75844SAndroid Build Coastguard Worker   // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-currentroundtriptime
75*d9f75844SAndroid Build Coastguard Worker   absl::optional<uint32_t> current_round_trip_time_ms;
76*d9f75844SAndroid Build Coastguard Worker 
77*d9f75844SAndroid Build Coastguard Worker   // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-lastpacketreceivedtimestamp
78*d9f75844SAndroid Build Coastguard Worker   absl::optional<webrtc::Timestamp> last_data_received;
79*d9f75844SAndroid Build Coastguard Worker   absl::optional<webrtc::Timestamp> last_data_sent;
80*d9f75844SAndroid Build Coastguard Worker };
81*d9f75844SAndroid Build Coastguard Worker 
82*d9f75844SAndroid Build Coastguard Worker // Information about all the candidate pairs of a channel.
83*d9f75844SAndroid Build Coastguard Worker typedef std::vector<ConnectionInfo> ConnectionInfos;
84*d9f75844SAndroid Build Coastguard Worker 
85*d9f75844SAndroid Build Coastguard Worker }  // namespace cricket
86*d9f75844SAndroid Build Coastguard Worker 
87*d9f75844SAndroid Build Coastguard Worker #endif  // P2P_BASE_CONNECTION_INFO_H_
88