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

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

Issue 2130103002: Landing Recent QUIC changes until 2016-07-02 02:45 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/congestion_control/pacing_sender.h" 5 #include "net/quic/congestion_control/pacing_sender.h"
6 6
7 #include "net/quic/quic_flags.h" 7 #include "net/quic/quic_flags.h"
8 8
9 using std::min; 9 using std::min;
10 10
(...skipping 22 matching lines...) Expand all
33 const CachedNetworkParameters& cached_network_params, 33 const CachedNetworkParameters& cached_network_params,
34 bool max_bandwidth_resumption) { 34 bool max_bandwidth_resumption) {
35 sender_->ResumeConnectionState(cached_network_params, 35 sender_->ResumeConnectionState(cached_network_params,
36 max_bandwidth_resumption); 36 max_bandwidth_resumption);
37 } 37 }
38 38
39 void PacingSender::SetNumEmulatedConnections(int num_connections) { 39 void PacingSender::SetNumEmulatedConnections(int num_connections) {
40 sender_->SetNumEmulatedConnections(num_connections); 40 sender_->SetNumEmulatedConnections(num_connections);
41 } 41 }
42 42
43 void PacingSender::SetMaxCongestionWindow(QuicByteCount max_congestion_window) {
44 sender_->SetMaxCongestionWindow(max_congestion_window);
45 }
46
47 void PacingSender::SetMaxPacingRate(QuicBandwidth max_pacing_rate) { 43 void PacingSender::SetMaxPacingRate(QuicBandwidth max_pacing_rate) {
48 max_pacing_rate_ = max_pacing_rate; 44 max_pacing_rate_ = max_pacing_rate;
49 } 45 }
50 46
51 void PacingSender::OnCongestionEvent(bool rtt_updated, 47 void PacingSender::OnCongestionEvent(bool rtt_updated,
52 QuicByteCount bytes_in_flight, 48 QuicByteCount bytes_in_flight,
53 const CongestionVector& acked_packets, 49 const CongestionVector& acked_packets,
54 const CongestionVector& lost_packets) { 50 const CongestionVector& lost_packets) {
55 if (FLAGS_quic_allow_noprr && !lost_packets.empty()) { 51 if (FLAGS_quic_allow_noprr && !lost_packets.empty()) {
56 // Clear any burst tokens when entering recovery. 52 // Clear any burst tokens when entering recovery.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 ideal_next_packet_send_time_ = QuicTime::Zero(); 84 ideal_next_packet_send_time_ = QuicTime::Zero();
89 return in_flight; 85 return in_flight;
90 } 86 }
91 // The next packet should be sent as soon as the current packet has been 87 // The next packet should be sent as soon as the current packet has been
92 // transferred. PacingRate is based on bytes in flight including this packet. 88 // transferred. PacingRate is based on bytes in flight including this packet.
93 QuicTime::Delta delay = 89 QuicTime::Delta delay =
94 PacingRate(bytes_in_flight + bytes).TransferTime(bytes); 90 PacingRate(bytes_in_flight + bytes).TransferTime(bytes);
95 // If the last send was delayed, and the alarm took a long time to get 91 // If the last send was delayed, and the alarm took a long time to get
96 // invoked, allow the connection to make up for lost time. 92 // invoked, allow the connection to make up for lost time.
97 if (was_last_send_delayed_) { 93 if (was_last_send_delayed_) {
98 ideal_next_packet_send_time_ = ideal_next_packet_send_time_.Add(delay); 94 ideal_next_packet_send_time_ = ideal_next_packet_send_time_ + delay;
99 // The send was application limited if it takes longer than the 95 // The send was application limited if it takes longer than the
100 // pacing delay between sent packets. 96 // pacing delay between sent packets.
101 const bool application_limited = 97 const bool application_limited =
102 last_delayed_packet_sent_time_.IsInitialized() && 98 last_delayed_packet_sent_time_.IsInitialized() &&
103 sent_time > last_delayed_packet_sent_time_.Add(delay); 99 sent_time > last_delayed_packet_sent_time_ + delay;
104 const bool making_up_for_lost_time = 100 const bool making_up_for_lost_time =
105 ideal_next_packet_send_time_ <= sent_time; 101 ideal_next_packet_send_time_ <= sent_time;
106 // As long as we're making up time and not application limited, 102 // As long as we're making up time and not application limited,
107 // continue to consider the packets delayed, allowing the packets to be 103 // continue to consider the packets delayed, allowing the packets to be
108 // sent immediately. 104 // sent immediately.
109 if (making_up_for_lost_time && !application_limited) { 105 if (making_up_for_lost_time && !application_limited) {
110 last_delayed_packet_sent_time_ = sent_time; 106 last_delayed_packet_sent_time_ = sent_time;
111 } else { 107 } else {
112 was_last_send_delayed_ = false; 108 was_last_send_delayed_ = false;
113 last_delayed_packet_sent_time_ = QuicTime::Zero(); 109 last_delayed_packet_sent_time_ = QuicTime::Zero();
114 } 110 }
115 } else { 111 } else {
116 ideal_next_packet_send_time_ = QuicTime::Max( 112 ideal_next_packet_send_time_ =
117 ideal_next_packet_send_time_.Add(delay), sent_time.Add(delay)); 113 QuicTime::Max(ideal_next_packet_send_time_ + delay, sent_time + delay);
118 } 114 }
119 return in_flight; 115 return in_flight;
120 } 116 }
121 117
122 void PacingSender::OnRetransmissionTimeout(bool packets_retransmitted) { 118 void PacingSender::OnRetransmissionTimeout(bool packets_retransmitted) {
123 sender_->OnRetransmissionTimeout(packets_retransmitted); 119 sender_->OnRetransmissionTimeout(packets_retransmitted);
124 } 120 }
125 121
126 void PacingSender::OnConnectionMigration() { 122 void PacingSender::OnConnectionMigration() {
127 sender_->OnConnectionMigration(); 123 sender_->OnConnectionMigration();
128 } 124 }
129 125
130 QuicTime::Delta PacingSender::TimeUntilSend( 126 QuicTime::Delta PacingSender::TimeUntilSend(
131 QuicTime now, 127 QuicTime now,
132 QuicByteCount bytes_in_flight) const { 128 QuicByteCount bytes_in_flight) const {
133 QuicTime::Delta time_until_send = 129 QuicTime::Delta time_until_send =
134 sender_->TimeUntilSend(now, bytes_in_flight); 130 sender_->TimeUntilSend(now, bytes_in_flight);
135 if (burst_tokens_ > 0 || bytes_in_flight == 0) { 131 if (burst_tokens_ > 0 || bytes_in_flight == 0) {
136 // Don't pace if we have burst tokens available or leaving quiescence. 132 // Don't pace if we have burst tokens available or leaving quiescence.
137 return time_until_send; 133 return time_until_send;
138 } 134 }
139 135
140 if (!time_until_send.IsZero()) { 136 if (!time_until_send.IsZero()) {
141 DCHECK(time_until_send.IsInfinite()); 137 DCHECK(time_until_send.IsInfinite());
142 // The underlying sender prevents sending. 138 // The underlying sender prevents sending.
143 return time_until_send; 139 return time_until_send;
144 } 140 }
145 141
146 // If the next send time is within the alarm granularity, send immediately. 142 // If the next send time is within the alarm granularity, send immediately.
147 if (ideal_next_packet_send_time_ > now.Add(alarm_granularity_)) { 143 if (ideal_next_packet_send_time_ > now + alarm_granularity_) {
148 DVLOG(1) << "Delaying packet: " 144 DVLOG(1) << "Delaying packet: "
149 << ideal_next_packet_send_time_.Subtract(now).ToMicroseconds(); 145 << (ideal_next_packet_send_time_ - now).ToMicroseconds();
150 was_last_send_delayed_ = true; 146 was_last_send_delayed_ = true;
151 return ideal_next_packet_send_time_.Subtract(now); 147 return ideal_next_packet_send_time_ - now;
152 } 148 }
153 149
154 DVLOG(1) << "Sending packet now"; 150 DVLOG(1) << "Sending packet now";
155 return QuicTime::Delta::Zero(); 151 return QuicTime::Delta::Zero();
156 } 152 }
157 153
158 QuicBandwidth PacingSender::PacingRate(QuicByteCount bytes_in_flight) const { 154 QuicBandwidth PacingSender::PacingRate(QuicByteCount bytes_in_flight) const {
159 if (!max_pacing_rate_.IsZero()) { 155 if (!max_pacing_rate_.IsZero()) {
160 return QuicBandwidth::FromBitsPerSecond( 156 return QuicBandwidth::FromBitsPerSecond(
161 min(max_pacing_rate_.ToBitsPerSecond(), 157 min(max_pacing_rate_.ToBitsPerSecond(),
(...skipping 24 matching lines...) Expand all
186 182
187 QuicByteCount PacingSender::GetSlowStartThreshold() const { 183 QuicByteCount PacingSender::GetSlowStartThreshold() const {
188 return sender_->GetSlowStartThreshold(); 184 return sender_->GetSlowStartThreshold();
189 } 185 }
190 186
191 CongestionControlType PacingSender::GetCongestionControlType() const { 187 CongestionControlType PacingSender::GetCongestionControlType() const {
192 return sender_->GetCongestionControlType(); 188 return sender_->GetCongestionControlType();
193 } 189 }
194 190
195 } // namespace net 191 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/pacing_sender.h ('k') | net/quic/congestion_control/pacing_sender_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698