stats.go 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. package ice
  2. import (
  3. "time"
  4. )
  5. // CandidatePairStats contains ICE candidate pair statistics
  6. type CandidatePairStats struct {
  7. // Timestamp is the timestamp associated with this object.
  8. Timestamp time.Time
  9. // LocalCandidateID is the ID of the local candidate
  10. LocalCandidateID string
  11. // RemoteCandidateID is the ID of the remote candidate
  12. RemoteCandidateID string
  13. // State represents the state of the checklist for the local and remote
  14. // candidates in a pair.
  15. State CandidatePairState
  16. // Nominated is true when this valid pair that should be used for media
  17. // if it is the highest-priority one amongst those whose nominated flag is set
  18. Nominated bool
  19. // PacketsSent represents the total number of packets sent on this candidate pair.
  20. PacketsSent uint32
  21. // PacketsReceived represents the total number of packets received on this candidate pair.
  22. PacketsReceived uint32
  23. // BytesSent represents the total number of payload bytes sent on this candidate pair
  24. // not including headers or padding.
  25. BytesSent uint64
  26. // BytesReceived represents the total number of payload bytes received on this candidate pair
  27. // not including headers or padding.
  28. BytesReceived uint64
  29. // LastPacketSentTimestamp represents the timestamp at which the last packet was
  30. // sent on this particular candidate pair, excluding STUN packets.
  31. LastPacketSentTimestamp time.Time
  32. // LastPacketReceivedTimestamp represents the timestamp at which the last packet
  33. // was received on this particular candidate pair, excluding STUN packets.
  34. LastPacketReceivedTimestamp time.Time
  35. // FirstRequestTimestamp represents the timestamp at which the first STUN request
  36. // was sent on this particular candidate pair.
  37. FirstRequestTimestamp time.Time
  38. // LastRequestTimestamp represents the timestamp at which the last STUN request
  39. // was sent on this particular candidate pair. The average interval between two
  40. // consecutive connectivity checks sent can be calculated with
  41. // (LastRequestTimestamp - FirstRequestTimestamp) / RequestsSent.
  42. LastRequestTimestamp time.Time
  43. // LastResponseTimestamp represents the timestamp at which the last STUN response
  44. // was received on this particular candidate pair.
  45. LastResponseTimestamp time.Time
  46. // TotalRoundTripTime represents the sum of all round trip time measurements
  47. // in seconds since the beginning of the session, based on STUN connectivity
  48. // check responses (ResponsesReceived), including those that reply to requests
  49. // that are sent in order to verify consent. The average round trip time can
  50. // be computed from TotalRoundTripTime by dividing it by ResponsesReceived.
  51. TotalRoundTripTime float64
  52. // CurrentRoundTripTime represents the latest round trip time measured in seconds,
  53. // computed from both STUN connectivity checks, including those that are sent
  54. // for consent verification.
  55. CurrentRoundTripTime float64
  56. // AvailableOutgoingBitrate is calculated by the underlying congestion control
  57. // by combining the available bitrate for all the outgoing RTP streams using
  58. // this candidate pair. The bitrate measurement does not count the size of the
  59. // IP or other transport layers like TCP or UDP. It is similar to the TIAS defined
  60. // in RFC 3890, i.e., it is measured in bits per second and the bitrate is calculated
  61. // over a 1 second window.
  62. AvailableOutgoingBitrate float64
  63. // AvailableIncomingBitrate is calculated by the underlying congestion control
  64. // by combining the available bitrate for all the incoming RTP streams using
  65. // this candidate pair. The bitrate measurement does not count the size of the
  66. // IP or other transport layers like TCP or UDP. It is similar to the TIAS defined
  67. // in RFC 3890, i.e., it is measured in bits per second and the bitrate is
  68. // calculated over a 1 second window.
  69. AvailableIncomingBitrate float64
  70. // CircuitBreakerTriggerCount represents the number of times the circuit breaker
  71. // is triggered for this particular 5-tuple, ceasing transmission.
  72. CircuitBreakerTriggerCount uint32
  73. // RequestsReceived represents the total number of connectivity check requests
  74. // received (including retransmissions). It is impossible for the receiver to
  75. // tell whether the request was sent in order to check connectivity or check
  76. // consent, so all connectivity checks requests are counted here.
  77. RequestsReceived uint64
  78. // RequestsSent represents the total number of connectivity check requests
  79. // sent (not including retransmissions).
  80. RequestsSent uint64
  81. // ResponsesReceived represents the total number of connectivity check responses received.
  82. ResponsesReceived uint64
  83. // ResponsesSent epresents the total number of connectivity check responses sent.
  84. // Since we cannot distinguish connectivity check requests and consent requests,
  85. // all responses are counted.
  86. ResponsesSent uint64
  87. // RetransmissionsReceived represents the total number of connectivity check
  88. // request retransmissions received.
  89. RetransmissionsReceived uint64
  90. // RetransmissionsSent represents the total number of connectivity check
  91. // request retransmissions sent.
  92. RetransmissionsSent uint64
  93. // ConsentRequestsSent represents the total number of consent requests sent.
  94. ConsentRequestsSent uint64
  95. // ConsentExpiredTimestamp represents the timestamp at which the latest valid
  96. // STUN binding response expired.
  97. ConsentExpiredTimestamp time.Time
  98. }
  99. // CandidateStats contains ICE candidate statistics related to the ICETransport objects.
  100. type CandidateStats struct {
  101. // Timestamp is the timestamp associated with this object.
  102. Timestamp time.Time
  103. // ID is the candidate ID
  104. ID string
  105. // NetworkType represents the type of network interface used by the base of a
  106. // local candidate (the address the ICE agent sends from). Only present for
  107. // local candidates; it's not possible to know what type of network interface
  108. // a remote candidate is using.
  109. //
  110. // Note:
  111. // This stat only tells you about the network interface used by the first "hop";
  112. // it's possible that a connection will be bottlenecked by another type of network.
  113. // For example, when using Wi-Fi tethering, the networkType of the relevant candidate
  114. // would be "wifi", even when the next hop is over a cellular connection.
  115. NetworkType NetworkType
  116. // IP is the IP address of the candidate, allowing for IPv4 addresses and
  117. // IPv6 addresses, but fully qualified domain names (FQDNs) are not allowed.
  118. IP string
  119. // Port is the port number of the candidate.
  120. Port int
  121. // CandidateType is the "Type" field of the ICECandidate.
  122. CandidateType CandidateType
  123. // Priority is the "Priority" field of the ICECandidate.
  124. Priority uint32
  125. // URL is the URL of the TURN or STUN server indicated in the that translated
  126. // this IP address. It is the URL address surfaced in an PeerConnectionICEEvent.
  127. URL string
  128. // RelayProtocol is the protocol used by the endpoint to communicate with the
  129. // TURN server. This is only present for local candidates. Valid values for
  130. // the TURN URL protocol is one of udp, tcp, or tls.
  131. RelayProtocol string
  132. // Deleted is true if the candidate has been deleted/freed. For host candidates,
  133. // this means that any network resources (typically a socket) associated with the
  134. // candidate have been released. For TURN candidates, this means the TURN allocation
  135. // is no longer active.
  136. //
  137. // Only defined for local candidates. For remote candidates, this property is not applicable.
  138. Deleted bool
  139. }