blob: c8921268e6bbeb0f436b4d4f4607d55c1ec5fd96 [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_SENT_PACKET_MANAGER_H_
6#define QUICHE_QUIC_CORE_QUIC_SENT_PACKET_MANAGER_H_
7
8#include <cstddef>
9#include <map>
10#include <memory>
11#include <set>
vasilvv872e7a32019-03-12 16:42:44 -070012#include <string>
QUICHE teama6ef0a62019-03-07 20:34:33 -050013#include <utility>
14#include <vector>
15
QUICHE teama6ef0a62019-03-07 20:34:33 -050016#include "net/third_party/quiche/src/quic/core/congestion_control/pacing_sender.h"
17#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h"
18#include "net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h"
19#include "net/third_party/quiche/src/quic/core/congestion_control/uber_loss_algorithm.h"
20#include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters.pb.h"
21#include "net/third_party/quiche/src/quic/core/quic_packets.h"
22#include "net/third_party/quiche/src/quic/core/quic_pending_retransmission.h"
23#include "net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder.h"
24#include "net/third_party/quiche/src/quic/core/quic_transmission_info.h"
25#include "net/third_party/quiche/src/quic/core/quic_types.h"
26#include "net/third_party/quiche/src/quic/core/quic_unacked_packet_map.h"
27#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h"
28#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050029
30namespace quic {
31
32namespace test {
33class QuicConnectionPeer;
34class QuicSentPacketManagerPeer;
35} // namespace test
36
37class QuicClock;
38class QuicConfig;
39struct QuicConnectionStats;
40
41// Class which tracks the set of packets sent on a QUIC connection and contains
42// a send algorithm to decide when to send new packets. It keeps track of any
43// retransmittable data associated with each packet. If a packet is
44// retransmitted, it will keep track of each version of a packet so that if a
45// previous transmission is acked, the data will not be retransmitted.
46class QUIC_EXPORT_PRIVATE QuicSentPacketManager {
47 public:
48 // Interface which gets callbacks from the QuicSentPacketManager at
49 // interesting points. Implementations must not mutate the state of
50 // the packet manager or connection as a result of these callbacks.
51 class QUIC_EXPORT_PRIVATE DebugDelegate {
52 public:
53 virtual ~DebugDelegate() {}
54
55 // Called when a spurious retransmission is detected.
56 virtual void OnSpuriousPacketRetransmission(
57 TransmissionType transmission_type,
58 QuicByteCount byte_size) {}
59
60 virtual void OnIncomingAck(const QuicAckFrame& ack_frame,
61 QuicTime ack_receive_time,
62 QuicPacketNumber largest_observed,
63 bool rtt_updated,
64 QuicPacketNumber least_unacked_sent_packet) {}
65
66 virtual void OnPacketLoss(QuicPacketNumber lost_packet_number,
67 TransmissionType transmission_type,
68 QuicTime detection_time) {}
69
70 virtual void OnApplicationLimited() {}
71
72 virtual void OnAdjustNetworkParameters(QuicBandwidth bandwidth,
73 QuicTime::Delta rtt) {}
74 };
75
76 // Interface which gets callbacks from the QuicSentPacketManager when
77 // network-related state changes. Implementations must not mutate the
78 // state of the packet manager as a result of these callbacks.
79 class QUIC_EXPORT_PRIVATE NetworkChangeVisitor {
80 public:
81 virtual ~NetworkChangeVisitor() {}
82
83 // Called when congestion window or RTT may have changed.
84 virtual void OnCongestionChange() = 0;
85
86 // Called when the Path MTU may have increased.
87 virtual void OnPathMtuIncreased(QuicPacketLength packet_size) = 0;
88 };
89
90 QuicSentPacketManager(Perspective perspective,
91 const QuicClock* clock,
92 QuicConnectionStats* stats,
93 CongestionControlType congestion_control_type,
94 LossDetectionType loss_type);
95 QuicSentPacketManager(const QuicSentPacketManager&) = delete;
96 QuicSentPacketManager& operator=(const QuicSentPacketManager&) = delete;
97 virtual ~QuicSentPacketManager();
98
99 virtual void SetFromConfig(const QuicConfig& config);
100
101 // Pass the CachedNetworkParameters to the send algorithm.
102 void ResumeConnectionState(
103 const CachedNetworkParameters& cached_network_params,
104 bool max_bandwidth_resumption);
105
106 void SetMaxPacingRate(QuicBandwidth max_pacing_rate) {
107 pacing_sender_.set_max_pacing_rate(max_pacing_rate);
108 }
109
110 QuicBandwidth MaxPacingRate() const {
111 return pacing_sender_.max_pacing_rate();
112 }
113
114 // Set handshake_confirmed_ to true and neuter packets in HANDSHAKE packet
115 // number space.
116 void SetHandshakeConfirmed();
117
118 // Requests retransmission of all unacked packets of |retransmission_type|.
119 // The behavior of this method depends on the value of |retransmission_type|:
120 // ALL_UNACKED_RETRANSMISSION - All unacked packets will be retransmitted.
121 // This can happen, for example, after a version negotiation packet has been
122 // received and all packets needs to be retransmitted with the new version.
123 // ALL_INITIAL_RETRANSMISSION - Only initially encrypted packets will be
124 // retransmitted. This can happen, for example, when a CHLO has been rejected
125 // and the previously encrypted data needs to be encrypted with a new key.
126 void RetransmitUnackedPackets(TransmissionType retransmission_type);
127
128 // Notify the sent packet manager of an external network measurement or
129 // prediction for either |bandwidth| or |rtt|; either can be empty.
130 void AdjustNetworkParameters(QuicBandwidth bandwidth, QuicTime::Delta rtt);
131
132 // Retransmits the oldest pending packet there is still a tail loss probe
133 // pending. Invoked after OnRetransmissionTimeout.
134 bool MaybeRetransmitTailLossProbe();
135
136 // Retransmits the oldest pending packet.
137 bool MaybeRetransmitOldestPacket(TransmissionType type);
138
139 // Removes the retransmittable frames from all unencrypted packets to ensure
140 // they don't get retransmitted.
141 // TODO(fayang): Consider remove this function when deprecating
142 // quic_use_uber_loss_algorithm.
143 void NeuterUnencryptedPackets();
144
145 // Returns true if there are pending retransmissions.
146 // Not const because retransmissions may be cancelled before returning.
147 bool HasPendingRetransmissions() const {
148 return !pending_retransmissions_.empty();
149 }
150
151 // Retrieves the next pending retransmission. You must ensure that
152 // there are pending retransmissions prior to calling this function.
153 QuicPendingRetransmission NextPendingRetransmission();
154
155 // Returns true if there's outstanding crypto data.
156 bool HasUnackedCryptoPackets() const {
157 return unacked_packets_.HasPendingCryptoPackets();
158 }
159
160 // Returns true if there are packets in flight expecting to be acknowledged.
161 bool HasInFlightPackets() const {
162 return unacked_packets_.HasInFlightPackets();
163 }
164
165 // Returns the smallest packet number of a serialized packet which has not
166 // been acked by the peer.
167 QuicPacketNumber GetLeastUnacked() const {
168 return unacked_packets_.GetLeastUnacked();
169 }
170
171 // Called when we have sent bytes to the peer. This informs the manager both
172 // the number of bytes sent and if they were retransmitted. Returns true if
173 // the sender should reset the retransmission timer.
174 bool OnPacketSent(SerializedPacket* serialized_packet,
175 QuicPacketNumber original_packet_number,
176 QuicTime sent_time,
177 TransmissionType transmission_type,
178 HasRetransmittableData has_retransmittable_data);
179
180 // Called when the retransmission timer expires.
181 void OnRetransmissionTimeout();
182
183 // Calculate the time until we can send the next packet to the wire.
184 // Note 1: When kUnknownWaitTime is returned, there is no need to poll
185 // TimeUntilSend again until we receive an OnIncomingAckFrame event.
186 // Note 2: Send algorithms may or may not use |retransmit| in their
187 // calculations.
188 QuicTime::Delta TimeUntilSend(QuicTime now) const;
189
190 // Returns the current delay for the retransmission timer, which may send
191 // either a tail loss probe or do a full RTO. Returns QuicTime::Zero() if
192 // there are no retransmittable packets.
193 const QuicTime GetRetransmissionTime() const;
194
195 // Returns the current delay for the path degrading timer, which is used to
196 // notify the session that this connection is degrading.
197 const QuicTime::Delta GetPathDegradingDelay() const;
198
199 const RttStats* GetRttStats() const { return &rtt_stats_; }
200
201 // Returns the estimated bandwidth calculated by the congestion algorithm.
202 QuicBandwidth BandwidthEstimate() const {
203 return send_algorithm_->BandwidthEstimate();
204 }
205
206 const QuicSustainedBandwidthRecorder* SustainedBandwidthRecorder() const {
207 return &sustained_bandwidth_recorder_;
208 }
209
210 // Returns the size of the current congestion window in number of
211 // kDefaultTCPMSS-sized segments. Note, this is not the *available* window.
212 // Some send algorithms may not use a congestion window and will return 0.
213 QuicPacketCount GetCongestionWindowInTcpMss() const {
214 return send_algorithm_->GetCongestionWindow() / kDefaultTCPMSS;
215 }
216
217 // Returns the number of packets of length |max_packet_length| which fit in
218 // the current congestion window. More packets may end up in flight if the
219 // congestion window has been recently reduced, of if non-full packets are
220 // sent.
221 QuicPacketCount EstimateMaxPacketsInFlight(
222 QuicByteCount max_packet_length) const {
223 return send_algorithm_->GetCongestionWindow() / max_packet_length;
224 }
225
226 // Returns the size of the current congestion window size in bytes.
227 QuicByteCount GetCongestionWindowInBytes() const {
228 return send_algorithm_->GetCongestionWindow();
229 }
230
231 // Returns the size of the slow start congestion window in nume of 1460 byte
232 // TCP segments, aka ssthresh. Some send algorithms do not define a slow
233 // start threshold and will return 0.
234 QuicPacketCount GetSlowStartThresholdInTcpMss() const {
235 return send_algorithm_->GetSlowStartThreshold() / kDefaultTCPMSS;
236 }
237
wub967ba572019-04-01 09:27:52 -0700238 // Return the total time spent in slow start so far. If the sender is
239 // currently in slow start, the return value will include the duration between
240 // the most recent entry to slow start and now.
241 //
242 // Only implemented for BBR. Return QuicTime::Delta::Infinite() for other
243 // congestion controllers.
244 QuicTime::Delta GetSlowStartDuration() const;
245
QUICHE teama6ef0a62019-03-07 20:34:33 -0500246 // Returns debugging information about the state of the congestion controller.
vasilvvc48c8712019-03-11 13:38:16 -0700247 std::string GetDebugState() const;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500248
249 // Returns the number of bytes that are considered in-flight, i.e. not lost or
250 // acknowledged.
251 QuicByteCount GetBytesInFlight() const {
252 return unacked_packets_.bytes_in_flight();
253 }
254
255 // No longer retransmit data for |stream_id|.
256 void CancelRetransmissionsForStream(QuicStreamId stream_id);
257
258 // Called when peer address changes and the connection migrates.
259 void OnConnectionMigration(AddressChangeType type);
260
261 // Called when an ack frame is initially parsed.
262 void OnAckFrameStart(QuicPacketNumber largest_acked,
263 QuicTime::Delta ack_delay_time,
264 QuicTime ack_receive_time);
265
266 // Called when ack range [start, end) is received. Populates packets_acked_
267 // with newly acked packets.
268 void OnAckRange(QuicPacketNumber start, QuicPacketNumber end);
269
270 // Called when a timestamp is processed. If it's present in packets_acked_,
271 // the timestamp field is set. Otherwise, the timestamp is ignored.
272 void OnAckTimestamp(QuicPacketNumber packet_number, QuicTime timestamp);
273
274 // Called when an ack frame is parsed completely. Returns true if a previously
275 // -unacked packet is acked.
276 bool OnAckFrameEnd(QuicTime ack_receive_time);
277
278 // Called to enable/disable letting session decide what to write.
279 void SetSessionDecideWhatToWrite(bool session_decides_what_to_write) {
280 unacked_packets_.SetSessionDecideWhatToWrite(session_decides_what_to_write);
281 }
282
QUICHE teamc279cec2019-03-22 06:51:48 -0700283 void EnableMultiplePacketNumberSpacesSupport();
284
QUICHE teama6ef0a62019-03-07 20:34:33 -0500285 void SetDebugDelegate(DebugDelegate* debug_delegate);
286
287 void SetPacingAlarmGranularity(QuicTime::Delta alarm_granularity) {
288 pacing_sender_.set_alarm_granularity(alarm_granularity);
289 }
290
291 QuicPacketNumber GetLargestObserved() const {
292 return unacked_packets_.largest_acked();
293 }
294
QUICHE teamc279cec2019-03-22 06:51:48 -0700295 QuicPacketNumber GetLargestAckedPacket(
296 EncryptionLevel decrypted_packet_level) const;
297
QUICHE teama6ef0a62019-03-07 20:34:33 -0500298 QuicPacketNumber GetLargestSentPacket() const {
299 return unacked_packets_.largest_sent_packet();
300 }
301
QUICHE teamc279cec2019-03-22 06:51:48 -0700302 QuicPacketNumber GetLargestSentPacket(
303 EncryptionLevel decrypted_packet_level) const;
304
305 QuicPacketNumber GetLargestPacketPeerKnowsIsAcked(
306 EncryptionLevel decrypted_packet_level) const;
307
QUICHE teama6ef0a62019-03-07 20:34:33 -0500308 void SetNetworkChangeVisitor(NetworkChangeVisitor* visitor) {
309 DCHECK(!network_change_visitor_);
310 DCHECK(visitor);
311 network_change_visitor_ = visitor;
312 }
313
314 bool InSlowStart() const { return send_algorithm_->InSlowStart(); }
315
316 size_t GetConsecutiveRtoCount() const { return consecutive_rto_count_; }
317
318 size_t GetConsecutiveTlpCount() const { return consecutive_tlp_count_; }
319
320 void OnApplicationLimited();
321
322 const SendAlgorithmInterface* GetSendAlgorithm() const {
323 return send_algorithm_.get();
324 }
325
326 void SetSessionNotifier(SessionNotifierInterface* session_notifier) {
327 unacked_packets_.SetSessionNotifier(session_notifier);
328 }
329
330 QuicTime GetNextReleaseTime() const;
331
332 QuicPacketCount initial_congestion_window() const {
333 return initial_congestion_window_;
334 }
335
336 QuicPacketNumber largest_packet_peer_knows_is_acked() const {
337 return largest_packet_peer_knows_is_acked_;
338 }
339
340 bool handshake_confirmed() const { return handshake_confirmed_; }
341
342 bool session_decides_what_to_write() const {
343 return unacked_packets_.session_decides_what_to_write();
344 }
345
346 size_t pending_timer_transmission_count() const {
347 return pending_timer_transmission_count_;
348 }
349
350 QuicTime::Delta delayed_ack_time() const { return delayed_ack_time_; }
351
352 void set_delayed_ack_time(QuicTime::Delta delayed_ack_time) {
353 // The delayed ack time should never be more than one half the min RTO time.
354 DCHECK_LE(delayed_ack_time, (min_rto_timeout_ * 0.5));
355 delayed_ack_time_ = delayed_ack_time;
356 }
357
358 const QuicUnackedPacketMap& unacked_packets() const {
359 return unacked_packets_;
360 }
361
362 // Sets the send algorithm to the given congestion control type and points the
363 // pacing sender at |send_algorithm_|. Can be called any number of times.
364 void SetSendAlgorithm(CongestionControlType congestion_control_type);
365
366 // Sets the send algorithm to |send_algorithm| and points the pacing sender at
367 // |send_algorithm_|. Takes ownership of |send_algorithm|. Can be called any
368 // number of times.
369 // Setting the send algorithm once the connection is underway is dangerous.
370 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm);
371
QUICHE team9929cc42019-03-13 08:17:43 -0700372 bool tolerate_reneging() const { return tolerate_reneging_; }
373
QUICHE teamc279cec2019-03-22 06:51:48 -0700374 bool supports_multiple_packet_number_spaces() const {
375 return unacked_packets_.supports_multiple_packet_number_spaces();
376 }
377
QUICHE teamcd098022019-03-22 18:49:55 -0700378 bool use_uber_loss_algorithm() const {
379 return unacked_packets_.use_uber_loss_algorithm();
380 }
381
QUICHE teama6ef0a62019-03-07 20:34:33 -0500382 private:
383 friend class test::QuicConnectionPeer;
384 friend class test::QuicSentPacketManagerPeer;
385
386 // The retransmission timer is a single timer which switches modes depending
387 // upon connection state.
388 enum RetransmissionTimeoutMode {
389 // A conventional TCP style RTO.
390 RTO_MODE,
391 // A tail loss probe. By default, QUIC sends up to two before RTOing.
392 TLP_MODE,
393 // Retransmission of handshake packets prior to handshake completion.
394 HANDSHAKE_MODE,
395 // Re-invoke the loss detection when a packet is not acked before the
396 // loss detection algorithm expects.
397 LOSS_MODE,
398 };
399
400 typedef QuicLinkedHashMap<QuicPacketNumber,
401 TransmissionType,
402 QuicPacketNumberHash>
403 PendingRetransmissionMap;
404
405 // Returns the current retransmission mode.
406 RetransmissionTimeoutMode GetRetransmissionMode() const;
407
408 // Retransmits all crypto stream packets.
409 void RetransmitCryptoPackets();
410
411 // Retransmits two packets for an RTO and removes any non-retransmittable
412 // packets from flight.
413 void RetransmitRtoPackets();
414
415 // Returns the timeout for retransmitting crypto handshake packets.
416 const QuicTime::Delta GetCryptoRetransmissionDelay() const;
417
418 // Returns the timeout for a new tail loss probe. |consecutive_tlp_count| is
419 // the number of consecutive tail loss probes that have already been sent.
420 const QuicTime::Delta GetTailLossProbeDelay(
421 size_t consecutive_tlp_count) const;
422
423 // Calls GetTailLossProbeDelay() with values from the current state of this
424 // packet manager as its params.
425 const QuicTime::Delta GetTailLossProbeDelay() const {
426 return GetTailLossProbeDelay(consecutive_tlp_count_);
427 }
428
429 // Returns the retransmission timeout, after which a full RTO occurs.
430 // |consecutive_rto_count| is the number of consecutive RTOs that have already
431 // occurred.
432 const QuicTime::Delta GetRetransmissionDelay(
433 size_t consecutive_rto_count) const;
434
435 // Calls GetRetransmissionDelay() with values from the current state of this
436 // packet manager as its params.
437 const QuicTime::Delta GetRetransmissionDelay() const {
438 return GetRetransmissionDelay(consecutive_rto_count_);
439 }
440
441 // Returns the newest transmission associated with a packet.
442 QuicPacketNumber GetNewestRetransmission(
443 QuicPacketNumber packet_number,
444 const QuicTransmissionInfo& transmission_info) const;
445
446 // Update the RTT if the ack is for the largest acked packet number.
447 // Returns true if the rtt was updated.
448 bool MaybeUpdateRTT(QuicPacketNumber largest_acked,
449 QuicTime::Delta ack_delay_time,
450 QuicTime ack_receive_time);
451
452 // Invokes the loss detection algorithm and loses and retransmits packets if
453 // necessary.
454 void InvokeLossDetection(QuicTime time);
455
456 // Invokes OnCongestionEvent if |rtt_updated| is true, there are pending acks,
457 // or pending losses. Clears pending acks and pending losses afterwards.
458 // |prior_in_flight| is the number of bytes in flight before the losses or
459 // acks, |event_time| is normally the timestamp of the ack packet which caused
460 // the event, although it can be the time at which loss detection was
461 // triggered.
462 void MaybeInvokeCongestionEvent(bool rtt_updated,
463 QuicByteCount prior_in_flight,
464 QuicTime event_time);
465
466 // Removes the retransmittability and in flight properties from the packet at
467 // |info| due to receipt by the peer.
468 void MarkPacketHandled(QuicPacketNumber packet_number,
469 QuicTransmissionInfo* info,
470 QuicTime::Delta ack_delay_time);
471
472 // Request that |packet_number| be retransmitted after the other pending
473 // retransmissions. Does not add it to the retransmissions if it's already
474 // a pending retransmission.
475 void MarkForRetransmission(QuicPacketNumber packet_number,
476 TransmissionType transmission_type);
477
478 // Performs whatever work is need to retransmit the data correctly, either
479 // by retransmitting the frames directly or by notifying that the frames
480 // are lost.
481 void HandleRetransmission(TransmissionType transmission_type,
482 QuicTransmissionInfo* transmission_info);
483
484 // Called after packets have been marked handled with last received ack frame.
485 void PostProcessAfterMarkingPacketHandled(
486 const QuicAckFrame& ack_frame,
487 QuicTime ack_receive_time,
488 bool rtt_updated,
489 QuicByteCount prior_bytes_in_flight);
490
491 // Notify observers that packet with QuicTransmissionInfo |info| is a spurious
492 // retransmission. It is caller's responsibility to guarantee the packet with
493 // QuicTransmissionInfo |info| is a spurious retransmission before calling
494 // this function.
495 void RecordOneSpuriousRetransmission(const QuicTransmissionInfo& info);
496
497 // Notify observers about spurious retransmits of packet with
498 // QuicTransmissionInfo |info|.
499 void RecordSpuriousRetransmissions(const QuicTransmissionInfo& info,
500 QuicPacketNumber acked_packet_number);
501
502 // Sets the initial RTT of the connection.
503 void SetInitialRtt(QuicTime::Delta rtt);
504
wub37ec5962019-04-03 09:02:51 -0700505 // Should only be called from constructor.
506 LossDetectionInterface* GetInitialLossAlgorithm();
507
QUICHE teama6ef0a62019-03-07 20:34:33 -0500508 // Called when handshake is confirmed to remove the retransmittable frames
509 // from all packets of HANDSHAKE_DATA packet number space to ensure they don't
510 // get retransmitted and will eventually be removed from unacked packets map.
511 // Only used when quic_use_uber_loss_algorithm is true. Please note, this only
512 // applies to QUIC Crypto and needs to be changed when switches to IETF QUIC
513 // with QUIC TLS.
514 void NeuterHandshakePackets();
515
516 // Newly serialized retransmittable packets are added to this map, which
517 // contains owning pointers to any contained frames. If a packet is
518 // retransmitted, this map will contain entries for both the old and the new
519 // packet. The old packet's retransmittable frames entry will be nullptr,
520 // while the new packet's entry will contain the frames to retransmit.
521 // If the old packet is acked before the new packet, then the old entry will
522 // be removed from the map and the new entry's retransmittable frames will be
523 // set to nullptr.
524 QuicUnackedPacketMap unacked_packets_;
525
526 // Pending retransmissions which have not been packetized and sent yet.
527 PendingRetransmissionMap pending_retransmissions_;
528
529 const QuicClock* clock_;
530 QuicConnectionStats* stats_;
531
532 DebugDelegate* debug_delegate_;
533 NetworkChangeVisitor* network_change_visitor_;
534 QuicPacketCount initial_congestion_window_;
535 RttStats rtt_stats_;
536 std::unique_ptr<SendAlgorithmInterface> send_algorithm_;
537 // Not owned. Always points to |general_loss_algorithm_| outside of tests.
538 LossDetectionInterface* loss_algorithm_;
539 // TODO(fayang): Remove general_loss_algorithm_ when deprecating
540 // quic_use_uber_loss_algorithm.
541 GeneralLossAlgorithm general_loss_algorithm_;
542 UberLossAlgorithm uber_loss_algorithm_;
543
544 // Tracks the first RTO packet. If any packet before that packet gets acked,
545 // it indicates the RTO was spurious and should be reversed(F-RTO).
546 QuicPacketNumber first_rto_transmission_;
547 // Number of times the RTO timer has fired in a row without receiving an ack.
548 size_t consecutive_rto_count_;
549 // Number of times the tail loss probe has been sent.
550 size_t consecutive_tlp_count_;
551 // Number of times the crypto handshake has been retransmitted.
552 size_t consecutive_crypto_retransmission_count_;
553 // Number of pending transmissions of TLP, RTO, or crypto packets.
554 size_t pending_timer_transmission_count_;
555 // Maximum number of tail loss probes to send before firing an RTO.
556 size_t max_tail_loss_probes_;
557 // Maximum number of packets to send upon RTO.
558 QuicPacketCount max_rto_packets_;
559 // If true, send the TLP at 0.5 RTT.
560 bool enable_half_rtt_tail_loss_probe_;
561 bool using_pacing_;
562 // If true, use the new RTO with loss based CWND reduction instead of the send
563 // algorithms's OnRetransmissionTimeout to reduce the congestion window.
564 bool use_new_rto_;
565 // If true, use a more conservative handshake retransmission policy.
566 bool conservative_handshake_retransmits_;
567 // The minimum TLP timeout.
568 QuicTime::Delta min_tlp_timeout_;
569 // The minimum RTO.
570 QuicTime::Delta min_rto_timeout_;
571 // Whether to use IETF style TLP that includes the max ack delay.
572 bool ietf_style_tlp_;
573 // IETF style TLP, but with a 2x multiplier instead of 1.5x.
574 bool ietf_style_2x_tlp_;
575
576 // Vectors packets acked and lost as a result of the last congestion event.
577 AckedPacketVector packets_acked_;
578 LostPacketVector packets_lost_;
579 // Largest newly acknowledged packet.
580 QuicPacketNumber largest_newly_acked_;
581 // Largest packet in bytes ever acknowledged.
582 QuicPacketLength largest_mtu_acked_;
583
584 // Replaces certain calls to |send_algorithm_| when |using_pacing_| is true.
585 // Calls into |send_algorithm_| for the underlying congestion control.
586 PacingSender pacing_sender_;
587
588 // Set to true after the crypto handshake has successfully completed. After
589 // this is true we no longer use HANDSHAKE_MODE, and further frames sent on
590 // the crypto stream (i.e. SCUP messages) are treated like normal
591 // retransmittable frames.
592 bool handshake_confirmed_;
593
594 // Records bandwidth from server to client in normal operation, over periods
595 // of time with no loss events.
596 QuicSustainedBandwidthRecorder sustained_bandwidth_recorder_;
597
598 // The largest acked value that was sent in an ack, which has then been acked.
599 QuicPacketNumber largest_packet_peer_knows_is_acked_;
QUICHE teamc279cec2019-03-22 06:51:48 -0700600 // The largest acked value that was sent in an ack, which has then been acked
601 // for per packet number space. Only used when connection supports multiple
602 // packet number spaces.
603 QuicPacketNumber
604 largest_packets_peer_knows_is_acked_[NUM_PACKET_NUMBER_SPACES];
QUICHE teama6ef0a62019-03-07 20:34:33 -0500605
606 // The maximum amount of time to wait before sending an acknowledgement.
607 // The recovery code assumes the delayed ack time is the same on both sides.
608 QuicTime::Delta delayed_ack_time_;
609
610 // Latest received ack frame.
611 QuicAckFrame last_ack_frame_;
612
613 // Record whether RTT gets updated by last largest acked..
614 bool rtt_updated_;
615
616 // A reverse iterator of last_ack_frame_.packets. This is reset in
617 // OnAckRangeStart, and gradually moves in OnAckRange..
618 PacketNumberQueue::const_reverse_iterator acked_packets_iter_;
QUICHE team9929cc42019-03-13 08:17:43 -0700619
620 // Latched value of quic_tolerate_reneging.
621 const bool tolerate_reneging_;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500622};
623
624} // namespace quic
625
626#endif // QUICHE_QUIC_CORE_QUIC_SENT_PACKET_MANAGER_H_