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

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

Issue 693943003: Update from https://crrev.com/302630 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « net/quic/quic_sent_packet_manager.h ('k') | net/quic/quic_sent_packet_manager_test.cc » ('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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 is_server_(is_server), 71 is_server_(is_server),
72 clock_(clock), 72 clock_(clock),
73 stats_(stats), 73 stats_(stats),
74 debug_delegate_(nullptr), 74 debug_delegate_(nullptr),
75 network_change_visitor_(nullptr), 75 network_change_visitor_(nullptr),
76 send_algorithm_(SendAlgorithmInterface::Create(clock, 76 send_algorithm_(SendAlgorithmInterface::Create(clock,
77 &rtt_stats_, 77 &rtt_stats_,
78 congestion_control_type, 78 congestion_control_type,
79 stats)), 79 stats)),
80 loss_algorithm_(LossDetectionInterface::Create(loss_type)), 80 loss_algorithm_(LossDetectionInterface::Create(loss_type)),
81 n_connection_simulation_(false),
81 receive_buffer_bytes_(kDefaultSocketReceiveBuffer), 82 receive_buffer_bytes_(kDefaultSocketReceiveBuffer),
82 least_packet_awaited_by_peer_(1), 83 least_packet_awaited_by_peer_(1),
83 first_rto_transmission_(0), 84 first_rto_transmission_(0),
84 consecutive_rto_count_(0), 85 consecutive_rto_count_(0),
85 consecutive_tlp_count_(0), 86 consecutive_tlp_count_(0),
86 consecutive_crypto_retransmission_count_(0), 87 consecutive_crypto_retransmission_count_(0),
87 pending_timer_transmission_count_(0), 88 pending_timer_transmission_count_(0),
88 max_tail_loss_probes_(kDefaultMaxTailLossProbes), 89 max_tail_loss_probes_(kDefaultMaxTailLossProbes),
89 using_pacing_(false), 90 using_pacing_(false),
90 handshake_confirmed_(false) { 91 handshake_confirmed_(false) {
(...skipping 27 matching lines...) Expand all
118 ContainsQuicTag(config.ReceivedConnectionOptions(), kRENO)) { 119 ContainsQuicTag(config.ReceivedConnectionOptions(), kRENO)) {
119 send_algorithm_.reset( 120 send_algorithm_.reset(
120 SendAlgorithmInterface::Create(clock_, &rtt_stats_, kReno, stats_)); 121 SendAlgorithmInterface::Create(clock_, &rtt_stats_, kReno, stats_));
121 } 122 }
122 if (HasClientSentConnectionOption(config, kPACE)) { 123 if (HasClientSentConnectionOption(config, kPACE)) {
123 EnablePacing(); 124 EnablePacing();
124 } 125 }
125 if (HasClientSentConnectionOption(config, k1CON)) { 126 if (HasClientSentConnectionOption(config, k1CON)) {
126 send_algorithm_->SetNumEmulatedConnections(1); 127 send_algorithm_->SetNumEmulatedConnections(1);
127 } 128 }
129 if (HasClientSentConnectionOption(config, kNCON)) {
130 n_connection_simulation_ = true;
131 }
128 if (HasClientSentConnectionOption(config, kNTLP)) { 132 if (HasClientSentConnectionOption(config, kNTLP)) {
129 max_tail_loss_probes_ = 0; 133 max_tail_loss_probes_ = 0;
130 } 134 }
131 if (config.HasReceivedConnectionOptions() && 135 if (config.HasReceivedConnectionOptions() &&
132 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { 136 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) {
133 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); 137 loss_algorithm_.reset(LossDetectionInterface::Create(kTime));
134 } 138 }
135 if (config.HasReceivedSocketReceiveBuffer()) { 139 if (config.HasReceivedSocketReceiveBuffer()) {
136 receive_buffer_bytes_ = 140 receive_buffer_bytes_ =
137 max(kMinSocketReceiveBuffer, 141 max(kMinSocketReceiveBuffer,
138 static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer())); 142 static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer()));
139 } 143 }
140 send_algorithm_->SetFromConfig(config, is_server_); 144 send_algorithm_->SetFromConfig(config, is_server_);
141 145
142 if (network_change_visitor_ != nullptr) { 146 if (network_change_visitor_ != nullptr) {
143 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); 147 network_change_visitor_->OnCongestionWindowChange();
144 } 148 }
145 } 149 }
146 150
151 void QuicSentPacketManager::SetNumOpenStreams(size_t num_streams) {
152 if (n_connection_simulation_) {
153 // Ensure the number of connections is between 1 and 5.
154 send_algorithm_->SetNumEmulatedConnections(
155 min<size_t>(5, max<size_t>(1, num_streams)));
156 }
157 }
158
147 bool QuicSentPacketManager::HasClientSentConnectionOption( 159 bool QuicSentPacketManager::HasClientSentConnectionOption(
148 const QuicConfig& config, QuicTag tag) const { 160 const QuicConfig& config, QuicTag tag) const {
149 if (is_server_) { 161 if (is_server_) {
150 if (config.HasReceivedConnectionOptions() && 162 if (config.HasReceivedConnectionOptions() &&
151 ContainsQuicTag(config.ReceivedConnectionOptions(), tag)) { 163 ContainsQuicTag(config.ReceivedConnectionOptions(), tag)) {
152 return true; 164 return true;
153 } 165 }
154 } else if (config.HasSendConnectionOptions() && 166 } else if (config.HasSendConnectionOptions() &&
155 ContainsQuicTag(config.SendConnectionOptions(), tag)) { 167 ContainsQuicTag(config.SendConnectionOptions(), tag)) {
156 return true; 168 return true;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 void QuicSentPacketManager::MaybeInvokeCongestionEvent( 230 void QuicSentPacketManager::MaybeInvokeCongestionEvent(
219 bool rtt_updated, QuicByteCount bytes_in_flight) { 231 bool rtt_updated, QuicByteCount bytes_in_flight) {
220 if (!rtt_updated && packets_acked_.empty() && packets_lost_.empty()) { 232 if (!rtt_updated && packets_acked_.empty() && packets_lost_.empty()) {
221 return; 233 return;
222 } 234 }
223 send_algorithm_->OnCongestionEvent(rtt_updated, bytes_in_flight, 235 send_algorithm_->OnCongestionEvent(rtt_updated, bytes_in_flight,
224 packets_acked_, packets_lost_); 236 packets_acked_, packets_lost_);
225 packets_acked_.clear(); 237 packets_acked_.clear();
226 packets_lost_.clear(); 238 packets_lost_.clear();
227 if (network_change_visitor_ != nullptr) { 239 if (network_change_visitor_ != nullptr) {
228 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); 240 network_change_visitor_->OnCongestionWindowChange();
229 } 241 }
230 } 242 }
231 243
232 void QuicSentPacketManager::HandleAckForSentPackets( 244 void QuicSentPacketManager::HandleAckForSentPackets(
233 const QuicAckFrame& ack_frame) { 245 const QuicAckFrame& ack_frame) {
234 // Go through the packets we have not received an ack for and see if this 246 // Go through the packets we have not received an ack for and see if this
235 // incoming_ack shows they've been seen by the peer. 247 // incoming_ack shows they've been seen by the peer.
236 QuicTime::Delta delta_largest_observed = 248 QuicTime::Delta delta_largest_observed =
237 ack_frame.delta_time_largest_observed; 249 ack_frame.delta_time_largest_observed;
238 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); 250 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked();
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 655
644 send_algorithm_->OnRetransmissionTimeout(packets_retransmitted); 656 send_algorithm_->OnRetransmissionTimeout(packets_retransmitted);
645 if (packets_retransmitted) { 657 if (packets_retransmitted) {
646 if (consecutive_rto_count_ == 0) { 658 if (consecutive_rto_count_ == 0) {
647 first_rto_transmission_ = unacked_packets_.largest_sent_packet() + 1; 659 first_rto_transmission_ = unacked_packets_.largest_sent_packet() + 1;
648 } 660 }
649 ++consecutive_rto_count_; 661 ++consecutive_rto_count_;
650 } 662 }
651 663
652 if (network_change_visitor_ != nullptr) { 664 if (network_change_visitor_ != nullptr) {
653 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); 665 network_change_visitor_->OnCongestionWindowChange();
654 } 666 }
655 } 667 }
656 668
657 QuicSentPacketManager::RetransmissionTimeoutMode 669 QuicSentPacketManager::RetransmissionTimeoutMode
658 QuicSentPacketManager::GetRetransmissionMode() const { 670 QuicSentPacketManager::GetRetransmissionMode() const {
659 DCHECK(unacked_packets_.HasInFlightPackets()); 671 DCHECK(unacked_packets_.HasInFlightPackets());
660 if (!handshake_confirmed_ && unacked_packets_.HasPendingCryptoPackets()) { 672 if (!handshake_confirmed_ && unacked_packets_.HasPendingCryptoPackets()) {
661 return HANDSHAKE_MODE; 673 return HANDSHAKE_MODE;
662 } 674 }
663 if (loss_algorithm_->GetLossTimeout() != QuicTime::Zero()) { 675 if (loss_algorithm_->GetLossTimeout() != QuicTime::Zero()) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 max(kMinHandshakeTimeoutMs, 823 max(kMinHandshakeTimeoutMs,
812 static_cast<int64>(1.5 * rtt_stats_.SmoothedRtt().ToMilliseconds())); 824 static_cast<int64>(1.5 * rtt_stats_.SmoothedRtt().ToMilliseconds()));
813 return QuicTime::Delta::FromMilliseconds( 825 return QuicTime::Delta::FromMilliseconds(
814 delay_ms << consecutive_crypto_retransmission_count_); 826 delay_ms << consecutive_crypto_retransmission_count_);
815 } 827 }
816 828
817 const QuicTime::Delta QuicSentPacketManager::GetTailLossProbeDelay() const { 829 const QuicTime::Delta QuicSentPacketManager::GetTailLossProbeDelay() const {
818 QuicTime::Delta srtt = rtt_stats_.SmoothedRtt(); 830 QuicTime::Delta srtt = rtt_stats_.SmoothedRtt();
819 if (!unacked_packets_.HasMultipleInFlightPackets()) { 831 if (!unacked_packets_.HasMultipleInFlightPackets()) {
820 return QuicTime::Delta::Max( 832 return QuicTime::Delta::Max(
821 srtt.Multiply(2), 833 srtt.Multiply(2), srtt.Multiply(1.5).Add(
822 srtt.Multiply(1.5).Add(
823 QuicTime::Delta::FromMilliseconds(kMinRetransmissionTimeMs / 2))); 834 QuicTime::Delta::FromMilliseconds(kMinRetransmissionTimeMs / 2)));
824 } 835 }
825 return QuicTime::Delta::FromMilliseconds( 836 return QuicTime::Delta::FromMilliseconds(
826 max(kMinTailLossProbeTimeoutMs, 837 max(kMinTailLossProbeTimeoutMs,
827 static_cast<int64>(2 * srtt.ToMilliseconds()))); 838 static_cast<int64>(2 * srtt.ToMilliseconds())));
828 } 839 }
829 840
830 const QuicTime::Delta QuicSentPacketManager::GetRetransmissionDelay() const { 841 const QuicTime::Delta QuicSentPacketManager::GetRetransmissionDelay() const {
831 QuicTime::Delta retransmission_delay = send_algorithm_->RetransmissionDelay(); 842 QuicTime::Delta retransmission_delay = send_algorithm_->RetransmissionDelay();
832 // TODO(rch): This code should move to |send_algorithm_|. 843 // TODO(rch): This code should move to |send_algorithm_|.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as 893 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as
883 // the default granularity of the Linux kernel's FQ qdisc. 894 // the default granularity of the Linux kernel's FQ qdisc.
884 using_pacing_ = true; 895 using_pacing_ = true;
885 send_algorithm_.reset( 896 send_algorithm_.reset(
886 new PacingSender(send_algorithm_.release(), 897 new PacingSender(send_algorithm_.release(),
887 QuicTime::Delta::FromMilliseconds(1), 898 QuicTime::Delta::FromMilliseconds(1),
888 kInitialUnpacedBurst)); 899 kInitialUnpacedBurst));
889 } 900 }
890 901
891 } // namespace net 902 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager.h ('k') | net/quic/quic_sent_packet_manager_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698