QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef QUICHE_QUIC_CORE_QUIC_CONNECTION_STATS_H_ |
| 6 | #define QUICHE_QUIC_CORE_QUIC_CONNECTION_STATS_H_ |
| 7 | |
| 8 | #include <cstdint> |
| 9 | #include <ostream> |
| 10 | |
QUICHE team | 5be974e | 2020-12-29 18:35:24 -0500 | [diff] [blame] | 11 | #include "quic/core/quic_bandwidth.h" |
| 12 | #include "quic/core/quic_packets.h" |
| 13 | #include "quic/core/quic_time.h" |
| 14 | #include "quic/core/quic_time_accumulator.h" |
| 15 | #include "quic/platform/api/quic_export.h" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 16 | |
| 17 | namespace quic { |
wub | 9528ecf | 2020-01-16 13:16:48 -0800 | [diff] [blame] | 18 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 19 | // Structure to hold stats for a QuicConnection. |
| 20 | struct QUIC_EXPORT_PRIVATE QuicConnectionStats { |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 21 | QUIC_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 22 | std::ostream& os, |
| 23 | const QuicConnectionStats& s); |
| 24 | |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 25 | QuicByteCount bytes_sent = 0; // Includes retransmissions. |
| 26 | QuicPacketCount packets_sent = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 27 | // Non-retransmitted bytes sent in a stream frame. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 28 | QuicByteCount stream_bytes_sent = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 29 | // Packets serialized and discarded before sending. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 30 | QuicPacketCount packets_discarded = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 31 | |
| 32 | // These include version negotiation and public reset packets, which do not |
| 33 | // have packet numbers or frame data. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 34 | QuicByteCount bytes_received = 0; // Includes duplicate data for a stream. |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 35 | // Includes packets which were not processable. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 36 | QuicPacketCount packets_received = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 37 | // Excludes packets which were not processable. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 38 | QuicPacketCount packets_processed = 0; |
| 39 | QuicByteCount stream_bytes_received = 0; // Bytes received in a stream frame. |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 40 | |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 41 | QuicByteCount bytes_retransmitted = 0; |
| 42 | QuicPacketCount packets_retransmitted = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 43 | |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 44 | QuicByteCount bytes_spuriously_retransmitted = 0; |
| 45 | QuicPacketCount packets_spuriously_retransmitted = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 46 | // Number of packets abandoned as lost by the loss detection algorithm. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 47 | QuicPacketCount packets_lost = 0; |
wub | 02831dc | 2020-02-28 12:00:54 -0800 | [diff] [blame] | 48 | QuicPacketCount packet_spuriously_detected_lost = 0; |
| 49 | |
wub | 050d2d4 | 2020-06-22 14:45:27 -0700 | [diff] [blame] | 50 | // The sum of loss detection response times of all lost packets, in number of |
| 51 | // round trips. |
| 52 | // Given a packet detected as lost: |
| 53 | // T(S) T(1Rtt) T(D) |
| 54 | // |_________________________________|_______| |
| 55 | // Where |
| 56 | // T(S) is the time when the packet is sent. |
| 57 | // T(1Rtt) is one rtt after T(S), using the rtt at the time of detection. |
| 58 | // T(D) is the time of detection, i.e. when the packet is declared as lost. |
| 59 | // The loss detection response time is defined as |
| 60 | // (T(D) - T(S)) / (T(1Rtt) - T(S)) |
| 61 | // |
| 62 | // The average loss detection response time is this number divided by |
| 63 | // |packets_lost|. Smaller result means detection is faster. |
| 64 | float total_loss_detection_response_time = 0.0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 65 | |
wub | 967ba57 | 2019-04-01 09:27:52 -0700 | [diff] [blame] | 66 | // Number of times this connection went through the slow start phase. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 67 | uint32_t slowstart_count = 0; |
wub | 967ba57 | 2019-04-01 09:27:52 -0700 | [diff] [blame] | 68 | // Number of round trips spent in slow start. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 69 | uint32_t slowstart_num_rtts = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 70 | // Number of packets sent in slow start. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 71 | QuicPacketCount slowstart_packets_sent = 0; |
wub | 967ba57 | 2019-04-01 09:27:52 -0700 | [diff] [blame] | 72 | // Number of bytes sent in slow start. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 73 | QuicByteCount slowstart_bytes_sent = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 74 | // Number of packets lost exiting slow start. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 75 | QuicPacketCount slowstart_packets_lost = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 76 | // Number of bytes lost exiting slow start. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 77 | QuicByteCount slowstart_bytes_lost = 0; |
wub | be29b9e | 2019-11-24 06:56:04 -0800 | [diff] [blame] | 78 | // Time spent in slow start. Populated for BBRv1 and BBRv2. |
| 79 | QuicTimeAccumulator slowstart_duration; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 80 | |
wub | 9528ecf | 2020-01-16 13:16:48 -0800 | [diff] [blame] | 81 | // Number of PROBE_BW cycles. Populated for BBRv1 and BBRv2. |
| 82 | uint32_t bbr_num_cycles = 0; |
| 83 | // Number of PROBE_BW cycles shortened for reno coexistence. BBRv2 only. |
| 84 | uint32_t bbr_num_short_cycles_for_reno_coexistence = 0; |
| 85 | // Whether BBR exited STARTUP due to excessive loss. Populated for BBRv1 and |
| 86 | // BBRv2. |
| 87 | bool bbr_exit_startup_due_to_loss = false; |
| 88 | |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 89 | QuicPacketCount packets_dropped = 0; // Duplicate or less than least unacked. |
dschinazi | 6ece500 | 2019-05-22 06:35:49 -0700 | [diff] [blame] | 90 | |
dschinazi | 7d0f3c8 | 2019-09-16 16:14:32 -0700 | [diff] [blame] | 91 | // Packets that failed to decrypt when they were first received, |
| 92 | // before the handshake was complete. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 93 | QuicPacketCount undecryptable_packets_received_before_handshake_complete = 0; |
dschinazi | 6ece500 | 2019-05-22 06:35:49 -0700 | [diff] [blame] | 94 | |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 95 | size_t crypto_retransmit_count = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 96 | // Count of times the loss detection alarm fired. At least one packet should |
| 97 | // be lost when the alarm fires. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 98 | size_t loss_timeout_count = 0; |
| 99 | size_t tlp_count = 0; |
| 100 | size_t rto_count = 0; // Count of times the rto timer fired. |
| 101 | size_t pto_count = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 102 | |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 103 | int64_t min_rtt_us = 0; // Minimum RTT in microseconds. |
| 104 | int64_t srtt_us = 0; // Smoothed RTT in microseconds. |
haoyuewang | 8e29e90 | 2020-06-17 07:29:31 -0700 | [diff] [blame] | 105 | int64_t cwnd_bootstrapping_rtt_us = 0; // RTT used in cwnd_bootstrapping. |
wub | 3127a54 | 2021-05-19 14:48:23 -0700 | [diff] [blame] | 106 | // The connection's |long_term_mtu_| used for sending packets, populated by |
| 107 | // QuicConnection::GetStats(). |
wub | 9e97f80 | 2021-05-19 08:54:35 -0700 | [diff] [blame] | 108 | QuicByteCount egress_mtu = 0; |
wub | 3127a54 | 2021-05-19 14:48:23 -0700 | [diff] [blame] | 109 | // The maximum |long_term_mtu_| the connection ever used. |
| 110 | QuicByteCount max_egress_mtu = 0; |
| 111 | // Size of the largest packet received from the peer, populated by |
| 112 | // QuicConnection::GetStats(). |
wub | 9e97f80 | 2021-05-19 08:54:35 -0700 | [diff] [blame] | 113 | QuicByteCount ingress_mtu = 0; |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 114 | QuicBandwidth estimated_bandwidth = QuicBandwidth::Zero(); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 115 | |
| 116 | // Reordering stats for received packets. |
| 117 | // Number of packets received out of packet number order. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 118 | QuicPacketCount packets_reordered = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 119 | // Maximum reordering observed in packet number space. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 120 | QuicPacketCount max_sequence_reordering = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 121 | // Maximum reordering observed in microseconds |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 122 | int64_t max_time_reordering_us = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 123 | |
wub | aa51f0e | 2020-05-12 15:08:16 -0700 | [diff] [blame] | 124 | // Maximum sequence reordering observed from acked packets. |
| 125 | QuicPacketCount sent_packets_max_sequence_reordering = 0; |
wub | d8b383e | 2020-05-22 07:24:39 -0700 | [diff] [blame] | 126 | // Number of times that a packet is not detected as lost per reordering_shift, |
| 127 | // but would have been if the reordering_shift increases by one. |
| 128 | QuicPacketCount sent_packets_num_borderline_time_reorderings = 0; |
wub | aa51f0e | 2020-05-12 15:08:16 -0700 | [diff] [blame] | 129 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 130 | // The following stats are used only in TcpCubicSender. |
| 131 | // The number of loss events from TCP's perspective. Each loss event includes |
| 132 | // one or more lost packets. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 133 | uint32_t tcp_loss_events = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 134 | |
| 135 | // Creation time, as reported by the QuicClock. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 136 | QuicTime connection_creation_time = QuicTime::Zero(); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 137 | |
fayang | 8607b29 | 2020-08-19 09:00:55 -0700 | [diff] [blame] | 138 | // Handshake completion time. |
| 139 | QuicTime handshake_completion_time = QuicTime::Zero(); |
| 140 | |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 141 | uint64_t blocked_frames_received = 0; |
| 142 | uint64_t blocked_frames_sent = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 143 | |
| 144 | // Number of connectivity probing packets received by this connection. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 145 | uint64_t num_connectivity_probing_received = 0; |
dschinazi | 8a030dd | 2019-10-14 13:17:18 -0700 | [diff] [blame] | 146 | |
| 147 | // Whether a RETRY packet was successfully processed. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 148 | bool retry_packet_processed = false; |
fayang | 58f7107 | 2019-11-05 08:47:02 -0800 | [diff] [blame] | 149 | |
| 150 | // Number of received coalesced packets. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 151 | uint64_t num_coalesced_packets_received = 0; |
fayang | 58f7107 | 2019-11-05 08:47:02 -0800 | [diff] [blame] | 152 | // Number of successfully processed coalesced packets. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 153 | uint64_t num_coalesced_packets_processed = 0; |
wub | 5cd4959 | 2019-11-25 15:17:13 -0800 | [diff] [blame] | 154 | // Number of ack aggregation epochs. For the same number of bytes acked, the |
| 155 | // smaller this value, the more ack aggregation is going on. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 156 | uint64_t num_ack_aggregation_epochs = 0; |
fayang | 7d164eb | 2020-01-10 12:31:33 -0800 | [diff] [blame] | 157 | |
| 158 | // Whether overshooting is detected (and pacing rate decreases) during start |
| 159 | // up with network parameters adjusted. |
| 160 | bool overshooting_detected_with_network_parameters_adjusted = false; |
fayang | 5b2a346 | 2020-03-11 15:18:27 -0700 | [diff] [blame] | 161 | |
| 162 | // Whether there is any non app-limited bandwidth sample. |
| 163 | bool has_non_app_limited_sample = false; |
fayang | 643c7dd | 2020-05-18 07:11:27 -0700 | [diff] [blame] | 164 | |
| 165 | // Packet number of first decrypted packet. |
| 166 | QuicPacketNumber first_decrypted_packet; |
fayang | 2a379bf | 2020-05-18 11:49:25 -0700 | [diff] [blame] | 167 | |
| 168 | // Max consecutive retransmission timeout before making forward progress. |
| 169 | size_t max_consecutive_rto_with_forward_progress = 0; |
dschinazi | 6458eb3 | 2020-06-23 12:38:41 -0700 | [diff] [blame] | 170 | |
| 171 | // Number of sent packets that were encapsulated using Legacy Version |
| 172 | // Encapsulation. |
| 173 | QuicPacketCount sent_legacy_version_encapsulated_packets = 0; |
wub | b104f0f | 2020-07-06 11:58:08 -0700 | [diff] [blame] | 174 | |
fayang | b3359b0 | 2020-07-17 14:51:29 -0700 | [diff] [blame] | 175 | // Number of times when the connection tries to send data but gets throttled |
| 176 | // by amplification factor. |
| 177 | size_t num_amplification_throttling = 0; |
mattm | 072a7e3 | 2020-10-09 16:16:56 -0700 | [diff] [blame] | 178 | |
| 179 | // Number of key phase updates that have occurred. In the case of a locally |
| 180 | // initiated key update, this is incremented when the keys are updated, before |
| 181 | // the peer has acknowledged the key update. |
| 182 | uint32_t key_update_count = 0; |
mattm | a2ae935 | 2020-10-23 15:55:14 -0700 | [diff] [blame] | 183 | |
| 184 | // Counts the number of undecryptable packets received across all keys. Does |
| 185 | // not include packets where a decryption key for that level was absent. |
| 186 | QuicPacketCount num_failed_authentication_packets_received = 0; |
mattm | ad5eb5d | 2020-12-03 16:12:15 -0800 | [diff] [blame] | 187 | |
| 188 | // Counts the number of QUIC+TLS 0-RTT packets received after 0-RTT decrypter |
| 189 | // was discarded, only on server connections. |
| 190 | QuicPacketCount |
| 191 | num_tls_server_zero_rtt_packets_received_after_discarding_decrypter = 0; |
fayang | 133b868 | 2020-12-08 05:50:33 -0800 | [diff] [blame] | 192 | |
| 193 | // True if address is validated via decrypting HANDSHAKE or 1-RTT packet. |
| 194 | bool address_validated_via_decrypting_packet = false; |
| 195 | |
| 196 | // True if address is validated via validating token received in INITIAL |
| 197 | // packet. |
| 198 | bool address_validated_via_token = false; |
wub | d05824d | 2020-12-09 09:50:20 -0800 | [diff] [blame] | 199 | |
| 200 | size_t ping_frames_sent = 0; |
danzh | a25ed9d | 2021-02-19 12:40:26 -0800 | [diff] [blame] | 201 | |
| 202 | // Number of detected peer address changes which changes to a peer address |
| 203 | // validated by earlier path validation. |
| 204 | size_t num_peer_migration_to_proactively_validated_address = 0; |
| 205 | // Number of detected peer address changes which triggers reverse path |
| 206 | // validation. |
| 207 | size_t num_reverse_path_validtion_upon_migration = 0; |
| 208 | // Number of detected peer migrations which either succeed reverse path |
| 209 | // validation or no need to be validated. |
| 210 | size_t num_validated_peer_migration = 0; |
| 211 | // Number of detected peer migrations which triggered reverse path validation |
| 212 | // and failed and fell back to the old path. |
| 213 | size_t num_invalid_peer_migration = 0; |
| 214 | // Number of detected peer migrations which triggered reverse path validation |
| 215 | // which was canceled because the peer migrated again. Such migration is also |
| 216 | // counted as invalid peer migration. |
| 217 | size_t num_peer_migration_while_validating_default_path = 0; |
haoyuewang | b25dd21 | 2021-05-05 07:33:07 -0700 | [diff] [blame] | 218 | // Number of NEW_CONNECTION_ID frames sent. |
| 219 | size_t num_new_connection_id_sent = 0; |
| 220 | // Number of RETIRE_CONNECTION_ID frames sent. |
| 221 | size_t num_retire_connection_id_sent = 0; |
wub | ab3139c | 2021-03-15 13:40:39 -0700 | [diff] [blame] | 222 | |
| 223 | struct QUIC_NO_EXPORT TlsServerOperationStats { |
| 224 | bool success = false; |
| 225 | // If the operation is performed asynchronously, how long did it take. |
| 226 | // Zero() for synchronous operations. |
| 227 | QuicTime::Delta async_latency = QuicTime::Delta::Zero(); |
| 228 | }; |
| 229 | |
| 230 | // The TLS server op stats only have values when the corresponding operation |
| 231 | // is performed by TlsServerHandshaker. If an operation is done within |
| 232 | // BoringSSL, e.g. ticket decrypted without using |
| 233 | // TlsServerHandshaker::SessionTicketOpen, it will not be recorded here. |
| 234 | absl::optional<TlsServerOperationStats> tls_server_select_cert_stats; |
| 235 | absl::optional<TlsServerOperationStats> tls_server_compute_signature_stats; |
| 236 | absl::optional<TlsServerOperationStats> tls_server_decrypt_ticket_stats; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 237 | }; |
| 238 | |
| 239 | } // namespace quic |
| 240 | |
| 241 | #endif // QUICHE_QUIC_CORE_QUIC_CONNECTION_STATS_H_ |