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

Side by Side Diff: net/quic/quic_sent_packet_manager.cc

Issue 312553003: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
« no previous file with comments | « net/quic/quic_sent_packet_manager.h ('k') | net/quic/quic_session.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/quic_sent_packet_manager.h" 5 #include "net/quic/quic_sent_packet_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 is_server_(is_server), 62 is_server_(is_server),
63 clock_(clock), 63 clock_(clock),
64 stats_(stats), 64 stats_(stats),
65 send_algorithm_( 65 send_algorithm_(
66 SendAlgorithmInterface::Create(clock, &rtt_stats_, type, stats)), 66 SendAlgorithmInterface::Create(clock, &rtt_stats_, type, stats)),
67 loss_algorithm_(LossDetectionInterface::Create(loss_type)), 67 loss_algorithm_(LossDetectionInterface::Create(loss_type)),
68 largest_observed_(0), 68 largest_observed_(0),
69 consecutive_rto_count_(0), 69 consecutive_rto_count_(0),
70 consecutive_tlp_count_(0), 70 consecutive_tlp_count_(0),
71 consecutive_crypto_retransmission_count_(0), 71 consecutive_crypto_retransmission_count_(0),
72 pending_tlp_transmission_(false),
72 max_tail_loss_probes_(kDefaultMaxTailLossProbes), 73 max_tail_loss_probes_(kDefaultMaxTailLossProbes),
73 using_pacing_(false) { 74 using_pacing_(false) {
74 } 75 }
75 76
76 QuicSentPacketManager::~QuicSentPacketManager() { 77 QuicSentPacketManager::~QuicSentPacketManager() {
77 } 78 }
78 79
79 void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) { 80 void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) {
80 if (config.HasReceivedInitialRoundTripTimeUs() && 81 if (config.HasReceivedInitialRoundTripTimeUs() &&
81 config.ReceivedInitialRoundTripTimeUs() > 0) { 82 config.ReceivedInitialRoundTripTimeUs() > 0) {
82 rtt_stats_.set_initial_rtt_us(min(kMaxInitialRoundTripTimeUs, 83 rtt_stats_.set_initial_rtt_us(min(kMaxInitialRoundTripTimeUs,
83 config.ReceivedInitialRoundTripTimeUs())); 84 config.ReceivedInitialRoundTripTimeUs()));
84 } 85 }
85 if (config.congestion_control() == kPACE) { 86 // TODO(ianswett): BBR is currently a server only feature.
87 if (config.HasReceivedCongestionOptions() &&
88 ContainsQuicTag(config.ReceivedCongestionOptions(), kTBBR)) {
89 send_algorithm_.reset(
90 SendAlgorithmInterface::Create(clock_, &rtt_stats_, kTCPBBR, stats_));
91 }
92 if (config.congestion_feedback() == kPACE) {
86 MaybeEnablePacing(); 93 MaybeEnablePacing();
87 } 94 }
88 if (config.HasReceivedLossDetection() && 95 if (config.HasReceivedLossDetection() &&
89 config.ReceivedLossDetection() == kTIME) { 96 config.ReceivedLossDetection() == kTIME) {
90 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); 97 loss_algorithm_.reset(LossDetectionInterface::Create(kTime));
91 } 98 }
92 send_algorithm_->SetFromConfig(config, is_server_); 99 send_algorithm_->SetFromConfig(config, is_server_);
93 } 100 }
94 101
95 // TODO(ianswett): Combine this method with OnPacketSent once packets are always 102 // TODO(ianswett): Combine this method with OnPacketSent once packets are always
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 396 }
390 397
391 bool QuicSentPacketManager::OnPacketSent( 398 bool QuicSentPacketManager::OnPacketSent(
392 QuicPacketSequenceNumber sequence_number, 399 QuicPacketSequenceNumber sequence_number,
393 QuicTime sent_time, 400 QuicTime sent_time,
394 QuicByteCount bytes, 401 QuicByteCount bytes,
395 TransmissionType transmission_type, 402 TransmissionType transmission_type,
396 HasRetransmittableData has_retransmittable_data) { 403 HasRetransmittableData has_retransmittable_data) {
397 DCHECK_LT(0u, sequence_number); 404 DCHECK_LT(0u, sequence_number);
398 LOG_IF(DFATAL, bytes == 0) << "Cannot send empty packets."; 405 LOG_IF(DFATAL, bytes == 0) << "Cannot send empty packets.";
406 pending_tlp_transmission_ = false;
399 // In rare circumstances, the packet could be serialized, sent, and then acked 407 // In rare circumstances, the packet could be serialized, sent, and then acked
400 // before OnPacketSent is called. 408 // before OnPacketSent is called.
401 if (!unacked_packets_.IsUnacked(sequence_number)) { 409 if (!unacked_packets_.IsUnacked(sequence_number)) {
402 return false; 410 return false;
403 } 411 }
404 412
405 if (unacked_packets_.bytes_in_flight() == 0) { 413 if (unacked_packets_.bytes_in_flight() == 0) {
406 // TODO(ianswett): Consider being less aggressive to force a new 414 // TODO(ianswett): Consider being less aggressive to force a new
407 // recent_min_rtt, likely by not discarding a relatively new sample. 415 // recent_min_rtt, likely by not discarding a relatively new sample.
408 DVLOG(1) << "Sampling a new recent min rtt within 2 samples. currently:" 416 DVLOG(1) << "Sampling a new recent min rtt within 2 samples. currently:"
(...skipping 30 matching lines...) Expand all
439 ++stats_->loss_timeout_count; 447 ++stats_->loss_timeout_count;
440 QuicByteCount bytes_in_flight = unacked_packets_.bytes_in_flight(); 448 QuicByteCount bytes_in_flight = unacked_packets_.bytes_in_flight();
441 InvokeLossDetection(clock_->Now()); 449 InvokeLossDetection(clock_->Now());
442 MaybeInvokeCongestionEvent(false, bytes_in_flight); 450 MaybeInvokeCongestionEvent(false, bytes_in_flight);
443 return; 451 return;
444 } 452 }
445 case TLP_MODE: 453 case TLP_MODE:
446 // If no tail loss probe can be sent, because there are no retransmittable 454 // If no tail loss probe can be sent, because there are no retransmittable
447 // packets, execute a conventional RTO to abandon old packets. 455 // packets, execute a conventional RTO to abandon old packets.
448 ++stats_->tlp_count; 456 ++stats_->tlp_count;
457 pending_tlp_transmission_ = true;
449 RetransmitOldestPacket(); 458 RetransmitOldestPacket();
450 return; 459 return;
451 case RTO_MODE: 460 case RTO_MODE:
452 ++stats_->rto_count; 461 ++stats_->rto_count;
453 RetransmitAllPackets(); 462 RetransmitAllPackets();
454 return; 463 return;
455 } 464 }
456 } 465 }
457 466
458 void QuicSentPacketManager::RetransmitCryptoPackets() { 467 void QuicSentPacketManager::RetransmitCryptoPackets() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 } 499 }
491 DCHECK_NE(IS_HANDSHAKE, frames->HasCryptoHandshake()); 500 DCHECK_NE(IS_HANDSHAKE, frames->HasCryptoHandshake());
492 MarkForRetransmission(sequence_number, TLP_RETRANSMISSION); 501 MarkForRetransmission(sequence_number, TLP_RETRANSMISSION);
493 return; 502 return;
494 } 503 }
495 DLOG(FATAL) 504 DLOG(FATAL)
496 << "No retransmittable packets, so RetransmitOldestPacket failed."; 505 << "No retransmittable packets, so RetransmitOldestPacket failed.";
497 } 506 }
498 507
499 void QuicSentPacketManager::RetransmitAllPackets() { 508 void QuicSentPacketManager::RetransmitAllPackets() {
500 // Abandon all retransmittable packets and packets older than the 509 DVLOG(1) << "RetransmitAllPackets() called with "
501 // retransmission delay.
502
503 DVLOG(1) << "OnRetransmissionTimeout() fired with "
504 << unacked_packets_.GetNumUnackedPackets() << " unacked packets."; 510 << unacked_packets_.GetNumUnackedPackets() << " unacked packets.";
505
506 // Request retransmission of all retransmittable packets when the RTO 511 // Request retransmission of all retransmittable packets when the RTO
507 // fires, and let the congestion manager decide how many to send 512 // fires, and let the congestion manager decide how many to send
508 // immediately and the remaining packets will be queued. 513 // immediately and the remaining packets will be queued.
509 // Abandon any non-retransmittable packets that are sufficiently old. 514 // Abandon any non-retransmittable packets that are sufficiently old.
510 bool packets_retransmitted = false; 515 bool packets_retransmitted = false;
511 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); 516 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
512 while (it != unacked_packets_.end()) { 517 while (it != unacked_packets_.end()) {
513 const RetransmittableFrames* frames = it->second.retransmittable_frames; 518 const RetransmittableFrames* frames = it->second.retransmittable_frames;
514 QuicPacketSequenceNumber sequence_number = it->first; 519 QuicPacketSequenceNumber sequence_number = it->first;
515 ++it; 520 ++it;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 603
599 QuicTime::Delta send_delta = 604 QuicTime::Delta send_delta =
600 ack_receive_time.Subtract(transmission_info.sent_time); 605 ack_receive_time.Subtract(transmission_info.sent_time);
601 rtt_stats_.UpdateRtt( 606 rtt_stats_.UpdateRtt(
602 send_delta, received_info.delta_time_largest_observed, ack_receive_time); 607 send_delta, received_info.delta_time_largest_observed, ack_receive_time);
603 return true; 608 return true;
604 } 609 }
605 610
606 QuicTime::Delta QuicSentPacketManager::TimeUntilSend( 611 QuicTime::Delta QuicSentPacketManager::TimeUntilSend(
607 QuicTime now, 612 QuicTime now,
608 TransmissionType transmission_type,
609 HasRetransmittableData retransmittable) { 613 HasRetransmittableData retransmittable) {
610 // The TLP logic is entirely contained within QuicSentPacketManager, so the 614 // The TLP logic is entirely contained within QuicSentPacketManager, so the
611 // send algorithm does not need to be consulted. 615 // send algorithm does not need to be consulted.
612 if (transmission_type == TLP_RETRANSMISSION) { 616 if (pending_tlp_transmission_) {
613 return QuicTime::Delta::Zero(); 617 return QuicTime::Delta::Zero();
614 } 618 }
615 return send_algorithm_->TimeUntilSend( 619 return send_algorithm_->TimeUntilSend(
616 now, unacked_packets_.bytes_in_flight(), retransmittable); 620 now, unacked_packets_.bytes_in_flight(), retransmittable);
617 } 621 }
618 622
619 // Ensures that the Delayed Ack timer is always set to a value lesser 623 // Ensures that the Delayed Ack timer is always set to a value lesser
620 // than the retransmission timer's minimum value (MinRTO). We want the 624 // than the retransmission timer's minimum value (MinRTO). We want the
621 // delayed ack to get back to the QUIC peer before the sender's 625 // delayed ack to get back to the QUIC peer before the sender's
622 // retransmission timer triggers. Since we do not know the 626 // retransmission timer triggers. Since we do not know the
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 728
725 void QuicSentPacketManager::MaybeEnablePacing() { 729 void QuicSentPacketManager::MaybeEnablePacing() {
726 if (!FLAGS_enable_quic_pacing) { 730 if (!FLAGS_enable_quic_pacing) {
727 return; 731 return;
728 } 732 }
729 733
730 if (using_pacing_) { 734 if (using_pacing_) {
731 return; 735 return;
732 } 736 }
733 737
738 // Set up a pacing sender with a 5 millisecond alarm granularity.
734 using_pacing_ = true; 739 using_pacing_ = true;
735 send_algorithm_.reset( 740 send_algorithm_.reset(
736 new PacingSender(send_algorithm_.release(), 741 new PacingSender(send_algorithm_.release(),
737 QuicTime::Delta::FromMicroseconds(1))); 742 QuicTime::Delta::FromMilliseconds(5)));
738 } 743 }
739 744
740 } // namespace net 745 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager.h ('k') | net/quic/quic_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698