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

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

Issue 131743009: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use size_t instead of int to fix win_x64 compile error Created 6 years, 11 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 | Annotate | Revision Log
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/inter_arrival_sender.h" 5 #include "net/quic/congestion_control/inter_arrival_sender.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 using std::max; 9 using std::max;
10 using std::min; 10 using std::min;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 << new_rate.ToKBitsPerSecond() << " Kbits/s " 209 << new_rate.ToKBitsPerSecond() << " Kbits/s "
210 << " available estimate:" 210 << " available estimate:"
211 << available_channel_estimate.ToKBitsPerSecond() << " Kbits/s " 211 << available_channel_estimate.ToKBitsPerSecond() << " Kbits/s "
212 << " channel estimate:" 212 << " channel estimate:"
213 << channel_estimate.ToKBitsPerSecond() << " Kbits/s "; 213 << channel_estimate.ToKBitsPerSecond() << " Kbits/s ";
214 return false; 214 return false;
215 } 215 }
216 216
217 void InterArrivalSender::OnPacketAcked( 217 void InterArrivalSender::OnPacketAcked(
218 QuicPacketSequenceNumber /*acked_sequence_number*/, 218 QuicPacketSequenceNumber /*acked_sequence_number*/,
219 QuicByteCount acked_bytes, 219 QuicByteCount acked_bytes) {
220 QuicTime::Delta rtt) {
221 // RTT can't be negative.
222 DCHECK_LE(0, rtt.ToMicroseconds());
223
224 if (probing_) { 220 if (probing_) {
225 probe_->OnAcknowledgedPacket(acked_bytes); 221 probe_->OnAcknowledgedPacket(acked_bytes);
226 } 222 }
227
228 if (rtt.IsInfinite()) {
229 return;
230 }
231
232 if (smoothed_rtt_.IsZero()) {
233 smoothed_rtt_ = rtt;
234 } else {
235 smoothed_rtt_ = QuicTime::Delta::FromMicroseconds(
236 kOneMinusAlpha * smoothed_rtt_.ToMicroseconds() +
237 kAlpha * rtt.ToMicroseconds());
238 }
239 state_machine_->set_rtt(smoothed_rtt_);
240 } 223 }
241 224
242 void InterArrivalSender::OnPacketLost( 225 void InterArrivalSender::OnPacketLost(
243 QuicPacketSequenceNumber /*sequence_number*/, 226 QuicPacketSequenceNumber /*sequence_number*/,
244 QuicTime ack_receive_time) { 227 QuicTime ack_receive_time) {
245 // Packet loss was reported. 228 // Packet loss was reported.
246 if (!probing_) { 229 if (!probing_) {
247 if (!state_machine_->PacketLossEvent()) { 230 if (!state_machine_->PacketLossEvent()) {
248 // Less than one RTT since last PacketLossEvent. 231 // Less than one RTT since last PacketLossEvent.
249 return; 232 return;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 313 }
331 break; 314 break;
332 } 315 }
333 bandwidth_usage_state_ = new_bandwidth_usage_state; 316 bandwidth_usage_state_ = new_bandwidth_usage_state;
334 } 317 }
335 318
336 QuicBandwidth InterArrivalSender::BandwidthEstimate() const { 319 QuicBandwidth InterArrivalSender::BandwidthEstimate() const {
337 return current_bandwidth_; 320 return current_bandwidth_;
338 } 321 }
339 322
323 void InterArrivalSender::UpdateRtt(QuicTime::Delta rtt) {
324 // RTT can't be negative.
325 DCHECK_LE(0, rtt.ToMicroseconds());
326
327 if (rtt.IsInfinite()) {
328 return;
329 }
330
331 if (smoothed_rtt_.IsZero()) {
332 smoothed_rtt_ = rtt;
333 } else {
334 smoothed_rtt_ = QuicTime::Delta::FromMicroseconds(
335 kOneMinusAlpha * smoothed_rtt_.ToMicroseconds() +
336 kAlpha * rtt.ToMicroseconds());
337 }
338 state_machine_->set_rtt(smoothed_rtt_);
339 }
340
340 QuicTime::Delta InterArrivalSender::SmoothedRtt() const { 341 QuicTime::Delta InterArrivalSender::SmoothedRtt() const {
341 if (smoothed_rtt_.IsZero()) { 342 if (smoothed_rtt_.IsZero()) {
342 return QuicTime::Delta::FromMilliseconds(kInitialRttMs); 343 return QuicTime::Delta::FromMilliseconds(kInitialRttMs);
343 } 344 }
344 return smoothed_rtt_; 345 return smoothed_rtt_;
345 } 346 }
346 347
347 QuicTime::Delta InterArrivalSender::RetransmissionDelay() const { 348 QuicTime::Delta InterArrivalSender::RetransmissionDelay() const {
348 // TODO(pwestin): Calculate and return retransmission delay. 349 // TODO(pwestin): Calculate and return retransmission delay.
349 // Use 2 * the smoothed RTT for now. 350 // Use 2 * the smoothed RTT for now.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 bitrate_ramp_up_->Reset(new_rate, current_bandwidth_, channel_estimate); 530 bitrate_ramp_up_->Reset(new_rate, current_bandwidth_, channel_estimate);
530 if (new_rate != current_bandwidth_) { 531 if (new_rate != current_bandwidth_) {
531 current_bandwidth_ = new_rate; 532 current_bandwidth_ = new_rate;
532 paced_sender_->UpdateBandwidthEstimate(feedback_receive_time, 533 paced_sender_->UpdateBandwidthEstimate(feedback_receive_time,
533 current_bandwidth_); 534 current_bandwidth_);
534 state_machine_->DecreaseBitrateDecision(); 535 state_machine_->DecreaseBitrateDecision();
535 } 536 }
536 } 537 }
537 538
538 } // namespace net 539 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/inter_arrival_sender.h ('k') | net/quic/congestion_control/inter_arrival_sender_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698