OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // | 4 // |
5 // TCP cubic send side congestion algorithm, emulates the behavior of | 5 // TCP cubic send side congestion algorithm, emulates the behavior of |
6 // TCP cubic. | 6 // TCP cubic. |
7 | 7 |
8 #ifndef NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_H_ | 8 #ifndef NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_H_ |
9 #define NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_H_ | 9 #define NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_H_ |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
14 #include "net/quic/congestion_control/cubic.h" | 14 #include "net/quic/congestion_control/cubic.h" |
15 #include "net/quic/congestion_control/hybrid_slow_start.h" | 15 #include "net/quic/congestion_control/hybrid_slow_start.h" |
| 16 #include "net/quic/congestion_control/prr_sender.h" |
16 #include "net/quic/congestion_control/send_algorithm_interface.h" | 17 #include "net/quic/congestion_control/send_algorithm_interface.h" |
17 #include "net/quic/quic_bandwidth.h" | 18 #include "net/quic/quic_bandwidth.h" |
18 #include "net/quic/quic_connection_stats.h" | 19 #include "net/quic/quic_connection_stats.h" |
19 #include "net/quic/quic_protocol.h" | 20 #include "net/quic/quic_protocol.h" |
20 #include "net/quic/quic_time.h" | 21 #include "net/quic/quic_time.h" |
21 | 22 |
22 namespace net { | 23 namespace net { |
23 | 24 |
24 class RttStats; | 25 class RttStats; |
25 | 26 |
26 namespace test { | 27 namespace test { |
27 class TcpCubicSenderPeer; | 28 class TcpCubicSenderPeer; |
28 } // namespace test | 29 } // namespace test |
29 | 30 |
30 class NET_EXPORT_PRIVATE TcpCubicSender : public SendAlgorithmInterface { | 31 class NET_EXPORT_PRIVATE TcpCubicSender : public SendAlgorithmInterface { |
31 public: | 32 public: |
32 // Reno option and max_tcp_congestion_window are provided for testing. | 33 // Reno option and max_tcp_congestion_window are provided for testing. |
33 TcpCubicSender(const QuicClock* clock, | 34 TcpCubicSender(const QuicClock* clock, |
34 const RttStats* rtt_stats, | 35 const RttStats* rtt_stats, |
35 bool reno, | 36 bool reno, |
36 QuicTcpCongestionWindow max_tcp_congestion_window, | 37 QuicPacketCount max_tcp_congestion_window, |
37 QuicConnectionStats* stats); | 38 QuicConnectionStats* stats); |
38 ~TcpCubicSender() override; | 39 ~TcpCubicSender() override; |
39 | 40 |
40 // Start implementation of SendAlgorithmInterface. | 41 // Start implementation of SendAlgorithmInterface. |
41 void SetFromConfig(const QuicConfig& config, bool is_server) override; | 42 void SetFromConfig(const QuicConfig& config, bool is_server) override; |
42 void SetNumEmulatedConnections(int num_connections) override; | 43 void SetNumEmulatedConnections(int num_connections) override; |
43 void OnIncomingQuicCongestionFeedbackFrame( | |
44 const QuicCongestionFeedbackFrame& feedback, | |
45 QuicTime feedback_receive_time) override; | |
46 void OnCongestionEvent(bool rtt_updated, | 44 void OnCongestionEvent(bool rtt_updated, |
47 QuicByteCount bytes_in_flight, | 45 QuicByteCount bytes_in_flight, |
48 const CongestionVector& acked_packets, | 46 const CongestionVector& acked_packets, |
49 const CongestionVector& lost_packets) override; | 47 const CongestionVector& lost_packets) override; |
50 bool OnPacketSent(QuicTime sent_time, | 48 bool OnPacketSent(QuicTime sent_time, |
51 QuicByteCount bytes_in_flight, | 49 QuicByteCount bytes_in_flight, |
52 QuicPacketSequenceNumber sequence_number, | 50 QuicPacketSequenceNumber sequence_number, |
53 QuicByteCount bytes, | 51 QuicByteCount bytes, |
54 HasRetransmittableData is_retransmittable) override; | 52 HasRetransmittableData is_retransmittable) override; |
55 void OnRetransmissionTimeout(bool packets_retransmitted) override; | 53 void OnRetransmissionTimeout(bool packets_retransmitted) override; |
(...skipping 16 matching lines...) Expand all Loading... |
72 private: | 70 private: |
73 friend class test::TcpCubicSenderPeer; | 71 friend class test::TcpCubicSenderPeer; |
74 | 72 |
75 // TODO(ianswett): Remove these and migrate to OnCongestionEvent. | 73 // TODO(ianswett): Remove these and migrate to OnCongestionEvent. |
76 void OnPacketAcked(QuicPacketSequenceNumber acked_sequence_number, | 74 void OnPacketAcked(QuicPacketSequenceNumber acked_sequence_number, |
77 QuicByteCount acked_bytes, | 75 QuicByteCount acked_bytes, |
78 QuicByteCount bytes_in_flight); | 76 QuicByteCount bytes_in_flight); |
79 void OnPacketLost(QuicPacketSequenceNumber largest_loss, | 77 void OnPacketLost(QuicPacketSequenceNumber largest_loss, |
80 QuicByteCount bytes_in_flight); | 78 QuicByteCount bytes_in_flight); |
81 | 79 |
82 QuicByteCount SendWindow() const; | |
83 void MaybeIncreaseCwnd(QuicPacketSequenceNumber acked_sequence_number, | 80 void MaybeIncreaseCwnd(QuicPacketSequenceNumber acked_sequence_number, |
84 QuicByteCount bytes_in_flight); | 81 QuicByteCount bytes_in_flight); |
85 bool IsCwndLimited(QuicByteCount bytes_in_flight) const; | 82 bool IsCwndLimited(QuicByteCount bytes_in_flight) const; |
86 // Methods for isolating PRR from the rest of TCP Cubic. | |
87 void PrrOnPacketLost(QuicByteCount bytes_in_flight); | |
88 void PrrOnPacketAcked(QuicByteCount acked_bytes); | |
89 QuicTime::Delta PrrTimeUntilSend(QuicByteCount bytes_in_flight) const; | |
90 | |
91 | 83 |
92 HybridSlowStart hybrid_slow_start_; | 84 HybridSlowStart hybrid_slow_start_; |
93 Cubic cubic_; | 85 Cubic cubic_; |
| 86 PrrSender prr_; |
94 const RttStats* rtt_stats_; | 87 const RttStats* rtt_stats_; |
95 QuicConnectionStats* stats_; | 88 QuicConnectionStats* stats_; |
96 | 89 |
97 // If true, Reno congestion control is used instead of Cubic. | 90 // If true, Reno congestion control is used instead of Cubic. |
98 const bool reno_; | 91 const bool reno_; |
99 | 92 |
100 // Number of connections to simulate. | 93 // Number of connections to simulate. |
101 int num_connections_; | 94 uint32 num_connections_; |
102 | 95 |
103 // ACK counter for the Reno implementation. | 96 // ACK counter for the Reno implementation. |
104 int64 congestion_window_count_; | 97 uint64 congestion_window_count_; |
105 | |
106 // Receiver side advertised window. | |
107 QuicByteCount receive_window_; | |
108 | |
109 // Bytes sent and acked since the last loss event. Used for PRR. | |
110 QuicByteCount prr_out_; | |
111 QuicByteCount prr_delivered_; | |
112 size_t ack_count_since_loss_; | |
113 | |
114 // The congestion window before the last loss event. | |
115 QuicByteCount bytes_in_flight_before_loss_; | |
116 | 98 |
117 // Track the largest packet that has been sent. | 99 // Track the largest packet that has been sent. |
118 QuicPacketSequenceNumber largest_sent_sequence_number_; | 100 QuicPacketSequenceNumber largest_sent_sequence_number_; |
119 | 101 |
120 // Track the largest packet that has been acked. | 102 // Track the largest packet that has been acked. |
121 QuicPacketSequenceNumber largest_acked_sequence_number_; | 103 QuicPacketSequenceNumber largest_acked_sequence_number_; |
122 | 104 |
123 // Track the largest sequence number outstanding when a CWND cutback occurs. | 105 // Track the largest sequence number outstanding when a CWND cutback occurs. |
124 QuicPacketSequenceNumber largest_sent_at_last_cutback_; | 106 QuicPacketSequenceNumber largest_sent_at_last_cutback_; |
125 | 107 |
126 // Congestion window in packets. | 108 // Congestion window in packets. |
127 QuicTcpCongestionWindow congestion_window_; | 109 QuicPacketCount congestion_window_; |
128 | 110 |
129 // Congestion window before the last loss event or RTO. | 111 // Congestion window before the last loss event or RTO. |
130 QuicByteCount previous_congestion_window_; | 112 QuicByteCount previous_congestion_window_; |
131 | 113 |
132 // Slow start congestion window in packets, aka ssthresh. | 114 // Slow start congestion window in packets, aka ssthresh. |
133 QuicTcpCongestionWindow slowstart_threshold_; | 115 QuicPacketCount slowstart_threshold_; |
134 | 116 |
135 // Slow start threshold before the last loss event or RTO. | 117 // Slow start threshold before the last loss event or RTO. |
136 QuicTcpCongestionWindow previous_slowstart_threshold_; | 118 QuicPacketCount previous_slowstart_threshold_; |
137 | 119 |
138 // Whether the last loss event caused us to exit slowstart. | 120 // Whether the last loss event caused us to exit slowstart. |
139 // Used for stats collection of slowstart_packets_lost | 121 // Used for stats collection of slowstart_packets_lost |
140 bool last_cutback_exited_slowstart_; | 122 bool last_cutback_exited_slowstart_; |
141 | 123 |
142 // Maximum number of outstanding packets for tcp. | 124 // Maximum number of outstanding packets for tcp. |
143 QuicTcpCongestionWindow max_tcp_congestion_window_; | 125 QuicPacketCount max_tcp_congestion_window_; |
144 | 126 |
145 DISALLOW_COPY_AND_ASSIGN(TcpCubicSender); | 127 DISALLOW_COPY_AND_ASSIGN(TcpCubicSender); |
146 }; | 128 }; |
147 | 129 |
148 } // namespace net | 130 } // namespace net |
149 | 131 |
150 #endif // NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_H_ | 132 #endif // NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_H_ |
OLD | NEW |