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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 least_packet_awaited_by_peer_(1), | 92 least_packet_awaited_by_peer_(1), |
93 first_rto_transmission_(0), | 93 first_rto_transmission_(0), |
94 consecutive_rto_count_(0), | 94 consecutive_rto_count_(0), |
95 consecutive_tlp_count_(0), | 95 consecutive_tlp_count_(0), |
96 consecutive_crypto_retransmission_count_(0), | 96 consecutive_crypto_retransmission_count_(0), |
97 pending_timer_transmission_count_(0), | 97 pending_timer_transmission_count_(0), |
98 max_tail_loss_probes_(kDefaultMaxTailLossProbes), | 98 max_tail_loss_probes_(kDefaultMaxTailLossProbes), |
99 enable_half_rtt_tail_loss_probe_(false), | 99 enable_half_rtt_tail_loss_probe_(false), |
100 using_pacing_(false), | 100 using_pacing_(false), |
101 use_new_rto_(false), | 101 use_new_rto_(false), |
| 102 undo_pending_retransmits_(false), |
102 largest_newly_acked_(0), | 103 largest_newly_acked_(0), |
103 handshake_confirmed_(false) {} | 104 handshake_confirmed_(false) {} |
104 | 105 |
105 QuicSentPacketManager::~QuicSentPacketManager() {} | 106 QuicSentPacketManager::~QuicSentPacketManager() {} |
106 | 107 |
107 void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) { | 108 void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) { |
108 if (config.HasReceivedInitialRoundTripTimeUs() && | 109 if (config.HasReceivedInitialRoundTripTimeUs() && |
109 config.ReceivedInitialRoundTripTimeUs() > 0) { | 110 config.ReceivedInitialRoundTripTimeUs() > 0) { |
110 rtt_stats_.set_initial_rtt_us( | 111 rtt_stats_.set_initial_rtt_us( |
111 max(kMinInitialRoundTripTimeUs, | 112 max(kMinInitialRoundTripTimeUs, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 164 } |
164 if (config.HasReceivedConnectionOptions() && | 165 if (config.HasReceivedConnectionOptions() && |
165 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { | 166 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { |
166 loss_algorithm_.reset(new GeneralLossAlgorithm(kTime)); | 167 loss_algorithm_.reset(new GeneralLossAlgorithm(kTime)); |
167 } | 168 } |
168 if (FLAGS_quic_adaptive_loss_recovery && | 169 if (FLAGS_quic_adaptive_loss_recovery && |
169 config.HasReceivedConnectionOptions() && | 170 config.HasReceivedConnectionOptions() && |
170 ContainsQuicTag(config.ReceivedConnectionOptions(), kATIM)) { | 171 ContainsQuicTag(config.ReceivedConnectionOptions(), kATIM)) { |
171 loss_algorithm_.reset(new GeneralLossAlgorithm(kAdaptiveTime)); | 172 loss_algorithm_.reset(new GeneralLossAlgorithm(kAdaptiveTime)); |
172 } | 173 } |
| 174 if (FLAGS_quic_loss_recovery_use_largest_acked && |
| 175 config.HasClientSentConnectionOption(kUNDO, perspective_)) { |
| 176 undo_pending_retransmits_ = true; |
| 177 } |
173 if (config.HasReceivedSocketReceiveBuffer()) { | 178 if (config.HasReceivedSocketReceiveBuffer()) { |
174 receive_buffer_bytes_ = | 179 receive_buffer_bytes_ = |
175 max(kMinSocketReceiveBuffer, | 180 max(kMinSocketReceiveBuffer, |
176 static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer())); | 181 static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer())); |
177 QuicByteCount max_cwnd_bytes = static_cast<QuicByteCount>( | 182 QuicByteCount max_cwnd_bytes = static_cast<QuicByteCount>( |
178 receive_buffer_bytes_ * kConservativeReceiveBufferFraction); | 183 receive_buffer_bytes_ * kConservativeReceiveBufferFraction); |
179 send_algorithm_->SetMaxCongestionWindow(max_cwnd_bytes); | 184 send_algorithm_->SetMaxCongestionWindow(max_cwnd_bytes); |
180 } | 185 } |
181 send_algorithm_->SetFromConfig(config, perspective_); | 186 send_algorithm_->SetFromConfig(config, perspective_); |
182 | 187 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 if (!use_new_rto_) { | 256 if (!use_new_rto_) { |
252 send_algorithm_->OnRetransmissionTimeout(true); | 257 send_algorithm_->OnRetransmissionTimeout(true); |
253 } | 258 } |
254 } | 259 } |
255 } | 260 } |
256 // Reset all retransmit counters any time a new packet is acked. | 261 // Reset all retransmit counters any time a new packet is acked. |
257 consecutive_rto_count_ = 0; | 262 consecutive_rto_count_ = 0; |
258 consecutive_tlp_count_ = 0; | 263 consecutive_tlp_count_ = 0; |
259 consecutive_crypto_retransmission_count_ = 0; | 264 consecutive_crypto_retransmission_count_ = 0; |
260 } | 265 } |
| 266 // TODO(ianswett): Consider replacing the pending_retransmissions_ with a |
| 267 // fast way to retrieve the next pending retransmission, if there are any. |
| 268 // A single packet number indicating all packets below that are lost should |
| 269 // be all the state that is necessary. |
| 270 while (undo_pending_retransmits_ && !pending_retransmissions_.empty() && |
| 271 pending_retransmissions_.front().first > largest_newly_acked_ && |
| 272 pending_retransmissions_.front().second == LOSS_RETRANSMISSION) { |
| 273 // Cancel any pending retransmissions larger than largest_newly_acked_. |
| 274 unacked_packets_.RestoreToInFlight(pending_retransmissions_.front().first); |
| 275 pending_retransmissions_.erase(pending_retransmissions_.begin()); |
| 276 } |
261 | 277 |
262 if (debug_delegate_ != nullptr) { | 278 if (debug_delegate_ != nullptr) { |
263 debug_delegate_->OnIncomingAck(ack_frame, ack_receive_time, | 279 debug_delegate_->OnIncomingAck(ack_frame, ack_receive_time, |
264 unacked_packets_.largest_observed(), | 280 unacked_packets_.largest_observed(), |
265 rtt_updated, GetLeastUnacked()); | 281 rtt_updated, GetLeastUnacked()); |
266 } | 282 } |
267 } | 283 } |
268 | 284 |
269 void QuicSentPacketManager::UpdatePacketInformationReceivedByPeer( | 285 void QuicSentPacketManager::UpdatePacketInformationReceivedByPeer( |
270 const QuicAckFrame& ack_frame) { | 286 const QuicAckFrame& ack_frame) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 337 } |
322 unacked_packets_.NackPacket(packet_number, min_nacks); | 338 unacked_packets_.NackPacket(packet_number, min_nacks); |
323 continue; | 339 continue; |
324 } | 340 } |
325 // Packet was acked, so remove it from our unacked packet list. | 341 // Packet was acked, so remove it from our unacked packet list. |
326 DVLOG(1) << ENDPOINT << "Got an ack for packet " << packet_number; | 342 DVLOG(1) << ENDPOINT << "Got an ack for packet " << packet_number; |
327 // If data is associated with the most recent transmission of this | 343 // If data is associated with the most recent transmission of this |
328 // packet, then inform the caller. | 344 // packet, then inform the caller. |
329 if (it->in_flight) { | 345 if (it->in_flight) { |
330 packets_acked_.push_back(std::make_pair(packet_number, it->bytes_sent)); | 346 packets_acked_.push_back(std::make_pair(packet_number, it->bytes_sent)); |
| 347 } else if (FLAGS_quic_loss_recovery_use_largest_acked && |
| 348 !it->is_unackable) { |
| 349 largest_newly_acked_ = packet_number; |
331 } | 350 } |
332 MarkPacketHandled(packet_number, &(*it), ack_delay_time); | 351 MarkPacketHandled(packet_number, &(*it), ack_delay_time); |
333 } | 352 } |
334 } | 353 } |
335 | 354 |
336 bool QuicSentPacketManager::HasRetransmittableFrames( | 355 bool QuicSentPacketManager::HasRetransmittableFrames( |
337 QuicPacketNumber packet_number) const { | 356 QuicPacketNumber packet_number) const { |
338 return unacked_packets_.HasRetransmittableFrames(packet_number); | 357 return unacked_packets_.HasRetransmittableFrames(packet_number); |
339 } | 358 } |
340 | 359 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 // only handle nullptr encrypted packets in a special way. | 547 // only handle nullptr encrypted packets in a special way. |
529 const TransmissionInfo& newest_transmission_info = | 548 const TransmissionInfo& newest_transmission_info = |
530 unacked_packets_.GetTransmissionInfo(newest_transmission); | 549 unacked_packets_.GetTransmissionInfo(newest_transmission); |
531 if (HasCryptoHandshake(newest_transmission_info)) { | 550 if (HasCryptoHandshake(newest_transmission_info)) { |
532 unacked_packets_.RemoveFromInFlight(newest_transmission); | 551 unacked_packets_.RemoveFromInFlight(newest_transmission); |
533 } | 552 } |
534 } | 553 } |
535 | 554 |
536 unacked_packets_.RemoveFromInFlight(info); | 555 unacked_packets_.RemoveFromInFlight(info); |
537 unacked_packets_.RemoveRetransmittability(info); | 556 unacked_packets_.RemoveRetransmittability(info); |
| 557 if (FLAGS_quic_loss_recovery_use_largest_acked) { |
| 558 info->is_unackable = true; |
| 559 } |
538 } | 560 } |
539 | 561 |
540 bool QuicSentPacketManager::IsUnacked(QuicPacketNumber packet_number) const { | 562 bool QuicSentPacketManager::IsUnacked(QuicPacketNumber packet_number) const { |
541 return unacked_packets_.IsUnacked(packet_number); | 563 return unacked_packets_.IsUnacked(packet_number); |
542 } | 564 } |
543 | 565 |
544 bool QuicSentPacketManager::HasUnackedPackets() const { | 566 bool QuicSentPacketManager::HasUnackedPackets() const { |
545 return unacked_packets_.HasUnackedPackets(); | 567 return unacked_packets_.HasUnackedPackets(); |
546 } | 568 } |
547 | 569 |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 TransmissionInfo* QuicSentPacketManager::GetMutableTransmissionInfo( | 997 TransmissionInfo* QuicSentPacketManager::GetMutableTransmissionInfo( |
976 QuicPacketNumber packet_number) { | 998 QuicPacketNumber packet_number) { |
977 return unacked_packets_.GetMutableTransmissionInfo(packet_number); | 999 return unacked_packets_.GetMutableTransmissionInfo(packet_number); |
978 } | 1000 } |
979 | 1001 |
980 void QuicSentPacketManager::RemoveObsoletePackets() { | 1002 void QuicSentPacketManager::RemoveObsoletePackets() { |
981 unacked_packets_.RemoveObsoletePackets(); | 1003 unacked_packets_.RemoveObsoletePackets(); |
982 } | 1004 } |
983 | 1005 |
984 } // namespace net | 1006 } // namespace net |
OLD | NEW |