OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | |
5 // TCP cubic send side congestion algorithm, emulates the behavior of | |
6 // TCP cubic. | |
7 | 4 |
8 #ifndef NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_H_ | 5 // TCP cubic send side congestion algorithm, emulates the behavior of TCP cubic. |
9 #define NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_H_ | 6 |
| 7 #ifndef NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_BYTES_SENDER_H_ |
| 8 #define NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_BYTES_SENDER_H_ |
10 | 9 |
11 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | |
13 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
14 #include "net/quic/congestion_control/cubic.h" | 12 #include "net/quic/congestion_control/cubic_bytes.h" |
15 #include "net/quic/congestion_control/hybrid_slow_start.h" | 13 #include "net/quic/congestion_control/hybrid_slow_start.h" |
16 #include "net/quic/congestion_control/prr_sender.h" | 14 #include "net/quic/congestion_control/prr_sender.h" |
17 #include "net/quic/congestion_control/send_algorithm_interface.h" | 15 #include "net/quic/congestion_control/send_algorithm_interface.h" |
18 #include "net/quic/crypto/cached_network_parameters.h" | |
19 #include "net/quic/quic_bandwidth.h" | 16 #include "net/quic/quic_bandwidth.h" |
20 #include "net/quic/quic_connection_stats.h" | 17 #include "net/quic/quic_connection_stats.h" |
21 #include "net/quic/quic_protocol.h" | 18 #include "net/quic/quic_protocol.h" |
22 #include "net/quic/quic_time.h" | 19 #include "net/quic/quic_time.h" |
23 | 20 |
24 namespace net { | 21 namespace net { |
25 | 22 |
26 class RttStats; | 23 class RttStats; |
27 | 24 |
28 namespace test { | 25 namespace test { |
29 class TcpCubicSenderPeer; | 26 class TcpCubicBytesSenderPeer; |
30 } // namespace test | 27 } // namespace test |
31 | 28 |
32 class NET_EXPORT_PRIVATE TcpCubicSender : public SendAlgorithmInterface { | 29 class NET_EXPORT_PRIVATE TcpCubicBytesSender : public SendAlgorithmInterface { |
33 public: | 30 public: |
34 TcpCubicSender(const QuicClock* clock, | 31 TcpCubicBytesSender(const QuicClock* clock, |
35 const RttStats* rtt_stats, | 32 const RttStats* rtt_stats, |
36 bool reno, | 33 bool reno, |
37 QuicPacketCount initial_tcp_congestion_window, | 34 QuicPacketCount initial_tcp_congestion_window, |
38 QuicConnectionStats* stats); | 35 QuicConnectionStats* stats); |
39 ~TcpCubicSender() override; | 36 ~TcpCubicBytesSender() override; |
40 | 37 |
41 // Start implementation of SendAlgorithmInterface. | 38 // Start implementation of SendAlgorithmInterface. |
42 void SetFromConfig(const QuicConfig& config, | 39 void SetFromConfig(const QuicConfig& config, |
43 Perspective perspective, | 40 Perspective perspective, |
44 bool using_pacing) override; | 41 bool using_pacing) override; |
45 bool ResumeConnectionState( | 42 bool ResumeConnectionState( |
46 const CachedNetworkParameters& cached_network_params) override; | 43 const CachedNetworkParameters& cached_network_params) override; |
47 void SetNumEmulatedConnections(int num_connections) override; | 44 void SetNumEmulatedConnections(int num_connections) override; |
48 void OnCongestionEvent(bool rtt_updated, | 45 void OnCongestionEvent(bool rtt_updated, |
49 QuicByteCount bytes_in_flight, | 46 QuicByteCount bytes_in_flight, |
(...skipping 14 matching lines...) Expand all Loading... |
64 bool HasReliableBandwidthEstimate() const override; | 61 bool HasReliableBandwidthEstimate() const override; |
65 QuicTime::Delta RetransmissionDelay() const override; | 62 QuicTime::Delta RetransmissionDelay() const override; |
66 QuicByteCount GetCongestionWindow() const override; | 63 QuicByteCount GetCongestionWindow() const override; |
67 bool InSlowStart() const override; | 64 bool InSlowStart() const override; |
68 bool InRecovery() const override; | 65 bool InRecovery() const override; |
69 QuicByteCount GetSlowStartThreshold() const override; | 66 QuicByteCount GetSlowStartThreshold() const override; |
70 CongestionControlType GetCongestionControlType() const override; | 67 CongestionControlType GetCongestionControlType() const override; |
71 // End implementation of SendAlgorithmInterface. | 68 // End implementation of SendAlgorithmInterface. |
72 | 69 |
73 private: | 70 private: |
74 friend class test::TcpCubicSenderPeer; | 71 friend class test::TcpCubicBytesSenderPeer; |
75 | 72 |
76 // Compute the TCP Reno beta based on the current number of connections. | 73 // Compute the TCP Reno beta based on the current number of connections. |
77 float RenoBeta() const; | 74 float RenoBeta() const; |
78 | 75 |
79 // TODO(ianswett): Remove these and migrate to OnCongestionEvent. | 76 // TODO(ianswett): Remove these and migrate to OnCongestionEvent. |
80 void OnPacketAcked(QuicPacketSequenceNumber acked_sequence_number, | 77 void OnPacketAcked(QuicPacketSequenceNumber acked_sequence_number, |
81 QuicByteCount acked_bytes, | 78 QuicByteCount acked_bytes, |
82 QuicByteCount bytes_in_flight); | 79 QuicByteCount bytes_in_flight); |
83 void OnPacketLost(QuicPacketSequenceNumber largest_loss, | 80 void OnPacketLost(QuicPacketSequenceNumber largest_loss, |
84 QuicByteCount bytes_in_flight); | 81 QuicByteCount bytes_in_flight); |
85 | 82 |
86 void MaybeIncreaseCwnd(QuicPacketSequenceNumber acked_sequence_number, | 83 void MaybeIncreaseCwnd(QuicPacketSequenceNumber acked_sequence_number, |
| 84 QuicByteCount acked_bytes, |
87 QuicByteCount bytes_in_flight); | 85 QuicByteCount bytes_in_flight); |
88 bool IsCwndLimited(QuicByteCount bytes_in_flight) const; | 86 bool IsCwndLimited(QuicByteCount bytes_in_flight) const; |
89 | 87 |
90 HybridSlowStart hybrid_slow_start_; | 88 HybridSlowStart hybrid_slow_start_; |
91 Cubic cubic_; | 89 CubicBytes cubic_; |
92 PrrSender prr_; | 90 PrrSender prr_; |
93 const RttStats* rtt_stats_; | 91 const RttStats* rtt_stats_; |
94 QuicConnectionStats* stats_; | 92 QuicConnectionStats* stats_; |
95 | 93 |
96 // If true, Reno congestion control is used instead of Cubic. | 94 // If true, Reno congestion control is used instead of Cubic. |
97 const bool reno_; | 95 const bool reno_; |
98 | 96 |
99 // Number of connections to simulate. | 97 // Number of connections to simulate. |
100 uint32 num_connections_; | 98 uint32 num_connections_; |
101 | 99 |
102 // ACK counter for the Reno implementation. | 100 // ACK counter for the Reno implementation. |
103 uint64 num_acked_packets_; | 101 uint64 num_acked_packets_; |
104 | 102 |
105 // Track the largest packet that has been sent. | 103 // Track the largest packet that has been sent. |
106 QuicPacketSequenceNumber largest_sent_sequence_number_; | 104 QuicPacketSequenceNumber largest_sent_sequence_number_; |
107 | 105 |
108 // Track the largest packet that has been acked. | 106 // Track the largest packet that has been acked. |
109 QuicPacketSequenceNumber largest_acked_sequence_number_; | 107 QuicPacketSequenceNumber largest_acked_sequence_number_; |
110 | 108 |
111 // Track the largest sequence number outstanding when a CWND cutback occurs. | 109 // Track the largest sequence number outstanding when a CWND cutback occurs. |
112 QuicPacketSequenceNumber largest_sent_at_last_cutback_; | 110 QuicPacketSequenceNumber largest_sent_at_last_cutback_; |
113 | 111 |
114 // Congestion window in packets. | 112 // Congestion window in bytes. |
115 QuicPacketCount congestion_window_; | 113 QuicByteCount congestion_window_; |
116 | 114 |
117 // Slow start congestion window in packets, aka ssthresh. | 115 // Slow start congestion window in bytes, aka ssthresh. |
118 QuicPacketCount slowstart_threshold_; | 116 QuicByteCount slowstart_threshold_; |
119 | 117 |
120 // Whether the last loss event caused us to exit slowstart. | 118 // Whether the last loss event caused us to exit slowstart. Used for stats |
121 // Used for stats collection of slowstart_packets_lost | 119 // collection of slowstart_packets_lost. |
122 bool last_cutback_exited_slowstart_; | 120 bool last_cutback_exited_slowstart_; |
123 | 121 |
124 const QuicClock* clock_; | 122 const QuicClock* clock_; |
125 | 123 |
126 DISALLOW_COPY_AND_ASSIGN(TcpCubicSender); | 124 DISALLOW_COPY_AND_ASSIGN(TcpCubicBytesSender); |
127 }; | 125 }; |
128 | 126 |
129 } // namespace net | 127 } // namespace net |
130 | 128 |
131 #endif // NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_H_ | 129 #endif // NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_BYTES_SENDER_H_ |
OLD | NEW |