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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 use_new_rto_ = true; | 165 use_new_rto_ = true; |
166 } | 166 } |
167 if (config.HasReceivedConnectionOptions() && | 167 if (config.HasReceivedConnectionOptions() && |
168 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { | 168 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { |
169 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); | 169 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); |
170 } | 170 } |
171 if (config.HasReceivedSocketReceiveBuffer()) { | 171 if (config.HasReceivedSocketReceiveBuffer()) { |
172 receive_buffer_bytes_ = | 172 receive_buffer_bytes_ = |
173 max(kMinSocketReceiveBuffer, | 173 max(kMinSocketReceiveBuffer, |
174 static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer())); | 174 static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer())); |
| 175 if (FLAGS_quic_limit_max_cwnd_to_receive_buffer) { |
| 176 send_algorithm_->SetMaxCongestionWindow(receive_buffer_bytes_ * |
| 177 kUsableRecieveBufferFraction); |
| 178 } |
175 } | 179 } |
176 send_algorithm_->SetFromConfig(config, perspective_, using_pacing_); | 180 send_algorithm_->SetFromConfig(config, perspective_, using_pacing_); |
177 | 181 |
178 if (network_change_visitor_ != nullptr) { | 182 if (network_change_visitor_ != nullptr) { |
179 network_change_visitor_->OnCongestionWindowChange(); | 183 network_change_visitor_->OnCongestionWindowChange(); |
180 } | 184 } |
181 } | 185 } |
182 | 186 |
183 bool QuicSentPacketManager::ResumeConnectionState( | 187 bool QuicSentPacketManager::ResumeConnectionState( |
184 const CachedNetworkParameters& cached_network_params) { | 188 const CachedNetworkParameters& cached_network_params, |
| 189 bool max_bandwidth_resumption) { |
185 if (cached_network_params.has_min_rtt_ms()) { | 190 if (cached_network_params.has_min_rtt_ms()) { |
186 uint32 initial_rtt_us = | 191 uint32 initial_rtt_us = |
187 kNumMicrosPerMilli * cached_network_params.min_rtt_ms(); | 192 kNumMicrosPerMilli * cached_network_params.min_rtt_ms(); |
188 rtt_stats_.set_initial_rtt_us( | 193 rtt_stats_.set_initial_rtt_us( |
189 max(kMinInitialRoundTripTimeUs, | 194 max(kMinInitialRoundTripTimeUs, |
190 min(kMaxInitialRoundTripTimeUs, initial_rtt_us))); | 195 min(kMaxInitialRoundTripTimeUs, initial_rtt_us))); |
191 } | 196 } |
192 return send_algorithm_->ResumeConnectionState(cached_network_params); | 197 return send_algorithm_->ResumeConnectionState(cached_network_params, |
| 198 max_bandwidth_resumption); |
193 } | 199 } |
194 | 200 |
195 void QuicSentPacketManager::SetNumOpenStreams(size_t num_streams) { | 201 void QuicSentPacketManager::SetNumOpenStreams(size_t num_streams) { |
196 if (n_connection_simulation_) { | 202 if (n_connection_simulation_) { |
197 // Ensure the number of connections is between 1 and 5. | 203 // Ensure the number of connections is between 1 and 5. |
198 send_algorithm_->SetNumEmulatedConnections( | 204 send_algorithm_->SetNumEmulatedConnections( |
199 min<size_t>(5, max<size_t>(1, num_streams))); | 205 min<size_t>(5, max<size_t>(1, num_streams))); |
200 } | 206 } |
201 } | 207 } |
202 | 208 |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 } | 790 } |
785 | 791 |
786 QuicTime::Delta QuicSentPacketManager::TimeUntilSend( | 792 QuicTime::Delta QuicSentPacketManager::TimeUntilSend( |
787 QuicTime now, | 793 QuicTime now, |
788 HasRetransmittableData retransmittable) { | 794 HasRetransmittableData retransmittable) { |
789 // The TLP logic is entirely contained within QuicSentPacketManager, so the | 795 // The TLP logic is entirely contained within QuicSentPacketManager, so the |
790 // send algorithm does not need to be consulted. | 796 // send algorithm does not need to be consulted. |
791 if (pending_timer_transmission_count_ > 0) { | 797 if (pending_timer_transmission_count_ > 0) { |
792 return QuicTime::Delta::Zero(); | 798 return QuicTime::Delta::Zero(); |
793 } | 799 } |
794 if (unacked_packets_.bytes_in_flight() >= | 800 if (!FLAGS_quic_limit_max_cwnd_to_receive_buffer && |
795 kUsableRecieveBufferFraction * receive_buffer_bytes_) { | 801 unacked_packets_.bytes_in_flight() >= |
| 802 kUsableRecieveBufferFraction * receive_buffer_bytes_) { |
796 return QuicTime::Delta::Infinite(); | 803 return QuicTime::Delta::Infinite(); |
797 } | 804 } |
798 return send_algorithm_->TimeUntilSend( | 805 return send_algorithm_->TimeUntilSend( |
799 now, unacked_packets_.bytes_in_flight(), retransmittable); | 806 now, unacked_packets_.bytes_in_flight(), retransmittable); |
800 } | 807 } |
801 | 808 |
802 // Uses a 25ms delayed ack timer. Also helps with better signaling | 809 // Uses a 25ms delayed ack timer. Also helps with better signaling |
803 // in low-bandwidth (< ~384 kbps), where an ack is sent per packet. | 810 // in low-bandwidth (< ~384 kbps), where an ack is sent per packet. |
804 // Ensures that the Delayed Ack timer is always set to a value lesser | 811 // Ensures that the Delayed Ack timer is always set to a value lesser |
805 // than the retransmission timer's minimum value (MinRTO). We want the | 812 // than the retransmission timer's minimum value (MinRTO). We want the |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as | 971 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as |
965 // the default granularity of the Linux kernel's FQ qdisc. | 972 // the default granularity of the Linux kernel's FQ qdisc. |
966 using_pacing_ = true; | 973 using_pacing_ = true; |
967 send_algorithm_.reset( | 974 send_algorithm_.reset( |
968 new PacingSender(send_algorithm_.release(), | 975 new PacingSender(send_algorithm_.release(), |
969 QuicTime::Delta::FromMilliseconds(1), | 976 QuicTime::Delta::FromMilliseconds(1), |
970 kInitialUnpacedBurst)); | 977 kInitialUnpacedBurst)); |
971 } | 978 } |
972 | 979 |
973 } // namespace net | 980 } // namespace net |
OLD | NEW |