blob: 118e9c4bcd5d9ffd0b44aaba282dc4a9c2f72f44 [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// Copyright (c) 2012 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// The entity that handles framing writes for a Quic client or server.
6// Each QuicSession will have a connection associated with it.
7//
8// On the server side, the Dispatcher handles the raw reads, and hands off
9// packets via ProcessUdpPacket for framing and processing.
10//
11// On the client side, the Connection handles the raw reads, as well as the
12// processing.
13//
14// Note: this class is not thread-safe.
15
16#ifndef QUICHE_QUIC_CORE_QUIC_CONNECTION_H_
17#define QUICHE_QUIC_CORE_QUIC_CONNECTION_H_
18
19#include <cstddef>
20#include <cstdint>
21#include <list>
22#include <map>
23#include <memory>
vasilvv872e7a32019-03-12 16:42:44 -070024#include <string>
QUICHE teama6ef0a62019-03-07 20:34:33 -050025#include <vector>
26
QUICHE teama6ef0a62019-03-07 20:34:33 -050027#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h"
28#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h"
dschinazi631f1602020-05-19 10:10:22 -070029#include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h"
renjietangc7054902019-09-25 13:13:52 -070030#include "net/third_party/quiche/src/quic/core/frames/quic_max_streams_frame.h"
dschinazi56fb53e2019-06-21 15:30:04 -070031#include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050032#include "net/third_party/quiche/src/quic/core/quic_alarm.h"
33#include "net/third_party/quiche/src/quic/core/quic_alarm_factory.h"
34#include "net/third_party/quiche/src/quic/core/quic_blocked_writer_interface.h"
danzhbf4836c2020-02-11 20:29:15 -080035#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h"
QUICHE teamc65d1d12019-03-19 20:58:04 -070036#include "net/third_party/quiche/src/quic/core/quic_connection_id.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050037#include "net/third_party/quiche/src/quic/core/quic_connection_stats.h"
38#include "net/third_party/quiche/src/quic/core/quic_framer.h"
fayangb9c88442020-03-26 07:03:57 -070039#include "net/third_party/quiche/src/quic/core/quic_idle_network_detector.h"
wubf76cf2a2019-10-11 18:49:07 -070040#include "net/third_party/quiche/src/quic/core/quic_mtu_discovery.h"
fayangb59c6f12020-03-23 15:06:14 -070041#include "net/third_party/quiche/src/quic/core/quic_network_blackhole_detector.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050042#include "net/third_party/quiche/src/quic/core/quic_one_block_arena.h"
43#include "net/third_party/quiche/src/quic/core/quic_packet_creator.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050044#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h"
45#include "net/third_party/quiche/src/quic/core/quic_packets.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050046#include "net/third_party/quiche/src/quic/core/quic_sent_packet_manager.h"
47#include "net/third_party/quiche/src/quic/core/quic_time.h"
48#include "net/third_party/quiche/src/quic/core/quic_types.h"
QUICHE teamb23daa72019-03-21 08:37:48 -070049#include "net/third_party/quiche/src/quic/core/uber_received_packet_manager.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050050#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h"
51#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
52#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h"
dschinazi39e5e552020-05-06 13:55:24 -070053#include "net/third_party/quiche/src/common/platform/api/quiche_optional.h"
dmcardlecf0bfcf2019-12-13 08:08:21 -080054#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h"
55#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050056
57namespace quic {
58
59class QuicClock;
60class QuicConfig;
61class QuicConnection;
62class QuicRandom;
63
64namespace test {
65class QuicConnectionPeer;
66} // namespace test
67
QUICHE teama6ef0a62019-03-07 20:34:33 -050068// Class that receives callbacks from the connection when frames are received
69// and when other interesting events happen.
70class QUIC_EXPORT_PRIVATE QuicConnectionVisitorInterface {
71 public:
72 virtual ~QuicConnectionVisitorInterface() {}
73
74 // A simple visitor interface for dealing with a data frame.
75 virtual void OnStreamFrame(const QuicStreamFrame& frame) = 0;
76
77 // Called when a CRYPTO frame containing handshake data is received.
78 virtual void OnCryptoFrame(const QuicCryptoFrame& frame) = 0;
79
80 // The session should process the WINDOW_UPDATE frame, adjusting both stream
81 // and connection level flow control windows.
82 virtual void OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) = 0;
83
84 // A BLOCKED frame indicates the peer is flow control blocked
85 // on a specified stream.
86 virtual void OnBlockedFrame(const QuicBlockedFrame& frame) = 0;
87
88 // Called when the stream is reset by the peer.
89 virtual void OnRstStream(const QuicRstStreamFrame& frame) = 0;
90
91 // Called when the connection is going away according to the peer.
92 virtual void OnGoAway(const QuicGoAwayFrame& frame) = 0;
93
94 // Called when |message| has been received.
dmcardlecf0bfcf2019-12-13 08:08:21 -080095 virtual void OnMessageReceived(quiche::QuicheStringPiece message) = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -050096
fayang01062942020-01-22 07:23:23 -080097 // Called when a HANDSHAKE_DONE frame has been received.
98 virtual void OnHandshakeDoneReceived() = 0;
99
fkastenholz3c4eabf2019-04-22 07:49:59 -0700100 // Called when a MAX_STREAMS frame has been received from the peer.
101 virtual bool OnMaxStreamsFrame(const QuicMaxStreamsFrame& frame) = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500102
fkastenholz3c4eabf2019-04-22 07:49:59 -0700103 // Called when a STREAMS_BLOCKED frame has been received from the peer.
104 virtual bool OnStreamsBlockedFrame(const QuicStreamsBlockedFrame& frame) = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500105
106 // Called when the connection is closed either locally by the framer, or
107 // remotely by the peer.
fkastenholz5d880a92019-06-21 09:01:56 -0700108 virtual void OnConnectionClosed(const QuicConnectionCloseFrame& frame,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500109 ConnectionCloseSource source) = 0;
110
111 // Called when the connection failed to write because the socket was blocked.
112 virtual void OnWriteBlocked() = 0;
113
114 // Called once a specific QUIC version is agreed by both endpoints.
115 virtual void OnSuccessfulVersionNegotiation(
116 const ParsedQuicVersion& version) = 0;
117
zhongyi83161e42019-08-19 09:06:25 -0700118 // Called when a packet has been received by the connection, after being
119 // validated and parsed. Only called when the client receives a valid packet
120 // or the server receives a connectivity probing packet.
121 // |is_connectivity_probe| is true if the received packet is a connectivity
122 // probe.
123 virtual void OnPacketReceived(const QuicSocketAddress& self_address,
124 const QuicSocketAddress& peer_address,
125 bool is_connectivity_probe) = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500126
127 // Called when a blocked socket becomes writable.
128 virtual void OnCanWrite() = 0;
129
QUICHE teamb8343252019-04-29 13:58:01 -0700130 // Called when the connection needs more data to probe for additional
131 // bandwidth. Returns true if data was sent, false otherwise.
132 virtual bool SendProbingData() = 0;
133
renjietang7f483b52020-05-20 14:30:47 -0700134 // Called when stateless reset packet is received. Returns true if the
135 // connection needs to be closed.
136 virtual bool ValidateStatelessReset(
137 const quic::QuicSocketAddress& self_address,
138 const quic::QuicSocketAddress& peer_address) = 0;
renjietang5b245892020-05-18 11:57:26 -0700139
QUICHE teama6ef0a62019-03-07 20:34:33 -0500140 // Called when the connection experiences a change in congestion window.
141 virtual void OnCongestionWindowChange(QuicTime now) = 0;
142
143 // Called when the connection receives a packet from a migrated client.
144 virtual void OnConnectionMigration(AddressChangeType type) = 0;
145
146 // Called when the peer seems unreachable over the current path.
147 virtual void OnPathDegrading() = 0;
148
zhongyief1d6752020-06-11 16:19:28 -0700149 // Called when forward progress made after path degrading.
150 virtual void OnForwardProgressMadeAfterPathDegrading() = 0;
151
QUICHE teama6ef0a62019-03-07 20:34:33 -0500152 // Called when the connection sends ack after
153 // max_consecutive_num_packets_with_no_retransmittable_frames_ consecutive not
154 // retransmittable packets sent. To instigate an ack from peer, a
155 // retransmittable frame needs to be added.
156 virtual void OnAckNeedsRetransmittableFrame() = 0;
157
158 // Called when a ping needs to be sent.
159 virtual void SendPing() = 0;
160
161 // Called to ask if the visitor wants to schedule write resumption as it both
162 // has pending data to write, and is able to write (e.g. based on flow control
163 // limits).
164 // Writes may be pending because they were write-blocked, congestion-throttled
165 // or yielded to other connections.
166 virtual bool WillingAndAbleToWrite() const = 0;
167
QUICHE teama6ef0a62019-03-07 20:34:33 -0500168 // Called to ask if the connection should be kept alive and prevented
169 // from timing out, for example if there are outstanding application
170 // transactions expecting a response.
171 virtual bool ShouldKeepConnectionAlive() const = 0;
172
173 // Called when a self address change is observed. Returns true if self address
174 // change is allowed.
175 virtual bool AllowSelfAddressChange() const = 0;
176
fayangc67c5202020-01-22 07:43:15 -0800177 // Called to get current handshake state.
178 virtual HandshakeState GetHandshakeState() const = 0;
179
QUICHE teama6ef0a62019-03-07 20:34:33 -0500180 // Called when a STOP_SENDING frame has been received.
renjietangeab918f2019-10-28 12:10:32 -0700181 virtual void OnStopSendingFrame(const QuicStopSendingFrame& frame) = 0;
fayangd58736d2019-11-27 13:35:31 -0800182
183 // Called when a packet of encryption |level| has been successfully decrypted.
184 virtual void OnPacketDecrypted(EncryptionLevel level) = 0;
fayang2f2915d2020-01-24 06:47:15 -0800185
186 // Called when a 1RTT packet has been acknowledged.
187 virtual void OnOneRttPacketAcknowledged() = 0;
fayang44ae4e92020-04-28 13:09:42 -0700188
189 // Called when a packet of ENCRYPTION_HANDSHAKE gets sent.
190 virtual void OnHandshakePacketSent() = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500191};
192
193// Interface which gets callbacks from the QuicConnection at interesting
194// points. Implementations must not mutate the state of the connection
195// as a result of these callbacks.
196class QUIC_EXPORT_PRIVATE QuicConnectionDebugVisitor
197 : public QuicSentPacketManager::DebugDelegate {
198 public:
199 ~QuicConnectionDebugVisitor() override {}
200
201 // Called when a packet has been sent.
dschinazi17d42422019-06-18 16:35:07 -0700202 virtual void OnPacketSent(const SerializedPacket& /*serialized_packet*/,
dschinazi17d42422019-06-18 16:35:07 -0700203 TransmissionType /*transmission_type*/,
204 QuicTime /*sent_time*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500205
fayang6100ab72020-03-18 13:16:25 -0700206 // Called when a coalesced packet has been sent.
207 virtual void OnCoalescedPacketSent(
208 const QuicCoalescedPacket& /*coalesced_packet*/,
209 size_t /*length*/) {}
210
QUICHE teama6ef0a62019-03-07 20:34:33 -0500211 // Called when a PING frame has been sent.
212 virtual void OnPingSent() {}
213
214 // Called when a packet has been received, but before it is
215 // validated or parsed.
dschinazi17d42422019-06-18 16:35:07 -0700216 virtual void OnPacketReceived(const QuicSocketAddress& /*self_address*/,
217 const QuicSocketAddress& /*peer_address*/,
218 const QuicEncryptedPacket& /*packet*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500219
220 // Called when the unauthenticated portion of the header has been parsed.
dschinazi17d42422019-06-18 16:35:07 -0700221 virtual void OnUnauthenticatedHeader(const QuicPacketHeader& /*header*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500222
223 // Called when a packet is received with a connection id that does not
224 // match the ID of this connection.
dschinazi17d42422019-06-18 16:35:07 -0700225 virtual void OnIncorrectConnectionId(QuicConnectionId /*connection_id*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500226
fayang9dcfaca2020-04-24 06:57:14 -0700227 // Called when an undecryptable packet has been received. If |dropped| is
228 // true, the packet has been dropped. Otherwise, the packet will be queued and
229 // connection will attempt to process it later.
230 virtual void OnUndecryptablePacket(EncryptionLevel /*decryption_level*/,
231 bool /*dropped*/) {}
232
233 // Called when attempting to process a previously undecryptable packet.
234 virtual void OnAttemptingToProcessUndecryptablePacket(
235 EncryptionLevel /*decryption_level*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500236
237 // Called when a duplicate packet has been received.
dschinazi17d42422019-06-18 16:35:07 -0700238 virtual void OnDuplicatePacket(QuicPacketNumber /*packet_number*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500239
240 // Called when the protocol version on the received packet doensn't match
241 // current protocol version of the connection.
dschinazi17d42422019-06-18 16:35:07 -0700242 virtual void OnProtocolVersionMismatch(ParsedQuicVersion /*version*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500243
244 // Called when the complete header of a packet has been parsed.
dschinazi17d42422019-06-18 16:35:07 -0700245 virtual void OnPacketHeader(const QuicPacketHeader& /*header*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500246
247 // Called when a StreamFrame has been parsed.
dschinazi17d42422019-06-18 16:35:07 -0700248 virtual void OnStreamFrame(const QuicStreamFrame& /*frame*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500249
rchb7e6e642019-09-03 21:57:05 -0700250 // Called when a CRYPTO frame containing handshake data is received.
251 virtual void OnCryptoFrame(const QuicCryptoFrame& /*frame*/) {}
252
QUICHE teama6ef0a62019-03-07 20:34:33 -0500253 // Called when a StopWaitingFrame has been parsed.
dschinazi17d42422019-06-18 16:35:07 -0700254 virtual void OnStopWaitingFrame(const QuicStopWaitingFrame& /*frame*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500255
256 // Called when a QuicPaddingFrame has been parsed.
dschinazi17d42422019-06-18 16:35:07 -0700257 virtual void OnPaddingFrame(const QuicPaddingFrame& /*frame*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500258
259 // Called when a Ping has been parsed.
dschinazi17d42422019-06-18 16:35:07 -0700260 virtual void OnPingFrame(const QuicPingFrame& /*frame*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500261
262 // Called when a GoAway has been parsed.
dschinazi17d42422019-06-18 16:35:07 -0700263 virtual void OnGoAwayFrame(const QuicGoAwayFrame& /*frame*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500264
265 // Called when a RstStreamFrame has been parsed.
dschinazi17d42422019-06-18 16:35:07 -0700266 virtual void OnRstStreamFrame(const QuicRstStreamFrame& /*frame*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500267
fkastenholz04bd4f32019-04-16 12:24:38 -0700268 // Called when a ConnectionCloseFrame has been parsed. All forms
269 // of CONNECTION CLOSE are handled, Google QUIC, IETF QUIC
270 // CONNECTION CLOSE/Transport and IETF QUIC CONNECTION CLOSE/Application
dschinazi17d42422019-06-18 16:35:07 -0700271 virtual void OnConnectionCloseFrame(
272 const QuicConnectionCloseFrame& /*frame*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500273
QUICHE teama6ef0a62019-03-07 20:34:33 -0500274 // Called when a WindowUpdate has been parsed.
dschinazi17d42422019-06-18 16:35:07 -0700275 virtual void OnWindowUpdateFrame(const QuicWindowUpdateFrame& /*frame*/,
276 const QuicTime& /*receive_time*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500277
278 // Called when a BlockedFrame has been parsed.
dschinazi17d42422019-06-18 16:35:07 -0700279 virtual void OnBlockedFrame(const QuicBlockedFrame& /*frame*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500280
rchb7e6e642019-09-03 21:57:05 -0700281 // Called when a NewConnectionIdFrame has been parsed.
282 virtual void OnNewConnectionIdFrame(
283 const QuicNewConnectionIdFrame& /*frame*/) {}
284
285 // Called when a RetireConnectionIdFrame has been parsed.
286 virtual void OnRetireConnectionIdFrame(
287 const QuicRetireConnectionIdFrame& /*frame*/) {}
288
289 // Called when a NewTokenFrame has been parsed.
290 virtual void OnNewTokenFrame(const QuicNewTokenFrame& /*frame*/) {}
291
QUICHE teama6ef0a62019-03-07 20:34:33 -0500292 // Called when a MessageFrame has been parsed.
dschinazi17d42422019-06-18 16:35:07 -0700293 virtual void OnMessageFrame(const QuicMessageFrame& /*frame*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500294
fayang01062942020-01-22 07:23:23 -0800295 // Called when a HandshakeDoneFrame has been parsed.
296 virtual void OnHandshakeDoneFrame(const QuicHandshakeDoneFrame& /*frame*/) {}
297
QUICHE teama6ef0a62019-03-07 20:34:33 -0500298 // Called when a public reset packet has been received.
dschinazi17d42422019-06-18 16:35:07 -0700299 virtual void OnPublicResetPacket(const QuicPublicResetPacket& /*packet*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500300
301 // Called when a version negotiation packet has been received.
302 virtual void OnVersionNegotiationPacket(
dschinazi17d42422019-06-18 16:35:07 -0700303 const QuicVersionNegotiationPacket& /*packet*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500304
305 // Called when the connection is closed.
fkastenholzac11db02019-06-24 06:22:04 -0700306 virtual void OnConnectionClosed(const QuicConnectionCloseFrame& /*frame*/,
dschinazi17d42422019-06-18 16:35:07 -0700307 ConnectionCloseSource /*source*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500308
309 // Called when the version negotiation is successful.
310 virtual void OnSuccessfulVersionNegotiation(
dschinazi17d42422019-06-18 16:35:07 -0700311 const ParsedQuicVersion& /*version*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500312
313 // Called when a CachedNetworkParameters is sent to the client.
314 virtual void OnSendConnectionState(
dschinazi17d42422019-06-18 16:35:07 -0700315 const CachedNetworkParameters& /*cached_network_params*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500316
317 // Called when a CachedNetworkParameters are received from the client.
318 virtual void OnReceiveConnectionState(
dschinazi17d42422019-06-18 16:35:07 -0700319 const CachedNetworkParameters& /*cached_network_params*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500320
321 // Called when the connection parameters are set from the supplied
322 // |config|.
dschinazi17d42422019-06-18 16:35:07 -0700323 virtual void OnSetFromConfig(const QuicConfig& /*config*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500324
325 // Called when RTT may have changed, including when an RTT is read from
326 // the config.
dschinazi17d42422019-06-18 16:35:07 -0700327 virtual void OnRttChanged(QuicTime::Delta /*rtt*/) const {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500328
329 // Called when a StopSendingFrame has been parsed.
dschinazi17d42422019-06-18 16:35:07 -0700330 virtual void OnStopSendingFrame(const QuicStopSendingFrame& /*frame*/) {}
rchb7e6e642019-09-03 21:57:05 -0700331
332 // Called when a PathChallengeFrame has been parsed.
333 virtual void OnPathChallengeFrame(const QuicPathChallengeFrame& /*frame*/) {}
334
335 // Called when a PathResponseFrame has been parsed.
336 virtual void OnPathResponseFrame(const QuicPathResponseFrame& /*frame*/) {}
renjietangc7054902019-09-25 13:13:52 -0700337
338 // Called when a StreamsBlockedFrame has been parsed.
339 virtual void OnStreamsBlockedFrame(const QuicStreamsBlockedFrame& /*frame*/) {
340 }
341
342 // Called when a MaxStreamsFrame has been parsed.
343 virtual void OnMaxStreamsFrame(const QuicMaxStreamsFrame& /*frame*/) {}
fayang2cbfccf2019-11-14 14:02:15 -0800344
345 // Called when |count| packet numbers have been skipped.
346 virtual void OnNPacketNumbersSkipped(QuicPacketCount /*count*/) {}
dschinazi631f1602020-05-19 10:10:22 -0700347
348 // Called for QUIC+TLS versions when we send transport parameters.
349 virtual void OnTransportParametersSent(
350 const TransportParameters& /*transport_parameters*/) {}
351
352 // Called for QUIC+TLS versions when we receive transport parameters.
353 virtual void OnTransportParametersReceived(
354 const TransportParameters& /*transport_parameters*/) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -0500355};
356
357class QUIC_EXPORT_PRIVATE QuicConnectionHelperInterface {
358 public:
359 virtual ~QuicConnectionHelperInterface() {}
360
361 // Returns a QuicClock to be used for all time related functions.
362 virtual const QuicClock* GetClock() const = 0;
363
364 // Returns a QuicRandom to be used for all random number related functions.
365 virtual QuicRandom* GetRandomGenerator() = 0;
366
367 // Returns a QuicBufferAllocator to be used for stream send buffers.
368 virtual QuicBufferAllocator* GetStreamSendBufferAllocator() = 0;
369};
370
371class QUIC_EXPORT_PRIVATE QuicConnection
372 : public QuicFramerVisitorInterface,
373 public QuicBlockedWriterInterface,
fayangcad11792019-09-16 13:11:44 -0700374 public QuicPacketCreator::DelegateInterface,
fayangb59c6f12020-03-23 15:06:14 -0700375 public QuicSentPacketManager::NetworkChangeVisitor,
fayangb9c88442020-03-26 07:03:57 -0700376 public QuicNetworkBlackholeDetector::Delegate,
377 public QuicIdleNetworkDetector::Delegate {
QUICHE teama6ef0a62019-03-07 20:34:33 -0500378 public:
QUICHE teama6ef0a62019-03-07 20:34:33 -0500379 // Constructs a new QuicConnection for |connection_id| and
380 // |initial_peer_address| using |writer| to write packets. |owns_writer|
381 // specifies whether the connection takes ownership of |writer|. |helper| must
382 // outlive this connection.
dschinazi7b9278c2019-05-20 07:36:21 -0700383 QuicConnection(QuicConnectionId server_connection_id,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500384 QuicSocketAddress initial_peer_address,
385 QuicConnectionHelperInterface* helper,
386 QuicAlarmFactory* alarm_factory,
387 QuicPacketWriter* writer,
388 bool owns_writer,
389 Perspective perspective,
390 const ParsedQuicVersionVector& supported_versions);
391 QuicConnection(const QuicConnection&) = delete;
392 QuicConnection& operator=(const QuicConnection&) = delete;
393 ~QuicConnection() override;
394
395 // Sets connection parameters from the supplied |config|.
396 void SetFromConfig(const QuicConfig& config);
397
wubd09f1a62020-05-04 06:57:40 -0700398 // Apply |connection_options| for this connection. Unlike SetFromConfig, this
399 // can happen at anytime in the life of a connection.
400 // Note there is no guarantee that all options can be applied. Components will
401 // only apply cherrypicked options that make sense at the time of the call.
402 void ApplyConnectionOptions(const QuicTagVector& connection_options);
403
QUICHE teama6ef0a62019-03-07 20:34:33 -0500404 // Called by the session when sending connection state to the client.
405 virtual void OnSendConnectionState(
406 const CachedNetworkParameters& cached_network_params);
407
408 // Called by the session when receiving connection state from the client.
409 virtual void OnReceiveConnectionState(
410 const CachedNetworkParameters& cached_network_params);
411
412 // Called by the Session when the client has provided CachedNetworkParameters.
413 virtual void ResumeConnectionState(
414 const CachedNetworkParameters& cached_network_params,
415 bool max_bandwidth_resumption);
416
417 // Called by the Session when a max pacing rate for the connection is needed.
418 virtual void SetMaxPacingRate(QuicBandwidth max_pacing_rate);
419
420 // Allows the client to adjust network parameters based on external
421 // information.
QUICHE teamfdcfe3b2019-11-06 10:54:25 -0800422 void AdjustNetworkParameters(
423 const SendAlgorithmInterface::NetworkParams& params);
fayangf1b99dc2019-05-14 06:29:18 -0700424 void AdjustNetworkParameters(QuicBandwidth bandwidth,
425 QuicTime::Delta rtt,
426 bool allow_cwnd_to_decrease);
QUICHE teama6ef0a62019-03-07 20:34:33 -0500427
wub44e33052020-03-03 17:11:40 -0800428 // Install a loss detection tuner. Must be called before OnConfigNegotiated.
429 void SetLossDetectionTuner(
430 std::unique_ptr<LossDetectionTunerInterface> tuner);
431 // Called by the session when session->is_configured() becomes true.
432 void OnConfigNegotiated();
433
QUICHE teama6ef0a62019-03-07 20:34:33 -0500434 // Returns the max pacing rate for the connection.
435 virtual QuicBandwidth MaxPacingRate() const;
436
437 // Sends crypto handshake messages of length |write_length| to the peer in as
438 // few packets as possible. Returns the number of bytes consumed from the
439 // data.
440 virtual size_t SendCryptoData(EncryptionLevel level,
441 size_t write_length,
442 QuicStreamOffset offset);
443
444 // Send the data of length |write_length| to the peer in as few packets as
445 // possible. Returns the number of bytes consumed from data, and a boolean
446 // indicating if the fin bit was consumed. This does not indicate the data
447 // has been sent on the wire: it may have been turned into a packet and queued
448 // if the socket was unexpectedly blocked.
449 virtual QuicConsumedData SendStreamData(QuicStreamId id,
450 size_t write_length,
451 QuicStreamOffset offset,
452 StreamSendingState state);
453
454 // Send |frame| to the peer. Returns true if frame is consumed, false
455 // otherwise.
456 virtual bool SendControlFrame(const QuicFrame& frame);
457
458 // Called when stream |id| is reset because of |error|.
459 virtual void OnStreamReset(QuicStreamId id, QuicRstStreamErrorCode error);
460
461 // Closes the connection.
462 // |connection_close_behavior| determines whether or not a connection close
463 // packet is sent to the peer.
464 virtual void CloseConnection(
465 QuicErrorCode error,
vasilvvc48c8712019-03-11 13:38:16 -0700466 const std::string& details,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500467 ConnectionCloseBehavior connection_close_behavior);
468
469 // Returns statistics tracked for this connection.
470 const QuicConnectionStats& GetStats();
471
472 // Processes an incoming UDP packet (consisting of a QuicEncryptedPacket) from
473 // the peer.
474 // In a client, the packet may be "stray" and have a different connection ID
475 // than that of this connection.
476 virtual void ProcessUdpPacket(const QuicSocketAddress& self_address,
477 const QuicSocketAddress& peer_address,
478 const QuicReceivedPacket& packet);
479
480 // QuicBlockedWriterInterface
481 // Called when the underlying connection becomes writable to allow queued
482 // writes to happen.
483 void OnBlockedWriterCanWrite() override;
484
485 bool IsWriterBlocked() const override {
486 return writer_ != nullptr && writer_->IsWriteBlocked();
487 }
488
489 // Called when the caller thinks it's worth a try to write.
490 virtual void OnCanWrite();
491
492 // Called when an error occurs while attempting to write a packet to the
493 // network.
494 void OnWriteError(int error_code);
495
496 // Whether |result| represents a MSG TOO BIG write error.
497 bool IsMsgTooBig(const WriteResult& result);
498
499 // If the socket is not blocked, writes queued packets.
500 void WriteIfNotBlocked();
501
502 // If the socket is not blocked, writes queued packets and bundles any pending
503 // ACKs.
504 void WriteAndBundleAcksIfNotBlocked();
505
506 // Set the packet writer.
507 void SetQuicPacketWriter(QuicPacketWriter* writer, bool owns_writer) {
508 DCHECK(writer != nullptr);
509 if (writer_ != nullptr && owns_writer_) {
510 delete writer_;
511 }
512 writer_ = writer;
513 owns_writer_ = owns_writer;
514 }
515
516 // Set self address.
517 void SetSelfAddress(QuicSocketAddress address) { self_address_ = address; }
518
519 // The version of the protocol this connection is using.
520 QuicTransportVersion transport_version() const {
521 return framer_.transport_version();
522 }
523
524 ParsedQuicVersion version() const { return framer_.version(); }
525
526 // The versions of the protocol that this connection supports.
527 const ParsedQuicVersionVector& supported_versions() const {
528 return framer_.supported_versions();
529 }
530
wubf75c2c62020-02-05 06:34:09 -0800531 // Mark version negotiated for this connection. Once called, the connection
532 // will ignore received version negotiation packets.
533 void SetVersionNegotiated() {
534 version_negotiated_ = true;
535 if (perspective_ == Perspective::IS_SERVER) {
536 framer_.InferPacketHeaderTypeFromVersion();
537 }
538 }
539
QUICHE teama6ef0a62019-03-07 20:34:33 -0500540 // From QuicFramerVisitorInterface
541 void OnError(QuicFramer* framer) override;
fayang8aba1ff2019-06-21 12:00:54 -0700542 bool OnProtocolVersionMismatch(ParsedQuicVersion received_version) override;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500543 void OnPacket() override;
544 void OnPublicResetPacket(const QuicPublicResetPacket& packet) override;
545 void OnVersionNegotiationPacket(
546 const QuicVersionNegotiationPacket& packet) override;
dschinazi244f6dc2019-05-06 15:45:16 -0700547 void OnRetryPacket(QuicConnectionId original_connection_id,
548 QuicConnectionId new_connection_id,
dschinazi278efae2020-01-28 17:03:09 -0800549 quiche::QuicheStringPiece retry_token,
550 quiche::QuicheStringPiece retry_integrity_tag,
551 quiche::QuicheStringPiece retry_without_tag) override;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500552 bool OnUnauthenticatedPublicHeader(const QuicPacketHeader& header) override;
553 bool OnUnauthenticatedHeader(const QuicPacketHeader& header) override;
554 void OnDecryptedPacket(EncryptionLevel level) override;
555 bool OnPacketHeader(const QuicPacketHeader& header) override;
556 void OnCoalescedPacket(const QuicEncryptedPacket& packet) override;
dschinazi4b5a68a2019-08-15 15:45:36 -0700557 void OnUndecryptablePacket(const QuicEncryptedPacket& packet,
558 EncryptionLevel decryption_level,
559 bool has_decryption_key) override;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500560 bool OnStreamFrame(const QuicStreamFrame& frame) override;
561 bool OnCryptoFrame(const QuicCryptoFrame& frame) override;
562 bool OnAckFrameStart(QuicPacketNumber largest_acked,
563 QuicTime::Delta ack_delay_time) override;
564 bool OnAckRange(QuicPacketNumber start, QuicPacketNumber end) override;
565 bool OnAckTimestamp(QuicPacketNumber packet_number,
566 QuicTime timestamp) override;
567 bool OnAckFrameEnd(QuicPacketNumber start) override;
568 bool OnStopWaitingFrame(const QuicStopWaitingFrame& frame) override;
569 bool OnPaddingFrame(const QuicPaddingFrame& frame) override;
570 bool OnPingFrame(const QuicPingFrame& frame) override;
571 bool OnRstStreamFrame(const QuicRstStreamFrame& frame) override;
572 bool OnConnectionCloseFrame(const QuicConnectionCloseFrame& frame) override;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500573 bool OnStopSendingFrame(const QuicStopSendingFrame& frame) override;
574 bool OnPathChallengeFrame(const QuicPathChallengeFrame& frame) override;
575 bool OnPathResponseFrame(const QuicPathResponseFrame& frame) override;
576 bool OnGoAwayFrame(const QuicGoAwayFrame& frame) override;
fkastenholz3c4eabf2019-04-22 07:49:59 -0700577 bool OnMaxStreamsFrame(const QuicMaxStreamsFrame& frame) override;
578 bool OnStreamsBlockedFrame(const QuicStreamsBlockedFrame& frame) override;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500579 bool OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override;
580 bool OnBlockedFrame(const QuicBlockedFrame& frame) override;
581 bool OnNewConnectionIdFrame(const QuicNewConnectionIdFrame& frame) override;
582 bool OnRetireConnectionIdFrame(
583 const QuicRetireConnectionIdFrame& frame) override;
584 bool OnNewTokenFrame(const QuicNewTokenFrame& frame) override;
585 bool OnMessageFrame(const QuicMessageFrame& frame) override;
fayang01062942020-01-22 07:23:23 -0800586 bool OnHandshakeDoneFrame(const QuicHandshakeDoneFrame& frame) override;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500587 void OnPacketComplete() override;
588 bool IsValidStatelessResetToken(QuicUint128 token) const override;
589 void OnAuthenticatedIetfStatelessResetPacket(
590 const QuicIetfStatelessResetPacket& packet) override;
591
fayang4245c212019-11-05 13:33:46 -0800592 // QuicPacketCreator::DelegateInterface
QUICHE teama6ef0a62019-03-07 20:34:33 -0500593 bool ShouldGeneratePacket(HasRetransmittableData retransmittable,
594 IsHandshake handshake) override;
595 const QuicFrames MaybeBundleAckOpportunistically() override;
wub50d4c712020-05-19 15:48:28 -0700596 QuicPacketBuffer GetPacketBuffer() override;
wub8a5dafa2020-05-13 12:30:17 -0700597 void OnSerializedPacket(SerializedPacket packet) override;
ianswettb023c7b2019-05-06 12:38:10 -0700598 void OnUnrecoverableError(QuicErrorCode error,
fkastenholz85f18902019-05-28 12:47:00 -0700599 const std::string& error_details) override;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500600
601 // QuicSentPacketManager::NetworkChangeVisitor
602 void OnCongestionChange() override;
603 void OnPathMtuIncreased(QuicPacketLength packet_size) override;
604
fayangb59c6f12020-03-23 15:06:14 -0700605 // QuicNetworkBlackholeDetector::Delegate
606 void OnPathDegradingDetected() override;
607 void OnBlackholeDetected() override;
608
fayangb9c88442020-03-26 07:03:57 -0700609 // QuicIdleNetworkDetector::Delegate
610 void OnHandshakeTimeout() override;
611 void OnIdleNetworkDetected() override;
612
fayanga4b37b22019-06-18 13:37:47 -0700613 // Please note, this is not a const function. For logging purpose, please use
614 // ack_frame().
615 const QuicFrame GetUpdatedAckFrame();
616
fayangbd793922019-08-26 14:19:24 -0700617 // Called when the handshake completes. On the client side, handshake
618 // completes on receipt of SHLO. On the server side, handshake completes when
619 // SHLO gets ACKed (or a forward secure packet gets decrypted successfully).
620 // TODO(fayang): Add a guard that this only gets called once.
QUICHE teama6ef0a62019-03-07 20:34:33 -0500621 void OnHandshakeComplete();
622
623 // Accessors
624 void set_visitor(QuicConnectionVisitorInterface* visitor) {
625 visitor_ = visitor;
626 }
627 void set_debug_visitor(QuicConnectionDebugVisitor* debug_visitor) {
628 debug_visitor_ = debug_visitor;
629 sent_packet_manager_.SetDebugDelegate(debug_visitor);
630 }
631 // Used in Chromium, but not internally.
632 // Must only be called before ping_alarm_ is set.
633 void set_ping_timeout(QuicTime::Delta ping_timeout) {
634 DCHECK(!ping_alarm_->IsSet());
635 ping_timeout_ = ping_timeout;
636 }
zhongyicdf8b1b2019-10-22 12:03:10 -0700637 const QuicTime::Delta ping_timeout() const { return ping_timeout_; }
QUICHE teama6ef0a62019-03-07 20:34:33 -0500638 // Used in Chromium, but not internally.
zhongyi79ace162019-10-21 15:57:09 -0700639 // Sets an initial timeout for the ping alarm when there is no retransmittable
640 // data in flight, allowing for a more aggressive ping alarm in that case.
641 void set_initial_retransmittable_on_wire_timeout(
QUICHE teama6ef0a62019-03-07 20:34:33 -0500642 QuicTime::Delta retransmittable_on_wire_timeout) {
643 DCHECK(!ping_alarm_->IsSet());
zhongyi79ace162019-10-21 15:57:09 -0700644 initial_retransmittable_on_wire_timeout_ = retransmittable_on_wire_timeout;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500645 }
zhongyicdf8b1b2019-10-22 12:03:10 -0700646 const QuicTime::Delta initial_retransmittable_on_wire_timeout() const {
647 return initial_retransmittable_on_wire_timeout_;
648 }
QUICHE teama6ef0a62019-03-07 20:34:33 -0500649 // Used in Chromium, but not internally.
650 void set_creator_debug_delegate(QuicPacketCreator::DebugDelegate* visitor) {
fayang4245c212019-11-05 13:33:46 -0800651 packet_creator_.set_debug_delegate(visitor);
QUICHE teama6ef0a62019-03-07 20:34:33 -0500652 }
653 const QuicSocketAddress& self_address() const { return self_address_; }
654 const QuicSocketAddress& peer_address() const { return direct_peer_address_; }
655 const QuicSocketAddress& effective_peer_address() const {
656 return effective_peer_address_;
657 }
dschinazi7b9278c2019-05-20 07:36:21 -0700658 QuicConnectionId connection_id() const { return server_connection_id_; }
dschinazi346b7ce2019-06-05 01:38:18 -0700659 QuicConnectionId client_connection_id() const {
660 return client_connection_id_;
661 }
662 void set_client_connection_id(QuicConnectionId client_connection_id);
QUICHE teama6ef0a62019-03-07 20:34:33 -0500663 const QuicClock* clock() const { return clock_; }
664 QuicRandom* random_generator() const { return random_generator_; }
665 QuicByteCount max_packet_length() const;
666 void SetMaxPacketLength(QuicByteCount length);
667
668 size_t mtu_probe_count() const { return mtu_probe_count_; }
669
670 bool connected() const { return connected_; }
671
672 // Must only be called on client connections.
673 const ParsedQuicVersionVector& server_supported_versions() const {
674 DCHECK_EQ(Perspective::IS_CLIENT, perspective_);
675 return server_supported_versions_;
676 }
677
ianswettfc16a2b2020-05-18 16:05:49 -0700678 bool HasQueuedPackets() const { return !buffered_packets_.empty(); }
679 // Testing only. TODO(ianswett): Use a peer instead.
fayange62e63c2019-12-04 07:16:25 -0800680 size_t NumQueuedPackets() const { return buffered_packets_.size(); }
QUICHE teama6ef0a62019-03-07 20:34:33 -0500681
QUICHE teama6ef0a62019-03-07 20:34:33 -0500682 // Returns true if the connection has queued packets or frames.
683 bool HasQueuedData() const;
684
685 // Sets the handshake and idle state connection timeouts.
686 void SetNetworkTimeouts(QuicTime::Delta handshake_timeout,
687 QuicTime::Delta idle_timeout);
688
689 // If the connection has timed out, this will close the connection.
690 // Otherwise, it will reschedule the timeout alarm.
691 void CheckForTimeout();
692
693 // Called when the ping alarm fires. Causes a ping frame to be sent only
694 // if the retransmission alarm is not running.
695 void OnPingTimeout();
696
697 // Sets up a packet with an QuicAckFrame and sends it out.
698 void SendAck();
699
QUICHE teama6ef0a62019-03-07 20:34:33 -0500700 // Called when an RTO fires. Resets the retransmission alarm if there are
701 // remaining unacked packets.
702 void OnRetransmissionTimeout();
703
renjietangc0080082020-05-26 18:35:19 -0700704 // Retransmits all sent 0-RTT encrypted packets. Called when new 0-RTT or
705 // 1-RTT key is available.
706 void RetransmitZeroRttPackets();
QUICHE teama6ef0a62019-03-07 20:34:33 -0500707
708 // Calls |sent_packet_manager_|'s NeuterUnencryptedPackets. Used when the
709 // connection becomes forward secure and hasn't received acks for all packets.
710 void NeuterUnencryptedPackets();
711
712 // Changes the encrypter used for level |level| to |encrypter|.
713 void SetEncrypter(EncryptionLevel level,
714 std::unique_ptr<QuicEncrypter> encrypter);
715
fayangb296fb82020-02-11 08:14:28 -0800716 // Called to remove encrypter of encryption |level|.
717 void RemoveEncrypter(EncryptionLevel level);
718
QUICHE teama6ef0a62019-03-07 20:34:33 -0500719 // SetNonceForPublicHeader sets the nonce that will be transmitted in the
720 // header of each packet encrypted at the initial encryption level decrypted.
721 // This should only be called on the server side.
722 void SetDiversificationNonce(const DiversificationNonce& nonce);
723
724 // SetDefaultEncryptionLevel sets the encryption level that will be applied
725 // to new packets.
726 void SetDefaultEncryptionLevel(EncryptionLevel level);
727
728 // SetDecrypter sets the primary decrypter, replacing any that already exists.
729 // If an alternative decrypter is in place then the function DCHECKs. This is
730 // intended for cases where one knows that future packets will be using the
731 // new decrypter and the previous decrypter is now obsolete. |level| indicates
732 // the encryption level of the new decrypter.
733 void SetDecrypter(EncryptionLevel level,
734 std::unique_ptr<QuicDecrypter> decrypter);
735
736 // SetAlternativeDecrypter sets a decrypter that may be used to decrypt
737 // future packets. |level| indicates the encryption level of the decrypter. If
738 // |latch_once_used| is true, then the first time that the decrypter is
739 // successful it will replace the primary decrypter. Otherwise both
740 // decrypters will remain active and the primary decrypter will be the one
741 // last used.
742 void SetAlternativeDecrypter(EncryptionLevel level,
743 std::unique_ptr<QuicDecrypter> decrypter,
744 bool latch_once_used);
745
zhongyi546cc452019-04-12 15:27:49 -0700746 void InstallDecrypter(EncryptionLevel level,
747 std::unique_ptr<QuicDecrypter> decrypter);
748 void RemoveDecrypter(EncryptionLevel level);
749
QUICHE teama6ef0a62019-03-07 20:34:33 -0500750 const QuicDecrypter* decrypter() const;
751 const QuicDecrypter* alternative_decrypter() const;
752
753 Perspective perspective() const { return perspective_; }
754
755 // Allow easy overriding of truncated connection IDs.
756 void set_can_truncate_connection_ids(bool can) {
757 can_truncate_connection_ids_ = can;
758 }
759
760 // Returns the underlying sent packet manager.
761 const QuicSentPacketManager& sent_packet_manager() const {
762 return sent_packet_manager_;
763 }
764
765 // Returns the underlying sent packet manager.
766 QuicSentPacketManager& sent_packet_manager() { return sent_packet_manager_; }
767
ianswett309987e2019-08-02 13:16:26 -0700768 UberReceivedPacketManager& received_packet_manager() {
769 return uber_received_packet_manager_;
770 }
771
QUICHE teama6ef0a62019-03-07 20:34:33 -0500772 bool CanWrite(HasRetransmittableData retransmittable);
773
774 // When the flusher is out of scope, only the outermost flusher will cause a
775 // flush of the connection and set the retransmission alarm if there is one
776 // pending. In addition, this flusher can be configured to ensure that an ACK
777 // frame is included in the first packet created, if there's new ack
778 // information to be sent.
779 class QUIC_EXPORT_PRIVATE ScopedPacketFlusher {
780 public:
fayanga4b37b22019-06-18 13:37:47 -0700781 explicit ScopedPacketFlusher(QuicConnection* connection);
QUICHE teama6ef0a62019-03-07 20:34:33 -0500782 ~ScopedPacketFlusher();
783
784 private:
QUICHE teama6ef0a62019-03-07 20:34:33 -0500785 QuicConnection* connection_;
786 // If true, when this flusher goes out of scope, flush connection and set
787 // retransmission alarm if there is one pending.
788 bool flush_and_set_pending_retransmission_alarm_on_delete_;
789 };
790
791 QuicPacketWriter* writer() { return writer_; }
792 const QuicPacketWriter* writer() const { return writer_; }
793
794 // Sends an MTU discovery packet of size |target_mtu|. If the packet is
795 // acknowledged by the peer, the maximum packet size will be increased to
796 // |target_mtu|.
797 void SendMtuDiscoveryPacket(QuicByteCount target_mtu);
798
799 // Sends a connectivity probing packet to |peer_address| with
800 // |probing_writer|. If |probing_writer| is nullptr, will use default
801 // packet writer to write the packet. Returns true if subsequent packets can
802 // be written to the probing writer. If connection is V99, a padded IETF QUIC
803 // PATH_CHALLENGE packet is transmitted; if not V99, a Google QUIC padded PING
804 // packet is transmitted.
805 virtual bool SendConnectivityProbingPacket(
806 QuicPacketWriter* probing_writer,
807 const QuicSocketAddress& peer_address);
808
809 // Sends response to a connectivity probe. Sends either a Padded Ping
810 // or an IETF PATH_RESPONSE based on the version of the connection.
811 // Is the counterpart to SendConnectivityProbingPacket().
812 virtual void SendConnectivityProbingResponsePacket(
813 const QuicSocketAddress& peer_address);
814
wub173916e2019-11-27 14:36:24 -0800815 // Sends an MTU discovery packet and updates the MTU discovery alarm.
QUICHE teama6ef0a62019-03-07 20:34:33 -0500816 void DiscoverMtu();
817
818 // Sets the session notifier on the SentPacketManager.
819 void SetSessionNotifier(SessionNotifierInterface* session_notifier);
820
821 // Set data producer in framer.
822 void SetDataProducer(QuicStreamFrameDataProducer* data_producer);
823
824 // Set transmission type of next sending packets.
825 void SetTransmissionType(TransmissionType type);
826
827 // Tries to send |message| and returns the message status.
QUICHE team350e9e62019-11-19 13:16:24 -0800828 // If |flush| is false, this will return a MESSAGE_STATUS_BLOCKED
829 // when the connection is deemed unwritable.
QUICHE teama6ef0a62019-03-07 20:34:33 -0500830 virtual MessageStatus SendMessage(QuicMessageId message_id,
QUICHE team350e9e62019-11-19 13:16:24 -0800831 QuicMemSliceSpan message,
832 bool flush);
QUICHE teama6ef0a62019-03-07 20:34:33 -0500833
834 // Returns the largest payload that will fit into a single MESSAGE frame.
ianswettb239f862019-04-05 09:15:06 -0700835 // Because overhead can vary during a connection, this method should be
836 // checked for every message.
837 QuicPacketLength GetCurrentLargestMessagePayload() const;
838 // Returns the largest payload that will fit into a single MESSAGE frame at
839 // any point during the connection. This assumes the version and
840 // connection ID lengths do not change.
841 QuicPacketLength GetGuaranteedLargestMessagePayload() const;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500842
zhongyi546cc452019-04-12 15:27:49 -0700843 // Returns the id of the cipher last used for decrypting packets.
844 uint32_t cipher_id() const;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500845
846 std::vector<std::unique_ptr<QuicEncryptedPacket>>* termination_packets() {
847 return termination_packets_.get();
848 }
849
QUICHE teama6ef0a62019-03-07 20:34:33 -0500850 bool ack_frame_updated() const;
851
852 QuicConnectionHelperInterface* helper() { return helper_; }
853 QuicAlarmFactory* alarm_factory() { return alarm_factory_; }
854
dmcardlecf0bfcf2019-12-13 08:08:21 -0800855 quiche::QuicheStringPiece GetCurrentPacket();
QUICHE teama6ef0a62019-03-07 20:34:33 -0500856
857 const QuicFramer& framer() const { return framer_; }
858
fayang4245c212019-11-05 13:33:46 -0800859 const QuicPacketCreator& packet_creator() const { return packet_creator_; }
QUICHE teama6ef0a62019-03-07 20:34:33 -0500860
QUICHE teama6ef0a62019-03-07 20:34:33 -0500861 EncryptionLevel encryption_level() const { return encryption_level_; }
862 EncryptionLevel last_decrypted_level() const {
863 return last_decrypted_packet_level_;
864 }
865
866 const QuicSocketAddress& last_packet_source_address() const {
867 return last_packet_source_address_;
868 }
869
870 bool fill_up_link_during_probing() const {
871 return fill_up_link_during_probing_;
872 }
873 void set_fill_up_link_during_probing(bool new_value) {
874 fill_up_link_during_probing_ = new_value;
875 }
876
877 // This setting may be changed during the crypto handshake in order to
878 // enable/disable padding of different packets in the crypto handshake.
879 //
880 // This setting should never be set to false in public facing endpoints. It
881 // can only be set to false if there is some other mechanism of preventing
882 // amplification attacks, such as ICE (plus its a non-standard quic).
nharper3907ac22019-09-25 15:32:28 -0700883 void set_fully_pad_crypto_handshake_packets(bool new_value) {
fayang4245c212019-11-05 13:33:46 -0800884 packet_creator_.set_fully_pad_crypto_handshake_packets(new_value);
QUICHE teama6ef0a62019-03-07 20:34:33 -0500885 }
886
887 bool fully_pad_during_crypto_handshake() const {
fayang4245c212019-11-05 13:33:46 -0800888 return packet_creator_.fully_pad_crypto_handshake_packets();
QUICHE teama6ef0a62019-03-07 20:34:33 -0500889 }
890
891 size_t min_received_before_ack_decimation() const;
892 void set_min_received_before_ack_decimation(size_t new_value);
893
894 size_t ack_frequency_before_ack_decimation() const;
895 void set_ack_frequency_before_ack_decimation(size_t new_value);
896
897 // If |defer| is true, configures the connection to defer sending packets in
898 // response to an ACK to the SendAlarm. If |defer| is false, packets may be
899 // sent immediately after receiving an ACK.
900 void set_defer_send_in_response_to_packets(bool defer) {
901 defer_send_in_response_to_packets_ = defer;
902 }
903
QUICHE teama6ef0a62019-03-07 20:34:33 -0500904 // Sets the current per-packet options for the connection. The QuicConnection
905 // does not take ownership of |options|; |options| must live for as long as
906 // the QuicConnection is in use.
907 void set_per_packet_options(PerPacketOptions* options) {
908 per_packet_options_ = options;
909 }
910
911 bool IsPathDegrading() const { return is_path_degrading_; }
912
913 // Attempts to process any queued undecryptable packets.
914 void MaybeProcessUndecryptablePackets();
915
916 // Queue a coalesced packet.
917 void QueueCoalescedPacket(const QuicEncryptedPacket& packet);
918
919 // Process previously queued coalesced packets.
920 void MaybeProcessCoalescedPackets();
921
922 enum PacketContent : uint8_t {
923 NO_FRAMES_RECEIVED,
924 // TODO(fkastenholz): Change name when we get rid of padded ping/
925 // pre-version-99.
926 // Also PATH CHALLENGE and PATH RESPONSE.
927 FIRST_FRAME_IS_PING,
928 SECOND_FRAME_IS_PADDING,
929 NOT_PADDED_PING, // Set if the packet is not {PING, PADDING}.
930 };
931
fayangfa3b1d62019-11-18 08:02:13 -0800932 // Whether the handshake completes from this connection's perspective.
fayang63a19842020-01-23 02:51:28 -0800933 bool IsHandshakeComplete() const;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500934
fayang5014e922020-01-22 12:28:11 -0800935 // Whether peer completes handshake. Only used with TLS handshake.
936 bool IsHandshakeConfirmed() const;
937
QUICHE team1f3de242019-03-20 07:24:48 -0700938 // Returns the largest received packet number sent by peer.
939 QuicPacketNumber GetLargestReceivedPacket() const;
940
dschinazi187683d2020-05-27 17:34:51 -0400941 // Sets the original destination connection ID on the connection.
942 // This is called by QuicDispatcher when it has replaced the connection ID.
943 void SetOriginalDestinationConnectionId(
944 const QuicConnectionId& original_destination_connection_id);
QUICHE teamc65d1d12019-03-19 20:58:04 -0700945
dschinazie7c38a52020-05-29 15:25:45 -0700946 // Returns the original destination connection ID used for this connection.
947 QuicConnectionId GetOriginalDestinationConnectionId();
948
QUICHE teamcd098022019-03-22 18:49:55 -0700949 // Called when ACK alarm goes off. Sends ACKs of those packet number spaces
950 // which have expired ACK timeout. Only used when this connection supports
951 // multiple packet number spaces.
952 void SendAllPendingAcks();
953
954 // Returns true if this connection supports multiple packet number spaces.
955 bool SupportsMultiplePacketNumberSpaces() const;
956
fayang21ffb712019-05-16 08:39:26 -0700957 // For logging purpose.
958 const QuicAckFrame& ack_frame() const;
959
dschinazi5c030852019-07-11 15:45:53 -0700960 // Install encrypter and decrypter for ENCRYPTION_INITIAL using
961 // |connection_id| as the first client-sent destination connection ID,
962 // or the one sent after an IETF Retry.
963 void InstallInitialCrypters(QuicConnectionId connection_id);
964
wub256b2d62019-11-25 08:46:55 -0800965 // Called when version is considered negotiated.
966 void OnSuccessfulVersionNegotiation();
967
zhongyi2da16be2020-06-17 11:05:23 -0700968 // Called when self migration succeeds after probing.
969 void OnSuccessfulMigrationAfterProbing();
970
dschinazi631f1602020-05-19 10:10:22 -0700971 // Called for QUIC+TLS versions when we send transport parameters.
972 void OnTransportParametersSent(
973 const TransportParameters& transport_parameters) const;
974
975 // Called for QUIC+TLS versions when we receive transport parameters.
976 void OnTransportParametersReceived(
977 const TransportParameters& transport_parameters) const;
978
fayang9adfb532020-06-04 06:58:45 -0700979 // Returns true if ack_alarm_ is set.
980 bool HasPendingAcks() const;
981
fayang6a258412020-05-28 08:57:12 -0700982 size_t anti_amplification_factor() const {
983 return anti_amplification_factor_;
984 }
985
wubbe634b72020-06-16 08:41:26 -0700986 void OnUserAgentIdKnown() { sent_packet_manager_.OnUserAgentIdKnown(); }
987
QUICHE teama6ef0a62019-03-07 20:34:33 -0500988 protected:
989 // Calls cancel() on all the alarms owned by this connection.
990 void CancelAllAlarms();
991
992 // Send a packet to the peer, and takes ownership of the packet if the packet
993 // cannot be written immediately.
wub8a5dafa2020-05-13 12:30:17 -0700994 virtual void SendOrQueuePacket(SerializedPacket packet);
QUICHE teama6ef0a62019-03-07 20:34:33 -0500995
996 // Called after a packet is received from a new effective peer address and is
997 // decrypted. Starts validation of effective peer's address change. Calls
998 // OnConnectionMigration as soon as the address changed.
999 void StartEffectivePeerMigration(AddressChangeType type);
1000
1001 // Called when a effective peer address migration is validated.
1002 virtual void OnEffectivePeerMigrationValidated();
1003
1004 // Get the effective peer address from the packet being processed. For proxied
1005 // connections, effective peer address is the address of the endpoint behind
1006 // the proxy. For non-proxied connections, effective peer address is the same
1007 // as peer address.
1008 //
1009 // Notes for implementations in subclasses:
1010 // - If the connection is not proxied, the overridden method should use the
1011 // base implementation:
1012 //
1013 // return QuicConnection::GetEffectivePeerAddressFromCurrentPacket();
1014 //
1015 // - If the connection is proxied, the overridden method may return either of
1016 // the following:
1017 // a) The address of the endpoint behind the proxy. The address is used to
1018 // drive effective peer migration.
1019 // b) An uninitialized address, meaning the effective peer address does not
1020 // change.
1021 virtual QuicSocketAddress GetEffectivePeerAddressFromCurrentPacket() const;
1022
1023 // Selects and updates the version of the protocol being used by selecting a
1024 // version from |available_versions| which is also supported. Returns true if
1025 // such a version exists, false otherwise.
1026 bool SelectMutualVersion(const ParsedQuicVersionVector& available_versions);
1027
1028 // Returns the current per-packet options for the connection.
1029 PerPacketOptions* per_packet_options() { return per_packet_options_; }
1030
1031 AddressChangeType active_effective_peer_migration_type() const {
1032 return active_effective_peer_migration_type_;
1033 }
1034
ianswettdc1e7ab2019-05-03 16:10:44 -07001035 // Sends a connection close packet to the peer and includes an ACK if the ACK
1036 // is not empty, the |error| is not PACKET_WRITE_ERROR, and it fits.
QUICHE teama6ef0a62019-03-07 20:34:33 -05001037 virtual void SendConnectionClosePacket(QuicErrorCode error,
ianswettdc1e7ab2019-05-03 16:10:44 -07001038 const std::string& details);
QUICHE teama6ef0a62019-03-07 20:34:33 -05001039
1040 // Returns true if the packet should be discarded and not sent.
1041 virtual bool ShouldDiscardPacket(const SerializedPacket& packet);
1042
1043 // Retransmits packets continuously until blocked by the congestion control.
1044 // If there are no packets to retransmit, does not do anything.
1045 void SendProbingRetransmissions();
1046
1047 // Decides whether to send probing retransmissions, and does so if required.
1048 void MaybeSendProbingRetransmissions();
1049
1050 // Notify various components(SendPacketManager, Session etc.) that this
1051 // connection has been migrated.
1052 virtual void OnConnectionMigration(AddressChangeType addr_change_type);
1053
1054 // Return whether the packet being processed is a connectivity probing.
1055 // A packet is a connectivity probing if it is a padded ping packet with self
1056 // and/or peer address changes.
1057 bool IsCurrentPacketConnectivityProbing() const;
1058
1059 // Return true iff the writer is blocked, if blocked, call
1060 // visitor_->OnWriteBlocked() to add the connection into the write blocked
1061 // list.
1062 bool HandleWriteBlocked();
1063
1064 private:
1065 friend class test::QuicConnectionPeer;
1066
1067 typedef std::list<SerializedPacket> QueuedPacketList;
1068
fayang2ce66082019-10-02 06:29:04 -07001069 // BufferedPacket stores necessary information (encrypted buffer and self/peer
1070 // addresses) of those packets which are serialized but failed to send because
1071 // socket is blocked. From unacked packet map and send algorithm's
1072 // perspective, buffered packets are treated as sent.
dschinazif25169a2019-10-23 08:12:18 -07001073 struct QUIC_EXPORT_PRIVATE BufferedPacket {
fayang2ce66082019-10-02 06:29:04 -07001074 BufferedPacket(const SerializedPacket& packet,
1075 const QuicSocketAddress& self_address,
1076 const QuicSocketAddress& peer_address);
fayang58f71072019-11-05 08:47:02 -08001077 BufferedPacket(char* encrypted_buffer,
1078 QuicPacketLength encrypted_length,
1079 const QuicSocketAddress& self_address,
1080 const QuicSocketAddress& peer_address);
fayang2ce66082019-10-02 06:29:04 -07001081 BufferedPacket(const BufferedPacket& other) = delete;
1082 BufferedPacket(const BufferedPacket&& other) = delete;
1083
1084 ~BufferedPacket();
1085
1086 // encrypted_buffer is owned by buffered packet.
dmcardlecf0bfcf2019-12-13 08:08:21 -08001087 quiche::QuicheStringPiece encrypted_buffer;
fayang2ce66082019-10-02 06:29:04 -07001088 // Self and peer addresses when the packet is serialized.
1089 const QuicSocketAddress self_address;
1090 const QuicSocketAddress peer_address;
1091 };
1092
fayang9dcfaca2020-04-24 06:57:14 -07001093 // UndecrytablePacket comprises a undecryptable packet and the its encryption
1094 // level.
1095 struct QUIC_EXPORT_PRIVATE UndecryptablePacket {
1096 UndecryptablePacket(const QuicEncryptedPacket& packet,
1097 EncryptionLevel encryption_level)
1098 : packet(packet.Clone()), encryption_level(encryption_level) {}
1099
1100 std::unique_ptr<QuicEncryptedPacket> packet;
1101 // Currently, |encryption_level| is only used for logging and does not
1102 // affect processing of the packet.
1103 EncryptionLevel encryption_level;
1104 };
1105
QUICHE teama6ef0a62019-03-07 20:34:33 -05001106 // Notifies the visitor of the close and marks the connection as disconnected.
fkastenholz85f18902019-05-28 12:47:00 -07001107 // Does not send a connection close frame to the peer. It should only be
1108 // called by CloseConnection or OnConnectionCloseFrame, OnPublicResetPacket,
1109 // and OnAuthenticatedIetfStatelessResetPacket.
QUICHE teama6ef0a62019-03-07 20:34:33 -05001110 void TearDownLocalConnectionState(QuicErrorCode error,
vasilvvc48c8712019-03-11 13:38:16 -07001111 const std::string& details,
QUICHE teama6ef0a62019-03-07 20:34:33 -05001112 ConnectionCloseSource source);
fkastenholz488a4622019-08-26 06:24:46 -07001113 void TearDownLocalConnectionState(const QuicConnectionCloseFrame& frame,
1114 ConnectionCloseSource source);
QUICHE teama6ef0a62019-03-07 20:34:33 -05001115
1116 // Writes the given packet to socket, encrypted with packet's
1117 // encryption_level. Returns true on successful write, and false if the writer
1118 // was blocked and the write needs to be tried again. Notifies the
1119 // SentPacketManager when the write is successful and sets
1120 // retransmittable frames to nullptr.
1121 // Saves the connection close packet for later transmission, even if the
1122 // writer is write blocked.
1123 bool WritePacket(SerializedPacket* packet);
1124
1125 // Flush packets buffered in the writer, if any.
1126 void FlushPackets();
1127
QUICHE teama6ef0a62019-03-07 20:34:33 -05001128 // Make sure a stop waiting we got from our peer is sane.
1129 // Returns nullptr if the frame is valid or an error string if it was invalid.
1130 const char* ValidateStopWaitingFrame(
1131 const QuicStopWaitingFrame& stop_waiting);
1132
1133 // Sends a version negotiation packet to the peer.
dschinazi48ac9192019-07-31 00:07:26 -07001134 void SendVersionNegotiationPacket(bool ietf_quic, bool has_length_prefix);
QUICHE teama6ef0a62019-03-07 20:34:33 -05001135
1136 // Clears any accumulated frames from the last received packet.
1137 void ClearLastFrames();
1138
1139 // Deletes and clears any queued packets.
1140 void ClearQueuedPackets();
1141
1142 // Closes the connection if the sent packet manager is tracking too many
1143 // outstanding packets.
1144 void CloseIfTooManyOutstandingSentPackets();
1145
1146 // Writes as many queued packets as possible. The connection must not be
1147 // blocked when this is called.
1148 void WriteQueuedPackets();
1149
QUICHE teama6ef0a62019-03-07 20:34:33 -05001150 // Writes new data if congestion control allows.
1151 void WriteNewData();
1152
1153 // Queues |packet| in the hopes that it can be decrypted in the
1154 // future, when a new key is installed.
fayang9dcfaca2020-04-24 06:57:14 -07001155 void QueueUndecryptablePacket(const QuicEncryptedPacket& packet,
1156 EncryptionLevel decryption_level);
QUICHE teama6ef0a62019-03-07 20:34:33 -05001157
1158 // Sends any packets which are a response to the last packet, including both
1159 // acks and pending writes if an ack opened the congestion window.
1160 void MaybeSendInResponseToPacket();
1161
QUICHE teama6ef0a62019-03-07 20:34:33 -05001162 // Gets the least unacked packet number, which is the next packet number to be
1163 // sent if there are no outstanding packets.
1164 QuicPacketNumber GetLeastUnacked() const;
1165
1166 // Sets the timeout alarm to the appropriate value, if any.
1167 void SetTimeoutAlarm();
1168
1169 // Sets the ping alarm to the appropriate value, if any.
1170 void SetPingAlarm();
1171
1172 // Sets the retransmission alarm based on SentPacketManager.
1173 void SetRetransmissionAlarm();
1174
QUICHE teama6ef0a62019-03-07 20:34:33 -05001175 // Sets the MTU discovery alarm if necessary.
1176 // |sent_packet_number| is the recently sent packet number.
1177 void MaybeSetMtuAlarm(QuicPacketNumber sent_packet_number);
1178
QUICHE teama6ef0a62019-03-07 20:34:33 -05001179 HasRetransmittableData IsRetransmittable(const SerializedPacket& packet);
1180 bool IsTerminationPacket(const SerializedPacket& packet);
1181
1182 // Set the size of the packet we are targeting while doing path MTU discovery.
1183 void SetMtuDiscoveryTarget(QuicByteCount target);
1184
1185 // Returns |suggested_max_packet_size| clamped to any limits set by the
1186 // underlying writer, connection, or protocol.
1187 QuicByteCount GetLimitedMaxPacketSize(
1188 QuicByteCount suggested_max_packet_size);
1189
1190 // Do any work which logically would be done in OnPacket but can not be
1191 // safely done until the packet is validated. Returns true if packet can be
1192 // handled, false otherwise.
1193 bool ProcessValidatedPacket(const QuicPacketHeader& header);
1194
QUICHE teamd791e2c2019-03-15 10:28:21 -07001195 // Returns true if received |packet_number| can be processed. Please note,
1196 // this is called after packet got decrypted successfully.
1197 bool ValidateReceivedPacketNumber(QuicPacketNumber packet_number);
1198
QUICHE teama6ef0a62019-03-07 20:34:33 -05001199 // Consider receiving crypto frame on non crypto stream as memory corruption.
1200 bool MaybeConsiderAsMemoryCorruption(const QuicStreamFrame& frame);
1201
1202 // Check if the connection has no outstanding data to send and notify
1203 // congestion controller if it is the case.
1204 void CheckIfApplicationLimited();
1205
1206 // Sets |current_packet_content_| to |type| if applicable. And
1207 // starts effective peer migration if current packet is confirmed not a
1208 // connectivity probe and |current_effective_peer_migration_type_| indicates
1209 // effective peer address change.
1210 void UpdatePacketContent(PacketContent type);
1211
QUICHE teama6ef0a62019-03-07 20:34:33 -05001212 // Called when last received ack frame has been processed.
1213 // |send_stop_waiting| indicates whether a stop waiting needs to be sent.
1214 // |acked_new_packet| is true if a previously-unacked packet was acked.
1215 void PostProcessAfterAckFrame(bool send_stop_waiting, bool acked_new_packet);
1216
QUICHE teama6ef0a62019-03-07 20:34:33 -05001217 // Updates the release time into the future.
1218 void UpdateReleaseTimeIntoFuture();
1219
1220 // Sends generic path probe packet to the peer. If we are not IETF QUIC, will
1221 // always send a padded ping, regardless of whether this is a request or
1222 // response. If version 99/ietf quic, will send a PATH_RESPONSE if
1223 // |is_response| is true, a PATH_CHALLENGE if not.
1224 bool SendGenericPathProbePacket(QuicPacketWriter* probing_writer,
1225 const QuicSocketAddress& peer_address,
1226 bool is_response);
1227
1228 // Called when an ACK is about to send. Resets ACK related internal states,
1229 // e.g., cancels ack_alarm_, resets
1230 // num_retransmittable_packets_received_since_last_ack_sent_ etc.
1231 void ResetAckStates();
1232
ianswett6083a102020-02-09 12:04:04 -08001233 // Returns true if the ACK frame should be bundled with ACK-eliciting frame.
1234 bool ShouldBundleRetransmittableFrameWithAck() const;
1235
fayanga4b37b22019-06-18 13:37:47 -07001236 void PopulateStopWaitingFrame(QuicStopWaitingFrame* stop_waiting);
1237
QUICHE teamcd098022019-03-22 18:49:55 -07001238 // Enables multiple packet number spaces support based on handshake protocol
1239 // and flags.
1240 void MaybeEnableMultiplePacketNumberSpacesSupport();
1241
fayang9f430a52020-05-08 07:28:33 -07001242 // Called to update ACK timeout when an retransmittable frame has been parsed.
1243 void MaybeUpdateAckTimeout();
1244
fayang58f71072019-11-05 08:47:02 -08001245 // Returns packet fate when trying to write a packet via WritePacket().
1246 SerializedPacketFate DeterminePacketFate(bool is_mtu_discovery);
1247
1248 // Serialize and send coalesced_packet. Returns false if serialization fails
1249 // or the write causes errors, otherwise, returns true.
1250 bool FlushCoalescedPacket();
fayang2ce66082019-10-02 06:29:04 -07001251
QUICHE teama6ef0a62019-03-07 20:34:33 -05001252 // Returns the encryption level the connection close packet should be sent at,
1253 // which is the highest encryption level that peer can guarantee to process.
1254 EncryptionLevel GetConnectionCloseEncryptionLevel() const;
1255
QUICHE team76e1c622019-03-19 14:36:39 -07001256 // Called after an ACK frame is successfully processed to update largest
1257 // received packet number which contains an ACK frame.
1258 void SetLargestReceivedPacketWithAck(QuicPacketNumber new_value);
1259
fayang656cbb52020-06-09 13:29:35 -07001260 // Called when new packets have been acknowledged or old keys have been
1261 // discarded.
1262 void OnForwardProgressMade();
1263
QUICHE team76e1c622019-03-19 14:36:39 -07001264 // Returns largest received packet number which contains an ACK frame.
1265 QuicPacketNumber GetLargestReceivedPacketWithAck() const;
1266
1267 // Returns the largest packet number that has been sent.
1268 QuicPacketNumber GetLargestSentPacket() const;
1269
1270 // Returns the largest sent packet number that has been ACKed by peer.
1271 QuicPacketNumber GetLargestAckedPacket() const;
1272
QUICHE teamc65d1d12019-03-19 20:58:04 -07001273 // Whether incoming_connection_ids_ contains connection_id.
1274 bool HasIncomingConnectionId(QuicConnectionId connection_id);
1275
fayang5f135052019-08-22 17:59:40 -07001276 // Whether connection enforces anti-amplification limit.
1277 bool EnforceAntiAmplificationLimit() const;
1278
1279 // Whether connection is limited by amplification factor.
1280 bool LimitedByAmplificationFactor() const;
1281
wubed245d22020-05-07 10:46:00 -07001282 // Called before sending a packet to get packet send time and to set the
1283 // release time delay in |per_packet_options_|. Return the time when the
1284 // packet is scheduled to be released(a.k.a send time), which is NOW + delay.
1285 // Returns Now() and does not update release time delay if
1286 // |supports_release_time_| is false.
1287 QuicTime CalculatePacketSentTime();
1288
wub748e20b2020-03-20 14:33:59 -07001289 // We've got a packet write error, should we ignore it?
1290 // NOTE: This is not a const function - if return true, the max packet size is
1291 // reverted to a previous(smaller) value to avoid write errors in the future.
1292 bool ShouldIgnoreWriteError();
1293
fayangb59c6f12020-03-23 15:06:14 -07001294 // Returns path degrading deadline. QuicTime::Zero() means no path degrading
1295 // detection is needed.
1296 QuicTime GetPathDegradingDeadline() const;
1297
1298 // Returns true if path degrading should be detected.
1299 bool ShouldDetectPathDegrading() const;
1300
1301 // Returns network blackhole deadline. QuicTime::Zero() means no blackhole
1302 // detection is needed.
1303 QuicTime GetNetworkBlackholeDeadline() const;
1304
1305 // Returns true if network blackhole should be detected.
1306 bool ShouldDetectBlackhole() const;
1307
fayangb9c88442020-03-26 07:03:57 -07001308 // Remove these two when deprecating quic_use_idle_network_detector.
1309 QuicTime::Delta GetHandshakeTimeout() const;
1310 QuicTime GetTimeOfLastReceivedPacket() const;
1311
dschinazie7c38a52020-05-29 15:25:45 -07001312 // Validate connection IDs used during the handshake. Closes the connection
1313 // on validation failure.
1314 bool ValidateConfigConnectionIds(const QuicConfig& config);
1315 bool ValidateConfigConnectionIdsOld(const QuicConfig& config);
1316
QUICHE teama6ef0a62019-03-07 20:34:33 -05001317 QuicFramer framer_;
1318
1319 // Contents received in the current packet, especially used to identify
1320 // whether the current packet is a padded PING packet.
1321 PacketContent current_packet_content_;
1322 // Set to true as soon as the packet currently being processed has been
1323 // detected as a connectivity probing.
1324 // Always false outside the context of ProcessUdpPacket().
1325 bool is_current_packet_connectivity_probing_;
1326
1327 // Caches the current effective peer migration type if a effective peer
1328 // migration might be initiated. As soon as the current packet is confirmed
1329 // not a connectivity probe, effective peer migration will start.
1330 AddressChangeType current_effective_peer_migration_type_;
1331 QuicConnectionHelperInterface* helper_; // Not owned.
1332 QuicAlarmFactory* alarm_factory_; // Not owned.
1333 PerPacketOptions* per_packet_options_; // Not owned.
1334 QuicPacketWriter* writer_; // Owned or not depending on |owns_writer_|.
1335 bool owns_writer_;
1336 // Encryption level for new packets. Should only be changed via
1337 // SetDefaultEncryptionLevel().
1338 EncryptionLevel encryption_level_;
1339 const QuicClock* clock_;
1340 QuicRandom* random_generator_;
1341
dschinazi7b9278c2019-05-20 07:36:21 -07001342 QuicConnectionId server_connection_id_;
dschinazi346b7ce2019-06-05 01:38:18 -07001343 QuicConnectionId client_connection_id_;
1344 // On the server, the connection ID is set when receiving the first packet.
1345 // This variable ensures we only set it this way once.
1346 bool client_connection_id_is_set_;
QUICHE teama6ef0a62019-03-07 20:34:33 -05001347 // Address on the last successfully processed packet received from the
1348 // direct peer.
1349 QuicSocketAddress self_address_;
1350 QuicSocketAddress peer_address_;
1351
1352 QuicSocketAddress direct_peer_address_;
1353 // Address of the endpoint behind the proxy if the connection is proxied.
1354 // Otherwise it is the same as |peer_address_|.
1355 // NOTE: Currently |effective_peer_address_| and |peer_address_| are always
1356 // the same(the address of the direct peer), but soon we'll change
1357 // |effective_peer_address_| to be the address of the endpoint behind the
1358 // proxy if the connection is proxied.
1359 QuicSocketAddress effective_peer_address_;
1360
1361 // Records change type when the effective peer initiates migration to a new
1362 // address. Reset to NO_CHANGE after effective peer migration is validated.
1363 AddressChangeType active_effective_peer_migration_type_;
1364
1365 // Records highest sent packet number when effective peer migration is
1366 // started.
1367 QuicPacketNumber highest_packet_sent_before_effective_peer_migration_;
1368
1369 // True if the last packet has gotten far enough in the framer to be
1370 // decrypted.
1371 bool last_packet_decrypted_;
1372 QuicByteCount last_size_; // Size of the last received packet.
1373 // TODO(rch): remove this when b/27221014 is fixed.
1374 const char* current_packet_data_; // UDP payload of packet currently being
1375 // parsed or nullptr.
1376 EncryptionLevel last_decrypted_packet_level_;
1377 QuicPacketHeader last_header_;
1378 bool should_last_packet_instigate_acks_;
QUICHE teama6ef0a62019-03-07 20:34:33 -05001379
1380 // Track some peer state so we can do less bookkeeping
1381 // Largest sequence sent by the peer which had an ack frame (latest ack info).
QUICHE team76e1c622019-03-19 14:36:39 -07001382 // Do not read or write directly, use GetLargestReceivedPacketWithAck() and
1383 // SetLargestReceivedPacketWithAck() instead.
QUICHE teama6ef0a62019-03-07 20:34:33 -05001384 QuicPacketNumber largest_seen_packet_with_ack_;
QUICHE teamcd098022019-03-22 18:49:55 -07001385 // Largest packet number sent by the peer which had an ACK frame per packet
1386 // number space. Only used when this connection supports multiple packet
1387 // number spaces.
1388 QuicPacketNumber largest_seen_packets_with_ack_[NUM_PACKET_NUMBER_SPACES];
QUICHE teama6ef0a62019-03-07 20:34:33 -05001389
1390 // Largest packet number sent by the peer which had a stop waiting frame.
1391 QuicPacketNumber largest_seen_packet_with_stop_waiting_;
1392
1393 // Collection of packets which were received before encryption was
1394 // established, but which could not be decrypted. We buffer these on
1395 // the assumption that they could not be processed because they were
1396 // sent with the INITIAL encryption and the CHLO message was lost.
fayang9dcfaca2020-04-24 06:57:14 -07001397 QuicCircularDeque<UndecryptablePacket> undecryptable_packets_;
QUICHE teama6ef0a62019-03-07 20:34:33 -05001398
1399 // Collection of coalesced packets which were received while processing
1400 // the current packet.
wuba750aab2020-02-10 06:43:15 -08001401 QuicCircularDeque<std::unique_ptr<QuicEncryptedPacket>>
1402 received_coalesced_packets_;
QUICHE teama6ef0a62019-03-07 20:34:33 -05001403
1404 // Maximum number of undecryptable packets the connection will store.
1405 size_t max_undecryptable_packets_;
1406
1407 // Maximum number of tracked packets.
1408 QuicPacketCount max_tracked_packets_;
1409
1410 // When the version negotiation packet could not be sent because the socket
1411 // was not writable, this is set to true.
1412 bool pending_version_negotiation_packet_;
1413 // Used when pending_version_negotiation_packet_ is true.
1414 bool send_ietf_version_negotiation_packet_;
dschinazi48ac9192019-07-31 00:07:26 -07001415 bool send_version_negotiation_packet_with_prefixed_lengths_;
QUICHE teama6ef0a62019-03-07 20:34:33 -05001416
QUICHE teama6ef0a62019-03-07 20:34:33 -05001417 // Contains the connection close packets if the connection has been closed.
1418 std::unique_ptr<std::vector<std::unique_ptr<QuicEncryptedPacket>>>
1419 termination_packets_;
1420
1421 // Determines whether or not a connection close packet is sent to the peer
dschinazi9a6194e2020-04-30 16:21:09 -07001422 // after idle timeout due to lack of network activity. During the handshake,
1423 // a connection close packet is sent, but not after.
QUICHE teama6ef0a62019-03-07 20:34:33 -05001424 ConnectionCloseBehavior idle_timeout_connection_close_behavior_;
1425
fayangddd3e9d2020-06-03 11:00:19 -07001426 // When > 0, close the QUIC connection after this number of RTOs.
1427 size_t num_rtos_for_blackhole_detection_;
QUICHE teama6ef0a62019-03-07 20:34:33 -05001428
QUICHE teamb23daa72019-03-21 08:37:48 -07001429 UberReceivedPacketManager uber_received_packet_manager_;
QUICHE teama6ef0a62019-03-07 20:34:33 -05001430
QUICHE teama6ef0a62019-03-07 20:34:33 -05001431 // Indicates how many consecutive times an ack has arrived which indicates
1432 // the peer needs to stop waiting for some packets.
fayang8a27b0f2019-11-04 11:27:40 -08001433 // TODO(fayang): remove this when deprecating QUIC_VERSION_43.
QUICHE teama6ef0a62019-03-07 20:34:33 -05001434 int stop_waiting_count_;
QUICHE teama6ef0a62019-03-07 20:34:33 -05001435
1436 // Indicates the retransmission alarm needs to be set.
1437 bool pending_retransmission_alarm_;
1438
1439 // If true, defer sending data in response to received packets to the
1440 // SendAlarm.
1441 bool defer_send_in_response_to_packets_;
1442
1443 // The timeout for PING.
1444 QuicTime::Delta ping_timeout_;
1445
zhongyi79ace162019-10-21 15:57:09 -07001446 // Initial timeout for how long the wire can have no retransmittable packets.
1447 QuicTime::Delta initial_retransmittable_on_wire_timeout_;
1448
1449 // Indicates how many retransmittable-on-wire pings have been emitted without
1450 // receiving any new data in between.
1451 int consecutive_retransmittable_on_wire_ping_count_;
QUICHE teama6ef0a62019-03-07 20:34:33 -05001452
1453 // Arena to store class implementations within the QuicConnection.
1454 QuicConnectionArena arena_;
1455
1456 // An alarm that fires when an ACK should be sent to the peer.
1457 QuicArenaScopedPtr<QuicAlarm> ack_alarm_;
1458 // An alarm that fires when a packet needs to be retransmitted.
1459 QuicArenaScopedPtr<QuicAlarm> retransmission_alarm_;
1460 // An alarm that is scheduled when the SentPacketManager requires a delay
1461 // before sending packets and fires when the packet may be sent.
1462 QuicArenaScopedPtr<QuicAlarm> send_alarm_;
1463 // An alarm that is scheduled when the connection can still write and there
1464 // may be more data to send.
1465 // An alarm that fires when the connection may have timed out.
fayangb9c88442020-03-26 07:03:57 -07001466 // TODO(fayang): Remove this when deprecating quic_use_idle_network_detector.
QUICHE teama6ef0a62019-03-07 20:34:33 -05001467 QuicArenaScopedPtr<QuicAlarm> timeout_alarm_;
1468 // An alarm that fires when a ping should be sent.
1469 QuicArenaScopedPtr<QuicAlarm> ping_alarm_;
1470 // An alarm that fires when an MTU probe should be sent.
1471 QuicArenaScopedPtr<QuicAlarm> mtu_discovery_alarm_;
QUICHE teama6ef0a62019-03-07 20:34:33 -05001472 // An alarm that fires to process undecryptable packets when new decyrption
1473 // keys are available.
1474 QuicArenaScopedPtr<QuicAlarm> process_undecryptable_packets_alarm_;
1475 // Neither visitor is owned by this class.
1476 QuicConnectionVisitorInterface* visitor_;
1477 QuicConnectionDebugVisitor* debug_visitor_;
1478
fayang4245c212019-11-05 13:33:46 -08001479 QuicPacketCreator packet_creator_;
QUICHE teama6ef0a62019-03-07 20:34:33 -05001480
fayangb9c88442020-03-26 07:03:57 -07001481 // TODO(fayang): Remove these two when deprecating
1482 // quic_use_idle_network_detector.
QUICHE teama6ef0a62019-03-07 20:34:33 -05001483 // Network idle time before this connection is closed.
1484 QuicTime::Delta idle_network_timeout_;
1485 // The connection will wait this long for the handshake to complete.
1486 QuicTime::Delta handshake_timeout_;
1487
1488 // Statistics for this session.
1489 QuicConnectionStats stats_;
1490
1491 // Timestamps used for timeouts.
1492 // The time of the first retransmittable packet that was sent after the most
1493 // recently received packet.
fayange9304002020-05-07 11:57:48 -07001494 // TODO(fayang): Remove time_of_first_packet_sent_after_receiving_ when
1495 // deprecating quic_use_idle_network_detector.
QUICHE teama6ef0a62019-03-07 20:34:33 -05001496 QuicTime time_of_first_packet_sent_after_receiving_;
1497 // The time that a packet is received for this connection. Initialized to
1498 // connection creation time.
fayange9304002020-05-07 11:57:48 -07001499 // This does not indicate the packet was processed.
QUICHE teama6ef0a62019-03-07 20:34:33 -05001500 QuicTime time_of_last_received_packet_;
fayange9304002020-05-07 11:57:48 -07001501 // This gets set to time_of_last_received_packet_ when a packet gets
1502 // decrypted. Please note, this is not necessarily the original receive time
1503 // of this decrypt packet because connection can decryptable packet out of
1504 // order.
1505 // TODO(fayang): Remove time_of_last_decryptable_packet_ when
1506 // deprecating quic_use_idle_network_detector.
1507 QuicTime time_of_last_decryptable_packet_;
QUICHE teama6ef0a62019-03-07 20:34:33 -05001508
QUICHE teama6ef0a62019-03-07 20:34:33 -05001509 // Sent packet manager which tracks the status of packets sent by this
1510 // connection and contains the send and receive algorithms to determine when
1511 // to send packets.
1512 QuicSentPacketManager sent_packet_manager_;
1513
fayang8aba1ff2019-06-21 12:00:54 -07001514 // Indicates whether connection version has been negotiated.
wub256b2d62019-11-25 08:46:55 -08001515 // Always true for server connections.
fayang8aba1ff2019-06-21 12:00:54 -07001516 bool version_negotiated_;
QUICHE teama6ef0a62019-03-07 20:34:33 -05001517
1518 // Tracks if the connection was created by the server or the client.
1519 Perspective perspective_;
1520
1521 // True by default. False if we've received or sent an explicit connection
1522 // close.
1523 bool connected_;
1524
1525 // Destination address of the last received packet.
1526 QuicSocketAddress last_packet_destination_address_;
1527
1528 // Source address of the last received packet.
1529 QuicSocketAddress last_packet_source_address_;
1530
1531 // Set to false if the connection should not send truncated connection IDs to
1532 // the peer, even if the peer supports it.
1533 bool can_truncate_connection_ids_;
1534
1535 // If non-empty this contains the set of versions received in a
1536 // version negotiation packet.
1537 ParsedQuicVersionVector server_supported_versions_;
1538
QUICHE teama6ef0a62019-03-07 20:34:33 -05001539 // The number of MTU probes already sent.
1540 size_t mtu_probe_count_;
1541
wubecb643f2020-03-19 08:58:46 -07001542 // The value of |long_term_mtu_| prior to the last successful MTU increase.
1543 // 0 means either
1544 // - MTU discovery has never been enabled, or
1545 // - MTU discovery has been enabled, but the connection got a packet write
1546 // error with a new (successfully probed) MTU, so it reverted
wub748e20b2020-03-20 14:33:59 -07001547 // |long_term_mtu_| to the value before the last increase.
wubecb643f2020-03-19 08:58:46 -07001548 QuicPacketLength previous_validated_mtu_;
QUICHE teama6ef0a62019-03-07 20:34:33 -05001549 // The value of the MTU regularly used by the connection. This is different
1550 // from the value returned by max_packet_size(), as max_packet_size() returns
1551 // the value of the MTU as currently used by the serializer, so if
1552 // serialization of an MTU probe is in progress, those two values will be
1553 // different.
1554 QuicByteCount long_term_mtu_;
1555
dschinazi4ad1f462020-01-16 11:56:52 -08001556 // The maximum UDP payload size that our peer has advertised support for.
1557 // Defaults to kDefaultMaxPacketSizeTransportParam until received from peer.
1558 QuicByteCount peer_max_packet_size_;
1559
QUICHE teama6ef0a62019-03-07 20:34:33 -05001560 // The size of the largest packet received from peer.
1561 QuicByteCount largest_received_packet_size_;
1562
1563 // Indicates whether a write error is encountered currently. This is used to
1564 // avoid infinite write errors.
1565 bool write_error_occurred_;
1566
1567 // Indicates not to send or process stop waiting frames.
1568 bool no_stop_waiting_frames_;
1569
1570 // Consecutive number of sent packets which have no retransmittable frames.
1571 size_t consecutive_num_packets_with_no_retransmittable_frames_;
1572
1573 // After this many packets sent without retransmittable frames, an artificial
1574 // retransmittable frame(a WINDOW_UPDATE) will be created to solicit an ack
1575 // from the peer. Default to kMaxConsecutiveNonRetransmittablePackets.
1576 size_t max_consecutive_num_packets_with_no_retransmittable_frames_;
1577
ianswett6083a102020-02-09 12:04:04 -08001578 // If true, bundle an ack-eliciting frame with an ACK if the PTO or RTO alarm
1579 // have previously fired.
1580 bool bundle_retransmittable_with_pto_ack_;
1581
QUICHE teama6ef0a62019-03-07 20:34:33 -05001582 // If true, the connection will fill up the pipe with extra data whenever the
1583 // congestion controller needs it in order to make a bandwidth estimate. This
1584 // is useful if the application pesistently underutilizes the link, but still
1585 // relies on having a reasonable bandwidth estimate from the connection, e.g.
1586 // for real time applications.
1587 bool fill_up_link_during_probing_;
1588
1589 // If true, the probing retransmission will not be started again. This is
1590 // used to safeguard against an accidental tail recursion in probing
1591 // retransmission code.
1592 bool probing_retransmission_pending_;
1593
1594 // Indicates whether a stateless reset token has been received from peer.
1595 bool stateless_reset_token_received_;
1596 // Stores received stateless reset token from peer. Used to verify whether a
1597 // packet is a stateless reset packet.
1598 QuicUint128 received_stateless_reset_token_;
1599
1600 // Id of latest sent control frame. 0 if no control frame has been sent.
1601 QuicControlFrameId last_control_frame_id_;
1602
1603 // True if the peer is unreachable on the current path.
1604 bool is_path_degrading_;
1605
1606 // True if an ack frame is being processed.
1607 bool processing_ack_frame_;
1608
1609 // True if the writer supports release timestamp.
1610 bool supports_release_time_;
1611
1612 // Time this connection can release packets into the future.
1613 QuicTime::Delta release_time_into_future_;
1614
fkastenholz305e1732019-06-18 05:01:22 -07001615 // Payload of most recently transmitted IETF QUIC connectivity
QUICHE teama6ef0a62019-03-07 20:34:33 -05001616 // probe packet (the PATH_CHALLENGE payload). This implementation transmits
1617 // only one PATH_CHALLENGE per connectivity probe, so only one
1618 // QuicPathFrameBuffer is needed.
1619 std::unique_ptr<QuicPathFrameBuffer> transmitted_connectivity_probe_payload_;
1620
1621 // Payloads that were received in the most recent probe. This needs to be a
1622 // Deque because the peer might no be using this implementation, and others
1623 // might send a packet with more than one PATH_CHALLENGE, so all need to be
1624 // saved and responded to.
wuba750aab2020-02-10 06:43:15 -08001625 QuicCircularDeque<QuicPathFrameBuffer> received_path_challenge_payloads_;
QUICHE teama6ef0a62019-03-07 20:34:33 -05001626
QUICHE teamc65d1d12019-03-19 20:58:04 -07001627 // Set of connection IDs that should be accepted as destination on
1628 // received packets. This is conceptually a set but is implemented as a
1629 // vector to improve performance since it is expected to be very small.
1630 std::vector<QuicConnectionId> incoming_connection_ids_;
1631
dschinazie7c38a52020-05-29 15:25:45 -07001632 // When we receive a RETRY packet or some INITIAL packets, we replace
1633 // |server_connection_id_| with the value from that packet and save off the
1634 // original value of |server_connection_id_| into
1635 // |original_destination_connection_id_| for validation.
1636 quiche::QuicheOptional<QuicConnectionId> original_destination_connection_id_;
1637
1638 // After we receive a RETRY packet, |retry_source_connection_id_| contains
1639 // the source connection ID from that packet.
1640 quiche::QuicheOptional<QuicConnectionId> retry_source_connection_id_;
dschinazi39e5e552020-05-06 13:55:24 -07001641
dschinazi278efae2020-01-28 17:03:09 -08001642 // Indicates whether received RETRY packets should be dropped.
1643 bool drop_incoming_retry_packets_;
fayangce0a3162019-08-15 09:05:36 -07001644
fayang5f135052019-08-22 17:59:40 -07001645 // Bytes received before address validation. Only used when
1646 // EnforceAntiAmplificationLimit returns true.
1647 size_t bytes_received_before_address_validation_;
1648
1649 // Bytes sent before address validation. Only used when
1650 // EnforceAntiAmplificationLimit returns true.
1651 size_t bytes_sent_before_address_validation_;
1652
1653 // True if peer address has been validated. Address is considered validated
1654 // when 1) an address token is received and validated, or 2) a HANDSHAKE
1655 // packet has been successfully processed. Only used when
1656 // EnforceAntiAmplificationLimit returns true.
1657 bool address_validated_;
fayang4c1c2362019-09-13 07:20:01 -07001658
fayang2ce66082019-10-02 06:29:04 -07001659 // Used to store content of packets which cannot be sent because of write
1660 // blocked. Packets' encrypted buffers are copied and owned by
1661 // buffered_packets_. From unacked_packet_map (and congestion control)'s
fayange62e63c2019-12-04 07:16:25 -08001662 // perspective, those packets are considered sent.
fayang2ce66082019-10-02 06:29:04 -07001663 std::list<BufferedPacket> buffered_packets_;
1664
fayang58f71072019-11-05 08:47:02 -08001665 // Used to coalesce packets of different encryption level into the same UDP
1666 // datagram. Connection stops trying to coalesce packets if a forward secure
1667 // packet gets acknowledged.
1668 QuicCoalescedPacket coalesced_packet_;
1669
wubf76cf2a2019-10-11 18:49:07 -07001670 QuicConnectionMtuDiscoverer mtu_discoverer_;
fayangb59c6f12020-03-23 15:06:14 -07001671
1672 QuicNetworkBlackholeDetector blackhole_detector_;
1673
fayangb9c88442020-03-26 07:03:57 -07001674 QuicIdleNetworkDetector idle_network_detector_;
1675
fayangf78b6932020-06-08 08:36:45 -07001676 bool blackhole_detection_disabled_ = false;
1677
fayang5c362882020-06-16 07:39:39 -07001678 // True if this connection supports handshake done frame.
1679 bool support_handshake_done_;
1680
fayangb9c88442020-03-26 07:03:57 -07001681 const bool use_idle_network_detector_ =
fayangb9c88442020-03-26 07:03:57 -07001682 GetQuicReloadableFlag(quic_use_idle_network_detector);
fayange9304002020-05-07 11:57:48 -07001683
1684 const bool extend_idle_time_on_decryptable_packets_ =
1685 GetQuicReloadableFlag(quic_extend_idle_time_on_decryptable_packets);
fayang9f430a52020-05-08 07:28:33 -07001686
1687 const bool advance_ack_timeout_update_ =
1688 GetQuicReloadableFlag(quic_advance_ack_timeout_update);
wub9e7b4922020-05-20 10:39:44 -07001689
1690 const bool update_ack_alarm_in_send_all_pending_acks_ =
1691 GetQuicReloadableFlag(quic_update_ack_alarm_in_send_all_pending_acks);
fayang6a258412020-05-28 08:57:12 -07001692
1693 const bool move_amplification_limit_ =
1694 GetQuicReloadableFlag(quic_move_amplification_limit);
1695
1696 // TODO(fayang): Change the default value of quic_anti_amplification_factor to
1697 // 5 when deprecating quic_move_amplification_limit.
1698 // TODO(b/153892665): Change the default value of
1699 // quic_anti_amplification_factor back to 3 when cert compression is
1700 // supported.
1701 const size_t anti_amplification_factor_ =
1702 move_amplification_limit_
1703 ? 5
1704 : GetQuicFlag(FLAGS_quic_anti_amplification_factor);
fayangaa4f3f22020-06-05 16:22:00 -07001705
1706 const bool default_enable_5rto_blackhole_detection_ =
fayang656cbb52020-06-09 13:29:35 -07001707 GetQuicReloadableFlag(quic_default_enable_5rto_blackhole_detection2);
QUICHE teama6ef0a62019-03-07 20:34:33 -05001708};
1709
1710} // namespace quic
1711
1712#endif // QUICHE_QUIC_CORE_QUIC_CONNECTION_H_