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 | |
| 11 | #include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" |
| 12 | #include "net/third_party/quiche/src/quic/core/quic_packets.h" |
| 13 | #include "net/third_party/quiche/src/quic/core/quic_time.h" |
wub | be29b9e | 2019-11-24 06:56:04 -0800 | [diff] [blame] | 14 | #include "net/third_party/quiche/src/quic/core/quic_time_accumulator.h" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 15 | #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" |
| 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 | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 106 | QuicByteCount max_packet_size = 0; |
| 107 | QuicByteCount max_received_packet_size = 0; |
| 108 | QuicBandwidth estimated_bandwidth = QuicBandwidth::Zero(); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 109 | |
| 110 | // Reordering stats for received packets. |
| 111 | // Number of packets received out of packet number order. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 112 | QuicPacketCount packets_reordered = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 113 | // Maximum reordering observed in packet number space. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 114 | QuicPacketCount max_sequence_reordering = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 115 | // Maximum reordering observed in microseconds |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 116 | int64_t max_time_reordering_us = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 117 | |
wub | aa51f0e | 2020-05-12 15:08:16 -0700 | [diff] [blame] | 118 | // Maximum sequence reordering observed from acked packets. |
| 119 | QuicPacketCount sent_packets_max_sequence_reordering = 0; |
wub | d8b383e | 2020-05-22 07:24:39 -0700 | [diff] [blame] | 120 | // Number of times that a packet is not detected as lost per reordering_shift, |
| 121 | // but would have been if the reordering_shift increases by one. |
| 122 | QuicPacketCount sent_packets_num_borderline_time_reorderings = 0; |
wub | aa51f0e | 2020-05-12 15:08:16 -0700 | [diff] [blame] | 123 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 124 | // The following stats are used only in TcpCubicSender. |
| 125 | // The number of loss events from TCP's perspective. Each loss event includes |
| 126 | // one or more lost packets. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 127 | uint32_t tcp_loss_events = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 128 | |
| 129 | // Creation time, as reported by the QuicClock. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 130 | QuicTime connection_creation_time = QuicTime::Zero(); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 131 | |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 132 | uint64_t blocked_frames_received = 0; |
| 133 | uint64_t blocked_frames_sent = 0; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 134 | |
| 135 | // Number of connectivity probing packets received by this connection. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 136 | uint64_t num_connectivity_probing_received = 0; |
dschinazi | 8a030dd | 2019-10-14 13:17:18 -0700 | [diff] [blame] | 137 | |
| 138 | // Whether a RETRY packet was successfully processed. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 139 | bool retry_packet_processed = false; |
fayang | 58f7107 | 2019-11-05 08:47:02 -0800 | [diff] [blame] | 140 | |
| 141 | // Number of received coalesced packets. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 142 | uint64_t num_coalesced_packets_received = 0; |
fayang | 58f7107 | 2019-11-05 08:47:02 -0800 | [diff] [blame] | 143 | // Number of successfully processed coalesced packets. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 144 | uint64_t num_coalesced_packets_processed = 0; |
wub | 5cd4959 | 2019-11-25 15:17:13 -0800 | [diff] [blame] | 145 | // Number of ack aggregation epochs. For the same number of bytes acked, the |
| 146 | // smaller this value, the more ack aggregation is going on. |
wub | e619ef6 | 2019-11-26 08:59:14 -0800 | [diff] [blame] | 147 | uint64_t num_ack_aggregation_epochs = 0; |
fayang | 7d164eb | 2020-01-10 12:31:33 -0800 | [diff] [blame] | 148 | |
| 149 | // Whether overshooting is detected (and pacing rate decreases) during start |
| 150 | // up with network parameters adjusted. |
| 151 | bool overshooting_detected_with_network_parameters_adjusted = false; |
fayang | 5b2a346 | 2020-03-11 15:18:27 -0700 | [diff] [blame] | 152 | |
| 153 | // Whether there is any non app-limited bandwidth sample. |
| 154 | bool has_non_app_limited_sample = false; |
fayang | 643c7dd | 2020-05-18 07:11:27 -0700 | [diff] [blame] | 155 | |
| 156 | // Packet number of first decrypted packet. |
| 157 | QuicPacketNumber first_decrypted_packet; |
fayang | 2a379bf | 2020-05-18 11:49:25 -0700 | [diff] [blame] | 158 | |
| 159 | // Max consecutive retransmission timeout before making forward progress. |
| 160 | size_t max_consecutive_rto_with_forward_progress = 0; |
dschinazi | 6458eb3 | 2020-06-23 12:38:41 -0700 | [diff] [blame] | 161 | |
| 162 | // Number of sent packets that were encapsulated using Legacy Version |
| 163 | // Encapsulation. |
| 164 | QuicPacketCount sent_legacy_version_encapsulated_packets = 0; |
wub | b104f0f | 2020-07-06 11:58:08 -0700 | [diff] [blame] | 165 | |
| 166 | // HTTP server metrics. |
| 167 | // Number of success streams. i.e. streams in which all data are acked and |
| 168 | // have no stream error. |
| 169 | uint64_t num_responses = 0; |
| 170 | // Sum of response times for all success streams. A stream's response time is |
| 171 | // the time between stream creation to the time its last ack is received, |
| 172 | // minus the peer ack delay in the last ack. |
| 173 | QuicTime::Delta total_response_time = QuicTime::Delta::Zero(); |
fayang | b3359b0 | 2020-07-17 14:51:29 -0700 | [diff] [blame^] | 174 | |
| 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; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 178 | }; |
| 179 | |
| 180 | } // namespace quic |
| 181 | |
| 182 | #endif // QUICHE_QUIC_CORE_QUIC_CONNECTION_STATS_H_ |