1 // Copyright (c) 2020 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_FRAMES_QUIC_ACK_FREQUENCY_FRAME_H_
6 #define QUICHE_QUIC_CORE_FRAMES_QUIC_ACK_FREQUENCY_FRAME_H_
7 
8 #include <cstdint>
9 #include <ostream>
10 
11 #include "net/third_party/quiche/src/quic/core/quic_constants.h"
12 #include "net/third_party/quiche/src/quic/core/quic_time.h"
13 #include "net/third_party/quiche/src/quic/core/quic_types.h"
14 #include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
15 
16 namespace quic {
17 
18 // A frame that allows sender control of acknowledgement delays.
19 struct QUIC_EXPORT_PRIVATE QuicAckFrequencyFrame {
20   friend QUIC_EXPORT_PRIVATE std::ostream& operator<<(
21       std::ostream& os,
22       const QuicAckFrequencyFrame& ack_frequency_frame);
23 
24   QuicAckFrequencyFrame() = default;
25   QuicAckFrequencyFrame(QuicControlFrameId control_frame_id,
26                         uint64_t sequence_number,
27                         uint64_t packet_tolerance,
28                         QuicTime::Delta max_ack_delay);
29 
30   // A unique identifier of this control frame. 0 when this frame is
31   // received, and non-zero when sent.
32   QuicControlFrameId control_frame_id = kInvalidControlFrameId;
33 
34   // If true, do not ack immediately upon observeation of packet reordering.
35   bool ignore_order = false;
36 
37   // Sequence number assigned to the ACK_FREQUENCY frame by the sender to allow
38   // receivers to ignore obsolete frames.
39   uint64_t sequence_number = 0;
40 
41   // The maximum number of ack-eliciting packets after which the receiver sends
42   // an acknowledgement. Invald if == 0.
43   uint64_t packet_tolerance = 2;
44 
45   // The maximum time that ack packets can be delayed.
46   QuicTime::Delta max_ack_delay =
47       QuicTime::Delta::FromMilliseconds(kDefaultDelayedAckTimeMs);
48 };
49 
50 }  // namespace quic
51 
52 #endif  // QUICHE_QUIC_CORE_FRAMES_QUIC_ACK_FREQUENCY_FRAME_H_
53