1d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// found in the LICENSE file.
4d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
5d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#ifndef NET_QUIC_QUIC_SENT_PACKET_MANAGER_H_
6d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#define NET_QUIC_QUIC_SENT_PACKET_MANAGER_H_
7d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
8d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include <map>
9d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include <set>
10d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include <utility>
11d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include <vector>
12d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
13d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "base/containers/hash_tables.h"
145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
15d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "net/base/linked_hash_map.h"
16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "net/quic/congestion_control/loss_detection_interface.h"
17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "net/quic/congestion_control/rtt_stats.h"
18a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "net/quic/congestion_control/send_algorithm_interface.h"
194e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "net/quic/quic_ack_notifier_manager.h"
20d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "net/quic/quic_protocol.h"
2103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "net/quic/quic_sustained_bandwidth_recorder.h"
22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "net/quic/quic_unacked_packet_map.h"
23d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
24d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)namespace net {
25d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
26a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)namespace test {
27a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class QuicConnectionPeer;
28a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class QuicSentPacketManagerPeer;
29a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)}  // namespace test
30a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
31a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class QuicClock;
32a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class QuicConfig;
335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)struct QuicConnectionStats;
34a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
35a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Class which tracks the set of packets sent on a QUIC connection and contains
36a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// a send algorithm to decide when to send new packets.  It keeps track of any
37a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// retransmittable data associated with each packet. If a packet is
38a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// retransmitted, it will keep track of each version of a packet so that if a
39a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// previous transmission is acked, the data will not be retransmitted.
40d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)class NET_EXPORT_PRIVATE QuicSentPacketManager {
41d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) public:
4246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  // Interface which gets callbacks from the QuicSentPacketManager at
4346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  // interesting points.  Implementations must not mutate the state of
4446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  // the packet manager or connection as a result of these callbacks.
4546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  class NET_EXPORT_PRIVATE DebugDelegate {
4646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)   public:
4746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)    virtual ~DebugDelegate() {}
4846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)
4946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)    // Called when a spurious retransmission is detected.
5046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)    virtual void OnSpuriousPacketRetransmition(
5146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)        TransmissionType transmission_type,
5246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)        QuicByteCount byte_size) {}
53116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
54116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    virtual void OnSentPacket(
55116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch        QuicPacketSequenceNumber sequence_number,
56116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch        QuicTime sent_time,
571320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci        QuicByteCount bytes,
581320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci        TransmissionType transmission_type) {}
59116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
60116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    virtual void OnRetransmittedPacket(
61116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch        QuicPacketSequenceNumber old_sequence_number,
62116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch        QuicPacketSequenceNumber new_sequence_number,
63116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch        TransmissionType transmission_type,
64116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch        QuicTime time) {}
65116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
66116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    virtual void OnIncomingAck(
675f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)        const QuicAckFrame& ack_frame,
68116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch        QuicTime ack_receive_time,
69116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch        QuicPacketSequenceNumber largest_observed,
70116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch        bool largest_observed_acked,
71116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch        QuicPacketSequenceNumber least_unacked_sent_packet) {}
721320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
731320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    virtual void OnSerializedPacket(
741320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci        const SerializedPacket& packet) {}
7546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  };
7646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)
775f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Interface which gets callbacks from the QuicSentPacketManager when
785f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // network-related state changes. Implementations must not mutate the
795f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // state of the packet manager as a result of these callbacks.
805f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  class NET_EXPORT_PRIVATE NetworkChangeVisitor {
815f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)   public:
825f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    virtual ~NetworkChangeVisitor() {}
835f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
845f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    // Called when congestion window may have changed.
855f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    virtual void OnCongestionWindowChange(QuicByteCount congestion_window) = 0;
865f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    // TODO(jri): Add OnRttStatsChange() to this class as well.
875f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  };
885f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
8968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // Struct to store the pending retransmission information.
9068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  struct PendingRetransmission {
9168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)    PendingRetransmission(QuicPacketSequenceNumber sequence_number,
9268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)                          TransmissionType transmission_type,
9368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)                          const RetransmittableFrames& retransmittable_frames,
9468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)                          QuicSequenceNumberLength sequence_number_length)
9568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)            : sequence_number(sequence_number),
9668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)              transmission_type(transmission_type),
9768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)              retransmittable_frames(retransmittable_frames),
9868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)              sequence_number_length(sequence_number_length) {
9968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)        }
10068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
10168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)        QuicPacketSequenceNumber sequence_number;
10268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)        TransmissionType transmission_type;
10368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)        const RetransmittableFrames& retransmittable_frames;
10468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)        QuicSequenceNumberLength sequence_number_length;
10568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  };
10668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
107a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  QuicSentPacketManager(bool is_server,
108a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                        const QuicClock* clock,
1095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                        QuicConnectionStats* stats,
1105f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                        CongestionControlType congestion_control_type,
111e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch                        LossDetectionType loss_type);
112d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  virtual ~QuicSentPacketManager();
113d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
114a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void SetFromConfig(const QuicConfig& config);
115a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
1166e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  void SetHandshakeConfirmed() { handshake_confirmed_ = true; }
1176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
118d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // Called when a new packet is serialized.  If the packet contains
119d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // retransmittable data, it will be added to the unacked packet map.
1205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void OnSerializedPacket(const SerializedPacket& serialized_packet);
121d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
122d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // Called when a packet is retransmitted with a new sequence number.
123d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // Replaces the old entry in the unacked packet map with the new
124d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // sequence number.
125d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  void OnRetransmittedPacket(QuicPacketSequenceNumber old_sequence_number,
126d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)                             QuicPacketSequenceNumber new_sequence_number);
127d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
128e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  // Processes the incoming ack.
1295f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  void OnIncomingAck(const QuicAckFrame& ack_frame,
130a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                     QuicTime ack_receive_time);
131d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
132d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // Returns true if the non-FEC packet |sequence_number| is unacked.
133d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  bool IsUnacked(QuicPacketSequenceNumber sequence_number) const;
134d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
135a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Requests retransmission of all unacked packets of |retransmission_type|.
1361320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  void RetransmitUnackedPackets(TransmissionType retransmission_type);
137d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
138f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  // Retransmits the oldest pending packet there is still a tail loss probe
139f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  // pending.  Invoked after OnRetransmissionTimeout.
140f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  bool MaybeRetransmitTailLossProbe();
141f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
1425c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // Removes the retransmittable frames from all unencrypted packets to ensure
1435c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // they don't get retransmitted.
144cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  void NeuterUnencryptedPackets();
1455c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
14668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // Returns true if the unacked packet |sequence_number| has retransmittable
14768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // frames.  This will only return false if the packet has been acked, if a
14868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // previous transmission of this packet was ACK'd, or if this packet has been
14968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // retransmitted as with different sequence number.
15068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  bool HasRetransmittableFrames(QuicPacketSequenceNumber sequence_number) const;
15168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
15268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // Returns true if there are pending retransmissions.
15368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  bool HasPendingRetransmissions() const;
15468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
15568043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // Retrieves the next pending retransmission.
15668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  PendingRetransmission NextPendingRetransmission();
15768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
158d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  bool HasUnackedPackets() const;
159d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
1605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Returns the smallest sequence number of a serialized packet which has not
1611320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // been acked by the peer.
1621320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  QuicPacketSequenceNumber GetLeastUnacked() const;
163d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
164a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Called when a congestion feedback frame is received from peer.
165a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void OnIncomingQuicCongestionFeedbackFrame(
166a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      const QuicCongestionFeedbackFrame& frame,
167a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      const QuicTime& feedback_receive_time);
168a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
169a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Called when we have sent bytes to the peer.  This informs the manager both
1705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // the number of bytes sent and if they were retransmitted.  Returns true if
1715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // the sender should reset the retransmission timer.
1725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual bool OnPacketSent(QuicPacketSequenceNumber sequence_number,
173a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                            QuicTime sent_time,
174a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                            QuicByteCount bytes,
175a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                            TransmissionType transmission_type,
176a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                            HasRetransmittableData has_retransmittable_data);
177a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
178a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Called when the retransmission timer expires.
179a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void OnRetransmissionTimeout();
180a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
181a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Calculate the time until we can send the next packet to the wire.
182a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Note 1: When kUnknownWaitTime is returned, there is no need to poll
183a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // TimeUntilSend again until we receive an OnIncomingAckFrame event.
184a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Note 2: Send algorithms may or may not use |retransmit| in their
185a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // calculations.
186a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual QuicTime::Delta TimeUntilSend(QuicTime now,
187e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch                                        HasRetransmittableData retransmittable);
188a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
189a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Returns amount of time for delayed ack timer.
1905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const QuicTime::Delta DelayedAckTime() const;
191a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
1925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Returns the current delay for the retransmission timer, which may send
1935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // either a tail loss probe or do a full RTO.  Returns QuicTime::Zero() if
1945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // there are no retransmittable packets.
1955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const QuicTime GetRetransmissionTime() const;
196a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
1970529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  const RttStats* GetRttStats() const;
198a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
199a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Returns the estimated bandwidth calculated by the congestion algorithm.
200a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  QuicBandwidth BandwidthEstimate() const;
201a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
20203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  // Returns true if the current instantaneous bandwidth estimate is reliable.
203116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  bool HasReliableBandwidthEstimate() const;
204116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
20503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  const QuicSustainedBandwidthRecorder& SustainedBandwidthRecorder() const;
20603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
207a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Returns the size of the current congestion window in bytes.  Note, this is
208a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // not the *available* window.  Some send algorithms may not use a congestion
209a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // window and will return 0.
210a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  QuicByteCount GetCongestionWindow() const;
211a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
212116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Returns the size of the slow start congestion window in bytes,
213116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // aka ssthresh.  Some send algorithms do not define a slow start
214116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // threshold and will return 0.
215116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  QuicByteCount GetSlowStartThreshold() const;
216116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
21703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  // Enables pacing if it has not already been enabled.
21803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  void EnablePacing();
219a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
220a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  bool using_pacing() const { return using_pacing_; }
221a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
22246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  void set_debug_delegate(DebugDelegate* debug_delegate) {
22346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)    debug_delegate_ = debug_delegate;
22446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  }
22546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)
226116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  QuicPacketSequenceNumber largest_observed() const {
22703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    return unacked_packets_.largest_observed();
22803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  }
22903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
23003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  QuicPacketSequenceNumber least_packet_awaited_by_peer() {
23103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    return least_packet_awaited_by_peer_;
232116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  }
233116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
2345f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  void set_network_change_visitor(NetworkChangeVisitor* visitor) {
2355f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    DCHECK(!network_change_visitor_);
2365f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    DCHECK(visitor);
2375f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    network_change_visitor_ = visitor;
2385f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  }
2395f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
24003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  size_t consecutive_rto_count() const {
24103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    return consecutive_rto_count_;
24203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  }
24303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
24403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  size_t consecutive_tlp_count() const {
24503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    return consecutive_tlp_count_;
24603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  }
24703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
248d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) private:
249a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  friend class test::QuicConnectionPeer;
250a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  friend class test::QuicSentPacketManagerPeer;
251a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
252a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // The retransmission timer is a single timer which switches modes depending
253a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // upon connection state.
2545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  enum RetransmissionTimeoutMode {
255a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // A conventional TCP style RTO.
2565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    RTO_MODE,
257a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // A tail loss probe.  By default, QUIC sends up to two before RTOing.
2585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    TLP_MODE,
259a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // Retransmission of handshake packets prior to handshake completion.
2605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    HANDSHAKE_MODE,
261a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // Re-invoke the loss detection when a packet is not acked before the
262a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // loss detection algorithm expects.
263a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    LOSS_MODE,
2645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  };
2655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
26668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  typedef linked_hash_map<QuicPacketSequenceNumber,
26768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)                          TransmissionType> PendingRetransmissionMap;
2685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
26903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  // Updates the least_packet_awaited_by_peer.
27003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  void UpdatePacketInformationReceivedByPeer(const QuicAckFrame& ack_frame);
27103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
27268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // Process the incoming ack looking for newly ack'd data packets.
2735f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  void HandleAckForSentPackets(const QuicAckFrame& ack_frame);
27468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
2755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Returns the current retransmission mode.
2765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  RetransmissionTimeoutMode GetRetransmissionMode() const;
2775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Retransmits all crypto stream packets.
2795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void RetransmitCryptoPackets();
2805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Retransmits all the packets and abandons by invoking a full RTO.
2825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void RetransmitAllPackets();
2835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Returns the timer for retransmitting crypto handshake packets.
2855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const QuicTime::Delta GetCryptoRetransmissionDelay() const;
2865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Returns the timer for a new tail loss probe.
2885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const QuicTime::Delta GetTailLossProbeDelay() const;
2895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Returns the retransmission timeout, after which a full RTO occurs.
2915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const QuicTime::Delta GetRetransmissionDelay() const;
29268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
293a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Update the RTT if the ack is for the largest acked sequence number.
294010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  // Returns true if the rtt was updated.
2955f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  bool MaybeUpdateRTT(const QuicAckFrame& ack_frame,
296a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                      const QuicTime& ack_receive_time);
297a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
298a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Invokes the loss detection algorithm and loses and retransmits packets if
299a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // necessary.
300a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  void InvokeLossDetection(QuicTime time);
301a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
302010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  // Invokes OnCongestionEvent if |rtt_updated| is true, there are pending acks,
303010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  // or pending losses.  Clears pending acks and pending losses afterwards.
304010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  // |bytes_in_flight| is the number of bytes in flight before the losses or
305010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  // acks.
306010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  void MaybeInvokeCongestionEvent(bool rtt_updated,
307010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)                                  QuicByteCount bytes_in_flight);
308010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)
3090529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  // Marks |sequence_number| as having been revived by the peer, but not
3100529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  // received, so the packet remains pending if it is and the congestion control
3110529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  // does not consider the packet acked.
3120529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  void MarkPacketRevived(QuicPacketSequenceNumber sequence_number,
3130529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                         QuicTime::Delta delta_largest_observed);
3140529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch
315cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // Removes the retransmittability and pending properties from the packet at
316cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // |it| due to receipt by the peer.  Returns an iterator to the next remaining
317cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  // unacked packet.
3181320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  void MarkPacketHandled(QuicPacketSequenceNumber sequence_number,
3191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                         const TransmissionInfo& info,
3201320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                         QuicTime::Delta delta_largest_observed);
32168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
322a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Request that |sequence_number| be retransmitted after the other pending
3235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // retransmissions.  Does not add it to the retransmissions if it's already
3245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // a pending retransmission.
3255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void MarkForRetransmission(QuicPacketSequenceNumber sequence_number,
326a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                             TransmissionType transmission_type);
327a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
32846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  // Notify observers about spurious retransmits.
32946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  void RecordSpuriousRetransmissions(
3301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      const SequenceNumberList& all_transmissions,
33146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)      QuicPacketSequenceNumber acked_sequence_number);
33246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)
3335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Newly serialized retransmittable and fec packets are added to this map,
3345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // which contains owning pointers to any contained frames.  If a packet is
3355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // retransmitted, this map will contain entries for both the old and the new
3365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // packet. The old packet's retransmittable frames entry will be NULL, while
3375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // the new packet's entry will contain the frames to retransmit.
33868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // If the old packet is acked before the new packet, then the old entry will
33968043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // be removed from the map and the new entry's retransmittable frames will be
34068043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // set to NULL.
341a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  QuicUnackedPacketMap unacked_packets_;
342d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
34368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  // Pending retransmissions which have not been packetized and sent yet.
34468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)  PendingRetransmissionMap pending_retransmissions_;
345d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
346d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // Tracks if the connection was created by the server.
347d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  bool is_server_;
34868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)
3494e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // An AckNotifier can register to be informed when ACKs have been received for
3504e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // all packets that a given block of data was sent in. The AckNotifierManager
3514e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // maintains the currently active notifiers.
3524e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  AckNotifierManager ack_notifier_manager_;
3534e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
354a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  const QuicClock* clock_;
3555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  QuicConnectionStats* stats_;
35646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  DebugDelegate* debug_delegate_;
3575f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  NetworkChangeVisitor* network_change_visitor_;
358a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  RttStats rtt_stats_;
359a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  scoped_ptr<SendAlgorithmInterface> send_algorithm_;
360a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  scoped_ptr<LossDetectionInterface> loss_algorithm_;
361a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
36203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  // Least sequence number which the peer is still waiting for.
36303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  QuicPacketSequenceNumber least_packet_awaited_by_peer_;
364116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
365116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Tracks the first RTO packet.  If any packet before that packet gets acked,
366116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // it indicates the RTO was spurious and should be reversed(F-RTO).
367116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  QuicPacketSequenceNumber first_rto_transmission_;
368a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Number of times the RTO timer has fired in a row without receiving an ack.
369a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  size_t consecutive_rto_count_;
3705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Number of times the tail loss probe has been sent.
3715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  size_t consecutive_tlp_count_;
3725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Number of times the crypto handshake has been retransmitted.
3735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  size_t consecutive_crypto_retransmission_count_;
37403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  // Number of pending transmissions of TLP or crypto packets.
37503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  size_t pending_timer_transmission_count_;
3765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Maximum number of tail loss probes to send before firing an RTO.
3775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  size_t max_tail_loss_probes_;
378a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  bool using_pacing_;
379a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
3801320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Vectors packets acked and lost as a result of the last congestion event.
3811320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  SendAlgorithmInterface::CongestionVector packets_acked_;
3821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  SendAlgorithmInterface::CongestionVector packets_lost_;
383010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)
3846e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Set to true after the crypto handshake has successfully completed. After
3856e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // this is true we no longer use HANDSHAKE_MODE, and further frames sent on
3866e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // the crypto stream (i.e. SCUP messages) are treated like normal
3876e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // retransmittable frames.
3886e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  bool handshake_confirmed_;
3896e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
39003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  // Records bandwidth from server to client in normal operation, over periods
39103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  // of time with no loss events.
39203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  QuicSustainedBandwidthRecorder sustained_bandwidth_recorder_;
39303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
394d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(QuicSentPacketManager);
395d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)};
396d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
397d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)}  // namespace net
398d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
399d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#endif  // NET_QUIC_QUIC_SENT_PACKET_MANAGER_H_
400