Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / net / quic / congestion_control / tcp_cubic_sender.h
index 3f5baa3..7491565 100644 (file)
@@ -13,6 +13,7 @@
 #include "net/base/net_export.h"
 #include "net/quic/congestion_control/cubic.h"
 #include "net/quic/congestion_control/hybrid_slow_start.h"
+#include "net/quic/congestion_control/prr_sender.h"
 #include "net/quic/congestion_control/send_algorithm_interface.h"
 #include "net/quic/quic_bandwidth.h"
 #include "net/quic/quic_connection_stats.h"
@@ -33,43 +34,45 @@ class NET_EXPORT_PRIVATE TcpCubicSender : public SendAlgorithmInterface {
   TcpCubicSender(const QuicClock* clock,
                  const RttStats* rtt_stats,
                  bool reno,
-                 QuicTcpCongestionWindow max_tcp_congestion_window,
+                 QuicPacketCount max_tcp_congestion_window,
                  QuicConnectionStats* stats);
-  virtual ~TcpCubicSender();
+  ~TcpCubicSender() override;
 
   // Start implementation of SendAlgorithmInterface.
-  virtual void SetFromConfig(const QuicConfig& config, bool is_server) OVERRIDE;
-  virtual void OnIncomingQuicCongestionFeedbackFrame(
-      const QuicCongestionFeedbackFrame& feedback,
-      QuicTime feedback_receive_time) OVERRIDE;
-  virtual void OnCongestionEvent(bool rtt_updated,
-                                 QuicByteCount bytes_in_flight,
-                                 const CongestionVector& acked_packets,
-                                 const CongestionVector& lost_packets) OVERRIDE;
-  virtual bool OnPacketSent(QuicTime sent_time,
-                            QuicByteCount bytes_in_flight,
-                            QuicPacketSequenceNumber sequence_number,
-                            QuicByteCount bytes,
-                            HasRetransmittableData is_retransmittable) OVERRIDE;
-  virtual void OnRetransmissionTimeout(bool packets_retransmitted) OVERRIDE;
-  virtual void RevertRetransmissionTimeout() OVERRIDE;
-  virtual QuicTime::Delta TimeUntilSend(
+  void SetFromConfig(const QuicConfig& config, bool is_server) override;
+  void SetNumEmulatedConnections(int num_connections) override;
+  void OnCongestionEvent(bool rtt_updated,
+                         QuicByteCount bytes_in_flight,
+                         const CongestionVector& acked_packets,
+                         const CongestionVector& lost_packets) override;
+  bool OnPacketSent(QuicTime sent_time,
+                    QuicByteCount bytes_in_flight,
+                    QuicPacketSequenceNumber sequence_number,
+                    QuicByteCount bytes,
+                    HasRetransmittableData is_retransmittable) override;
+  void OnRetransmissionTimeout(bool packets_retransmitted) override;
+  void RevertRetransmissionTimeout() override;
+  QuicTime::Delta TimeUntilSend(
       QuicTime now,
       QuicByteCount bytes_in_flight,
-      HasRetransmittableData has_retransmittable_data) const OVERRIDE;
-  virtual QuicBandwidth BandwidthEstimate() const OVERRIDE;
-  virtual bool HasReliableBandwidthEstimate() const OVERRIDE;
-  virtual QuicTime::Delta RetransmissionDelay() const OVERRIDE;
-  virtual QuicByteCount GetCongestionWindow() const OVERRIDE;
-  virtual bool InSlowStart() const OVERRIDE;
-  virtual bool InRecovery() const OVERRIDE;
-  virtual QuicByteCount GetSlowStartThreshold() const OVERRIDE;
-  virtual CongestionControlType GetCongestionControlType() const OVERRIDE;
+      HasRetransmittableData has_retransmittable_data) const override;
+  QuicBandwidth PacingRate() const override;
+  QuicBandwidth BandwidthEstimate() const override;
+  bool HasReliableBandwidthEstimate() const override;
+  QuicTime::Delta RetransmissionDelay() const override;
+  QuicByteCount GetCongestionWindow() const override;
+  bool InSlowStart() const override;
+  bool InRecovery() const override;
+  QuicByteCount GetSlowStartThreshold() const override;
+  CongestionControlType GetCongestionControlType() const override;
   // End implementation of SendAlgorithmInterface.
 
  private:
   friend class test::TcpCubicSenderPeer;
 
+  // Compute the TCP Reno beta based on the current number of connections.
+  float RenoBeta() const;
+
   // TODO(ianswett): Remove these and migrate to OnCongestionEvent.
   void OnPacketAcked(QuicPacketSequenceNumber acked_sequence_number,
                      QuicByteCount acked_bytes,
@@ -77,37 +80,24 @@ class NET_EXPORT_PRIVATE TcpCubicSender : public SendAlgorithmInterface {
   void OnPacketLost(QuicPacketSequenceNumber largest_loss,
                     QuicByteCount bytes_in_flight);
 
-  QuicByteCount SendWindow() const;
   void MaybeIncreaseCwnd(QuicPacketSequenceNumber acked_sequence_number,
                          QuicByteCount bytes_in_flight);
   bool IsCwndLimited(QuicByteCount bytes_in_flight) const;
-  // Methods for isolating PRR from the rest of TCP Cubic.
-  void PrrOnPacketLost(QuicByteCount bytes_in_flight);
-  void PrrOnPacketAcked(QuicByteCount acked_bytes);
-  QuicTime::Delta PrrTimeUntilSend(QuicByteCount bytes_in_flight) const;
-
 
   HybridSlowStart hybrid_slow_start_;
   Cubic cubic_;
+  PrrSender prr_;
   const RttStats* rtt_stats_;
   QuicConnectionStats* stats_;
 
-  // Reno provided for testing.
+  // If true, Reno congestion control is used instead of Cubic.
   const bool reno_;
 
-  // ACK counter for the Reno implementation.
-  int64 congestion_window_count_;
-
-  // Receiver side advertised window.
-  QuicByteCount receive_window_;
-
-  // Bytes sent and acked since the last loss event.  Used for PRR.
-  QuicByteCount prr_out_;
-  QuicByteCount prr_delivered_;
-  size_t ack_count_since_loss_;
+  // Number of connections to simulate.
+  uint32 num_connections_;
 
-  // The congestion window before the last loss event.
-  QuicByteCount bytes_in_flight_before_loss_;
+  // ACK counter for the Reno implementation.
+  uint64 congestion_window_count_;
 
   // Track the largest packet that has been sent.
   QuicPacketSequenceNumber largest_sent_sequence_number_;
@@ -119,23 +109,23 @@ class NET_EXPORT_PRIVATE TcpCubicSender : public SendAlgorithmInterface {
   QuicPacketSequenceNumber largest_sent_at_last_cutback_;
 
   // Congestion window in packets.
-  QuicTcpCongestionWindow congestion_window_;
+  QuicPacketCount congestion_window_;
 
   // Congestion window before the last loss event or RTO.
   QuicByteCount previous_congestion_window_;
 
   // Slow start congestion window in packets, aka ssthresh.
-  QuicTcpCongestionWindow slowstart_threshold_;
+  QuicPacketCount slowstart_threshold_;
 
   // Slow start threshold before the last loss event or RTO.
-  QuicTcpCongestionWindow previous_slowstart_threshold_;
+  QuicPacketCount previous_slowstart_threshold_;
 
   // Whether the last loss event caused us to exit slowstart.
   // Used for stats collection of slowstart_packets_lost
   bool last_cutback_exited_slowstart_;
 
   // Maximum number of outstanding packets for tcp.
-  QuicTcpCongestionWindow max_tcp_congestion_window_;
+  QuicPacketCount max_tcp_congestion_window_;
 
   DISALLOW_COPY_AND_ASSIGN(TcpCubicSender);
 };