blob: d76ce134ed90ad6bf210789afe30c47cbfa75104 [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
fayang5d92c412020-02-19 12:10:31 -080073 // Return true if ack frame of |packet_number_space| is empty.
74 bool IsAckFrameEmpty(PacketNumberSpace packet_number_space) const;
75
QUICHE teamb23daa72019-03-21 08:37:48 -070076 QuicPacketNumber peer_least_packet_awaiting_ack() const;
77
78 size_t min_received_before_ack_decimation() const;
79 void set_min_received_before_ack_decimation(size_t new_value);
80
81 size_t ack_frequency_before_ack_decimation() const;
82 void set_ack_frequency_before_ack_decimation(size_t new_value);
83
QUICHE team1dfa46b2019-03-22 10:39:10 -070084 bool supports_multiple_packet_number_spaces() const {
85 return supports_multiple_packet_number_spaces_;
86 }
87
QUICHE teamb23daa72019-03-21 08:37:48 -070088 // For logging purposes.
89 const QuicAckFrame& ack_frame() const;
fayang21ffb712019-05-16 08:39:26 -070090 const QuicAckFrame& GetAckFrame(PacketNumberSpace packet_number_space) const;
QUICHE teamb23daa72019-03-21 08:37:48 -070091
92 void set_max_ack_ranges(size_t max_ack_ranges);
93
ianswett309987e2019-08-02 13:16:26 -070094 // Get and set the max ack delay to use for application data.
95 QuicTime::Delta max_ack_delay();
96 void set_max_ack_delay(QuicTime::Delta max_ack_delay);
97
QUICHE teamb23daa72019-03-21 08:37:48 -070098 void set_save_timestamps(bool save_timestamps);
99
100 private:
101 friend class test::QuicConnectionPeer;
102 friend class test::UberReceivedPacketManagerPeer;
103
QUICHE team1dfa46b2019-03-22 10:39:10 -0700104 // One received packet manager per packet number space. If
105 // supports_multiple_packet_number_spaces_ is false, only the first (0 index)
106 // received_packet_manager is used.
107 QuicReceivedPacketManager received_packet_managers_[NUM_PACKET_NUMBER_SPACES];
108
109 bool supports_multiple_packet_number_spaces_;
QUICHE teamb23daa72019-03-21 08:37:48 -0700110};
111
112} // namespace quic
113
114#endif // QUICHE_QUIC_CORE_UBER_RECEIVED_PACKET_MANAGER_H_