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 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 // This limits the tenth retransmitted packet to 10s after the initial CHLO. | 38 // This limits the tenth retransmitted packet to 10s after the initial CHLO. |
39 static const int64_t kMinHandshakeTimeoutMs = 10; | 39 static const int64_t kMinHandshakeTimeoutMs = 10; |
40 | 40 |
41 // Ensure the handshake timer isnt't faster than 25ms. | 41 // Ensure the handshake timer isnt't faster than 25ms. |
42 static const int64_t kConservativeMinHandshakeTimeoutMs = kMaxDelayedAckTimeMs; | 42 static const int64_t kConservativeMinHandshakeTimeoutMs = kMaxDelayedAckTimeMs; |
43 | 43 |
44 // Sends up to two tail loss probes before firing an RTO, | 44 // Sends up to two tail loss probes before firing an RTO, |
45 // per draft RFC draft-dukkipati-tcpm-tcp-loss-probe. | 45 // per draft RFC draft-dukkipati-tcpm-tcp-loss-probe. |
46 static const size_t kDefaultMaxTailLossProbes = 2; | 46 static const size_t kDefaultMaxTailLossProbes = 2; |
47 | 47 |
48 bool HasCryptoHandshake(const TransmissionInfo& transmission_info) { | 48 bool HasCryptoHandshake(const QuicTransmissionInfo& transmission_info) { |
49 DCHECK(!transmission_info.has_crypto_handshake || | 49 DCHECK(!transmission_info.has_crypto_handshake || |
50 !transmission_info.retransmittable_frames.empty()); | 50 !transmission_info.retransmittable_frames.empty()); |
51 return transmission_info.has_crypto_handshake; | 51 return transmission_info.has_crypto_handshake; |
52 } | 52 } |
53 | 53 |
54 } // namespace | 54 } // namespace |
55 | 55 |
56 #define ENDPOINT \ | 56 #define ENDPOINT \ |
57 (perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ") | 57 (perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ") |
58 | 58 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 max(kMinInitialRoundTripTimeUs, | 104 max(kMinInitialRoundTripTimeUs, |
105 min(kMaxInitialRoundTripTimeUs, | 105 min(kMaxInitialRoundTripTimeUs, |
106 config.ReceivedInitialRoundTripTimeUs()))); | 106 config.ReceivedInitialRoundTripTimeUs()))); |
107 } else if (config.HasInitialRoundTripTimeUsToSend() && | 107 } else if (config.HasInitialRoundTripTimeUsToSend() && |
108 config.GetInitialRoundTripTimeUsToSend() > 0) { | 108 config.GetInitialRoundTripTimeUsToSend() > 0) { |
109 rtt_stats_.set_initial_rtt_us( | 109 rtt_stats_.set_initial_rtt_us( |
110 max(kMinInitialRoundTripTimeUs, | 110 max(kMinInitialRoundTripTimeUs, |
111 min(kMaxInitialRoundTripTimeUs, | 111 min(kMaxInitialRoundTripTimeUs, |
112 config.GetInitialRoundTripTimeUsToSend()))); | 112 config.GetInitialRoundTripTimeUsToSend()))); |
113 } | 113 } |
114 if (FLAGS_quic_allow_new_bbr && config.HasReceivedConnectionOptions() && | 114 // Configure congestion control. |
115 ContainsQuicTag(config.ReceivedConnectionOptions(), kTBBR)) { | 115 const bool enable_client_connection_options = |
116 SetSendAlgorithm(kBBR); | 116 FLAGS_quic_client_connection_options; |
117 } | 117 if (enable_client_connection_options) { |
118 if (config.HasReceivedConnectionOptions() && | 118 if (FLAGS_quic_allow_new_bbr && |
119 ContainsQuicTag(config.ReceivedConnectionOptions(), kRENO)) { | 119 config.HasClientRequestedIndependentOption(kTBBR, perspective_)) { |
120 if (ContainsQuicTag(config.ReceivedConnectionOptions(), kBYTE)) { | 120 SetSendAlgorithm(kBBR); |
121 SetSendAlgorithm(kRenoBytes); | |
122 } else { | |
123 SetSendAlgorithm(kReno); | |
124 } | 121 } |
125 } else if (config.HasReceivedConnectionOptions() && | 122 if (config.HasClientRequestedIndependentOption(kRENO, perspective_)) { |
126 ContainsQuicTag(config.ReceivedConnectionOptions(), kBYTE)) { | 123 if (config.HasClientRequestedIndependentOption(kBYTE, perspective_)) { |
127 if (FLAGS_quic_default_enable_cubic_bytes) { | 124 SetSendAlgorithm(kRenoBytes); |
128 SetSendAlgorithm(kCubic); | 125 } else { |
129 } else { | 126 SetSendAlgorithm(kReno); |
130 SetSendAlgorithm(kCubicBytes); | 127 } |
| 128 } else if (config.HasClientRequestedIndependentOption(kBYTE, |
| 129 perspective_)) { |
| 130 if (FLAGS_quic_default_enable_cubic_bytes) { |
| 131 SetSendAlgorithm(kCubic); |
| 132 } else { |
| 133 SetSendAlgorithm(kCubicBytes); |
| 134 } |
| 135 } |
| 136 } else { |
| 137 if (FLAGS_quic_allow_new_bbr && config.HasReceivedConnectionOptions() && |
| 138 ContainsQuicTag(config.ReceivedConnectionOptions(), kTBBR)) { |
| 139 SetSendAlgorithm(kBBR); |
| 140 } |
| 141 if (config.HasReceivedConnectionOptions() && |
| 142 ContainsQuicTag(config.ReceivedConnectionOptions(), kRENO)) { |
| 143 if (ContainsQuicTag(config.ReceivedConnectionOptions(), kBYTE)) { |
| 144 SetSendAlgorithm(kRenoBytes); |
| 145 } else { |
| 146 SetSendAlgorithm(kReno); |
| 147 } |
| 148 } else if (config.HasReceivedConnectionOptions() && |
| 149 ContainsQuicTag(config.ReceivedConnectionOptions(), kBYTE)) { |
| 150 if (FLAGS_quic_default_enable_cubic_bytes) { |
| 151 SetSendAlgorithm(kCubic); |
| 152 } else { |
| 153 SetSendAlgorithm(kCubicBytes); |
| 154 } |
131 } | 155 } |
132 } | 156 } |
133 using_pacing_ = !FLAGS_quic_disable_pacing_for_perf_tests; | 157 using_pacing_ = !FLAGS_quic_disable_pacing_for_perf_tests; |
134 | 158 |
135 if (config.HasClientSentConnectionOption(k1CON, perspective_)) { | 159 if (config.HasClientSentConnectionOption(k1CON, perspective_)) { |
136 send_algorithm_->SetNumEmulatedConnections(1); | 160 send_algorithm_->SetNumEmulatedConnections(1); |
137 } | 161 } |
138 if (config.HasClientSentConnectionOption(kNCON, perspective_)) { | 162 if (config.HasClientSentConnectionOption(kNCON, perspective_)) { |
139 n_connection_simulation_ = true; | 163 n_connection_simulation_ = true; |
140 } | 164 } |
141 if (config.HasClientSentConnectionOption(kNTLP, perspective_)) { | 165 if (config.HasClientSentConnectionOption(kNTLP, perspective_)) { |
142 max_tail_loss_probes_ = 0; | 166 max_tail_loss_probes_ = 0; |
143 } | 167 } |
144 if (config.HasClientSentConnectionOption(kTLPR, perspective_)) { | 168 if (config.HasClientSentConnectionOption(kTLPR, perspective_)) { |
145 enable_half_rtt_tail_loss_probe_ = true; | 169 enable_half_rtt_tail_loss_probe_ = true; |
146 } | 170 } |
147 if (config.HasClientSentConnectionOption(kNRTO, perspective_)) { | 171 if (config.HasClientSentConnectionOption(kNRTO, perspective_)) { |
148 use_new_rto_ = true; | 172 use_new_rto_ = true; |
149 } | 173 } |
150 if (config.HasReceivedConnectionOptions() && | 174 // Configure loss detection. |
151 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { | 175 if (enable_client_connection_options) { |
152 general_loss_algorithm_.SetLossDetectionType(kTime); | 176 if (config.HasClientRequestedIndependentOption(kTIME, perspective_)) { |
153 } | 177 general_loss_algorithm_.SetLossDetectionType(kTime); |
154 if (config.HasReceivedConnectionOptions() && | 178 } |
155 ContainsQuicTag(config.ReceivedConnectionOptions(), kATIM)) { | 179 if (config.HasClientRequestedIndependentOption(kATIM, perspective_)) { |
156 general_loss_algorithm_.SetLossDetectionType(kAdaptiveTime); | 180 general_loss_algorithm_.SetLossDetectionType(kAdaptiveTime); |
157 } | 181 } |
158 if (FLAGS_quic_enable_lazy_fack && config.HasReceivedConnectionOptions() && | 182 if (FLAGS_quic_enable_lazy_fack && |
159 ContainsQuicTag(config.ReceivedConnectionOptions(), kLFAK)) { | 183 config.HasClientRequestedIndependentOption(kLFAK, perspective_)) { |
160 general_loss_algorithm_.SetLossDetectionType(kLazyFack); | 184 general_loss_algorithm_.SetLossDetectionType(kLazyFack); |
| 185 } |
| 186 } else { |
| 187 if (config.HasReceivedConnectionOptions() && |
| 188 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { |
| 189 general_loss_algorithm_.SetLossDetectionType(kTime); |
| 190 } |
| 191 if (config.HasReceivedConnectionOptions() && |
| 192 ContainsQuicTag(config.ReceivedConnectionOptions(), kATIM)) { |
| 193 general_loss_algorithm_.SetLossDetectionType(kAdaptiveTime); |
| 194 } |
| 195 if (FLAGS_quic_enable_lazy_fack && config.HasReceivedConnectionOptions() && |
| 196 ContainsQuicTag(config.ReceivedConnectionOptions(), kLFAK)) { |
| 197 general_loss_algorithm_.SetLossDetectionType(kLazyFack); |
| 198 } |
161 } | 199 } |
162 if (config.HasClientSentConnectionOption(kUNDO, perspective_)) { | 200 if (config.HasClientSentConnectionOption(kUNDO, perspective_)) { |
163 undo_pending_retransmits_ = true; | 201 undo_pending_retransmits_ = true; |
164 } | 202 } |
165 if (FLAGS_quic_conservative_handshake_retransmits && | 203 if (FLAGS_quic_conservative_handshake_retransmits && |
166 config.HasClientSentConnectionOption(kCONH, perspective_)) { | 204 config.HasClientSentConnectionOption(kCONH, perspective_)) { |
167 conservative_handshake_retransmits_ = true; | 205 conservative_handshake_retransmits_ = true; |
168 } | 206 } |
169 send_algorithm_->SetFromConfig(config, perspective_); | 207 send_algorithm_->SetFromConfig(config, perspective_); |
170 | 208 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 } | 397 } |
360 unacked_packets_.RemoveFromInFlight(packet_number); | 398 unacked_packets_.RemoveFromInFlight(packet_number); |
361 unacked_packets_.RemoveRetransmittability(packet_number); | 399 unacked_packets_.RemoveRetransmittability(packet_number); |
362 } | 400 } |
363 } | 401 } |
364 } | 402 } |
365 | 403 |
366 void QuicSentPacketManager::MarkForRetransmission( | 404 void QuicSentPacketManager::MarkForRetransmission( |
367 QuicPacketNumber packet_number, | 405 QuicPacketNumber packet_number, |
368 TransmissionType transmission_type) { | 406 TransmissionType transmission_type) { |
369 const TransmissionInfo& transmission_info = | 407 const QuicTransmissionInfo& transmission_info = |
370 unacked_packets_.GetTransmissionInfo(packet_number); | 408 unacked_packets_.GetTransmissionInfo(packet_number); |
371 QUIC_BUG_IF(transmission_info.retransmittable_frames.empty()); | 409 QUIC_BUG_IF(transmission_info.retransmittable_frames.empty()); |
372 // Both TLP and the new RTO leave the packets in flight and let the loss | 410 // Both TLP and the new RTO leave the packets in flight and let the loss |
373 // detection decide if packets are lost. | 411 // detection decide if packets are lost. |
374 if (transmission_type != TLP_RETRANSMISSION && | 412 if (transmission_type != TLP_RETRANSMISSION && |
375 transmission_type != RTO_RETRANSMISSION) { | 413 transmission_type != RTO_RETRANSMISSION) { |
376 unacked_packets_.RemoveFromInFlight(packet_number); | 414 unacked_packets_.RemoveFromInFlight(packet_number); |
377 } | 415 } |
378 if (delegate_ != nullptr) { | 416 if (delegate_ != nullptr) { |
379 delegate_->OnRetransmissionMarked(path_id_, packet_number, | 417 delegate_->OnRetransmissionMarked(path_id_, packet_number, |
380 transmission_type); | 418 transmission_type); |
381 } else { | 419 } else { |
382 // TODO(ianswett): Currently the RTO can fire while there are pending NACK | 420 // TODO(ianswett): Currently the RTO can fire while there are pending NACK |
383 // retransmissions for the same data, which is not ideal. | 421 // retransmissions for the same data, which is not ideal. |
384 if (base::ContainsKey(pending_retransmissions_, packet_number)) { | 422 if (base::ContainsKey(pending_retransmissions_, packet_number)) { |
385 return; | 423 return; |
386 } | 424 } |
387 | 425 |
388 pending_retransmissions_[packet_number] = transmission_type; | 426 pending_retransmissions_[packet_number] = transmission_type; |
389 } | 427 } |
390 } | 428 } |
391 | 429 |
392 void QuicSentPacketManager::RecordOneSpuriousRetransmission( | 430 void QuicSentPacketManager::RecordOneSpuriousRetransmission( |
393 const TransmissionInfo& info) { | 431 const QuicTransmissionInfo& info) { |
394 stats_->bytes_spuriously_retransmitted += info.bytes_sent; | 432 stats_->bytes_spuriously_retransmitted += info.bytes_sent; |
395 ++stats_->packets_spuriously_retransmitted; | 433 ++stats_->packets_spuriously_retransmitted; |
396 if (debug_delegate_ != nullptr) { | 434 if (debug_delegate_ != nullptr) { |
397 debug_delegate_->OnSpuriousPacketRetransmission(info.transmission_type, | 435 debug_delegate_->OnSpuriousPacketRetransmission(info.transmission_type, |
398 info.bytes_sent); | 436 info.bytes_sent); |
399 } | 437 } |
400 } | 438 } |
401 | 439 |
402 void QuicSentPacketManager::RecordSpuriousRetransmissions( | 440 void QuicSentPacketManager::RecordSpuriousRetransmissions( |
403 const TransmissionInfo& info, | 441 const QuicTransmissionInfo& info, |
404 QuicPacketNumber acked_packet_number) { | 442 QuicPacketNumber acked_packet_number) { |
405 QuicPacketNumber retransmission = info.retransmission; | 443 QuicPacketNumber retransmission = info.retransmission; |
406 while (retransmission != 0) { | 444 while (retransmission != 0) { |
407 const TransmissionInfo& retransmit_info = | 445 const QuicTransmissionInfo& retransmit_info = |
408 unacked_packets_.GetTransmissionInfo(retransmission); | 446 unacked_packets_.GetTransmissionInfo(retransmission); |
409 retransmission = retransmit_info.retransmission; | 447 retransmission = retransmit_info.retransmission; |
410 RecordOneSpuriousRetransmission(retransmit_info); | 448 RecordOneSpuriousRetransmission(retransmit_info); |
411 } | 449 } |
412 // Only inform the loss detection of spurious retransmits it caused. | 450 // Only inform the loss detection of spurious retransmits it caused. |
413 if (unacked_packets_.GetTransmissionInfo(info.retransmission) | 451 if (unacked_packets_.GetTransmissionInfo(info.retransmission) |
414 .transmission_type == LOSS_RETRANSMISSION) { | 452 .transmission_type == LOSS_RETRANSMISSION) { |
415 loss_algorithm_->SpuriousRetransmitDetected( | 453 loss_algorithm_->SpuriousRetransmitDetected( |
416 unacked_packets_, clock_->Now(), rtt_stats_, info.retransmission); | 454 unacked_packets_, clock_->Now(), rtt_stats_, info.retransmission); |
417 } | 455 } |
418 } | 456 } |
419 | 457 |
420 bool QuicSentPacketManager::HasPendingRetransmissions() const { | 458 bool QuicSentPacketManager::HasPendingRetransmissions() const { |
421 return !pending_retransmissions_.empty(); | 459 return !pending_retransmissions_.empty(); |
422 } | 460 } |
423 | 461 |
424 PendingRetransmission QuicSentPacketManager::NextPendingRetransmission() { | 462 QuicPendingRetransmission QuicSentPacketManager::NextPendingRetransmission() { |
425 QUIC_BUG_IF(pending_retransmissions_.empty()) | 463 QUIC_BUG_IF(pending_retransmissions_.empty()) |
426 << "Unexpected call to PendingRetransmissions() with empty pending " | 464 << "Unexpected call to PendingRetransmissions() with empty pending " |
427 << "retransmission list. Corrupted memory usage imminent."; | 465 << "retransmission list. Corrupted memory usage imminent."; |
428 QuicPacketNumber packet_number = pending_retransmissions_.begin()->first; | 466 QuicPacketNumber packet_number = pending_retransmissions_.begin()->first; |
429 TransmissionType transmission_type = pending_retransmissions_.begin()->second; | 467 TransmissionType transmission_type = pending_retransmissions_.begin()->second; |
430 if (unacked_packets_.HasPendingCryptoPackets()) { | 468 if (unacked_packets_.HasPendingCryptoPackets()) { |
431 // Ensure crypto packets are retransmitted before other packets. | 469 // Ensure crypto packets are retransmitted before other packets. |
432 for (const auto& pair : pending_retransmissions_) { | 470 for (const auto& pair : pending_retransmissions_) { |
433 if (HasCryptoHandshake( | 471 if (HasCryptoHandshake( |
434 unacked_packets_.GetTransmissionInfo(pair.first))) { | 472 unacked_packets_.GetTransmissionInfo(pair.first))) { |
435 packet_number = pair.first; | 473 packet_number = pair.first; |
436 transmission_type = pair.second; | 474 transmission_type = pair.second; |
437 break; | 475 break; |
438 } | 476 } |
439 } | 477 } |
440 } | 478 } |
441 DCHECK(unacked_packets_.IsUnacked(packet_number)) << packet_number; | 479 DCHECK(unacked_packets_.IsUnacked(packet_number)) << packet_number; |
442 const TransmissionInfo& transmission_info = | 480 const QuicTransmissionInfo& transmission_info = |
443 unacked_packets_.GetTransmissionInfo(packet_number); | 481 unacked_packets_.GetTransmissionInfo(packet_number); |
444 DCHECK(!transmission_info.retransmittable_frames.empty()); | 482 DCHECK(!transmission_info.retransmittable_frames.empty()); |
445 | 483 |
446 return PendingRetransmission(path_id_, packet_number, transmission_type, | 484 return QuicPendingRetransmission(path_id_, packet_number, transmission_type, |
447 transmission_info.retransmittable_frames, | 485 transmission_info.retransmittable_frames, |
448 transmission_info.has_crypto_handshake, | 486 transmission_info.has_crypto_handshake, |
449 transmission_info.num_padding_bytes, | 487 transmission_info.num_padding_bytes, |
450 transmission_info.encryption_level, | 488 transmission_info.encryption_level, |
451 transmission_info.packet_number_length); | 489 transmission_info.packet_number_length); |
452 } | 490 } |
453 | 491 |
454 QuicPacketNumber QuicSentPacketManager::GetNewestRetransmission( | 492 QuicPacketNumber QuicSentPacketManager::GetNewestRetransmission( |
455 QuicPacketNumber packet_number, | 493 QuicPacketNumber packet_number, |
456 const TransmissionInfo& transmission_info) const { | 494 const QuicTransmissionInfo& transmission_info) const { |
457 QuicPacketNumber retransmission = transmission_info.retransmission; | 495 QuicPacketNumber retransmission = transmission_info.retransmission; |
458 while (retransmission != 0) { | 496 while (retransmission != 0) { |
459 packet_number = retransmission; | 497 packet_number = retransmission; |
460 retransmission = | 498 retransmission = |
461 unacked_packets_.GetTransmissionInfo(retransmission).retransmission; | 499 unacked_packets_.GetTransmissionInfo(retransmission).retransmission; |
462 } | 500 } |
463 return packet_number; | 501 return packet_number; |
464 } | 502 } |
465 | 503 |
466 void QuicSentPacketManager::MarkPacketNotRetransmittable( | 504 void QuicSentPacketManager::MarkPacketNotRetransmittable( |
467 QuicPacketNumber packet_number, | 505 QuicPacketNumber packet_number, |
468 QuicTime::Delta ack_delay_time) { | 506 QuicTime::Delta ack_delay_time) { |
469 if (!unacked_packets_.IsUnacked(packet_number)) { | 507 if (!unacked_packets_.IsUnacked(packet_number)) { |
470 return; | 508 return; |
471 } | 509 } |
472 | 510 |
473 const TransmissionInfo& transmission_info = | 511 const QuicTransmissionInfo& transmission_info = |
474 unacked_packets_.GetTransmissionInfo(packet_number); | 512 unacked_packets_.GetTransmissionInfo(packet_number); |
475 QuicPacketNumber newest_transmission = | 513 QuicPacketNumber newest_transmission = |
476 GetNewestRetransmission(packet_number, transmission_info); | 514 GetNewestRetransmission(packet_number, transmission_info); |
477 // We do not need to retransmit this packet anymore. | 515 // We do not need to retransmit this packet anymore. |
478 if (delegate_ != nullptr) { | 516 if (delegate_ != nullptr) { |
479 delegate_->OnPacketMarkedNotRetransmittable(path_id_, newest_transmission, | 517 delegate_->OnPacketMarkedNotRetransmittable(path_id_, newest_transmission, |
480 ack_delay_time); | 518 ack_delay_time); |
481 } else { | 519 } else { |
482 pending_retransmissions_.erase(newest_transmission); | 520 pending_retransmissions_.erase(newest_transmission); |
483 } | 521 } |
484 | 522 |
485 unacked_packets_.NotifyAndClearListeners(newest_transmission, ack_delay_time); | 523 unacked_packets_.NotifyAndClearListeners(newest_transmission, ack_delay_time); |
486 unacked_packets_.RemoveRetransmittability(packet_number); | 524 unacked_packets_.RemoveRetransmittability(packet_number); |
487 } | 525 } |
488 | 526 |
489 void QuicSentPacketManager::MarkPacketHandled(QuicPacketNumber packet_number, | 527 void QuicSentPacketManager::MarkPacketHandled(QuicPacketNumber packet_number, |
490 TransmissionInfo* info, | 528 QuicTransmissionInfo* info, |
491 QuicTime::Delta ack_delay_time) { | 529 QuicTime::Delta ack_delay_time) { |
492 QuicPacketNumber newest_transmission = | 530 QuicPacketNumber newest_transmission = |
493 GetNewestRetransmission(packet_number, *info); | 531 GetNewestRetransmission(packet_number, *info); |
494 // Remove the most recent packet, if it is pending retransmission. | 532 // Remove the most recent packet, if it is pending retransmission. |
495 if (delegate_ != nullptr) { | 533 if (delegate_ != nullptr) { |
496 delegate_->OnPacketMarkedHandled(path_id_, newest_transmission, | 534 delegate_->OnPacketMarkedHandled(path_id_, newest_transmission, |
497 ack_delay_time); | 535 ack_delay_time); |
498 } else { | 536 } else { |
499 pending_retransmissions_.erase(newest_transmission); | 537 pending_retransmissions_.erase(newest_transmission); |
500 } | 538 } |
501 | 539 |
502 // The AckListener needs to be notified about the most recent | 540 // The AckListener needs to be notified about the most recent |
503 // transmission, since that's the one only one it tracks. | 541 // transmission, since that's the one only one it tracks. |
504 if (newest_transmission == packet_number) { | 542 if (newest_transmission == packet_number) { |
505 unacked_packets_.NotifyAndClearListeners(&info->ack_listeners, | 543 unacked_packets_.NotifyAndClearListeners(&info->ack_listeners, |
506 ack_delay_time); | 544 ack_delay_time); |
507 } else { | 545 } else { |
508 unacked_packets_.NotifyAndClearListeners(newest_transmission, | 546 unacked_packets_.NotifyAndClearListeners(newest_transmission, |
509 ack_delay_time); | 547 ack_delay_time); |
510 RecordSpuriousRetransmissions(*info, packet_number); | 548 RecordSpuriousRetransmissions(*info, packet_number); |
511 // Remove the most recent packet from flight if it's a crypto handshake | 549 // Remove the most recent packet from flight if it's a crypto handshake |
512 // packet, since they won't be acked now that one has been processed. | 550 // packet, since they won't be acked now that one has been processed. |
513 // Other crypto handshake packets won't be in flight, only the newest | 551 // Other crypto handshake packets won't be in flight, only the newest |
514 // transmission of a crypto packet is in flight at once. | 552 // transmission of a crypto packet is in flight at once. |
515 // TODO(ianswett): Instead of handling all crypto packets special, | 553 // TODO(ianswett): Instead of handling all crypto packets special, |
516 // only handle nullptr encrypted packets in a special way. | 554 // only handle nullptr encrypted packets in a special way. |
517 const TransmissionInfo& newest_transmission_info = | 555 const QuicTransmissionInfo& newest_transmission_info = |
518 unacked_packets_.GetTransmissionInfo(newest_transmission); | 556 unacked_packets_.GetTransmissionInfo(newest_transmission); |
519 if (HasCryptoHandshake(newest_transmission_info)) { | 557 if (HasCryptoHandshake(newest_transmission_info)) { |
520 unacked_packets_.RemoveFromInFlight(newest_transmission); | 558 unacked_packets_.RemoveFromInFlight(newest_transmission); |
521 } | 559 } |
522 } | 560 } |
523 | 561 |
524 if (network_change_visitor_ != nullptr && | 562 if (network_change_visitor_ != nullptr && |
525 info->bytes_sent > largest_mtu_acked_) { | 563 info->bytes_sent > largest_mtu_acked_) { |
526 largest_mtu_acked_ = info->bytes_sent; | 564 largest_mtu_acked_ = info->bytes_sent; |
527 network_change_visitor_->OnPathMtuIncreased(largest_mtu_acked_); | 565 network_change_visitor_->OnPathMtuIncreased(largest_mtu_acked_); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 QuicTime ack_receive_time) { | 776 QuicTime ack_receive_time) { |
739 // We rely on ack_delay_time to compute an RTT estimate, so we | 777 // We rely on ack_delay_time to compute an RTT estimate, so we |
740 // only update rtt when the largest observed gets acked. | 778 // only update rtt when the largest observed gets acked. |
741 // NOTE: If ack is a truncated ack, then the largest observed is in fact | 779 // NOTE: If ack is a truncated ack, then the largest observed is in fact |
742 // unacked, and may cause an RTT sample to be taken. | 780 // unacked, and may cause an RTT sample to be taken. |
743 if (!unacked_packets_.IsUnacked(ack_frame.largest_observed)) { | 781 if (!unacked_packets_.IsUnacked(ack_frame.largest_observed)) { |
744 return false; | 782 return false; |
745 } | 783 } |
746 // We calculate the RTT based on the highest ACKed packet number, the lower | 784 // We calculate the RTT based on the highest ACKed packet number, the lower |
747 // packet numbers will include the ACK aggregation delay. | 785 // packet numbers will include the ACK aggregation delay. |
748 const TransmissionInfo& transmission_info = | 786 const QuicTransmissionInfo& transmission_info = |
749 unacked_packets_.GetTransmissionInfo(ack_frame.largest_observed); | 787 unacked_packets_.GetTransmissionInfo(ack_frame.largest_observed); |
750 // Ensure the packet has a valid sent time. | 788 // Ensure the packet has a valid sent time. |
751 if (transmission_info.sent_time == QuicTime::Zero()) { | 789 if (transmission_info.sent_time == QuicTime::Zero()) { |
752 QUIC_BUG << "Acked packet has zero sent time, largest_observed:" | 790 QUIC_BUG << "Acked packet has zero sent time, largest_observed:" |
753 << ack_frame.largest_observed; | 791 << ack_frame.largest_observed; |
754 return false; | 792 return false; |
755 } | 793 } |
756 | 794 |
757 QuicTime::Delta send_delta = ack_receive_time - transmission_info.sent_time; | 795 QuicTime::Delta send_delta = ack_receive_time - transmission_info.sent_time; |
758 const int kMaxSendDeltaSeconds = 30; | 796 const int kMaxSendDeltaSeconds = 30; |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 } | 1042 } |
1005 | 1043 |
1006 size_t QuicSentPacketManager::GetConsecutiveRtoCount() const { | 1044 size_t QuicSentPacketManager::GetConsecutiveRtoCount() const { |
1007 return consecutive_rto_count_; | 1045 return consecutive_rto_count_; |
1008 } | 1046 } |
1009 | 1047 |
1010 size_t QuicSentPacketManager::GetConsecutiveTlpCount() const { | 1048 size_t QuicSentPacketManager::GetConsecutiveTlpCount() const { |
1011 return consecutive_tlp_count_; | 1049 return consecutive_tlp_count_; |
1012 } | 1050 } |
1013 | 1051 |
1014 TransmissionInfo* QuicSentPacketManager::GetMutableTransmissionInfo( | 1052 QuicTransmissionInfo* QuicSentPacketManager::GetMutableTransmissionInfo( |
1015 QuicPacketNumber packet_number) { | 1053 QuicPacketNumber packet_number) { |
1016 return unacked_packets_.GetMutableTransmissionInfo(packet_number); | 1054 return unacked_packets_.GetMutableTransmissionInfo(packet_number); |
1017 } | 1055 } |
1018 | 1056 |
1019 void QuicSentPacketManager::RemoveObsoletePackets() { | 1057 void QuicSentPacketManager::RemoveObsoletePackets() { |
1020 unacked_packets_.RemoveObsoletePackets(); | 1058 unacked_packets_.RemoveObsoletePackets(); |
1021 } | 1059 } |
1022 | 1060 |
1023 void QuicSentPacketManager::OnApplicationLimited() { | 1061 void QuicSentPacketManager::OnApplicationLimited() { |
1024 send_algorithm_->OnApplicationLimited(unacked_packets_.bytes_in_flight()); | 1062 send_algorithm_->OnApplicationLimited(unacked_packets_.bytes_in_flight()); |
1025 } | 1063 } |
1026 | 1064 |
| 1065 const SendAlgorithmInterface* QuicSentPacketManager::GetSendAlgorithm() const { |
| 1066 return send_algorithm_.get(); |
| 1067 } |
| 1068 |
1027 } // namespace net | 1069 } // namespace net |
OLD | NEW |