| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 QuicSentPacketManager::QuicSentPacketManager(bool is_server, | 66 QuicSentPacketManager::QuicSentPacketManager(bool is_server, |
| 67 const QuicClock* clock, | 67 const QuicClock* clock, |
| 68 QuicConnectionStats* stats, | 68 QuicConnectionStats* stats, |
| 69 CongestionFeedbackType type, | 69 CongestionFeedbackType type, |
| 70 LossDetectionType loss_type) | 70 LossDetectionType loss_type) |
| 71 : unacked_packets_(), | 71 : unacked_packets_(), |
| 72 is_server_(is_server), | 72 is_server_(is_server), |
| 73 clock_(clock), | 73 clock_(clock), |
| 74 stats_(stats), | 74 stats_(stats), |
| 75 debug_delegate_(NULL), | 75 debug_delegate_(NULL), |
| 76 network_change_visitor_(NULL), |
| 76 send_algorithm_( | 77 send_algorithm_( |
| 77 SendAlgorithmInterface::Create(clock, &rtt_stats_, type, stats)), | 78 SendAlgorithmInterface::Create(clock, &rtt_stats_, type, stats)), |
| 78 loss_algorithm_(LossDetectionInterface::Create(loss_type)), | 79 loss_algorithm_(LossDetectionInterface::Create(loss_type)), |
| 79 largest_observed_(0), | 80 largest_observed_(0), |
| 80 first_rto_transmission_(0), | 81 first_rto_transmission_(0), |
| 81 consecutive_rto_count_(0), | 82 consecutive_rto_count_(0), |
| 82 consecutive_tlp_count_(0), | 83 consecutive_tlp_count_(0), |
| 83 consecutive_crypto_retransmission_count_(0), | 84 consecutive_crypto_retransmission_count_(0), |
| 84 pending_tlp_transmission_(false), | 85 pending_tlp_transmission_(false), |
| 85 max_tail_loss_probes_(kDefaultMaxTailLossProbes), | 86 max_tail_loss_probes_(kDefaultMaxTailLossProbes), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 112 } | 113 } |
| 113 // TODO(ianswett): Remove the "HasReceivedLossDetection" branch once | 114 // TODO(ianswett): Remove the "HasReceivedLossDetection" branch once |
| 114 // the ConnectionOptions code is live everywhere. | 115 // the ConnectionOptions code is live everywhere. |
| 115 if ((config.HasReceivedLossDetection() && | 116 if ((config.HasReceivedLossDetection() && |
| 116 config.ReceivedLossDetection() == kTIME) || | 117 config.ReceivedLossDetection() == kTIME) || |
| 117 (config.HasReceivedConnectionOptions() && | 118 (config.HasReceivedConnectionOptions() && |
| 118 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME))) { | 119 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME))) { |
| 119 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); | 120 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); |
| 120 } | 121 } |
| 121 send_algorithm_->SetFromConfig(config, is_server_); | 122 send_algorithm_->SetFromConfig(config, is_server_); |
| 123 |
| 124 if (network_change_visitor_ != NULL) { |
| 125 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); |
| 126 } |
| 122 } | 127 } |
| 123 | 128 |
| 124 // TODO(ianswett): Combine this method with OnPacketSent once packets are always | 129 // TODO(ianswett): Combine this method with OnPacketSent once packets are always |
| 125 // sent in order and the connection tracks RetransmittableFrames for longer. | 130 // sent in order and the connection tracks RetransmittableFrames for longer. |
| 126 void QuicSentPacketManager::OnSerializedPacket( | 131 void QuicSentPacketManager::OnSerializedPacket( |
| 127 const SerializedPacket& serialized_packet) { | 132 const SerializedPacket& serialized_packet) { |
| 128 if (serialized_packet.retransmittable_frames) { | 133 if (serialized_packet.retransmittable_frames) { |
| 129 ack_notifier_manager_.OnSerializedPacket(serialized_packet); | 134 ack_notifier_manager_.OnSerializedPacket(serialized_packet); |
| 130 } | 135 } |
| 131 | 136 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 debug_delegate_->OnIncomingAck(received_info, | 205 debug_delegate_->OnIncomingAck(received_info, |
| 201 ack_receive_time, | 206 ack_receive_time, |
| 202 largest_observed_, | 207 largest_observed_, |
| 203 largest_observed_acked, | 208 largest_observed_acked, |
| 204 GetLeastUnackedSentPacket()); | 209 GetLeastUnackedSentPacket()); |
| 205 } | 210 } |
| 206 } | 211 } |
| 207 | 212 |
| 208 void QuicSentPacketManager::MaybeInvokeCongestionEvent( | 213 void QuicSentPacketManager::MaybeInvokeCongestionEvent( |
| 209 bool rtt_updated, QuicByteCount bytes_in_flight) { | 214 bool rtt_updated, QuicByteCount bytes_in_flight) { |
| 210 if (rtt_updated || !packets_acked_.empty() || | 215 if (!rtt_updated && packets_acked_.empty() && packets_lost_.empty()) { |
| 211 !packets_lost_.empty()) { | 216 return; |
| 212 send_algorithm_->OnCongestionEvent( | 217 } |
| 213 rtt_updated, bytes_in_flight, packets_acked_, packets_lost_); | 218 send_algorithm_->OnCongestionEvent(rtt_updated, bytes_in_flight, |
| 214 packets_acked_.clear(); | 219 packets_acked_, packets_lost_); |
| 215 packets_lost_.clear(); | 220 packets_acked_.clear(); |
| 221 packets_lost_.clear(); |
| 222 if (network_change_visitor_ != NULL) { |
| 223 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); |
| 216 } | 224 } |
| 217 } | 225 } |
| 218 | 226 |
| 219 void QuicSentPacketManager::HandleAckForSentPackets( | 227 void QuicSentPacketManager::HandleAckForSentPackets( |
| 220 const ReceivedPacketInfo& received_info) { | 228 const ReceivedPacketInfo& received_info) { |
| 221 // Go through the packets we have not received an ack for and see if this | 229 // Go through the packets we have not received an ack for and see if this |
| 222 // incoming_ack shows they've been seen by the peer. | 230 // incoming_ack shows they've been seen by the peer. |
| 223 QuicTime::Delta delta_largest_observed = | 231 QuicTime::Delta delta_largest_observed = |
| 224 received_info.delta_time_largest_observed; | 232 received_info.delta_time_largest_observed; |
| 225 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 233 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 } | 629 } |
| 622 } | 630 } |
| 623 | 631 |
| 624 send_algorithm_->OnRetransmissionTimeout(packets_retransmitted); | 632 send_algorithm_->OnRetransmissionTimeout(packets_retransmitted); |
| 625 if (packets_retransmitted) { | 633 if (packets_retransmitted) { |
| 626 if (consecutive_rto_count_ == 0) { | 634 if (consecutive_rto_count_ == 0) { |
| 627 first_rto_transmission_ = unacked_packets_.largest_sent_packet() + 1; | 635 first_rto_transmission_ = unacked_packets_.largest_sent_packet() + 1; |
| 628 } | 636 } |
| 629 ++consecutive_rto_count_; | 637 ++consecutive_rto_count_; |
| 630 } | 638 } |
| 639 |
| 640 if (network_change_visitor_ != NULL) { |
| 641 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); |
| 642 } |
| 631 } | 643 } |
| 632 | 644 |
| 633 QuicSentPacketManager::RetransmissionTimeoutMode | 645 QuicSentPacketManager::RetransmissionTimeoutMode |
| 634 QuicSentPacketManager::GetRetransmissionMode() const { | 646 QuicSentPacketManager::GetRetransmissionMode() const { |
| 635 DCHECK(unacked_packets_.HasInFlightPackets()); | 647 DCHECK(unacked_packets_.HasInFlightPackets()); |
| 636 if (unacked_packets_.HasPendingCryptoPackets()) { | 648 if (unacked_packets_.HasPendingCryptoPackets()) { |
| 637 return HANDSHAKE_MODE; | 649 return HANDSHAKE_MODE; |
| 638 } | 650 } |
| 639 if (loss_algorithm_->GetLossTimeout() != QuicTime::Zero()) { | 651 if (loss_algorithm_->GetLossTimeout() != QuicTime::Zero()) { |
| 640 return LOSS_MODE; | 652 return LOSS_MODE; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 | 855 |
| 844 // Set up a pacing sender with a 5 millisecond alarm granularity. | 856 // Set up a pacing sender with a 5 millisecond alarm granularity. |
| 845 using_pacing_ = true; | 857 using_pacing_ = true; |
| 846 send_algorithm_.reset( | 858 send_algorithm_.reset( |
| 847 new PacingSender(send_algorithm_.release(), | 859 new PacingSender(send_algorithm_.release(), |
| 848 QuicTime::Delta::FromMilliseconds(5), | 860 QuicTime::Delta::FromMilliseconds(5), |
| 849 kInitialUnpacedBurst)); | 861 kInitialUnpacedBurst)); |
| 850 } | 862 } |
| 851 | 863 |
| 852 } // namespace net | 864 } // namespace net |
| OLD | NEW |