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/send_algorithm_interface.h" | 16 #include "net/quic/congestion_control/send_algorithm_interface.h" |
17 #include "net/quic/quic_bandwidth.h" | 17 #include "net/quic/quic_bandwidth.h" |
18 #include "net/quic/quic_connection_stats.h" | 18 #include "net/quic/quic_connection_stats.h" |
19 #include "net/quic/quic_protocol.h" | 19 #include "net/quic/quic_protocol.h" |
20 #include "net/quic/quic_time.h" | 20 #include "net/quic/quic_time.h" |
21 | 21 |
22 namespace net { | 22 namespace net { |
23 | 23 |
24 // Default maximum packet size used in Linux TCP implementations. | 24 // Default maximum packet size used in Linux TCP implementations. |
25 const QuicByteCount kDefaultTCPMSS = 1460; | 25 const QuicByteCount kDefaultTCPMSS = 1460; |
26 | 26 |
| 27 class RttStats; |
| 28 |
27 namespace test { | 29 namespace test { |
28 class TcpCubicSenderPeer; | 30 class TcpCubicSenderPeer; |
29 } // namespace test | 31 } // namespace test |
30 | 32 |
31 class NET_EXPORT_PRIVATE TcpCubicSender : public SendAlgorithmInterface { | 33 class NET_EXPORT_PRIVATE TcpCubicSender : public SendAlgorithmInterface { |
32 public: | 34 public: |
33 // Reno option and max_tcp_congestion_window are provided for testing. | 35 // Reno option and max_tcp_congestion_window are provided for testing. |
34 TcpCubicSender(const QuicClock* clock, | 36 TcpCubicSender(const QuicClock* clock, |
| 37 const RttStats* rtt_stats, |
35 bool reno, | 38 bool reno, |
36 QuicTcpCongestionWindow max_tcp_congestion_window, | 39 QuicTcpCongestionWindow max_tcp_congestion_window, |
37 QuicConnectionStats* stats); | 40 QuicConnectionStats* stats); |
38 virtual ~TcpCubicSender(); | 41 virtual ~TcpCubicSender(); |
39 | 42 |
40 // Start implementation of SendAlgorithmInterface. | 43 // Start implementation of SendAlgorithmInterface. |
41 virtual void SetFromConfig(const QuicConfig& config, bool is_server) OVERRIDE; | 44 virtual void SetFromConfig(const QuicConfig& config, bool is_server) OVERRIDE; |
42 virtual void OnIncomingQuicCongestionFeedbackFrame( | 45 virtual void OnIncomingQuicCongestionFeedbackFrame( |
43 const QuicCongestionFeedbackFrame& feedback, | 46 const QuicCongestionFeedbackFrame& feedback, |
44 QuicTime feedback_receive_time) OVERRIDE; | 47 QuicTime feedback_receive_time) OVERRIDE; |
45 virtual void OnPacketAcked(QuicPacketSequenceNumber acked_sequence_number, | 48 virtual void OnPacketAcked(QuicPacketSequenceNumber acked_sequence_number, |
46 QuicByteCount acked_bytes) OVERRIDE; | 49 QuicByteCount acked_bytes) OVERRIDE; |
47 virtual void OnPacketLost(QuicPacketSequenceNumber largest_loss, | 50 virtual void OnPacketLost(QuicPacketSequenceNumber largest_loss, |
48 QuicTime ack_receive_time) OVERRIDE; | 51 QuicTime ack_receive_time) OVERRIDE; |
49 virtual bool OnPacketSent(QuicTime sent_time, | 52 virtual bool OnPacketSent(QuicTime sent_time, |
50 QuicPacketSequenceNumber sequence_number, | 53 QuicPacketSequenceNumber sequence_number, |
51 QuicByteCount bytes, | 54 QuicByteCount bytes, |
52 TransmissionType transmission_type, | 55 TransmissionType transmission_type, |
53 HasRetransmittableData is_retransmittable) OVERRIDE; | 56 HasRetransmittableData is_retransmittable) OVERRIDE; |
54 virtual void OnRetransmissionTimeout(bool packets_retransmitted) OVERRIDE; | 57 virtual void OnRetransmissionTimeout(bool packets_retransmitted) OVERRIDE; |
55 virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number, | 58 virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number, |
56 QuicByteCount abandoned_bytes) OVERRIDE; | 59 QuicByteCount abandoned_bytes) OVERRIDE; |
57 virtual QuicTime::Delta TimeUntilSend( | 60 virtual QuicTime::Delta TimeUntilSend( |
58 QuicTime now, | 61 QuicTime now, |
59 TransmissionType transmission_type, | 62 TransmissionType transmission_type, |
60 HasRetransmittableData has_retransmittable_data, | 63 HasRetransmittableData has_retransmittable_data, |
61 IsHandshake handshake) OVERRIDE; | 64 IsHandshake handshake) OVERRIDE; |
62 virtual QuicBandwidth BandwidthEstimate() const OVERRIDE; | 65 virtual QuicBandwidth BandwidthEstimate() const OVERRIDE; |
63 virtual void UpdateRtt(QuicTime::Delta rtt_sample) OVERRIDE; | 66 virtual void UpdateRtt(QuicTime::Delta rtt_sample) OVERRIDE; |
64 virtual QuicTime::Delta SmoothedRtt() const OVERRIDE; | |
65 virtual QuicTime::Delta RetransmissionDelay() const OVERRIDE; | 67 virtual QuicTime::Delta RetransmissionDelay() const OVERRIDE; |
66 virtual QuicByteCount GetCongestionWindow() const OVERRIDE; | 68 virtual QuicByteCount GetCongestionWindow() const OVERRIDE; |
67 // End implementation of SendAlgorithmInterface. | 69 // End implementation of SendAlgorithmInterface. |
68 | 70 |
69 private: | 71 private: |
70 friend class test::TcpCubicSenderPeer; | 72 friend class test::TcpCubicSenderPeer; |
71 | 73 |
72 QuicByteCount AvailableSendWindow(); | 74 QuicByteCount AvailableSendWindow(); |
73 QuicByteCount SendWindow(); | 75 QuicByteCount SendWindow(); |
74 void Reset(); | |
75 void MaybeIncreaseCwnd(QuicPacketSequenceNumber acked_sequence_number); | 76 void MaybeIncreaseCwnd(QuicPacketSequenceNumber acked_sequence_number); |
76 bool IsCwndLimited() const; | 77 bool IsCwndLimited() const; |
77 bool InRecovery() const; | 78 bool InRecovery() const; |
78 void OnTimeOut(); | |
79 | 79 |
80 HybridSlowStart hybrid_slow_start_; | 80 HybridSlowStart hybrid_slow_start_; |
81 Cubic cubic_; | 81 Cubic cubic_; |
| 82 const RttStats* rtt_stats_; |
82 | 83 |
83 // Reno provided for testing. | 84 // Reno provided for testing. |
84 const bool reno_; | 85 const bool reno_; |
85 | 86 |
86 // ACK counter for the Reno implementation. | 87 // ACK counter for the Reno implementation. |
87 int64 congestion_window_count_; | 88 int64 congestion_window_count_; |
88 | 89 |
89 // Receiver side advertised window. | 90 // Receiver side advertised window. |
90 QuicByteCount receive_window_; | 91 QuicByteCount receive_window_; |
91 | 92 |
(...skipping 23 matching lines...) Expand all Loading... |
115 | 116 |
116 // Congestion window in packets. | 117 // Congestion window in packets. |
117 QuicTcpCongestionWindow congestion_window_; | 118 QuicTcpCongestionWindow congestion_window_; |
118 | 119 |
119 // Slow start congestion window in packets, aka ssthresh. | 120 // Slow start congestion window in packets, aka ssthresh. |
120 QuicTcpCongestionWindow slowstart_threshold_; | 121 QuicTcpCongestionWindow slowstart_threshold_; |
121 | 122 |
122 // Maximum number of outstanding packets for tcp. | 123 // Maximum number of outstanding packets for tcp. |
123 QuicTcpCongestionWindow max_tcp_congestion_window_; | 124 QuicTcpCongestionWindow max_tcp_congestion_window_; |
124 | 125 |
125 // Min RTT during this session. | |
126 QuicTime::Delta delay_min_; | |
127 | |
128 // Smoothed RTT during this session. | |
129 QuicTime::Delta smoothed_rtt_; | |
130 | |
131 // Mean RTT deviation during this session. | |
132 // Approximation of standard deviation, the error is roughly 1.25 times | |
133 // larger than the standard deviation, for a normally distributed signal. | |
134 QuicTime::Delta mean_deviation_; | |
135 | |
136 DISALLOW_COPY_AND_ASSIGN(TcpCubicSender); | 126 DISALLOW_COPY_AND_ASSIGN(TcpCubicSender); |
137 }; | 127 }; |
138 | 128 |
139 } // namespace net | 129 } // namespace net |
140 | 130 |
141 #endif // NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_H_ | 131 #endif // NET_QUIC_CONGESTION_CONTROL_TCP_CUBIC_SENDER_H_ |
OLD | NEW |