| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015 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 // TCP cubic send side congestion algorithm, emulates the behavior of TCP cubic. | |
| 6 | |
| 7 #ifndef NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_BYTES_SENDER_H_ | |
| 8 #define NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_BYTES_SENDER_H_ | |
| 9 | |
| 10 #include <stdint.h> | |
| 11 | |
| 12 #include "base/macros.h" | |
| 13 #include "net/base/net_export.h" | |
| 14 #include "net/quic/congestion_control/cubic_bytes.h" | |
| 15 #include "net/quic/congestion_control/hybrid_slow_start.h" | |
| 16 #include "net/quic/congestion_control/prr_sender.h" | |
| 17 #include "net/quic/congestion_control/send_algorithm_interface.h" | |
| 18 #include "net/quic/quic_bandwidth.h" | |
| 19 #include "net/quic/quic_connection_stats.h" | |
| 20 #include "net/quic/quic_protocol.h" | |
| 21 #include "net/quic/quic_time.h" | |
| 22 | |
| 23 namespace net { | |
| 24 | |
| 25 class RttStats; | |
| 26 | |
| 27 namespace test { | |
| 28 class TcpCubicBytesSenderPeer; | |
| 29 } // namespace test | |
| 30 | |
| 31 class NET_EXPORT_PRIVATE TcpCubicBytesSender : public SendAlgorithmInterface { | |
| 32 public: | |
| 33 TcpCubicBytesSender(const QuicClock* clock, | |
| 34 const RttStats* rtt_stats, | |
| 35 bool reno, | |
| 36 QuicPacketCount initial_tcp_congestion_window, | |
| 37 QuicPacketCount max_congestion_window, | |
| 38 QuicConnectionStats* stats); | |
| 39 ~TcpCubicBytesSender() override; | |
| 40 | |
| 41 // Start implementation of SendAlgorithmInterface. | |
| 42 void SetFromConfig(const QuicConfig& config, | |
| 43 Perspective perspective) override; | |
| 44 void ResumeConnectionState( | |
| 45 const CachedNetworkParameters& cached_network_params, | |
| 46 bool max_bandwidth_resumption) override; | |
| 47 void SetNumEmulatedConnections(int num_connections) override; | |
| 48 void SetMaxCongestionWindow(QuicByteCount max_congestion_window) override; | |
| 49 void OnCongestionEvent(bool rtt_updated, | |
| 50 QuicByteCount bytes_in_flight, | |
| 51 const CongestionVector& acked_packets, | |
| 52 const CongestionVector& lost_packets) override; | |
| 53 bool OnPacketSent(QuicTime sent_time, | |
| 54 QuicByteCount bytes_in_flight, | |
| 55 QuicPacketNumber packet_number, | |
| 56 QuicByteCount bytes, | |
| 57 HasRetransmittableData is_retransmittable) override; | |
| 58 void OnRetransmissionTimeout(bool packets_retransmitted) override; | |
| 59 void OnConnectionMigration() override; | |
| 60 QuicTime::Delta TimeUntilSend( | |
| 61 QuicTime now, | |
| 62 QuicByteCount bytes_in_flight, | |
| 63 HasRetransmittableData has_retransmittable_data) const override; | |
| 64 QuicBandwidth PacingRate() const override; | |
| 65 QuicBandwidth BandwidthEstimate() const override; | |
| 66 QuicTime::Delta RetransmissionDelay() const override; | |
| 67 QuicByteCount GetCongestionWindow() const override; | |
| 68 bool InSlowStart() const override; | |
| 69 bool InRecovery() const override; | |
| 70 QuicByteCount GetSlowStartThreshold() const override; | |
| 71 CongestionControlType GetCongestionControlType() const override; | |
| 72 // End implementation of SendAlgorithmInterface. | |
| 73 | |
| 74 private: | |
| 75 friend class test::TcpCubicBytesSenderPeer; | |
| 76 | |
| 77 // Compute the TCP Reno beta based on the current number of connections. | |
| 78 float RenoBeta() const; | |
| 79 | |
| 80 // TODO(ianswett): Remove these and migrate to OnCongestionEvent. | |
| 81 void OnPacketAcked(QuicPacketNumber acked_packet_number, | |
| 82 QuicByteCount acked_bytes, | |
| 83 QuicByteCount bytes_in_flight); | |
| 84 void OnPacketLost(QuicPacketNumber largest_loss, | |
| 85 QuicByteCount bytes_in_flight); | |
| 86 | |
| 87 void MaybeIncreaseCwnd(QuicPacketNumber acked_packet_number, | |
| 88 QuicByteCount acked_bytes, | |
| 89 QuicByteCount bytes_in_flight); | |
| 90 bool IsCwndLimited(QuicByteCount bytes_in_flight) const; | |
| 91 | |
| 92 HybridSlowStart hybrid_slow_start_; | |
| 93 CubicBytes cubic_; | |
| 94 PrrSender prr_; | |
| 95 const RttStats* rtt_stats_; | |
| 96 QuicConnectionStats* stats_; | |
| 97 | |
| 98 // If true, Reno congestion control is used instead of Cubic. | |
| 99 const bool reno_; | |
| 100 | |
| 101 // Number of connections to simulate. | |
| 102 uint32_t num_connections_; | |
| 103 | |
| 104 // ACK counter for the Reno implementation. | |
| 105 uint64_t num_acked_packets_; | |
| 106 | |
| 107 // Track the largest packet that has been sent. | |
| 108 QuicPacketNumber largest_sent_packet_number_; | |
| 109 | |
| 110 // Track the largest packet that has been acked. | |
| 111 QuicPacketNumber largest_acked_packet_number_; | |
| 112 | |
| 113 // Track the largest packet number outstanding when a CWND cutback occurs. | |
| 114 QuicPacketNumber largest_sent_at_last_cutback_; | |
| 115 | |
| 116 // Congestion window in bytes. | |
| 117 QuicByteCount congestion_window_; | |
| 118 | |
| 119 // Minimum congestion window in bytes. | |
| 120 QuicByteCount min_congestion_window_; | |
| 121 | |
| 122 // Whether to use 4 packets as the actual min, but pace lower. | |
| 123 bool min4_mode_; | |
| 124 | |
| 125 // Maximum congestion window in bytes. | |
| 126 QuicByteCount max_congestion_window_; | |
| 127 | |
| 128 // Slow start congestion window in bytes, aka ssthresh. | |
| 129 QuicByteCount slowstart_threshold_; | |
| 130 | |
| 131 // Whether the last loss event caused us to exit slowstart. Used for stats | |
| 132 // collection of slowstart_packets_lost. | |
| 133 bool last_cutback_exited_slowstart_; | |
| 134 | |
| 135 // Initial TCP congestion window in bytes. This variable can only be set when | |
| 136 // this algorithm is created. | |
| 137 const QuicByteCount initial_tcp_congestion_window_; | |
| 138 | |
| 139 // Initial maximum TCP congestion window in bytes. This variable can only be | |
| 140 // set when this algorithm is created. | |
| 141 const QuicByteCount initial_max_tcp_congestion_window_; | |
| 142 | |
| 143 // When true, exit slow start with large cutback of congestion window. | |
| 144 bool slow_start_large_reduction_; | |
| 145 | |
| 146 DISALLOW_COPY_AND_ASSIGN(TcpCubicBytesSender); | |
| 147 }; | |
| 148 | |
| 149 } // namespace net | |
| 150 | |
| 151 #endif // NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_BYTES_SENDER_H_ | |
| OLD | NEW |