Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: net/quic/congestion_control/tcp_cubic_sender.cc

Issue 693943003: Update from https://crrev.com/302630 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/prr_sender.h" 10 #include "net/quic/congestion_control/prr_sender.h"
11 #include "net/quic/congestion_control/rtt_stats.h" 11 #include "net/quic/congestion_control/rtt_stats.h"
12 #include "net/quic/crypto/crypto_protocol.h" 12 #include "net/quic/crypto/crypto_protocol.h"
13 13
14 using std::max; 14 using std::max;
15 using std::min; 15 using std::min;
16 16
17 namespace net { 17 namespace net {
18 18
19 namespace { 19 namespace {
20 // Constants based on TCP defaults. 20 // Constants based on TCP defaults.
21 // The minimum cwnd based on RFC 3782 (TCP NewReno) for cwnd reductions on a 21 // The minimum cwnd based on RFC 3782 (TCP NewReno) for cwnd reductions on a
22 // fast retransmission. The cwnd after a timeout is still 1. 22 // fast retransmission. The cwnd after a timeout is still 1.
23 const QuicPacketCount kMinimumCongestionWindow = 2; 23 const QuicPacketCount kMinimumCongestionWindow = 2;
24 const QuicByteCount kMaxSegmentSize = kDefaultTCPMSS; 24 const QuicByteCount kMaxSegmentSize = kDefaultTCPMSS;
25 const int64 kInitialCongestionWindow = 10; 25 const int64 kInitialCongestionWindow = 10;
26 const int kMaxBurstLength = 3; 26 const int kMaxBurstLength = 3;
27 const float kRenoBeta = 0.7f; // Reno backoff factor.
28 const uint32 kDefaultNumConnections = 2; // N-connection emulation.
27 } // namespace 29 } // namespace
28 30
29 TcpCubicSender::TcpCubicSender( 31 TcpCubicSender::TcpCubicSender(
30 const QuicClock* clock, 32 const QuicClock* clock,
31 const RttStats* rtt_stats, 33 const RttStats* rtt_stats,
32 bool reno, 34 bool reno,
33 QuicPacketCount max_tcp_congestion_window, 35 QuicPacketCount max_tcp_congestion_window,
34 QuicConnectionStats* stats) 36 QuicConnectionStats* stats)
35 : hybrid_slow_start_(clock), 37 : hybrid_slow_start_(clock),
36 cubic_(clock, stats), 38 cubic_(clock, stats),
37 rtt_stats_(rtt_stats), 39 rtt_stats_(rtt_stats),
38 stats_(stats), 40 stats_(stats),
39 reno_(reno), 41 reno_(reno),
40 num_connections_(2), 42 num_connections_(kDefaultNumConnections),
41 congestion_window_count_(0), 43 congestion_window_count_(0),
42 largest_sent_sequence_number_(0), 44 largest_sent_sequence_number_(0),
43 largest_acked_sequence_number_(0), 45 largest_acked_sequence_number_(0),
44 largest_sent_at_last_cutback_(0), 46 largest_sent_at_last_cutback_(0),
45 congestion_window_(kInitialCongestionWindow), 47 congestion_window_(kInitialCongestionWindow),
46 previous_congestion_window_(0), 48 previous_congestion_window_(0),
47 slowstart_threshold_(max_tcp_congestion_window), 49 slowstart_threshold_(max_tcp_congestion_window),
48 previous_slowstart_threshold_(0), 50 previous_slowstart_threshold_(0),
49 last_cutback_exited_slowstart_(false), 51 last_cutback_exited_slowstart_(false),
50 max_tcp_congestion_window_(max_tcp_congestion_window) { 52 max_tcp_congestion_window_(max_tcp_congestion_window) {
(...skipping 17 matching lines...) Expand all
68 config.ReceivedInitialCongestionWindow()); 70 config.ReceivedInitialCongestionWindow());
69 } 71 }
70 } 72 }
71 } 73 }
72 74
73 void TcpCubicSender::SetNumEmulatedConnections(int num_connections) { 75 void TcpCubicSender::SetNumEmulatedConnections(int num_connections) {
74 num_connections_ = max(1, num_connections); 76 num_connections_ = max(1, num_connections);
75 cubic_.SetNumConnections(num_connections_); 77 cubic_.SetNumConnections(num_connections_);
76 } 78 }
77 79
80 float TcpCubicSender::RenoBeta() const {
81 // kNConnectionBeta is the backoff factor after loss for our N-connection
82 // emulation, which emulates the effective backoff of an ensemble of N
83 // TCP-Reno connections on a single loss event. The effective multiplier is
84 // computed as:
85 return (num_connections_ - 1 + kRenoBeta) / num_connections_;
86 }
87
78 void TcpCubicSender::OnCongestionEvent( 88 void TcpCubicSender::OnCongestionEvent(
79 bool rtt_updated, 89 bool rtt_updated,
80 QuicByteCount bytes_in_flight, 90 QuicByteCount bytes_in_flight,
81 const CongestionVector& acked_packets, 91 const CongestionVector& acked_packets,
82 const CongestionVector& lost_packets) { 92 const CongestionVector& lost_packets) {
83 if (rtt_updated && InSlowStart() && 93 if (rtt_updated && InSlowStart() &&
84 hybrid_slow_start_.ShouldExitSlowStart(rtt_stats_->latest_rtt(), 94 hybrid_slow_start_.ShouldExitSlowStart(rtt_stats_->latest_rtt(),
85 rtt_stats_->MinRtt(), 95 rtt_stats_->MinRtt(),
86 congestion_window_)) { 96 congestion_window_)) {
87 slowstart_threshold_ = congestion_window_; 97 slowstart_threshold_ = congestion_window_;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 136 }
127 ++stats_->tcp_loss_events; 137 ++stats_->tcp_loss_events;
128 last_cutback_exited_slowstart_ = InSlowStart(); 138 last_cutback_exited_slowstart_ = InSlowStart();
129 if (InSlowStart()) { 139 if (InSlowStart()) {
130 ++stats_->slowstart_packets_lost; 140 ++stats_->slowstart_packets_lost;
131 } 141 }
132 142
133 prr_.OnPacketLost(bytes_in_flight); 143 prr_.OnPacketLost(bytes_in_flight);
134 144
135 if (reno_) { 145 if (reno_) {
136 congestion_window_ = congestion_window_ >> 1; 146 congestion_window_ = congestion_window_ * RenoBeta();
137 } else { 147 } else {
138 congestion_window_ = 148 congestion_window_ =
139 cubic_.CongestionWindowAfterPacketLoss(congestion_window_); 149 cubic_.CongestionWindowAfterPacketLoss(congestion_window_);
140 } 150 }
141 slowstart_threshold_ = congestion_window_; 151 slowstart_threshold_ = congestion_window_;
142 // Enforce TCP's minimum congestion window of 2*MSS. 152 // Enforce TCP's minimum congestion window of 2*MSS.
143 if (congestion_window_ < kMinimumCongestionWindow) { 153 if (congestion_window_ < kMinimumCongestionWindow) {
144 congestion_window_ = kMinimumCongestionWindow; 154 congestion_window_ = kMinimumCongestionWindow;
145 } 155 }
146 largest_sent_at_last_cutback_ = largest_sent_sequence_number_; 156 largest_sent_at_last_cutback_ = largest_sent_sequence_number_;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 congestion_window_ = previous_congestion_window_; 326 congestion_window_ = previous_congestion_window_;
317 slowstart_threshold_ = previous_slowstart_threshold_; 327 slowstart_threshold_ = previous_slowstart_threshold_;
318 previous_congestion_window_ = 0; 328 previous_congestion_window_ = 0;
319 } 329 }
320 330
321 CongestionControlType TcpCubicSender::GetCongestionControlType() const { 331 CongestionControlType TcpCubicSender::GetCongestionControlType() const {
322 return reno_ ? kReno : kCubic; 332 return reno_ ? kReno : kCubic;
323 } 333 }
324 334
325 } // namespace net 335 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender.h ('k') | net/quic/congestion_control/tcp_cubic_sender_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698