1 // Copyright (c) 2013 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.
5 // Class that handle the initial probing phase of inter arrival congestion
7 #ifndef NET_QUIC_CONGESTION_CONTROL_INTER_ARRIVAL_PROBE_H_
8 #define NET_QUIC_CONGESTION_CONTROL_INTER_ARRIVAL_PROBE_H_
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "net/base/net_export.h"
13 #include "net/quic/congestion_control/available_channel_estimator.h"
14 #include "net/quic/quic_bandwidth.h"
18 class NET_EXPORT_PRIVATE InterArrivalProbe {
20 explicit InterArrivalProbe(QuicByteCount max_segment_size);
23 void set_max_segment_size(QuicByteCount max_segment_size);
25 // Call every time a packet is sent to the network.
26 void OnPacketSent(QuicByteCount bytes);
28 // Call once for each sent packet that we receive an acknowledgement from
30 void OnAcknowledgedPacket(QuicByteCount bytes);
32 // Call to get the number of bytes that can be sent as part of this probe.
33 QuicByteCount GetAvailableCongestionWindow();
35 // Call once for each sent packet we receive a congestion feedback from the
37 // If a peer sends both and ack and feedback for a sent packet, both
38 // OnAcknowledgedPacket and OnIncomingFeedback should be called.
39 void OnIncomingFeedback(QuicPacketSequenceNumber sequence_number,
40 QuicByteCount bytes_sent,
42 QuicTime time_received);
44 // Returns false as long as we are probing, available_channel_estimate is
45 // invalid during that time. When the probe is completed this function return
46 // true and available_channel_estimate contains the estimate.
47 bool GetEstimate(QuicBandwidth* available_channel_estimate);
50 QuicByteCount max_segment_size_;
51 scoped_ptr<AvailableChannelEstimator> available_channel_estimator_;
52 QuicPacketSequenceNumber first_sequence_number_;
53 bool estimate_available_;
54 QuicBandwidth available_channel_estimate_;
55 QuicByteCount unacked_data_;
57 DISALLOW_COPY_AND_ASSIGN(InterArrivalProbe);
61 #endif // NET_QUIC_CONGESTION_CONTROL_INTER_ARRIVAL_PROBE_H_