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 #include "net/quic/congestion_control/tcp_cubic_sender.h" | 5 #include "net/quic/congestion_control/tcp_cubic_sender.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "net/quic/congestion_control/rtt_stats.h" | 10 #include "net/quic/congestion_control/rtt_stats.h" |
11 #include "net/quic/crypto/crypto_protocol.h" | 11 #include "net/quic/crypto/crypto_protocol.h" |
12 | 12 |
13 using std::max; | 13 using std::max; |
14 using std::min; | 14 using std::min; |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 namespace { | 18 namespace { |
19 // Constants based on TCP defaults. | 19 // Constants based on TCP defaults. |
20 // The minimum cwnd based on RFC 3782 (TCP NewReno) for cwnd reductions on a | 20 // The minimum cwnd based on RFC 3782 (TCP NewReno) for cwnd reductions on a |
21 // fast retransmission. The cwnd after a timeout is still 1. | 21 // fast retransmission. The cwnd after a timeout is still 1. |
22 const QuicTcpCongestionWindow kMinimumCongestionWindow = 2; | 22 const QuicTcpCongestionWindow kMinimumCongestionWindow = 2; |
23 const QuicByteCount kMaxSegmentSize = kDefaultTCPMSS; | 23 const QuicByteCount kMaxSegmentSize = kDefaultTCPMSS; |
24 const QuicByteCount kDefaultReceiveWindow = 64000; | |
25 const int64 kInitialCongestionWindow = 10; | 24 const int64 kInitialCongestionWindow = 10; |
26 const int kMaxBurstLength = 3; | 25 const int kMaxBurstLength = 3; |
27 }; // namespace | 26 }; // namespace |
28 | 27 |
29 TcpCubicSender::TcpCubicSender( | 28 TcpCubicSender::TcpCubicSender( |
30 const QuicClock* clock, | 29 const QuicClock* clock, |
31 const RttStats* rtt_stats, | 30 const RttStats* rtt_stats, |
32 bool reno, | 31 bool reno, |
33 QuicTcpCongestionWindow max_tcp_congestion_window, | 32 QuicTcpCongestionWindow max_tcp_congestion_window, |
34 QuicConnectionStats* stats) | 33 QuicConnectionStats* stats) |
35 : hybrid_slow_start_(clock), | 34 : hybrid_slow_start_(clock), |
36 cubic_(clock, stats), | 35 cubic_(clock, stats), |
37 rtt_stats_(rtt_stats), | 36 rtt_stats_(rtt_stats), |
38 stats_(stats), | 37 stats_(stats), |
39 reno_(reno), | 38 reno_(reno), |
40 congestion_window_count_(0), | 39 congestion_window_count_(0), |
41 receive_window_(kDefaultReceiveWindow), | 40 receive_window_(kDefaultSocketReceiveBuffer), |
42 prr_out_(0), | 41 prr_out_(0), |
43 prr_delivered_(0), | 42 prr_delivered_(0), |
44 ack_count_since_loss_(0), | 43 ack_count_since_loss_(0), |
45 bytes_in_flight_before_loss_(0), | 44 bytes_in_flight_before_loss_(0), |
46 largest_sent_sequence_number_(0), | 45 largest_sent_sequence_number_(0), |
47 largest_acked_sequence_number_(0), | 46 largest_acked_sequence_number_(0), |
48 largest_sent_at_last_cutback_(0), | 47 largest_sent_at_last_cutback_(0), |
49 congestion_window_(kInitialCongestionWindow), | 48 congestion_window_(kInitialCongestionWindow), |
50 previous_congestion_window_(0), | 49 previous_congestion_window_(0), |
51 slowstart_threshold_(max_tcp_congestion_window), | 50 slowstart_threshold_(max_tcp_congestion_window), |
(...skipping 13 matching lines...) Expand all Loading... |
65 // Initial window experiment. Ignore the initial congestion | 64 // Initial window experiment. Ignore the initial congestion |
66 // window suggested by the client and use the default ICWND of | 65 // window suggested by the client and use the default ICWND of |
67 // 10 instead. | 66 // 10 instead. |
68 congestion_window_ = kInitialCongestionWindow; | 67 congestion_window_ = kInitialCongestionWindow; |
69 } else if (config.HasReceivedInitialCongestionWindow()) { | 68 } else if (config.HasReceivedInitialCongestionWindow()) { |
70 // Set the initial window size. | 69 // Set the initial window size. |
71 congestion_window_ = min(kMaxInitialWindow, | 70 congestion_window_ = min(kMaxInitialWindow, |
72 config.ReceivedInitialCongestionWindow()); | 71 config.ReceivedInitialCongestionWindow()); |
73 } | 72 } |
74 } | 73 } |
| 74 if (config.HasReceivedSocketReceiveBuffer()) { |
| 75 // Set the initial socket receive buffer size in bytes. |
| 76 receive_window_ = config.ReceivedSocketReceiveBuffer(); |
| 77 } |
75 } | 78 } |
76 | 79 |
77 void TcpCubicSender::OnIncomingQuicCongestionFeedbackFrame( | 80 void TcpCubicSender::OnIncomingQuicCongestionFeedbackFrame( |
78 const QuicCongestionFeedbackFrame& feedback, | 81 const QuicCongestionFeedbackFrame& feedback, |
79 QuicTime feedback_receive_time) { | 82 QuicTime feedback_receive_time) { |
80 if (feedback.type == kTCP) { | 83 if (feedback.type == kTCP) { |
81 receive_window_ = feedback.tcp.receive_window; | 84 receive_window_ = feedback.tcp.receive_window; |
82 } | 85 } |
83 } | 86 } |
84 | 87 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 return QuicTime::Delta::Zero(); | 357 return QuicTime::Delta::Zero(); |
355 } | 358 } |
356 return QuicTime::Delta::Infinite(); | 359 return QuicTime::Delta::Infinite(); |
357 } | 360 } |
358 | 361 |
359 CongestionControlType TcpCubicSender::GetCongestionControlType() const { | 362 CongestionControlType TcpCubicSender::GetCongestionControlType() const { |
360 return reno_ ? kReno : kCubic; | 363 return reno_ ? kReno : kCubic; |
361 } | 364 } |
362 | 365 |
363 } // namespace net | 366 } // namespace net |
OLD | NEW |