Home | History | Annotate | Download | only in congestion_control
      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.
      4 
      5 // Class that handle the initial probing phase of inter arrival congestion
      6 // control.
      7 #ifndef NET_QUIC_CONGESTION_CONTROL_INTER_ARRIVAL_PROBE_H_
      8 #define NET_QUIC_CONGESTION_CONTROL_INTER_ARRIVAL_PROBE_H_
      9 
     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"
     15 
     16 namespace net {
     17 
     18 class NET_EXPORT_PRIVATE InterArrivalProbe {
     19  public:
     20   InterArrivalProbe();
     21   ~InterArrivalProbe();
     22 
     23   // Call every time a packet is sent to the network.
     24   void OnSentPacket(QuicByteCount bytes);
     25 
     26   // Call once for each sent packet that we receive an acknowledgement from
     27   // the peer for.
     28   void OnAcknowledgedPacket(QuicByteCount bytes);
     29 
     30   // Call to get the number of bytes that can be sent as part of this probe.
     31   QuicByteCount GetAvailableCongestionWindow();
     32 
     33   // Call once for each sent packet we receive a congestion feedback from the
     34   // peer for.
     35   // If a peer sends both and ack and feedback for a sent packet, both
     36   // OnAcknowledgedPacket and OnIncomingFeedback should be called.
     37   void OnIncomingFeedback(QuicPacketSequenceNumber sequence_number,
     38                           QuicByteCount bytes_sent,
     39                           QuicTime time_sent,
     40                           QuicTime time_received);
     41 
     42   // Returns false as long as we are probing, available_channel_estimate is
     43   // invalid during that time. When the probe is completed this function return
     44   // true and available_channel_estimate contains the estimate.
     45   bool GetEstimate(QuicBandwidth* available_channel_estimate);
     46 
     47  private:
     48   scoped_ptr<AvailableChannelEstimator> available_channel_estimator_;
     49   QuicPacketSequenceNumber first_sequence_number_;
     50   bool estimate_available_;
     51   QuicBandwidth available_channel_estimate_;
     52   QuicByteCount unacked_data_;
     53 
     54   DISALLOW_COPY_AND_ASSIGN(InterArrivalProbe);
     55 };
     56 
     57 }  // namespace net
     58 #endif  // NET_QUIC_CONGESTION_CONTROL_INTER_ARRIVAL_PROBE_H_
     59