connection_info.h 3.7 KB

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