blob: 14ba8684f5a6ea1c8ffcd6df824b9feb8f15beaa [file] [log] [blame]
QUICHE teamb23daa72019-03-21 08:37:48 -07001// Copyright 2019 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_UBER_RECEIVED_PACKET_MANAGER_H_
6#define QUICHE_QUIC_CORE_UBER_RECEIVED_PACKET_MANAGER_H_
7
8#include "net/third_party/quiche/src/quic/core/quic_received_packet_manager.h"
9
10namespace quic {
11
QUICHE team1dfa46b2019-03-22 10:39:10 -070012// This class comprises multiple received packet managers, one per packet number
13// space. Please note, if multiple packet number spaces is not supported, only
14// one received packet manager will be used.
QUICHE teamb23daa72019-03-21 08:37:48 -070015class QUIC_EXPORT_PRIVATE UberReceivedPacketManager {
16 public:
17 explicit UberReceivedPacketManager(QuicConnectionStats* stats);
18 UberReceivedPacketManager(const UberReceivedPacketManager&) = delete;
19 UberReceivedPacketManager& operator=(const UberReceivedPacketManager&) =
20 delete;
21 virtual ~UberReceivedPacketManager();
22
23 void SetFromConfig(const QuicConfig& config, Perspective perspective);
24
25 // Checks if we are still waiting for the packet with |packet_number|.
QUICHE team1dfa46b2019-03-22 10:39:10 -070026 bool IsAwaitingPacket(EncryptionLevel decrypted_packet_level,
27 QuicPacketNumber packet_number) const;
QUICHE teamb23daa72019-03-21 08:37:48 -070028
29 // Called after a packet has been successfully decrypted and its header has
30 // been parsed.
QUICHE team1dfa46b2019-03-22 10:39:10 -070031 void RecordPacketReceived(EncryptionLevel decrypted_packet_level,
32 const QuicPacketHeader& header,
QUICHE teamb23daa72019-03-21 08:37:48 -070033 QuicTime receipt_time);
34
35 // Retrieves a frame containing a QuicAckFrame. The ack frame must be
36 // serialized before another packet is received, or it will change.
QUICHE team1dfa46b2019-03-22 10:39:10 -070037 const QuicFrame GetUpdatedAckFrame(PacketNumberSpace packet_number_space,
38 QuicTime approximate_now);
QUICHE teamb23daa72019-03-21 08:37:48 -070039
40 // Stop ACKing packets before |least_unacked|.
QUICHE team1dfa46b2019-03-22 10:39:10 -070041 void DontWaitForPacketsBefore(EncryptionLevel decrypted_packet_level,
42 QuicPacketNumber least_unacked);
QUICHE teamb23daa72019-03-21 08:37:48 -070043
44 // Called after header of last received packet has been successfully processed
45 // to update ACK timeout.
46 void MaybeUpdateAckTimeout(bool should_last_packet_instigate_acks,
QUICHE team1dfa46b2019-03-22 10:39:10 -070047 EncryptionLevel decrypted_packet_level,
QUICHE teamb23daa72019-03-21 08:37:48 -070048 QuicPacketNumber last_received_packet_number,
49 QuicTime time_of_last_received_packet,
50 QuicTime now,
ianswett309987e2019-08-02 13:16:26 -070051 const RttStats* rtt_stats);
QUICHE teamb23daa72019-03-21 08:37:48 -070052
53 // Resets ACK related states, called after an ACK is successfully sent.
QUICHE team1dfa46b2019-03-22 10:39:10 -070054 void ResetAckStates(EncryptionLevel encryption_level);
55
56 // Called to enable multiple packet number support.
57 void EnableMultiplePacketNumberSpacesSupport();
QUICHE teamb23daa72019-03-21 08:37:48 -070058
59 // Returns true if ACK frame has been updated since GetUpdatedAckFrame was
60 // last called.
QUICHE team1dfa46b2019-03-22 10:39:10 -070061 bool IsAckFrameUpdated() const;
QUICHE teamb23daa72019-03-21 08:37:48 -070062
63 // Returns the largest received packet number.
QUICHE team1dfa46b2019-03-22 10:39:10 -070064 QuicPacketNumber GetLargestObserved(
65 EncryptionLevel decrypted_packet_level) const;
QUICHE teamb23daa72019-03-21 08:37:48 -070066
QUICHE team1dfa46b2019-03-22 10:39:10 -070067 // Returns ACK timeout of |packet_number_space|.
68 QuicTime GetAckTimeout(PacketNumberSpace packet_number_space) const;
69
70 // Get the earliest ack_timeout of all packet number spaces.
71 QuicTime GetEarliestAckTimeout() const;
QUICHE teamb23daa72019-03-21 08:37:48 -070072
QUICHE teamb23daa72019-03-21 08:37:48 -070073 QuicPacketNumber peer_least_packet_awaiting_ack() const;
74
75 size_t min_received_before_ack_decimation() const;
76 void set_min_received_before_ack_decimation(size_t new_value);
77
78 size_t ack_frequency_before_ack_decimation() const;
79 void set_ack_frequency_before_ack_decimation(size_t new_value);
80
QUICHE team1dfa46b2019-03-22 10:39:10 -070081 bool supports_multiple_packet_number_spaces() const {
82 return supports_multiple_packet_number_spaces_;
83 }
84
QUICHE teamb23daa72019-03-21 08:37:48 -070085 // For logging purposes.
86 const QuicAckFrame& ack_frame() const;
fayang21ffb712019-05-16 08:39:26 -070087 const QuicAckFrame& GetAckFrame(PacketNumberSpace packet_number_space) const;
QUICHE teamb23daa72019-03-21 08:37:48 -070088
89 void set_max_ack_ranges(size_t max_ack_ranges);
90
ianswett309987e2019-08-02 13:16:26 -070091 // Get and set the max ack delay to use for application data.
92 QuicTime::Delta max_ack_delay();
93 void set_max_ack_delay(QuicTime::Delta max_ack_delay);
94
QUICHE teamb23daa72019-03-21 08:37:48 -070095 void set_save_timestamps(bool save_timestamps);
96
97 private:
98 friend class test::QuicConnectionPeer;
99 friend class test::UberReceivedPacketManagerPeer;
100
QUICHE team1dfa46b2019-03-22 10:39:10 -0700101 // One received packet manager per packet number space. If
102 // supports_multiple_packet_number_spaces_ is false, only the first (0 index)
103 // received_packet_manager is used.
104 QuicReceivedPacketManager received_packet_managers_[NUM_PACKET_NUMBER_SPACES];
105
106 bool supports_multiple_packet_number_spaces_;
QUICHE teamb23daa72019-03-21 08:37:48 -0700107};
108
109} // namespace quic
110
111#endif // QUICHE_QUIC_CORE_UBER_RECEIVED_PACKET_MANAGER_H_