blob: c4428041465034497a27225df65ea351de8f917c [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,
51 const RttStats* rtt_stats,
fkastenholz59c653b2019-07-15 09:55:53 -070052 QuicTime::Delta local_max_ack_delay);
QUICHE teamb23daa72019-03-21 08:37:48 -070053
54 // Resets ACK related states, called after an ACK is successfully sent.
QUICHE team1dfa46b2019-03-22 10:39:10 -070055 void ResetAckStates(EncryptionLevel encryption_level);
56
57 // Called to enable multiple packet number support.
58 void EnableMultiplePacketNumberSpacesSupport();
QUICHE teamb23daa72019-03-21 08:37:48 -070059
60 // Returns true if ACK frame has been updated since GetUpdatedAckFrame was
61 // last called.
QUICHE team1dfa46b2019-03-22 10:39:10 -070062 bool IsAckFrameUpdated() const;
QUICHE teamb23daa72019-03-21 08:37:48 -070063
64 // Returns the largest received packet number.
QUICHE team1dfa46b2019-03-22 10:39:10 -070065 QuicPacketNumber GetLargestObserved(
66 EncryptionLevel decrypted_packet_level) const;
QUICHE teamb23daa72019-03-21 08:37:48 -070067
QUICHE team1dfa46b2019-03-22 10:39:10 -070068 // Returns ACK timeout of |packet_number_space|.
69 QuicTime GetAckTimeout(PacketNumberSpace packet_number_space) const;
70
71 // Get the earliest ack_timeout of all packet number spaces.
72 QuicTime GetEarliestAckTimeout() const;
QUICHE teamb23daa72019-03-21 08:37:48 -070073
QUICHE teamb23daa72019-03-21 08:37:48 -070074 QuicPacketNumber peer_least_packet_awaiting_ack() const;
75
76 size_t min_received_before_ack_decimation() const;
77 void set_min_received_before_ack_decimation(size_t new_value);
78
79 size_t ack_frequency_before_ack_decimation() const;
80 void set_ack_frequency_before_ack_decimation(size_t new_value);
81
QUICHE team1dfa46b2019-03-22 10:39:10 -070082 bool supports_multiple_packet_number_spaces() const {
83 return supports_multiple_packet_number_spaces_;
84 }
85
QUICHE teamb23daa72019-03-21 08:37:48 -070086 // For logging purposes.
87 const QuicAckFrame& ack_frame() const;
fayang21ffb712019-05-16 08:39:26 -070088 const QuicAckFrame& GetAckFrame(PacketNumberSpace packet_number_space) const;
QUICHE teamb23daa72019-03-21 08:37:48 -070089
90 void set_max_ack_ranges(size_t max_ack_ranges);
91
92 void set_save_timestamps(bool save_timestamps);
93
94 private:
95 friend class test::QuicConnectionPeer;
96 friend class test::UberReceivedPacketManagerPeer;
97
QUICHE team1dfa46b2019-03-22 10:39:10 -070098 // One received packet manager per packet number space. If
99 // supports_multiple_packet_number_spaces_ is false, only the first (0 index)
100 // received_packet_manager is used.
101 QuicReceivedPacketManager received_packet_managers_[NUM_PACKET_NUMBER_SPACES];
102
103 bool supports_multiple_packet_number_spaces_;
QUICHE teamb23daa72019-03-21 08:37:48 -0700104};
105
106} // namespace quic
107
108#endif // QUICHE_QUIC_CORE_UBER_RECEIVED_PACKET_MANAGER_H_