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

Side by Side Diff: net/quic/core/congestion_control/pacing_sender.cc

Issue 2228613002: Rollback of internal changelist 128865569. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@129053230
Patch Set: Created 4 years, 4 months 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/core/congestion_control/pacing_sender.h" 5 #include "net/quic/core/congestion_control/pacing_sender.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "net/quic/core/quic_flags.h" 9 #include "net/quic/core/quic_flags.h"
10 10
11 using std::min; 11 using std::min;
12 12
13 namespace net { 13 namespace net {
14 namespace {
15 14
16 // The estimated system alarm granularity. 15 PacingSender::PacingSender(SendAlgorithmInterface* sender,
17 static const QuicTime::Delta kAlarmGranularity = 16 QuicTime::Delta alarm_granularity,
18 QuicTime::Delta::FromMilliseconds(1); 17 uint32_t initial_packet_burst)
19 18 : sender_(sender),
20 // Configured maximum size of the burst coming out of quiescence. The burst 19 alarm_granularity_(alarm_granularity),
21 // is never larger than the current CWND in packets. 20 initial_packet_burst_(initial_packet_burst),
22 static const uint32_t kInitialUnpacedBurst = 10;
23
24 } // namespace
25
26 PacingSender::PacingSender()
27 : sender_(nullptr),
28 max_pacing_rate_(QuicBandwidth::Zero()), 21 max_pacing_rate_(QuicBandwidth::Zero()),
29 burst_tokens_(kInitialUnpacedBurst), 22 burst_tokens_(initial_packet_burst),
30 last_delayed_packet_sent_time_(QuicTime::Zero()), 23 last_delayed_packet_sent_time_(QuicTime::Zero()),
31 ideal_next_packet_send_time_(QuicTime::Zero()), 24 ideal_next_packet_send_time_(QuicTime::Zero()),
32 was_last_send_delayed_(false), 25 was_last_send_delayed_(false) {}
33 owns_sender_(false) {}
34 26
35 PacingSender::~PacingSender() { 27 PacingSender::~PacingSender() {}
36 if (owns_sender_) {
37 delete sender_;
38 }
39 }
40 28
41 void PacingSender::SetFromConfig(const QuicConfig& config, 29 void PacingSender::SetFromConfig(const QuicConfig& config,
42 Perspective perspective) { 30 Perspective perspective) {
43 sender_->SetFromConfig(config, perspective); 31 sender_->SetFromConfig(config, perspective);
44 } 32 }
45 33
46 void PacingSender::ResumeConnectionState( 34 void PacingSender::ResumeConnectionState(
47 const CachedNetworkParameters& cached_network_params, 35 const CachedNetworkParameters& cached_network_params,
48 bool max_bandwidth_resumption) { 36 bool max_bandwidth_resumption) {
49 sender_->ResumeConnectionState(cached_network_params, 37 sender_->ResumeConnectionState(cached_network_params,
50 max_bandwidth_resumption); 38 max_bandwidth_resumption);
51 } 39 }
52 40
53 void PacingSender::SetNumEmulatedConnections(int num_connections) { 41 void PacingSender::SetNumEmulatedConnections(int num_connections) {
54 sender_->SetNumEmulatedConnections(num_connections); 42 sender_->SetNumEmulatedConnections(num_connections);
55 } 43 }
56 44
57 void PacingSender::SetMaxPacingRate(QuicBandwidth max_pacing_rate) { 45 void PacingSender::SetMaxPacingRate(QuicBandwidth max_pacing_rate) {
58 max_pacing_rate_ = max_pacing_rate; 46 max_pacing_rate_ = max_pacing_rate;
59 } 47 }
60 48
61 void PacingSender::SetSender(SendAlgorithmInterface* sender, bool owns_sender) {
62 if (owns_sender_) {
63 delete sender_;
64 }
65 sender_ = sender;
66 owns_sender_ = owns_sender;
67 }
68
69 void PacingSender::OnCongestionEvent(bool rtt_updated, 49 void PacingSender::OnCongestionEvent(bool rtt_updated,
70 QuicByteCount bytes_in_flight, 50 QuicByteCount bytes_in_flight,
71 const CongestionVector& acked_packets, 51 const CongestionVector& acked_packets,
72 const CongestionVector& lost_packets) { 52 const CongestionVector& lost_packets) {
73 if (!lost_packets.empty()) { 53 if (!lost_packets.empty()) {
74 // Clear any burst tokens when entering recovery. 54 // Clear any burst tokens when entering recovery.
75 burst_tokens_ = 0; 55 burst_tokens_ = 0;
76 } 56 }
77 sender_->OnCongestionEvent(rtt_updated, bytes_in_flight, acked_packets, 57 sender_->OnCongestionEvent(rtt_updated, bytes_in_flight, acked_packets,
78 lost_packets); 58 lost_packets);
(...skipping 10 matching lines...) Expand all
89 has_retransmittable_data); 69 has_retransmittable_data);
90 if (has_retransmittable_data != HAS_RETRANSMITTABLE_DATA) { 70 if (has_retransmittable_data != HAS_RETRANSMITTABLE_DATA) {
91 return in_flight; 71 return in_flight;
92 } 72 }
93 // If in recovery, the connection is not coming out of quiescence. 73 // If in recovery, the connection is not coming out of quiescence.
94 if (bytes_in_flight == 0 && !sender_->InRecovery()) { 74 if (bytes_in_flight == 0 && !sender_->InRecovery()) {
95 // Add more burst tokens anytime the connection is leaving quiescence, but 75 // Add more burst tokens anytime the connection is leaving quiescence, but
96 // limit it to the equivalent of a single bulk write, not exceeding the 76 // limit it to the equivalent of a single bulk write, not exceeding the
97 // current CWND in packets. 77 // current CWND in packets.
98 burst_tokens_ = min( 78 burst_tokens_ = min(
99 kInitialUnpacedBurst, 79 initial_packet_burst_,
100 static_cast<uint32_t>(sender_->GetCongestionWindow() / kDefaultTCPMSS)); 80 static_cast<uint32_t>(sender_->GetCongestionWindow() / kDefaultTCPMSS));
101 } 81 }
102 if (burst_tokens_ > 0) { 82 if (burst_tokens_ > 0) {
103 --burst_tokens_; 83 --burst_tokens_;
104 was_last_send_delayed_ = false; 84 was_last_send_delayed_ = false;
105 last_delayed_packet_sent_time_ = QuicTime::Zero(); 85 last_delayed_packet_sent_time_ = QuicTime::Zero();
106 ideal_next_packet_send_time_ = QuicTime::Zero(); 86 ideal_next_packet_send_time_ = QuicTime::Zero();
107 return in_flight; 87 return in_flight;
108 } 88 }
109 // The next packet should be sent as soon as the current packet has been 89 // The next packet should be sent as soon as the current packet has been
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 return time_until_send; 135 return time_until_send;
156 } 136 }
157 137
158 if (!time_until_send.IsZero()) { 138 if (!time_until_send.IsZero()) {
159 DCHECK(time_until_send.IsInfinite()); 139 DCHECK(time_until_send.IsInfinite());
160 // The underlying sender prevents sending. 140 // The underlying sender prevents sending.
161 return time_until_send; 141 return time_until_send;
162 } 142 }
163 143
164 // If the next send time is within the alarm granularity, send immediately. 144 // If the next send time is within the alarm granularity, send immediately.
165 if (ideal_next_packet_send_time_ > now + kAlarmGranularity) { 145 if (ideal_next_packet_send_time_ > now + alarm_granularity_) {
166 DVLOG(1) << "Delaying packet: " 146 DVLOG(1) << "Delaying packet: "
167 << (ideal_next_packet_send_time_ - now).ToMicroseconds(); 147 << (ideal_next_packet_send_time_ - now).ToMicroseconds();
168 was_last_send_delayed_ = true; 148 was_last_send_delayed_ = true;
169 return ideal_next_packet_send_time_ - now; 149 return ideal_next_packet_send_time_ - now;
170 } 150 }
171 151
172 DVLOG(1) << "Sending packet now"; 152 DVLOG(1) << "Sending packet now";
173 return QuicTime::Delta::Zero(); 153 return QuicTime::Delta::Zero();
174 } 154 }
175 155
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 188
209 CongestionControlType PacingSender::GetCongestionControlType() const { 189 CongestionControlType PacingSender::GetCongestionControlType() const {
210 return sender_->GetCongestionControlType(); 190 return sender_->GetCongestionControlType();
211 } 191 }
212 192
213 std::string PacingSender::GetDebugState() const { 193 std::string PacingSender::GetDebugState() const {
214 return sender_->GetDebugState(); 194 return sender_->GetDebugState();
215 } 195 }
216 196
217 } // namespace net 197 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/congestion_control/pacing_sender.h ('k') | net/quic/core/congestion_control/pacing_sender_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698