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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "net/quic/congestion_control/pacing_sender.h" | 9 #include "net/quic/congestion_control/pacing_sender.h" |
10 #include "net/quic/crypto/crypto_protocol.h" | 10 #include "net/quic/crypto/crypto_protocol.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 DCHECK(unacked_packets_.HasPendingPackets()); | 401 DCHECK(unacked_packets_.HasPendingPackets()); |
402 // Handshake retransmission, TLP, and RTO are implemented with a single alarm. | 402 // Handshake retransmission, TLP, and RTO are implemented with a single alarm. |
403 // The handshake alarm is set when the handshake has not completed, and the | 403 // The handshake alarm is set when the handshake has not completed, and the |
404 // TLP and RTO alarms are set after that. | 404 // TLP and RTO alarms are set after that. |
405 // The TLP alarm is always set to run for under an RTO. | 405 // The TLP alarm is always set to run for under an RTO. |
406 switch (GetRetransmissionMode()) { | 406 switch (GetRetransmissionMode()) { |
407 case HANDSHAKE_MODE: | 407 case HANDSHAKE_MODE: |
408 ++stats_->crypto_retransmit_count; | 408 ++stats_->crypto_retransmit_count; |
409 RetransmitCryptoPackets(); | 409 RetransmitCryptoPackets(); |
410 return; | 410 return; |
| 411 case LOSS_MODE: |
| 412 InvokeLossDetection(clock_->Now()); |
| 413 return; |
411 case TLP_MODE: | 414 case TLP_MODE: |
412 // If no tail loss probe can be sent, because there are no retransmittable | 415 // If no tail loss probe can be sent, because there are no retransmittable |
413 // packets, execute a conventional RTO to abandon old packets. | 416 // packets, execute a conventional RTO to abandon old packets. |
414 ++stats_->tlp_count; | 417 ++stats_->tlp_count; |
415 RetransmitOldestPacket(); | 418 RetransmitOldestPacket(); |
416 return; | 419 return; |
417 case RTO_MODE: | 420 case RTO_MODE: |
418 ++stats_->rto_count; | 421 ++stats_->rto_count; |
419 RetransmitAllPackets(); | 422 RetransmitAllPackets(); |
420 return; | 423 return; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 ++consecutive_rto_count_; | 493 ++consecutive_rto_count_; |
491 } | 494 } |
492 } | 495 } |
493 | 496 |
494 QuicSentPacketManager::RetransmissionTimeoutMode | 497 QuicSentPacketManager::RetransmissionTimeoutMode |
495 QuicSentPacketManager::GetRetransmissionMode() const { | 498 QuicSentPacketManager::GetRetransmissionMode() const { |
496 DCHECK(unacked_packets_.HasPendingPackets()); | 499 DCHECK(unacked_packets_.HasPendingPackets()); |
497 if (pending_crypto_packet_count_ > 0) { | 500 if (pending_crypto_packet_count_ > 0) { |
498 return HANDSHAKE_MODE; | 501 return HANDSHAKE_MODE; |
499 } | 502 } |
| 503 if (loss_algorithm_->GetLossTimeout() != QuicTime::Zero()) { |
| 504 return LOSS_MODE; |
| 505 } |
500 if (consecutive_tlp_count_ < max_tail_loss_probes_) { | 506 if (consecutive_tlp_count_ < max_tail_loss_probes_) { |
501 if (unacked_packets_.HasUnackedRetransmittableFrames()) { | 507 if (unacked_packets_.HasUnackedRetransmittableFrames()) { |
502 return TLP_MODE; | 508 return TLP_MODE; |
503 } | 509 } |
504 } | 510 } |
505 return RTO_MODE; | 511 return RTO_MODE; |
506 } | 512 } |
507 | 513 |
508 void QuicSentPacketManager::OnPacketAbandoned( | 514 void QuicSentPacketManager::OnPacketAbandoned( |
509 QuicPacketSequenceNumber sequence_number) { | 515 QuicPacketSequenceNumber sequence_number) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 } | 638 } |
633 | 639 |
634 const QuicTime QuicSentPacketManager::GetRetransmissionTime() const { | 640 const QuicTime QuicSentPacketManager::GetRetransmissionTime() const { |
635 // Don't set the timer if there are no pending packets. | 641 // Don't set the timer if there are no pending packets. |
636 if (!unacked_packets_.HasPendingPackets()) { | 642 if (!unacked_packets_.HasPendingPackets()) { |
637 return QuicTime::Zero(); | 643 return QuicTime::Zero(); |
638 } | 644 } |
639 switch (GetRetransmissionMode()) { | 645 switch (GetRetransmissionMode()) { |
640 case HANDSHAKE_MODE: | 646 case HANDSHAKE_MODE: |
641 return clock_->ApproximateNow().Add(GetCryptoRetransmissionDelay()); | 647 return clock_->ApproximateNow().Add(GetCryptoRetransmissionDelay()); |
| 648 case LOSS_MODE: |
| 649 return loss_algorithm_->GetLossTimeout(); |
642 case TLP_MODE: { | 650 case TLP_MODE: { |
643 // TODO(ianswett): When CWND is available, it would be preferable to | 651 // TODO(ianswett): When CWND is available, it would be preferable to |
644 // set the timer based on the earliest retransmittable packet. | 652 // set the timer based on the earliest retransmittable packet. |
645 // Base the updated timer on the send time of the last packet. | 653 // Base the updated timer on the send time of the last packet. |
646 // TODO(ianswett): I believe this is a subtle mis-implementation of tail | 654 // TODO(ianswett): I believe this is a subtle mis-implementation of tail |
647 // loss probe, since GetLastPacketSentTime actually returns the sent time | 655 // loss probe, since GetLastPacketSentTime actually returns the sent time |
648 // of the last pending packet which still has retransmittable frames. | 656 // of the last pending packet which still has retransmittable frames. |
649 const QuicTime sent_time = unacked_packets_.GetLastPacketSentTime(); | 657 const QuicTime sent_time = unacked_packets_.GetLastPacketSentTime(); |
650 const QuicTime tlp_time = sent_time.Add(GetTailLossProbeDelay()); | 658 const QuicTime tlp_time = sent_time.Add(GetTailLossProbeDelay()); |
651 // Ensure the tlp timer never gets set to a time in the past. | 659 // Ensure the tlp timer never gets set to a time in the past. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 return; | 739 return; |
732 } | 740 } |
733 | 741 |
734 using_pacing_ = true; | 742 using_pacing_ = true; |
735 send_algorithm_.reset( | 743 send_algorithm_.reset( |
736 new PacingSender(send_algorithm_.release(), | 744 new PacingSender(send_algorithm_.release(), |
737 QuicTime::Delta::FromMicroseconds(1))); | 745 QuicTime::Delta::FromMicroseconds(1))); |
738 } | 746 } |
739 | 747 |
740 } // namespace net | 748 } // namespace net |
OLD | NEW |