blob: 39fd5b087a6def0f92ce92738dc90252736f296b [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// 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 team5be974e2020-12-29 18:35:24 -050011#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 teama6ef0a62019-03-07 20:34:33 -050016
17namespace quic {
wub9528ecf2020-01-16 13:16:48 -080018
QUICHE teama6ef0a62019-03-07 20:34:33 -050019// Structure to hold stats for a QuicConnection.
20struct QUIC_EXPORT_PRIVATE QuicConnectionStats {
QUICHE teama6ef0a62019-03-07 20:34:33 -050021 QUIC_EXPORT_PRIVATE friend std::ostream& operator<<(
22 std::ostream& os,
23 const QuicConnectionStats& s);
24
wube619ef62019-11-26 08:59:14 -080025 QuicByteCount bytes_sent = 0; // Includes retransmissions.
26 QuicPacketCount packets_sent = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -050027 // Non-retransmitted bytes sent in a stream frame.
wube619ef62019-11-26 08:59:14 -080028 QuicByteCount stream_bytes_sent = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -050029 // Packets serialized and discarded before sending.
wube619ef62019-11-26 08:59:14 -080030 QuicPacketCount packets_discarded = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -050031
32 // These include version negotiation and public reset packets, which do not
33 // have packet numbers or frame data.
wube619ef62019-11-26 08:59:14 -080034 QuicByteCount bytes_received = 0; // Includes duplicate data for a stream.
QUICHE teama6ef0a62019-03-07 20:34:33 -050035 // Includes packets which were not processable.
wube619ef62019-11-26 08:59:14 -080036 QuicPacketCount packets_received = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -050037 // Excludes packets which were not processable.
wube619ef62019-11-26 08:59:14 -080038 QuicPacketCount packets_processed = 0;
39 QuicByteCount stream_bytes_received = 0; // Bytes received in a stream frame.
QUICHE teama6ef0a62019-03-07 20:34:33 -050040
wube619ef62019-11-26 08:59:14 -080041 QuicByteCount bytes_retransmitted = 0;
42 QuicPacketCount packets_retransmitted = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -050043
wube619ef62019-11-26 08:59:14 -080044 QuicByteCount bytes_spuriously_retransmitted = 0;
45 QuicPacketCount packets_spuriously_retransmitted = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -050046 // Number of packets abandoned as lost by the loss detection algorithm.
wube619ef62019-11-26 08:59:14 -080047 QuicPacketCount packets_lost = 0;
wub02831dc2020-02-28 12:00:54 -080048 QuicPacketCount packet_spuriously_detected_lost = 0;
49
wub050d2d42020-06-22 14:45:27 -070050 // 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 teama6ef0a62019-03-07 20:34:33 -050065
wub967ba572019-04-01 09:27:52 -070066 // Number of times this connection went through the slow start phase.
wube619ef62019-11-26 08:59:14 -080067 uint32_t slowstart_count = 0;
wub967ba572019-04-01 09:27:52 -070068 // Number of round trips spent in slow start.
wube619ef62019-11-26 08:59:14 -080069 uint32_t slowstart_num_rtts = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -050070 // Number of packets sent in slow start.
wube619ef62019-11-26 08:59:14 -080071 QuicPacketCount slowstart_packets_sent = 0;
wub967ba572019-04-01 09:27:52 -070072 // Number of bytes sent in slow start.
wube619ef62019-11-26 08:59:14 -080073 QuicByteCount slowstart_bytes_sent = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -050074 // Number of packets lost exiting slow start.
wube619ef62019-11-26 08:59:14 -080075 QuicPacketCount slowstart_packets_lost = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -050076 // Number of bytes lost exiting slow start.
wube619ef62019-11-26 08:59:14 -080077 QuicByteCount slowstart_bytes_lost = 0;
wubbe29b9e2019-11-24 06:56:04 -080078 // Time spent in slow start. Populated for BBRv1 and BBRv2.
79 QuicTimeAccumulator slowstart_duration;
QUICHE teama6ef0a62019-03-07 20:34:33 -050080
wub9528ecf2020-01-16 13:16:48 -080081 // 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
wube619ef62019-11-26 08:59:14 -080089 QuicPacketCount packets_dropped = 0; // Duplicate or less than least unacked.
dschinazi6ece5002019-05-22 06:35:49 -070090
dschinazi7d0f3c82019-09-16 16:14:32 -070091 // Packets that failed to decrypt when they were first received,
92 // before the handshake was complete.
wube619ef62019-11-26 08:59:14 -080093 QuicPacketCount undecryptable_packets_received_before_handshake_complete = 0;
dschinazi6ece5002019-05-22 06:35:49 -070094
wube619ef62019-11-26 08:59:14 -080095 size_t crypto_retransmit_count = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -050096 // Count of times the loss detection alarm fired. At least one packet should
97 // be lost when the alarm fires.
wube619ef62019-11-26 08:59:14 -080098 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 teama6ef0a62019-03-07 20:34:33 -0500102
wube619ef62019-11-26 08:59:14 -0800103 int64_t min_rtt_us = 0; // Minimum RTT in microseconds.
104 int64_t srtt_us = 0; // Smoothed RTT in microseconds.
haoyuewang8e29e902020-06-17 07:29:31 -0700105 int64_t cwnd_bootstrapping_rtt_us = 0; // RTT used in cwnd_bootstrapping.
wub3127a542021-05-19 14:48:23 -0700106 // The connection's |long_term_mtu_| used for sending packets, populated by
107 // QuicConnection::GetStats().
wub9e97f802021-05-19 08:54:35 -0700108 QuicByteCount egress_mtu = 0;
wub3127a542021-05-19 14:48:23 -0700109 // 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().
wub9e97f802021-05-19 08:54:35 -0700113 QuicByteCount ingress_mtu = 0;
wube619ef62019-11-26 08:59:14 -0800114 QuicBandwidth estimated_bandwidth = QuicBandwidth::Zero();
QUICHE teama6ef0a62019-03-07 20:34:33 -0500115
116 // Reordering stats for received packets.
117 // Number of packets received out of packet number order.
wube619ef62019-11-26 08:59:14 -0800118 QuicPacketCount packets_reordered = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500119 // Maximum reordering observed in packet number space.
wube619ef62019-11-26 08:59:14 -0800120 QuicPacketCount max_sequence_reordering = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500121 // Maximum reordering observed in microseconds
wube619ef62019-11-26 08:59:14 -0800122 int64_t max_time_reordering_us = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500123
wubaa51f0e2020-05-12 15:08:16 -0700124 // Maximum sequence reordering observed from acked packets.
125 QuicPacketCount sent_packets_max_sequence_reordering = 0;
wubd8b383e2020-05-22 07:24:39 -0700126 // 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;
wubaa51f0e2020-05-12 15:08:16 -0700129
QUICHE teama6ef0a62019-03-07 20:34:33 -0500130 // 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.
wube619ef62019-11-26 08:59:14 -0800133 uint32_t tcp_loss_events = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500134
135 // Creation time, as reported by the QuicClock.
wube619ef62019-11-26 08:59:14 -0800136 QuicTime connection_creation_time = QuicTime::Zero();
QUICHE teama6ef0a62019-03-07 20:34:33 -0500137
fayang8607b292020-08-19 09:00:55 -0700138 // Handshake completion time.
139 QuicTime handshake_completion_time = QuicTime::Zero();
140
wube619ef62019-11-26 08:59:14 -0800141 uint64_t blocked_frames_received = 0;
142 uint64_t blocked_frames_sent = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500143
144 // Number of connectivity probing packets received by this connection.
wube619ef62019-11-26 08:59:14 -0800145 uint64_t num_connectivity_probing_received = 0;
dschinazi8a030dd2019-10-14 13:17:18 -0700146
147 // Whether a RETRY packet was successfully processed.
wube619ef62019-11-26 08:59:14 -0800148 bool retry_packet_processed = false;
fayang58f71072019-11-05 08:47:02 -0800149
150 // Number of received coalesced packets.
wube619ef62019-11-26 08:59:14 -0800151 uint64_t num_coalesced_packets_received = 0;
fayang58f71072019-11-05 08:47:02 -0800152 // Number of successfully processed coalesced packets.
wube619ef62019-11-26 08:59:14 -0800153 uint64_t num_coalesced_packets_processed = 0;
wub5cd49592019-11-25 15:17:13 -0800154 // Number of ack aggregation epochs. For the same number of bytes acked, the
155 // smaller this value, the more ack aggregation is going on.
wube619ef62019-11-26 08:59:14 -0800156 uint64_t num_ack_aggregation_epochs = 0;
fayang7d164eb2020-01-10 12:31:33 -0800157
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;
fayang5b2a3462020-03-11 15:18:27 -0700161
162 // Whether there is any non app-limited bandwidth sample.
163 bool has_non_app_limited_sample = false;
fayang643c7dd2020-05-18 07:11:27 -0700164
165 // Packet number of first decrypted packet.
166 QuicPacketNumber first_decrypted_packet;
fayang2a379bf2020-05-18 11:49:25 -0700167
168 // Max consecutive retransmission timeout before making forward progress.
169 size_t max_consecutive_rto_with_forward_progress = 0;
dschinazi6458eb32020-06-23 12:38:41 -0700170
171 // Number of sent packets that were encapsulated using Legacy Version
172 // Encapsulation.
173 QuicPacketCount sent_legacy_version_encapsulated_packets = 0;
wubb104f0f2020-07-06 11:58:08 -0700174
fayangb3359b02020-07-17 14:51:29 -0700175 // Number of times when the connection tries to send data but gets throttled
176 // by amplification factor.
177 size_t num_amplification_throttling = 0;
mattm072a7e32020-10-09 16:16:56 -0700178
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;
mattma2ae9352020-10-23 15:55:14 -0700183
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;
mattmad5eb5d2020-12-03 16:12:15 -0800187
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;
fayang133b8682020-12-08 05:50:33 -0800192
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;
wubd05824d2020-12-09 09:50:20 -0800199
200 size_t ping_frames_sent = 0;
danzha25ed9d2021-02-19 12:40:26 -0800201
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;
haoyuewangb25dd212021-05-05 07:33:07 -0700218 // 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;
wubab3139c2021-03-15 13:40:39 -0700222
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 teama6ef0a62019-03-07 20:34:33 -0500237};
238
239} // namespace quic
240
241#endif // QUICHE_QUIC_CORE_QUIC_CONNECTION_STATS_H_