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/quic_ack_notifier_manager.h" | 10 #include "net/quic/quic_ack_notifier_manager.h" |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 void QuicSentPacketManager::RetransmitCryptoPackets() { | 603 void QuicSentPacketManager::RetransmitCryptoPackets() { |
604 DCHECK_EQ(HANDSHAKE_MODE, GetRetransmissionMode()); | 604 DCHECK_EQ(HANDSHAKE_MODE, GetRetransmissionMode()); |
605 // TODO(ianswett): Typical TCP implementations only retransmit 5 times. | 605 // TODO(ianswett): Typical TCP implementations only retransmit 5 times. |
606 consecutive_crypto_retransmission_count_ = | 606 consecutive_crypto_retransmission_count_ = |
607 min(kMaxHandshakeRetransmissionBackoffs, | 607 min(kMaxHandshakeRetransmissionBackoffs, |
608 consecutive_crypto_retransmission_count_ + 1); | 608 consecutive_crypto_retransmission_count_ + 1); |
609 bool packet_retransmitted = false; | 609 bool packet_retransmitted = false; |
610 for (UnackedPacketMap::iterator it = unacked_packets_.begin(); | 610 for (UnackedPacketMap::iterator it = unacked_packets_.begin(); |
611 it != unacked_packets_.end(); ++it) { | 611 it != unacked_packets_.end(); ++it) { |
612 QuicPacketSequenceNumber sequence_number = it->first; | 612 QuicPacketSequenceNumber sequence_number = it->first; |
613 DCHECK(ContainsKey(packet_history_map_, sequence_number)); | |
614 const RetransmittableFrames* frames = it->second.retransmittable_frames; | 613 const RetransmittableFrames* frames = it->second.retransmittable_frames; |
615 if (frames == NULL || frames->HasCryptoHandshake() != IS_HANDSHAKE) { | 614 // Only retransmit frames which are pending, and therefore have been sent. |
| 615 if (!it->second.pending || frames == NULL || |
| 616 frames->HasCryptoHandshake() != IS_HANDSHAKE) { |
616 continue; | 617 continue; |
617 } | 618 } |
| 619 DCHECK(ContainsKey(packet_history_map_, sequence_number)); |
618 packet_retransmitted = true; | 620 packet_retransmitted = true; |
619 MarkForRetransmission(sequence_number, TLP_RETRANSMISSION); | 621 MarkForRetransmission(sequence_number, TLP_RETRANSMISSION); |
620 // Abandon all the crypto retransmissions now so they're not lost later. | 622 // Abandon all the crypto retransmissions now so they're not lost later. |
621 OnPacketAbandoned(it); | 623 OnPacketAbandoned(it); |
622 } | 624 } |
623 DCHECK(packet_retransmitted) << "No crypto packets found to retransmit."; | 625 DCHECK(packet_retransmitted) << "No crypto packets found to retransmit."; |
624 } | 626 } |
625 | 627 |
626 void QuicSentPacketManager::RetransmitOldestPacket() { | 628 void QuicSentPacketManager::RetransmitOldestPacket() { |
627 DCHECK_EQ(TLP_MODE, GetRetransmissionMode()); | 629 DCHECK_EQ(TLP_MODE, GetRetransmissionMode()); |
628 ++consecutive_tlp_count_; | 630 ++consecutive_tlp_count_; |
629 for (UnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 631 for (UnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
630 it != unacked_packets_.end(); ++it) { | 632 it != unacked_packets_.end(); ++it) { |
631 QuicPacketSequenceNumber sequence_number = it->first; | 633 QuicPacketSequenceNumber sequence_number = it->first; |
632 const RetransmittableFrames* frames = it->second.retransmittable_frames; | 634 const RetransmittableFrames* frames = it->second.retransmittable_frames; |
633 if (frames == NULL) { | 635 // Only retransmit frames which are pending, and therefore have been sent. |
| 636 if (!it->second.pending || frames == NULL) { |
634 continue; | 637 continue; |
635 } | 638 } |
636 DCHECK_NE(IS_HANDSHAKE, frames->HasCryptoHandshake()); | 639 DCHECK_NE(IS_HANDSHAKE, frames->HasCryptoHandshake()); |
637 MarkForRetransmission(sequence_number, TLP_RETRANSMISSION); | 640 MarkForRetransmission(sequence_number, TLP_RETRANSMISSION); |
638 return; | 641 return; |
639 } | 642 } |
640 DLOG(FATAL) | 643 DLOG(FATAL) |
641 << "No retransmittable packets, so RetransmitOldestPacket failed."; | 644 << "No retransmittable packets, so RetransmitOldestPacket failed."; |
642 } | 645 } |
643 | 646 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 if (!it->second.pending) { | 719 if (!it->second.pending) { |
717 ++it; | 720 ++it; |
718 continue; | 721 continue; |
719 } | 722 } |
720 QuicPacketSequenceNumber sequence_number = it->first; | 723 QuicPacketSequenceNumber sequence_number = it->first; |
721 DVLOG(1) << "still missing packet " << sequence_number; | 724 DVLOG(1) << "still missing packet " << sequence_number; |
722 // Acks must be handled previously, so ensure it's missing and not acked. | 725 // Acks must be handled previously, so ensure it's missing and not acked. |
723 DCHECK(IsAwaitingPacket(received_info, sequence_number)); | 726 DCHECK(IsAwaitingPacket(received_info, sequence_number)); |
724 DCHECK(ContainsKey(packet_history_map_, sequence_number)); | 727 DCHECK(ContainsKey(packet_history_map_, sequence_number)); |
725 const TransmissionInfo& transmission_info = it->second; | 728 const TransmissionInfo& transmission_info = it->second; |
726 const SendAlgorithmInterface::SentPacket* sent_packet = | 729 SendAlgorithmInterface::SentPacket* sent_packet = |
727 packet_history_map_[sequence_number]; | 730 packet_history_map_[sequence_number]; |
728 | 731 |
729 // Consider it multiple nacks when there is a gap between the missing packet | 732 // Consider it multiple nacks when there is a gap between the missing packet |
730 // and the largest observed, since the purpose of a nack threshold is to | 733 // and the largest observed, since the purpose of a nack threshold is to |
731 // tolerate re-ordering. This handles both StretchAcks and Forward Acks. | 734 // tolerate re-ordering. This handles both StretchAcks and Forward Acks. |
732 // TODO(ianswett): This relies heavily on sequential reception of packets, | 735 // TODO(ianswett): This relies heavily on sequential reception of packets, |
733 // and makes an assumption that the congestion control uses TCP style nacks. | 736 // and makes an assumption that the congestion control uses TCP style nacks. |
734 size_t min_nacks = received_info.largest_observed - sequence_number; | 737 size_t min_nacks = received_info.largest_observed - sequence_number; |
735 packet_history_map_[sequence_number]->Nack(min_nacks); | 738 sent_packet->Nack(min_nacks); |
736 | 739 |
737 size_t num_nacks_needed = kNumberOfNacksBeforeRetransmission; | 740 size_t num_nacks_needed = kNumberOfNacksBeforeRetransmission; |
738 // Check for early retransmit(RFC5827) when the last packet gets acked and | 741 // Check for early retransmit(RFC5827) when the last packet gets acked and |
739 // the there are fewer than 4 pending packets. | 742 // the there are fewer than 4 pending packets. |
740 // TODO(ianswett): Set a retransmission timer instead of losing the packet | 743 // TODO(ianswett): Set a retransmission timer instead of losing the packet |
741 // and retransmitting immediately. Also consider only invoking OnPacketLost | 744 // and retransmitting immediately. Also consider only invoking OnPacketLost |
742 // and OnPacketAbandoned when they're actually retransmitted in case they | 745 // and OnPacketAbandoned when they're actually retransmitted in case they |
743 // arrive while queued for retransmission. | 746 // arrive while queued for retransmission. |
744 if (transmission_info.retransmittable_frames && | 747 if (transmission_info.retransmittable_frames && |
745 packet_history_map_.rbegin()->first == received_info.largest_observed) { | 748 packet_history_map_.rbegin()->first == received_info.largest_observed) { |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 } | 992 } |
990 previous_transmissions->erase(sequence_number); | 993 previous_transmissions->erase(sequence_number); |
991 if (previous_transmissions->size() == 1) { | 994 if (previous_transmissions->size() == 1) { |
992 QuicPacketSequenceNumber current = *previous_transmissions->begin(); | 995 QuicPacketSequenceNumber current = *previous_transmissions->begin(); |
993 unacked_packets_[current].previous_transmissions = NULL; | 996 unacked_packets_[current].previous_transmissions = NULL; |
994 delete previous_transmissions; | 997 delete previous_transmissions; |
995 } | 998 } |
996 } | 999 } |
997 | 1000 |
998 } // namespace net | 1001 } // namespace net |
OLD | NEW |