| OLD | NEW |
| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 congestion_control_type, | 80 congestion_control_type, |
| 81 stats)), | 81 stats)), |
| 82 loss_algorithm_(LossDetectionInterface::Create(loss_type)), | 82 loss_algorithm_(LossDetectionInterface::Create(loss_type)), |
| 83 largest_observed_(0), | 83 largest_observed_(0), |
| 84 first_rto_transmission_(0), | 84 first_rto_transmission_(0), |
| 85 consecutive_rto_count_(0), | 85 consecutive_rto_count_(0), |
| 86 consecutive_tlp_count_(0), | 86 consecutive_tlp_count_(0), |
| 87 consecutive_crypto_retransmission_count_(0), | 87 consecutive_crypto_retransmission_count_(0), |
| 88 pending_tlp_transmission_(false), | 88 pending_tlp_transmission_(false), |
| 89 max_tail_loss_probes_(kDefaultMaxTailLossProbes), | 89 max_tail_loss_probes_(kDefaultMaxTailLossProbes), |
| 90 using_pacing_(false) { | 90 using_pacing_(false), |
| 91 handshake_confirmed_(false) { |
| 91 } | 92 } |
| 92 | 93 |
| 93 QuicSentPacketManager::~QuicSentPacketManager() { | 94 QuicSentPacketManager::~QuicSentPacketManager() { |
| 94 } | 95 } |
| 95 | 96 |
| 96 void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) { | 97 void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) { |
| 97 if (config.HasReceivedInitialRoundTripTimeUs() && | 98 if (config.HasReceivedInitialRoundTripTimeUs() && |
| 98 config.ReceivedInitialRoundTripTimeUs() > 0) { | 99 config.ReceivedInitialRoundTripTimeUs() > 0) { |
| 99 rtt_stats_.set_initial_rtt_us(min(kMaxInitialRoundTripTimeUs, | 100 rtt_stats_.set_initial_rtt_us(min(kMaxInitialRoundTripTimeUs, |
| 100 config.ReceivedInitialRoundTripTimeUs())); | 101 config.ReceivedInitialRoundTripTimeUs())); |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 return false; | 600 return false; |
| 600 } | 601 } |
| 601 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 602 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
| 602 it != unacked_packets_.end(); ++it) { | 603 it != unacked_packets_.end(); ++it) { |
| 603 QuicPacketSequenceNumber sequence_number = it->first; | 604 QuicPacketSequenceNumber sequence_number = it->first; |
| 604 const RetransmittableFrames* frames = it->second.retransmittable_frames; | 605 const RetransmittableFrames* frames = it->second.retransmittable_frames; |
| 605 // Only retransmit frames which are in flight, and therefore have been sent. | 606 // Only retransmit frames which are in flight, and therefore have been sent. |
| 606 if (!it->second.in_flight || frames == NULL) { | 607 if (!it->second.in_flight || frames == NULL) { |
| 607 continue; | 608 continue; |
| 608 } | 609 } |
| 609 DCHECK_NE(IS_HANDSHAKE, frames->HasCryptoHandshake()); | 610 if (!handshake_confirmed_) { |
| 611 DCHECK_NE(IS_HANDSHAKE, frames->HasCryptoHandshake()); |
| 612 } |
| 610 MarkForRetransmission(sequence_number, TLP_RETRANSMISSION); | 613 MarkForRetransmission(sequence_number, TLP_RETRANSMISSION); |
| 611 return true; | 614 return true; |
| 612 } | 615 } |
| 613 DLOG(FATAL) | 616 DLOG(FATAL) |
| 614 << "No retransmittable packets, so RetransmitOldestPacket failed."; | 617 << "No retransmittable packets, so RetransmitOldestPacket failed."; |
| 615 return false; | 618 return false; |
| 616 } | 619 } |
| 617 | 620 |
| 618 void QuicSentPacketManager::RetransmitAllPackets() { | 621 void QuicSentPacketManager::RetransmitAllPackets() { |
| 619 DVLOG(1) << "RetransmitAllPackets() called with " | 622 DVLOG(1) << "RetransmitAllPackets() called with " |
| (...skipping 25 matching lines...) Expand all Loading... |
| 645 } | 648 } |
| 646 | 649 |
| 647 if (network_change_visitor_ != NULL) { | 650 if (network_change_visitor_ != NULL) { |
| 648 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); | 651 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); |
| 649 } | 652 } |
| 650 } | 653 } |
| 651 | 654 |
| 652 QuicSentPacketManager::RetransmissionTimeoutMode | 655 QuicSentPacketManager::RetransmissionTimeoutMode |
| 653 QuicSentPacketManager::GetRetransmissionMode() const { | 656 QuicSentPacketManager::GetRetransmissionMode() const { |
| 654 DCHECK(unacked_packets_.HasInFlightPackets()); | 657 DCHECK(unacked_packets_.HasInFlightPackets()); |
| 655 if (unacked_packets_.HasPendingCryptoPackets()) { | 658 if (!handshake_confirmed_ && unacked_packets_.HasPendingCryptoPackets()) { |
| 656 return HANDSHAKE_MODE; | 659 return HANDSHAKE_MODE; |
| 657 } | 660 } |
| 658 if (loss_algorithm_->GetLossTimeout() != QuicTime::Zero()) { | 661 if (loss_algorithm_->GetLossTimeout() != QuicTime::Zero()) { |
| 659 return LOSS_MODE; | 662 return LOSS_MODE; |
| 660 } | 663 } |
| 661 if (consecutive_tlp_count_ < max_tail_loss_probes_) { | 664 if (consecutive_tlp_count_ < max_tail_loss_probes_) { |
| 662 if (unacked_packets_.HasUnackedRetransmittableFrames()) { | 665 if (unacked_packets_.HasUnackedRetransmittableFrames()) { |
| 663 return TLP_MODE; | 666 return TLP_MODE; |
| 664 } | 667 } |
| 665 } | 668 } |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 | 865 |
| 863 // Set up a pacing sender with a 5 millisecond alarm granularity. | 866 // Set up a pacing sender with a 5 millisecond alarm granularity. |
| 864 using_pacing_ = true; | 867 using_pacing_ = true; |
| 865 send_algorithm_.reset( | 868 send_algorithm_.reset( |
| 866 new PacingSender(send_algorithm_.release(), | 869 new PacingSender(send_algorithm_.release(), |
| 867 QuicTime::Delta::FromMilliseconds(5), | 870 QuicTime::Delta::FromMilliseconds(5), |
| 868 kInitialUnpacedBurst)); | 871 kInitialUnpacedBurst)); |
| 869 } | 872 } |
| 870 | 873 |
| 871 } // namespace net | 874 } // namespace net |
| OLD | NEW |