blob: 88f8880611fb9e54b3a4bd94fee6cbac1a6a18d9 [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
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"
wubbe29b9e2019-11-24 06:56:04 -080014#include "net/third_party/quiche/src/quic/core/quic_time_accumulator.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050015#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
16
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.
wube619ef62019-11-26 08:59:14 -0800106 QuicByteCount max_packet_size = 0;
107 QuicByteCount max_received_packet_size = 0;
108 QuicBandwidth estimated_bandwidth = QuicBandwidth::Zero();
QUICHE teama6ef0a62019-03-07 20:34:33 -0500109
110 // Reordering stats for received packets.
111 // Number of packets received out of packet number order.
wube619ef62019-11-26 08:59:14 -0800112 QuicPacketCount packets_reordered = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500113 // Maximum reordering observed in packet number space.
wube619ef62019-11-26 08:59:14 -0800114 QuicPacketCount max_sequence_reordering = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500115 // Maximum reordering observed in microseconds
wube619ef62019-11-26 08:59:14 -0800116 int64_t max_time_reordering_us = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500117
wubaa51f0e2020-05-12 15:08:16 -0700118 // Maximum sequence reordering observed from acked packets.
119 QuicPacketCount sent_packets_max_sequence_reordering = 0;
wubd8b383e2020-05-22 07:24:39 -0700120 // 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;
wubaa51f0e2020-05-12 15:08:16 -0700123
QUICHE teama6ef0a62019-03-07 20:34:33 -0500124 // 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.
wube619ef62019-11-26 08:59:14 -0800127 uint32_t tcp_loss_events = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500128
129 // Creation time, as reported by the QuicClock.
wube619ef62019-11-26 08:59:14 -0800130 QuicTime connection_creation_time = QuicTime::Zero();
QUICHE teama6ef0a62019-03-07 20:34:33 -0500131
wube619ef62019-11-26 08:59:14 -0800132 uint64_t blocked_frames_received = 0;
133 uint64_t blocked_frames_sent = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500134
135 // Number of connectivity probing packets received by this connection.
wube619ef62019-11-26 08:59:14 -0800136 uint64_t num_connectivity_probing_received = 0;
dschinazi8a030dd2019-10-14 13:17:18 -0700137
138 // Whether a RETRY packet was successfully processed.
wube619ef62019-11-26 08:59:14 -0800139 bool retry_packet_processed = false;
fayang58f71072019-11-05 08:47:02 -0800140
141 // Number of received coalesced packets.
wube619ef62019-11-26 08:59:14 -0800142 uint64_t num_coalesced_packets_received = 0;
fayang58f71072019-11-05 08:47:02 -0800143 // Number of successfully processed coalesced packets.
wube619ef62019-11-26 08:59:14 -0800144 uint64_t num_coalesced_packets_processed = 0;
wub5cd49592019-11-25 15:17:13 -0800145 // Number of ack aggregation epochs. For the same number of bytes acked, the
146 // smaller this value, the more ack aggregation is going on.
wube619ef62019-11-26 08:59:14 -0800147 uint64_t num_ack_aggregation_epochs = 0;
fayang7d164eb2020-01-10 12:31:33 -0800148
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;
fayang5b2a3462020-03-11 15:18:27 -0700152
153 // Whether there is any non app-limited bandwidth sample.
154 bool has_non_app_limited_sample = false;
fayang643c7dd2020-05-18 07:11:27 -0700155
156 // Packet number of first decrypted packet.
157 QuicPacketNumber first_decrypted_packet;
fayang2a379bf2020-05-18 11:49:25 -0700158
159 // Max consecutive retransmission timeout before making forward progress.
160 size_t max_consecutive_rto_with_forward_progress = 0;
dschinazi6458eb32020-06-23 12:38:41 -0700161
162 // Number of sent packets that were encapsulated using Legacy Version
163 // Encapsulation.
164 QuicPacketCount sent_legacy_version_encapsulated_packets = 0;
wubb104f0f2020-07-06 11:58:08 -0700165
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();
fayangb3359b02020-07-17 14:51:29 -0700174
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 teama6ef0a62019-03-07 20:34:33 -0500178};
179
180} // namespace quic
181
182#endif // QUICHE_QUIC_CORE_QUIC_CONNECTION_STATS_H_