Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: net/quic/quic_sent_packet_manager.cc

Issue 125183003: Correctly handle NACK-based "retransmission" of packets which no longer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_sent_packet_manager.h ('k') | net/quic/quic_sent_packet_manager_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 unacked_packets_.find(newest_transmission); 411 unacked_packets_.find(newest_transmission);
412 if (HasCryptoHandshake(newest_it->second)) { 412 if (HasCryptoHandshake(newest_it->second)) {
413 --pending_crypto_packet_count_; 413 --pending_crypto_packet_count_;
414 } 414 }
415 // If we have received an ack for a previous transmission of a packet, 415 // If we have received an ack for a previous transmission of a packet,
416 // we want to keep the "new" transmission of the packet unacked, 416 // we want to keep the "new" transmission of the packet unacked,
417 // but prevent the data from being retransmitted. 417 // but prevent the data from being retransmitted.
418 delete newest_it->second.retransmittable_frames; 418 delete newest_it->second.retransmittable_frames;
419 newest_it->second.retransmittable_frames = NULL; 419 newest_it->second.retransmittable_frames = NULL;
420 newest_it->second.previous_transmissions = NULL; 420 newest_it->second.previous_transmissions = NULL;
421 pending_retransmissions_.erase(newest_transmission);
422 } 421 }
423 422
424 // Clear out information all previous transmissions. 423 // Clear out information all previous transmissions.
425 ++previous_transmissions_it; 424 ++previous_transmissions_it;
426 while (previous_transmissions_it != previous_transmissions->rend()) { 425 while (previous_transmissions_it != previous_transmissions->rend()) {
427 QuicPacketSequenceNumber previous_transmission = *previous_transmissions_it; 426 QuicPacketSequenceNumber previous_transmission = *previous_transmissions_it;
428 ++previous_transmissions_it; 427 ++previous_transmissions_it;
429 // If the packet was TLP retransmitted, the old copy was not yet considered 428 // If the packet was TLP retransmitted, the old copy was not yet considered
430 // lost or abandoned, so do that now. 429 // lost or abandoned, so do that now.
431 if (ContainsKey(pending_packets_, previous_transmission)) { 430 if (ContainsKey(pending_packets_, previous_transmission)) {
432 send_algorithm_->OnPacketLost(previous_transmission, clock_->Now()); 431 send_algorithm_->OnPacketLost(previous_transmission, clock_->Now());
433 OnPacketAbandoned(previous_transmission); 432 OnPacketAbandoned(previous_transmission);
434 } 433 }
435 DiscardPacket(previous_transmission); 434 DiscardPacket(previous_transmission);
436 } 435 }
437 436
438 delete previous_transmissions; 437 delete previous_transmissions;
439 438
439 if (ContainsKey(pending_retransmissions_, newest_transmission)) {
440 pending_retransmissions_.erase(newest_transmission);
441 if (!ContainsKey(pending_packets_, newest_transmission)) {
442 // If the newest transmission has already been marked for retransmission
443 // and has already been abandoned, then we should remove it from
444 // unacked_packets_, as well as cancel the retransmission.
445 DCHECK(ContainsKey(unacked_packets_, newest_transmission));
446 DCHECK(!unacked_packets_[newest_transmission].previous_transmissions);
447 unacked_packets_.erase(newest_transmission);
448 }
449 }
450
440 UnackedPacketMap::iterator next_unacked = unacked_packets_.begin(); 451 UnackedPacketMap::iterator next_unacked = unacked_packets_.begin();
441 while (next_unacked != unacked_packets_.end() && 452 while (next_unacked != unacked_packets_.end() &&
442 next_unacked->first < sequence_number) { 453 next_unacked->first < sequence_number) {
443 ++next_unacked; 454 ++next_unacked;
444 } 455 }
445 return next_unacked; 456 return next_unacked;
446 } 457 }
447 458
448 void QuicSentPacketManager::DiscardPacket( 459 void QuicSentPacketManager::DiscardPacket(
449 QuicPacketSequenceNumber sequence_number) { 460 QuicPacketSequenceNumber sequence_number) {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 // If the number of retransmissions has maxed out, don't lose or retransmit 744 // If the number of retransmissions has maxed out, don't lose or retransmit
734 // any more packets. 745 // any more packets.
735 if (num_retransmitted >= kMaxRetransmissionsPerAck) { 746 if (num_retransmitted >= kMaxRetransmissionsPerAck) {
736 ++it; 747 ++it;
737 continue; 748 continue;
738 } 749 }
739 750
740 lost_packets.insert(sequence_number); 751 lost_packets.insert(sequence_number);
741 if (transmission_info.retransmittable_frames) { 752 if (transmission_info.retransmittable_frames) {
742 ++num_retransmitted; 753 ++num_retransmitted;
743 MarkForRetransmission(*it, NACK_RETRANSMISSION); 754 MarkForRetransmission(sequence_number, NACK_RETRANSMISSION);
755 } else {
756 // Since we will not retransmit this, we need to remove it from
757 // unacked_packets_. This is either the current transmission of
758 // a packet whose previous transmission has been acked, or it
759 // is a packet that has been TLP retransmitted.
760 RemovePreviousTransmission(sequence_number);
761 unacked_packets_.erase(sequence_number);
744 } 762 }
745 763
746 ++it; 764 ++it;
747 } 765 }
748 // Abandon packets after the loop over pending packets, because otherwise it 766 // Abandon packets after the loop over pending packets, because otherwise it
749 // changes the early retransmit logic and iteration. 767 // changes the early retransmit logic and iteration.
750 for (SequenceNumberSet::const_iterator it = lost_packets.begin(); 768 for (SequenceNumberSet::const_iterator it = lost_packets.begin();
751 it != lost_packets.end(); ++it) { 769 it != lost_packets.end(); ++it) {
752 // TODO(ianswett): OnPacketLost is also called from TCPCubicSender when 770 // TODO(ianswett): OnPacketLost is also called from TCPCubicSender when
753 // an FEC packet is lost, but FEC loss information should be shared among 771 // an FEC packet is lost, but FEC loss information should be shared among
754 // congestion managers. Additionally, if it's expected the FEC packet may 772 // congestion managers. Additionally, if it's expected the FEC packet may
755 // repair the loss, it should be recorded as a loss to the congestion 773 // repair the loss, it should be recorded as a loss to the congestion
756 // manager, but not retransmitted until it's known whether the FEC packet 774 // manager, but not retransmitted until it's known whether the FEC packet
757 // arrived. 775 // arrived.
758 send_algorithm_->OnPacketLost(*it, ack_receive_time); 776 QuicPacketSequenceNumber lost_packet = *it;
759 OnPacketAbandoned(*it); 777 send_algorithm_->OnPacketLost(lost_packet, ack_receive_time);
778 OnPacketAbandoned(lost_packet);
760 } 779 }
761 } 780 }
762 781
763 void QuicSentPacketManager::MaybeUpdateRTT( 782 void QuicSentPacketManager::MaybeUpdateRTT(
764 const ReceivedPacketInfo& received_info, 783 const ReceivedPacketInfo& received_info,
765 const QuicTime& ack_receive_time) { 784 const QuicTime& ack_receive_time) {
766 // We calculate the RTT based on the highest ACKed sequence number, the lower 785 // We calculate the RTT based on the highest ACKed sequence number, the lower
767 // sequence numbers will include the ACK aggregation delay. 786 // sequence numbers will include the ACK aggregation delay.
768 SendAlgorithmInterface::SentPacketsMap::iterator history_it = 787 SendAlgorithmInterface::SentPacketsMap::iterator history_it =
769 packet_history_map_.find(received_info.largest_observed); 788 packet_history_map_.find(received_info.largest_observed);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 if (using_pacing_) { 949 if (using_pacing_) {
931 return; 950 return;
932 } 951 }
933 952
934 using_pacing_ = true; 953 using_pacing_ = true;
935 send_algorithm_.reset( 954 send_algorithm_.reset(
936 new PacingSender(send_algorithm_.release(), 955 new PacingSender(send_algorithm_.release(),
937 QuicTime::Delta::FromMicroseconds(1))); 956 QuicTime::Delta::FromMicroseconds(1)));
938 } 957 }
939 958
959 void QuicSentPacketManager::RemovePreviousTransmission(
960 QuicPacketSequenceNumber sequence_number) {
961 SequenceNumberSet* previous_transmissions =
962 unacked_packets_[sequence_number].previous_transmissions;
963 if (!previous_transmissions) {
964 return;
965 }
966 previous_transmissions->erase(sequence_number);
967 if (previous_transmissions->size() == 1) {
968 QuicPacketSequenceNumber current = *previous_transmissions->begin();
969 unacked_packets_[current].previous_transmissions = NULL;
970 delete previous_transmissions;
971 }
972 }
973
940 } // namespace net 974 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager.h ('k') | net/quic/quic_sent_packet_manager_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698