summaryrefslogtreecommitdiffstats
path: root/net/quic/congestion_control/prr_sender.h
blob: df73a9fbc6be56f85cebcffce03831e85f0a18eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Implements Proportional Rate Reduction (PRR) per RFC 6937.

#ifndef NET_QUIC_CONGESTION_CONTROL_PRR_SENDER_H_
#define NET_QUIC_CONGESTION_CONTROL_PRR_SENDER_H_

#include <stddef.h>

#include "net/quic/quic_bandwidth.h"
#include "net/quic/quic_time.h"

namespace net {

class NET_EXPORT_PRIVATE PrrSender {
 public:
  PrrSender();
  // OnPacketLost should be called on the first loss that triggers a recovery
  // period and all other methods in this class should only be called when in
  // recovery.
  void OnPacketLost(QuicByteCount bytes_in_flight);
  void OnPacketSent(QuicByteCount sent_bytes);
  void OnPacketAcked(QuicByteCount acked_bytes);
  QuicTime::Delta TimeUntilSend(QuicByteCount congestion_window,
                                QuicByteCount bytes_in_flight,
                                QuicByteCount slowstart_threshold) const;

 private:
  // Bytes sent and acked since the last loss event.
  // |bytes_sent_since_loss_| is the same as "prr_out_" in RFC 6937,
  // and |bytes_delivered_since_loss_| is the same as "prr_delivered_".
  QuicByteCount bytes_sent_since_loss_;
  QuicByteCount bytes_delivered_since_loss_;
  size_t ack_count_since_loss_;

  // The congestion window before the last loss event.
  QuicByteCount bytes_in_flight_before_loss_;
};

}  // namespace net

#endif  // NET_QUIC_CONGESTION_CONTROL_PRR_SENDER_H_