| 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/core/quic_sent_packet_manager.h" | 5 #include "net/quic/core/quic_sent_packet_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> |
| 8 | 9 |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 11 #include "net/quic/chromium/quic_utils_chromium.h" | 12 #include "net/quic/chromium/quic_utils_chromium.h" |
| 12 #include "net/quic/core/congestion_control/general_loss_algorithm.h" | 13 #include "net/quic/core/congestion_control/general_loss_algorithm.h" |
| 13 #include "net/quic/core/congestion_control/pacing_sender.h" | 14 #include "net/quic/core/congestion_control/pacing_sender.h" |
| 14 #include "net/quic/core/crypto/crypto_protocol.h" | 15 #include "net/quic/core/crypto/crypto_protocol.h" |
| 15 #include "net/quic/core/proto/cached_network_parameters.pb.h" | 16 #include "net/quic/core/proto/cached_network_parameters.pb.h" |
| 16 #include "net/quic/core/quic_bug_tracker.h" | 17 #include "net/quic/core/quic_bug_tracker.h" |
| 17 #include "net/quic/core/quic_connection_stats.h" | 18 #include "net/quic/core/quic_connection_stats.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 MultipathDelegateInterface* delegate) | 63 MultipathDelegateInterface* delegate) |
| 63 : unacked_packets_(), | 64 : unacked_packets_(), |
| 64 perspective_(perspective), | 65 perspective_(perspective), |
| 65 path_id_(path_id), | 66 path_id_(path_id), |
| 66 clock_(clock), | 67 clock_(clock), |
| 67 stats_(stats), | 68 stats_(stats), |
| 68 delegate_(delegate), | 69 delegate_(delegate), |
| 69 debug_delegate_(nullptr), | 70 debug_delegate_(nullptr), |
| 70 network_change_visitor_(nullptr), | 71 network_change_visitor_(nullptr), |
| 71 initial_congestion_window_(kInitialCongestionWindow), | 72 initial_congestion_window_(kInitialCongestionWindow), |
| 72 send_algorithm_( | 73 loss_algorithm_(&general_loss_algorithm_), |
| 73 SendAlgorithmInterface::Create(clock, | 74 general_loss_algorithm_(loss_type), |
| 74 &rtt_stats_, | |
| 75 congestion_control_type, | |
| 76 stats, | |
| 77 initial_congestion_window_)), | |
| 78 loss_algorithm_(new GeneralLossAlgorithm(loss_type)), | |
| 79 n_connection_simulation_(false), | 75 n_connection_simulation_(false), |
| 80 receive_buffer_bytes_(kDefaultSocketReceiveBuffer), | 76 receive_buffer_bytes_(kDefaultSocketReceiveBuffer), |
| 81 least_packet_awaited_by_peer_(1), | 77 least_packet_awaited_by_peer_(1), |
| 82 first_rto_transmission_(0), | 78 first_rto_transmission_(0), |
| 83 consecutive_rto_count_(0), | 79 consecutive_rto_count_(0), |
| 84 consecutive_tlp_count_(0), | 80 consecutive_tlp_count_(0), |
| 85 consecutive_crypto_retransmission_count_(0), | 81 consecutive_crypto_retransmission_count_(0), |
| 86 pending_timer_transmission_count_(0), | 82 pending_timer_transmission_count_(0), |
| 87 max_tail_loss_probes_(kDefaultMaxTailLossProbes), | 83 max_tail_loss_probes_(kDefaultMaxTailLossProbes), |
| 88 enable_half_rtt_tail_loss_probe_(false), | 84 enable_half_rtt_tail_loss_probe_(false), |
| 89 using_pacing_(false), | 85 using_pacing_(false), |
| 90 using_inline_pacing_(false), | |
| 91 use_new_rto_(false), | 86 use_new_rto_(false), |
| 92 undo_pending_retransmits_(false), | 87 undo_pending_retransmits_(false), |
| 93 largest_newly_acked_(0), | 88 largest_newly_acked_(0), |
| 94 largest_mtu_acked_(0), | 89 largest_mtu_acked_(0), |
| 95 handshake_confirmed_(false) {} | 90 handshake_confirmed_(false) { |
| 91 SetSendAlgorithm(congestion_control_type); |
| 92 } |
| 96 | 93 |
| 97 QuicSentPacketManager::~QuicSentPacketManager() {} | 94 QuicSentPacketManager::~QuicSentPacketManager() {} |
| 98 | 95 |
| 99 void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) { | 96 void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) { |
| 100 if (config.HasReceivedInitialRoundTripTimeUs() && | 97 if (config.HasReceivedInitialRoundTripTimeUs() && |
| 101 config.ReceivedInitialRoundTripTimeUs() > 0) { | 98 config.ReceivedInitialRoundTripTimeUs() > 0) { |
| 102 rtt_stats_.set_initial_rtt_us( | 99 rtt_stats_.set_initial_rtt_us( |
| 103 max(kMinInitialRoundTripTimeUs, | 100 max(kMinInitialRoundTripTimeUs, |
| 104 min(kMaxInitialRoundTripTimeUs, | 101 min(kMaxInitialRoundTripTimeUs, |
| 105 config.ReceivedInitialRoundTripTimeUs()))); | 102 config.ReceivedInitialRoundTripTimeUs()))); |
| 106 } else if (config.HasInitialRoundTripTimeUsToSend() && | 103 } else if (config.HasInitialRoundTripTimeUsToSend() && |
| 107 config.GetInitialRoundTripTimeUsToSend() > 0) { | 104 config.GetInitialRoundTripTimeUsToSend() > 0) { |
| 108 rtt_stats_.set_initial_rtt_us( | 105 rtt_stats_.set_initial_rtt_us( |
| 109 max(kMinInitialRoundTripTimeUs, | 106 max(kMinInitialRoundTripTimeUs, |
| 110 min(kMaxInitialRoundTripTimeUs, | 107 min(kMaxInitialRoundTripTimeUs, |
| 111 config.GetInitialRoundTripTimeUsToSend()))); | 108 config.GetInitialRoundTripTimeUsToSend()))); |
| 112 } | 109 } |
| 113 // TODO(ianswett): BBR is currently a server only feature. | 110 // TODO(ianswett): BBR is currently a server only feature. |
| 114 if (FLAGS_quic_allow_bbr && config.HasReceivedConnectionOptions() && | 111 if (FLAGS_quic_allow_bbr && config.HasReceivedConnectionOptions() && |
| 115 ContainsQuicTag(config.ReceivedConnectionOptions(), kTBBR)) { | 112 ContainsQuicTag(config.ReceivedConnectionOptions(), kTBBR)) { |
| 116 send_algorithm_.reset(SendAlgorithmInterface::Create( | 113 SetSendAlgorithm(kBBR); |
| 117 clock_, &rtt_stats_, kBBR, stats_, initial_congestion_window_)); | |
| 118 } | 114 } |
| 119 if (config.HasReceivedConnectionOptions() && | 115 if (config.HasReceivedConnectionOptions() && |
| 120 ContainsQuicTag(config.ReceivedConnectionOptions(), kRENO)) { | 116 ContainsQuicTag(config.ReceivedConnectionOptions(), kRENO)) { |
| 121 if (ContainsQuicTag(config.ReceivedConnectionOptions(), kBYTE)) { | 117 if (ContainsQuicTag(config.ReceivedConnectionOptions(), kBYTE)) { |
| 122 send_algorithm_.reset(SendAlgorithmInterface::Create( | 118 SetSendAlgorithm(kRenoBytes); |
| 123 clock_, &rtt_stats_, kRenoBytes, stats_, initial_congestion_window_)); | |
| 124 } else { | 119 } else { |
| 125 send_algorithm_.reset(SendAlgorithmInterface::Create( | 120 SetSendAlgorithm(kReno); |
| 126 clock_, &rtt_stats_, kReno, stats_, initial_congestion_window_)); | |
| 127 } | 121 } |
| 128 } else if (config.HasReceivedConnectionOptions() && | 122 } else if (config.HasReceivedConnectionOptions() && |
| 129 ContainsQuicTag(config.ReceivedConnectionOptions(), kBYTE)) { | 123 ContainsQuicTag(config.ReceivedConnectionOptions(), kBYTE)) { |
| 130 send_algorithm_.reset(SendAlgorithmInterface::Create( | 124 SetSendAlgorithm(kCubicBytes); |
| 131 clock_, &rtt_stats_, kCubicBytes, stats_, initial_congestion_window_)); | |
| 132 } | 125 } |
| 133 if (!FLAGS_quic_disable_pacing_for_perf_tests) { | 126 using_pacing_ = !FLAGS_quic_disable_pacing_for_perf_tests; |
| 134 EnablePacing(); | |
| 135 } | |
| 136 | 127 |
| 137 if (config.HasClientSentConnectionOption(k1CON, perspective_)) { | 128 if (config.HasClientSentConnectionOption(k1CON, perspective_)) { |
| 138 send_algorithm_->SetNumEmulatedConnections(1); | 129 send_algorithm_->SetNumEmulatedConnections(1); |
| 139 } | 130 } |
| 140 if (config.HasClientSentConnectionOption(kNCON, perspective_)) { | 131 if (config.HasClientSentConnectionOption(kNCON, perspective_)) { |
| 141 n_connection_simulation_ = true; | 132 n_connection_simulation_ = true; |
| 142 } | 133 } |
| 143 if (config.HasClientSentConnectionOption(kNTLP, perspective_)) { | 134 if (config.HasClientSentConnectionOption(kNTLP, perspective_)) { |
| 144 max_tail_loss_probes_ = 0; | 135 max_tail_loss_probes_ = 0; |
| 145 } | 136 } |
| 146 if (config.HasClientSentConnectionOption(kTLPR, perspective_)) { | 137 if (config.HasClientSentConnectionOption(kTLPR, perspective_)) { |
| 147 enable_half_rtt_tail_loss_probe_ = true; | 138 enable_half_rtt_tail_loss_probe_ = true; |
| 148 } | 139 } |
| 149 if (config.HasClientSentConnectionOption(kNRTO, perspective_)) { | 140 if (config.HasClientSentConnectionOption(kNRTO, perspective_)) { |
| 150 use_new_rto_ = true; | 141 use_new_rto_ = true; |
| 151 } | 142 } |
| 152 if (config.HasReceivedConnectionOptions() && | 143 if (config.HasReceivedConnectionOptions() && |
| 153 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { | 144 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { |
| 154 loss_algorithm_.reset(new GeneralLossAlgorithm(kTime)); | 145 general_loss_algorithm_.SetLossDetectionType(kTime); |
| 155 } | 146 } |
| 156 if (config.HasReceivedConnectionOptions() && | 147 if (config.HasReceivedConnectionOptions() && |
| 157 ContainsQuicTag(config.ReceivedConnectionOptions(), kATIM)) { | 148 ContainsQuicTag(config.ReceivedConnectionOptions(), kATIM)) { |
| 158 loss_algorithm_.reset(new GeneralLossAlgorithm(kAdaptiveTime)); | 149 general_loss_algorithm_.SetLossDetectionType(kAdaptiveTime); |
| 159 } | 150 } |
| 160 if (FLAGS_quic_loss_recovery_use_largest_acked && | 151 if (FLAGS_quic_loss_recovery_use_largest_acked && |
| 161 config.HasClientSentConnectionOption(kUNDO, perspective_)) { | 152 config.HasClientSentConnectionOption(kUNDO, perspective_)) { |
| 162 undo_pending_retransmits_ = true; | 153 undo_pending_retransmits_ = true; |
| 163 } | 154 } |
| 164 send_algorithm_->SetFromConfig(config, perspective_); | 155 send_algorithm_->SetFromConfig(config, perspective_); |
| 165 | 156 |
| 166 if (network_change_visitor_ != nullptr) { | 157 if (network_change_visitor_ != nullptr) { |
| 167 network_change_visitor_->OnCongestionChange(); | 158 network_change_visitor_->OnCongestionChange(); |
| 168 } | 159 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 184 | 175 |
| 185 void QuicSentPacketManager::SetNumOpenStreams(size_t num_streams) { | 176 void QuicSentPacketManager::SetNumOpenStreams(size_t num_streams) { |
| 186 if (n_connection_simulation_) { | 177 if (n_connection_simulation_) { |
| 187 // Ensure the number of connections is between 1 and 5. | 178 // Ensure the number of connections is between 1 and 5. |
| 188 send_algorithm_->SetNumEmulatedConnections( | 179 send_algorithm_->SetNumEmulatedConnections( |
| 189 min<size_t>(5, max<size_t>(1, num_streams))); | 180 min<size_t>(5, max<size_t>(1, num_streams))); |
| 190 } | 181 } |
| 191 } | 182 } |
| 192 | 183 |
| 193 void QuicSentPacketManager::SetMaxPacingRate(QuicBandwidth max_pacing_rate) { | 184 void QuicSentPacketManager::SetMaxPacingRate(QuicBandwidth max_pacing_rate) { |
| 194 if (using_inline_pacing_) { | 185 pacing_sender_.set_max_pacing_rate(max_pacing_rate); |
| 195 pacing_sender_.SetMaxPacingRate(max_pacing_rate); | |
| 196 } else if (using_pacing_) { | |
| 197 static_cast<PacingSender*>(send_algorithm_.get()) | |
| 198 ->SetMaxPacingRate(max_pacing_rate); | |
| 199 } | |
| 200 } | 186 } |
| 201 | 187 |
| 202 void QuicSentPacketManager::SetHandshakeConfirmed() { | 188 void QuicSentPacketManager::SetHandshakeConfirmed() { |
| 203 handshake_confirmed_ = true; | 189 handshake_confirmed_ = true; |
| 204 } | 190 } |
| 205 | 191 |
| 206 void QuicSentPacketManager::OnIncomingAck(const QuicAckFrame& ack_frame, | 192 void QuicSentPacketManager::OnIncomingAck(const QuicAckFrame& ack_frame, |
| 207 QuicTime ack_receive_time) { | 193 QuicTime ack_receive_time) { |
| 208 DCHECK_LE(ack_frame.largest_observed, unacked_packets_.largest_sent_packet()); | 194 DCHECK_LE(ack_frame.largest_observed, unacked_packets_.largest_sent_packet()); |
| 209 QuicByteCount bytes_in_flight = unacked_packets_.bytes_in_flight(); | 195 QuicByteCount bytes_in_flight = unacked_packets_.bytes_in_flight(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 least_packet_awaited_by_peer_ = ack_frame.packets.Min(); | 260 least_packet_awaited_by_peer_ = ack_frame.packets.Min(); |
| 275 } | 261 } |
| 276 } | 262 } |
| 277 | 263 |
| 278 void QuicSentPacketManager::MaybeInvokeCongestionEvent( | 264 void QuicSentPacketManager::MaybeInvokeCongestionEvent( |
| 279 bool rtt_updated, | 265 bool rtt_updated, |
| 280 QuicByteCount bytes_in_flight) { | 266 QuicByteCount bytes_in_flight) { |
| 281 if (!rtt_updated && packets_acked_.empty() && packets_lost_.empty()) { | 267 if (!rtt_updated && packets_acked_.empty() && packets_lost_.empty()) { |
| 282 return; | 268 return; |
| 283 } | 269 } |
| 284 if (using_inline_pacing_) { | 270 if (using_pacing_) { |
| 285 pacing_sender_.OnCongestionEvent(rtt_updated, bytes_in_flight, | 271 pacing_sender_.OnCongestionEvent(rtt_updated, bytes_in_flight, |
| 286 packets_acked_, packets_lost_); | 272 packets_acked_, packets_lost_); |
| 287 } else { | 273 } else { |
| 288 send_algorithm_->OnCongestionEvent(rtt_updated, bytes_in_flight, | 274 send_algorithm_->OnCongestionEvent(rtt_updated, bytes_in_flight, |
| 289 packets_acked_, packets_lost_); | 275 packets_acked_, packets_lost_); |
| 290 } | 276 } |
| 291 packets_acked_.clear(); | 277 packets_acked_.clear(); |
| 292 packets_lost_.clear(); | 278 packets_lost_.clear(); |
| 293 if (network_change_visitor_ != nullptr) { | 279 if (network_change_visitor_ != nullptr) { |
| 294 network_change_visitor_->OnCongestionChange(); | 280 network_change_visitor_->OnCongestionChange(); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 | 543 |
| 558 if (delegate_ == nullptr && original_packet_number != 0) { | 544 if (delegate_ == nullptr && original_packet_number != 0) { |
| 559 pending_retransmissions_.erase(original_packet_number); | 545 pending_retransmissions_.erase(original_packet_number); |
| 560 } | 546 } |
| 561 | 547 |
| 562 if (pending_timer_transmission_count_ > 0) { | 548 if (pending_timer_transmission_count_ > 0) { |
| 563 --pending_timer_transmission_count_; | 549 --pending_timer_transmission_count_; |
| 564 } | 550 } |
| 565 | 551 |
| 566 bool in_flight; | 552 bool in_flight; |
| 567 if (using_inline_pacing_) { | 553 if (using_pacing_) { |
| 568 in_flight = pacing_sender_.OnPacketSent( | 554 in_flight = pacing_sender_.OnPacketSent( |
| 569 sent_time, unacked_packets_.bytes_in_flight(), packet_number, | 555 sent_time, unacked_packets_.bytes_in_flight(), packet_number, |
| 570 serialized_packet->encrypted_length, has_retransmittable_data); | 556 serialized_packet->encrypted_length, has_retransmittable_data); |
| 571 } else { | 557 } else { |
| 572 in_flight = send_algorithm_->OnPacketSent( | 558 in_flight = send_algorithm_->OnPacketSent( |
| 573 sent_time, unacked_packets_.bytes_in_flight(), packet_number, | 559 sent_time, unacked_packets_.bytes_in_flight(), packet_number, |
| 574 serialized_packet->encrypted_length, has_retransmittable_data); | 560 serialized_packet->encrypted_length, has_retransmittable_data); |
| 575 } | 561 } |
| 576 | 562 |
| 577 unacked_packets_.AddSentPacket(serialized_packet, original_packet_number, | 563 unacked_packets_.AddSentPacket(serialized_packet, original_packet_number, |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 unacked_packets_.GetTransmissionInfo(ack_frame.largest_observed); | 740 unacked_packets_.GetTransmissionInfo(ack_frame.largest_observed); |
| 755 // Ensure the packet has a valid sent time. | 741 // Ensure the packet has a valid sent time. |
| 756 if (transmission_info.sent_time == QuicTime::Zero()) { | 742 if (transmission_info.sent_time == QuicTime::Zero()) { |
| 757 QUIC_BUG << "Acked packet has zero sent time, largest_observed:" | 743 QUIC_BUG << "Acked packet has zero sent time, largest_observed:" |
| 758 << ack_frame.largest_observed; | 744 << ack_frame.largest_observed; |
| 759 return false; | 745 return false; |
| 760 } | 746 } |
| 761 | 747 |
| 762 QuicTime::Delta send_delta = ack_receive_time - transmission_info.sent_time; | 748 QuicTime::Delta send_delta = ack_receive_time - transmission_info.sent_time; |
| 763 const int kMaxSendDeltaSeconds = 30; | 749 const int kMaxSendDeltaSeconds = 30; |
| 764 if (FLAGS_quic_socket_walltimestamps && | 750 if (send_delta.ToSeconds() > kMaxSendDeltaSeconds) { |
| 765 send_delta.ToSeconds() > kMaxSendDeltaSeconds) { | |
| 766 // send_delta can be very high if local clock is changed mid-connection. | 751 // send_delta can be very high if local clock is changed mid-connection. |
| 767 LOG(WARNING) << "Excessive send delta: " << send_delta.ToSeconds() | 752 LOG(WARNING) << "Excessive send delta: " << send_delta.ToSeconds() |
| 768 << ", setting to: " << kMaxSendDeltaSeconds | 753 << ", setting to: " << kMaxSendDeltaSeconds |
| 769 << " largest_observed:" << ack_frame.largest_observed | 754 << " largest_observed:" << ack_frame.largest_observed |
| 770 << " ack_receive_time:" << ack_receive_time.ToDebuggingValue() | 755 << " ack_receive_time:" << ack_receive_time.ToDebuggingValue() |
| 771 << " sent_time:" | 756 << " sent_time:" |
| 772 << transmission_info.sent_time.ToDebuggingValue(); | 757 << transmission_info.sent_time.ToDebuggingValue(); |
| 773 return false; | 758 return false; |
| 774 } | 759 } |
| 775 rtt_stats_.UpdateRtt(send_delta, ack_frame.ack_delay_time, ack_receive_time); | 760 rtt_stats_.UpdateRtt(send_delta, ack_frame.ack_delay_time, ack_receive_time); |
| 776 | 761 |
| 777 return true; | 762 return true; |
| 778 } | 763 } |
| 779 | 764 |
| 780 QuicTime::Delta QuicSentPacketManager::TimeUntilSend(QuicTime now, | 765 QuicTime::Delta QuicSentPacketManager::TimeUntilSend(QuicTime now, |
| 781 QuicPathId* path_id) { | 766 QuicPathId* path_id) { |
| 782 QuicTime::Delta delay = QuicTime::Delta::Infinite(); | 767 QuicTime::Delta delay = QuicTime::Delta::Infinite(); |
| 783 // The TLP logic is entirely contained within QuicSentPacketManager, so the | 768 // The TLP logic is entirely contained within QuicSentPacketManager, so the |
| 784 // send algorithm does not need to be consulted. | 769 // send algorithm does not need to be consulted. |
| 785 if (pending_timer_transmission_count_ > 0) { | 770 if (pending_timer_transmission_count_ > 0) { |
| 786 delay = QuicTime::Delta::Zero(); | 771 delay = QuicTime::Delta::Zero(); |
| 772 } else if (using_pacing_) { |
| 773 delay = |
| 774 pacing_sender_.TimeUntilSend(now, unacked_packets_.bytes_in_flight()); |
| 787 } else { | 775 } else { |
| 788 if (using_inline_pacing_) { | 776 delay = |
| 789 delay = | 777 send_algorithm_->TimeUntilSend(now, unacked_packets_.bytes_in_flight()); |
| 790 pacing_sender_.TimeUntilSend(now, unacked_packets_.bytes_in_flight()); | |
| 791 } else { | |
| 792 delay = send_algorithm_->TimeUntilSend( | |
| 793 now, unacked_packets_.bytes_in_flight()); | |
| 794 } | |
| 795 } | 778 } |
| 796 if (!delay.IsInfinite()) { | 779 if (!delay.IsInfinite()) { |
| 797 *path_id = path_id_; | 780 *path_id = path_id_; |
| 798 } | 781 } |
| 799 return delay; | 782 return delay; |
| 800 } | 783 } |
| 801 | 784 |
| 802 const QuicTime QuicSentPacketManager::GetRetransmissionTime() const { | 785 const QuicTime QuicSentPacketManager::GetRetransmissionTime() const { |
| 803 // Don't set the timer if there are no packets in flight or we've already | 786 // Don't set the timer if there are no packets in flight or we've already |
| 804 // queued a tlp transmission and it hasn't been sent yet. | 787 // queued a tlp transmission and it hasn't been sent yet. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 } | 897 } |
| 915 | 898 |
| 916 QuicByteCount QuicSentPacketManager::GetCongestionWindowInBytes() const { | 899 QuicByteCount QuicSentPacketManager::GetCongestionWindowInBytes() const { |
| 917 return send_algorithm_->GetCongestionWindow(); | 900 return send_algorithm_->GetCongestionWindow(); |
| 918 } | 901 } |
| 919 | 902 |
| 920 QuicPacketCount QuicSentPacketManager::GetSlowStartThresholdInTcpMss() const { | 903 QuicPacketCount QuicSentPacketManager::GetSlowStartThresholdInTcpMss() const { |
| 921 return send_algorithm_->GetSlowStartThreshold() / kDefaultTCPMSS; | 904 return send_algorithm_->GetSlowStartThreshold() / kDefaultTCPMSS; |
| 922 } | 905 } |
| 923 | 906 |
| 907 std::string QuicSentPacketManager::GetDebugState() const { |
| 908 return send_algorithm_->GetDebugState(); |
| 909 } |
| 910 |
| 924 void QuicSentPacketManager::CancelRetransmissionsForStream( | 911 void QuicSentPacketManager::CancelRetransmissionsForStream( |
| 925 QuicStreamId stream_id) { | 912 QuicStreamId stream_id) { |
| 926 unacked_packets_.CancelRetransmissionsForStream(stream_id); | 913 unacked_packets_.CancelRetransmissionsForStream(stream_id); |
| 927 if (delegate_ != nullptr) { | 914 if (delegate_ != nullptr) { |
| 928 return; | 915 return; |
| 929 } | 916 } |
| 930 PendingRetransmissionMap::iterator it = pending_retransmissions_.begin(); | 917 PendingRetransmissionMap::iterator it = pending_retransmissions_.begin(); |
| 931 while (it != pending_retransmissions_.end()) { | 918 while (it != pending_retransmissions_.end()) { |
| 932 if (unacked_packets_.HasRetransmittableFrames(it->first)) { | 919 if (unacked_packets_.HasRetransmittableFrames(it->first)) { |
| 933 ++it; | 920 ++it; |
| 934 continue; | 921 continue; |
| 935 } | 922 } |
| 936 it = pending_retransmissions_.erase(it); | 923 it = pending_retransmissions_.erase(it); |
| 937 } | 924 } |
| 938 } | 925 } |
| 939 | 926 |
| 940 void QuicSentPacketManager::EnablePacing() { | 927 void QuicSentPacketManager::SetSendAlgorithm( |
| 941 if (FLAGS_quic_use_inline_pacing) { | 928 CongestionControlType congestion_control_type) { |
| 942 using_inline_pacing_ = true; | 929 SetSendAlgorithm(SendAlgorithmInterface::Create( |
| 943 pacing_sender_.SetSender(send_algorithm_.get(), false); | 930 clock_, &rtt_stats_, congestion_control_type, stats_, |
| 944 } else { | 931 initial_congestion_window_)); |
| 945 // TODO(ianswett): Replace with a method which wraps the send algorithm in a | 932 } |
| 946 // pacer every time a new algorithm is set. | |
| 947 if (using_pacing_) { | |
| 948 return; | |
| 949 } | |
| 950 | 933 |
| 951 // Set up a pacing sender with a 1 millisecond alarm granularity, the same | 934 void QuicSentPacketManager::SetSendAlgorithm( |
| 952 // as the default granularity of the Linux kernel's FQ qdisc. | 935 SendAlgorithmInterface* send_algorithm) { |
| 953 using_pacing_ = true; | 936 send_algorithm_.reset(send_algorithm); |
| 954 PacingSender* pacing_sender = new PacingSender; | 937 pacing_sender_.set_sender(send_algorithm); |
| 955 pacing_sender->SetSender(send_algorithm_.release(), true); | |
| 956 send_algorithm_.reset(pacing_sender); | |
| 957 } | |
| 958 } | 938 } |
| 959 | 939 |
| 960 void QuicSentPacketManager::OnConnectionMigration(QuicPathId, | 940 void QuicSentPacketManager::OnConnectionMigration(QuicPathId, |
| 961 PeerAddressChangeType type) { | 941 PeerAddressChangeType type) { |
| 962 if (type == PORT_CHANGE || type == IPV4_SUBNET_CHANGE) { | 942 if (type == PORT_CHANGE || type == IPV4_SUBNET_CHANGE) { |
| 963 // Rtt and cwnd do not need to be reset when the peer address change is | 943 // Rtt and cwnd do not need to be reset when the peer address change is |
| 964 // considered to be caused by NATs. | 944 // considered to be caused by NATs. |
| 965 return; | 945 return; |
| 966 } | 946 } |
| 967 consecutive_rto_count_ = 0; | 947 consecutive_rto_count_ = 0; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 | 993 |
| 1014 TransmissionInfo* QuicSentPacketManager::GetMutableTransmissionInfo( | 994 TransmissionInfo* QuicSentPacketManager::GetMutableTransmissionInfo( |
| 1015 QuicPacketNumber packet_number) { | 995 QuicPacketNumber packet_number) { |
| 1016 return unacked_packets_.GetMutableTransmissionInfo(packet_number); | 996 return unacked_packets_.GetMutableTransmissionInfo(packet_number); |
| 1017 } | 997 } |
| 1018 | 998 |
| 1019 void QuicSentPacketManager::RemoveObsoletePackets() { | 999 void QuicSentPacketManager::RemoveObsoletePackets() { |
| 1020 unacked_packets_.RemoveObsoletePackets(); | 1000 unacked_packets_.RemoveObsoletePackets(); |
| 1021 } | 1001 } |
| 1022 | 1002 |
| 1003 void QuicSentPacketManager::OnApplicationLimited() { |
| 1004 send_algorithm_->OnApplicationLimited(unacked_packets_.bytes_in_flight()); |
| 1005 } |
| 1006 |
| 1023 } // namespace net | 1007 } // namespace net |
| OLD | NEW |