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 // Based on the inter arrival time of the received packets relative to the time
6 // those packets where sent we can estimate the available capacity of the
8 // We can only use packet trains that are sent out faster than the acctual
9 // available channel capacity.
10 // Note 1: this is intended to be a temporary class created when you send out a
11 // channel probing burst. Once the last packet have arrived you ask it for an
13 // Note 2: During this phase we should not update the overuse detector.
14 #ifndef NET_QUIC_CONGESTION_CONTROL_AVAILABLE_CHANNEL_ESTIMATOR_H_
15 #define NET_QUIC_CONGESTION_CONTROL_AVAILABLE_CHANNEL_ESTIMATOR_H_
17 #include "base/basictypes.h"
18 #include "net/base/net_export.h"
19 #include "net/quic/quic_bandwidth.h"
20 #include "net/quic/quic_protocol.h"
21 #include "net/quic/quic_time.h"
25 enum NET_EXPORT_PRIVATE AvailableChannelEstimateState
{
26 kAvailableChannelEstimateUnknown
= 0,
27 kAvailableChannelEstimateUncertain
= 1,
28 kAvailableChannelEstimateGood
= 2,
29 kAvailableChannelEstimateSenderLimited
= 3,
32 class NET_EXPORT_PRIVATE AvailableChannelEstimator
{
34 explicit AvailableChannelEstimator(
35 QuicPacketSequenceNumber first_sequence_number
,
36 QuicTime first_send_time
,
37 QuicTime first_receive_time
);
39 // Update the statistics with each receive time, for every packet we get a
40 // feedback message for.
41 void OnIncomingFeedback(QuicPacketSequenceNumber sequence_number
,
42 QuicByteCount packet_size
,
44 QuicTime receive_time
);
46 // Get the current estimated available channel capacity.
47 // bandwidth_estimate is invalid if kAvailableChannelEstimateUnknown
49 AvailableChannelEstimateState
GetAvailableChannelEstimate(
50 QuicBandwidth
* bandwidth_estimate
) const;
53 const QuicPacketSequenceNumber first_sequence_number_
;
54 const QuicTime first_send_time_
;
55 const QuicTime first_receive_time_
;
56 QuicPacketSequenceNumber last_incorporated_sequence_number_
;
57 QuicTime last_time_sent_
;
58 QuicTime last_receive_time_
;
59 int number_of_sequence_numbers_
;
60 QuicByteCount received_bytes_
;
64 #endif // NET_QUIC_CONGESTION_CONTROL_AVAILABLE_CHANNEL_ESTIMATOR_H_