summaryrefslogtreecommitdiff
path: root/chromium/net/quic/congestion_control/inter_arrival_probe.h
blob: 5788a68a926da04c0a941d46b881555d7749fa4e (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) 2013 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.

// Class that handle the initial probing phase of inter arrival congestion
// control.
#ifndef NET_QUIC_CONGESTION_CONTROL_INTER_ARRIVAL_PROBE_H_
#define NET_QUIC_CONGESTION_CONTROL_INTER_ARRIVAL_PROBE_H_

#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "net/base/net_export.h"
#include "net/quic/congestion_control/available_channel_estimator.h"
#include "net/quic/quic_bandwidth.h"

namespace net {

class NET_EXPORT_PRIVATE InterArrivalProbe {
 public:
  InterArrivalProbe();
  ~InterArrivalProbe();

  // Call every time a packet is sent to the network.
  void OnSentPacket(QuicByteCount bytes);

  // Call once for each sent packet that we receive an acknowledgement from
  // the peer for.
  void OnAcknowledgedPacket(QuicByteCount bytes);

  // Call to get the number of bytes that can be sent as part of this probe.
  QuicByteCount GetAvailableCongestionWindow();

  // Call once for each sent packet we receive a congestion feedback from the
  // peer for.
  // If a peer sends both and ack and feedback for a sent packet, both
  // OnAcknowledgedPacket and OnIncomingFeedback should be called.
  void OnIncomingFeedback(QuicPacketSequenceNumber sequence_number,
                          QuicByteCount bytes_sent,
                          QuicTime time_sent,
                          QuicTime time_received);

  // Returns false as long as we are probing, available_channel_estimate is
  // invalid during that time. When the probe is completed this function return
  // true and available_channel_estimate contains the estimate.
  bool GetEstimate(QuicBandwidth* available_channel_estimate);

 private:
  scoped_ptr<AvailableChannelEstimator> available_channel_estimator_;
  QuicPacketSequenceNumber first_sequence_number_;
  bool estimate_available_;
  QuicBandwidth available_channel_estimate_;
  QuicByteCount unacked_data_;

  DISALLOW_COPY_AND_ASSIGN(InterArrivalProbe);
};

}  // namespace net
#endif  // NET_QUIC_CONGESTION_CONTROL_INTER_ARRIVAL_PROBE_H_