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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 has_retransmittable_data)) { | 560 has_retransmittable_data)) { |
561 return; | 561 return; |
562 } | 562 } |
563 packet_history_map_[sequence_number] = new SendAlgorithmInterface::SentPacket( | 563 packet_history_map_[sequence_number] = new SendAlgorithmInterface::SentPacket( |
564 bytes, sent_time, has_retransmittable_data); | 564 bytes, sent_time, has_retransmittable_data); |
565 pending_packets_.insert(sequence_number); | 565 pending_packets_.insert(sequence_number); |
566 CleanupPacketHistory(); | 566 CleanupPacketHistory(); |
567 } | 567 } |
568 | 568 |
569 void QuicSentPacketManager::OnRetransmissionTimeout() { | 569 void QuicSentPacketManager::OnRetransmissionTimeout() { |
570 ++consecutive_rto_count_; | |
571 send_algorithm_->OnRetransmissionTimeout(); | |
572 // Abandon all pending packets to ensure the congestion window | 570 // Abandon all pending packets to ensure the congestion window |
573 // opens up before we attempt to retransmit packets. | 571 // opens up before we attempt to retransmit packets. |
574 for (SequenceNumberSet::const_iterator it = pending_packets_.begin(); | 572 for (SequenceNumberSet::const_iterator it = pending_packets_.begin(); |
575 it != pending_packets_.end(); ++it) { | 573 it != pending_packets_.end(); ++it) { |
576 QuicPacketSequenceNumber sequence_number = *it; | 574 QuicPacketSequenceNumber sequence_number = *it; |
577 DCHECK(ContainsKey(packet_history_map_, sequence_number)); | 575 DCHECK(ContainsKey(packet_history_map_, sequence_number)); |
578 send_algorithm_->OnPacketAbandoned( | 576 send_algorithm_->OnPacketAbandoned( |
579 sequence_number, packet_history_map_[sequence_number]->bytes_sent()); | 577 sequence_number, packet_history_map_[sequence_number]->bytes_sent()); |
580 } | 578 } |
581 pending_packets_.clear(); | 579 pending_packets_.clear(); |
582 | 580 |
583 // Attempt to send all the unacked packets when the RTO fires, let the | 581 // Attempt to send all the unacked packets when the RTO fires, let the |
584 // congestion manager decide how many to send immediately and the remaining | 582 // congestion manager decide how many to send immediately and the remaining |
585 // packets will be queued for future sending. | 583 // packets will be queued for future sending. |
586 DVLOG(1) << "OnRetransmissionTimeout() fired with " | 584 DVLOG(1) << "OnRetransmissionTimeout() fired with " |
587 << unacked_packets_.size() << " unacked packets."; | 585 << unacked_packets_.size() << " unacked packets."; |
588 | 586 |
589 // Retransmit any packet with retransmittable frames. | 587 // Retransmit any packet with retransmittable frames. |
| 588 bool packets_retransmitted = false; |
590 for (UnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 589 for (UnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
591 it != unacked_packets_.end(); ++it) { | 590 it != unacked_packets_.end(); ++it) { |
592 if (it->second.retransmittable_frames != NULL) { | 591 if (it->second.retransmittable_frames != NULL) { |
| 592 packets_retransmitted = true; |
593 MarkForRetransmission(it->first, RTO_RETRANSMISSION); | 593 MarkForRetransmission(it->first, RTO_RETRANSMISSION); |
594 } | 594 } |
595 } | 595 } |
| 596 |
| 597 // Only inform the sent packet manager of an RTO if data was retransmitted. |
| 598 if (packets_retransmitted) { |
| 599 ++consecutive_rto_count_; |
| 600 send_algorithm_->OnRetransmissionTimeout(); |
| 601 } |
596 } | 602 } |
597 | 603 |
598 QuicTime QuicSentPacketManager::OnAbandonFecTimeout() { | 604 QuicTime QuicSentPacketManager::OnAbandonFecTimeout() { |
599 // Abandon all the FEC packets older than the current RTO, then reschedule | 605 // Abandon all the FEC packets older than the current RTO, then reschedule |
600 // the alarm if there are more pending fec packets. | 606 // the alarm if there are more pending fec packets. |
601 QuicTime::Delta retransmission_delay = GetRetransmissionDelay(); | 607 QuicTime::Delta retransmission_delay = GetRetransmissionDelay(); |
602 QuicTime max_send_time = | 608 QuicTime max_send_time = |
603 clock_->ApproximateNow().Subtract(retransmission_delay); | 609 clock_->ApproximateNow().Subtract(retransmission_delay); |
604 while (!unacked_fec_packets_.empty()) { | 610 while (!unacked_fec_packets_.empty()) { |
605 UnackedFecPacketMap::iterator it = unacked_fec_packets_.begin(); | 611 UnackedFecPacketMap::iterator it = unacked_fec_packets_.begin(); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 return; | 855 return; |
850 } | 856 } |
851 | 857 |
852 using_pacing_ = true; | 858 using_pacing_ = true; |
853 send_algorithm_.reset( | 859 send_algorithm_.reset( |
854 new PacingSender(send_algorithm_.release(), | 860 new PacingSender(send_algorithm_.release(), |
855 QuicTime::Delta::FromMicroseconds(1))); | 861 QuicTime::Delta::FromMicroseconds(1))); |
856 } | 862 } |
857 | 863 |
858 } // namespace net | 864 } // namespace net |
OLD | NEW |