| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 is_server_(is_server), | 71 is_server_(is_server), |
| 72 clock_(clock), | 72 clock_(clock), |
| 73 stats_(stats), | 73 stats_(stats), |
| 74 debug_delegate_(nullptr), | 74 debug_delegate_(nullptr), |
| 75 network_change_visitor_(nullptr), | 75 network_change_visitor_(nullptr), |
| 76 send_algorithm_(SendAlgorithmInterface::Create(clock, | 76 send_algorithm_(SendAlgorithmInterface::Create(clock, |
| 77 &rtt_stats_, | 77 &rtt_stats_, |
| 78 congestion_control_type, | 78 congestion_control_type, |
| 79 stats)), | 79 stats)), |
| 80 loss_algorithm_(LossDetectionInterface::Create(loss_type)), | 80 loss_algorithm_(LossDetectionInterface::Create(loss_type)), |
| 81 receive_buffer_bytes_(kDefaultSocketReceiveBuffer), |
| 81 least_packet_awaited_by_peer_(1), | 82 least_packet_awaited_by_peer_(1), |
| 82 first_rto_transmission_(0), | 83 first_rto_transmission_(0), |
| 83 consecutive_rto_count_(0), | 84 consecutive_rto_count_(0), |
| 84 consecutive_tlp_count_(0), | 85 consecutive_tlp_count_(0), |
| 85 consecutive_crypto_retransmission_count_(0), | 86 consecutive_crypto_retransmission_count_(0), |
| 86 pending_timer_transmission_count_(0), | 87 pending_timer_transmission_count_(0), |
| 87 max_tail_loss_probes_(kDefaultMaxTailLossProbes), | 88 max_tail_loss_probes_(kDefaultMaxTailLossProbes), |
| 88 using_pacing_(false), | 89 using_pacing_(false), |
| 89 handshake_confirmed_(false) { | 90 handshake_confirmed_(false) { |
| 90 } | 91 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 117 ContainsQuicTag(config.ReceivedConnectionOptions(), kRENO)) { | 118 ContainsQuicTag(config.ReceivedConnectionOptions(), kRENO)) { |
| 118 send_algorithm_.reset( | 119 send_algorithm_.reset( |
| 119 SendAlgorithmInterface::Create(clock_, &rtt_stats_, kReno, stats_)); | 120 SendAlgorithmInterface::Create(clock_, &rtt_stats_, kReno, stats_)); |
| 120 } | 121 } |
| 121 if (HasClientSentConnectionOption(config, kPACE)) { | 122 if (HasClientSentConnectionOption(config, kPACE)) { |
| 122 EnablePacing(); | 123 EnablePacing(); |
| 123 } | 124 } |
| 124 if (HasClientSentConnectionOption(config, k1CON)) { | 125 if (HasClientSentConnectionOption(config, k1CON)) { |
| 125 send_algorithm_->SetNumEmulatedConnections(1); | 126 send_algorithm_->SetNumEmulatedConnections(1); |
| 126 } | 127 } |
| 128 if (HasClientSentConnectionOption(config, kNTLP)) { |
| 129 max_tail_loss_probes_ = 0; |
| 130 } |
| 127 if (config.HasReceivedConnectionOptions() && | 131 if (config.HasReceivedConnectionOptions() && |
| 128 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { | 132 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { |
| 129 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); | 133 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); |
| 130 } | 134 } |
| 135 if (config.HasReceivedSocketReceiveBuffer()) { |
| 136 receive_buffer_bytes_ = |
| 137 max(kMinSocketReceiveBuffer, |
| 138 static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer())); |
| 139 } |
| 131 send_algorithm_->SetFromConfig(config, is_server_); | 140 send_algorithm_->SetFromConfig(config, is_server_); |
| 132 | 141 |
| 133 if (network_change_visitor_ != nullptr) { | 142 if (network_change_visitor_ != nullptr) { |
| 134 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); | 143 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); |
| 135 } | 144 } |
| 136 } | 145 } |
| 137 | 146 |
| 138 bool QuicSentPacketManager::HasClientSentConnectionOption( | 147 bool QuicSentPacketManager::HasClientSentConnectionOption( |
| 139 const QuicConfig& config, QuicTag tag) const { | 148 const QuicConfig& config, QuicTag tag) const { |
| 140 if (is_server_) { | 149 if (is_server_) { |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 if (unacked_packets_.HasUnackedRetransmittableFrames()) { | 667 if (unacked_packets_.HasUnackedRetransmittableFrames()) { |
| 659 return TLP_MODE; | 668 return TLP_MODE; |
| 660 } | 669 } |
| 661 } | 670 } |
| 662 return RTO_MODE; | 671 return RTO_MODE; |
| 663 } | 672 } |
| 664 | 673 |
| 665 void QuicSentPacketManager::OnIncomingQuicCongestionFeedbackFrame( | 674 void QuicSentPacketManager::OnIncomingQuicCongestionFeedbackFrame( |
| 666 const QuicCongestionFeedbackFrame& frame, | 675 const QuicCongestionFeedbackFrame& frame, |
| 667 const QuicTime& feedback_receive_time) { | 676 const QuicTime& feedback_receive_time) { |
| 668 send_algorithm_->OnIncomingQuicCongestionFeedbackFrame( | 677 if (frame.type == kTCP) { |
| 669 frame, feedback_receive_time); | 678 receive_buffer_bytes_ = frame.tcp.receive_window; |
| 679 } |
| 670 } | 680 } |
| 671 | 681 |
| 672 void QuicSentPacketManager::InvokeLossDetection(QuicTime time) { | 682 void QuicSentPacketManager::InvokeLossDetection(QuicTime time) { |
| 673 SequenceNumberSet lost_packets = | 683 SequenceNumberSet lost_packets = |
| 674 loss_algorithm_->DetectLostPackets(unacked_packets_, | 684 loss_algorithm_->DetectLostPackets(unacked_packets_, |
| 675 time, | 685 time, |
| 676 unacked_packets_.largest_observed(), | 686 unacked_packets_.largest_observed(), |
| 677 rtt_stats_); | 687 rtt_stats_); |
| 678 for (SequenceNumberSet::const_iterator it = lost_packets.begin(); | 688 for (SequenceNumberSet::const_iterator it = lost_packets.begin(); |
| 679 it != lost_packets.end(); ++it) { | 689 it != lost_packets.end(); ++it) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 } | 734 } |
| 725 | 735 |
| 726 QuicTime::Delta QuicSentPacketManager::TimeUntilSend( | 736 QuicTime::Delta QuicSentPacketManager::TimeUntilSend( |
| 727 QuicTime now, | 737 QuicTime now, |
| 728 HasRetransmittableData retransmittable) { | 738 HasRetransmittableData retransmittable) { |
| 729 // The TLP logic is entirely contained within QuicSentPacketManager, so the | 739 // The TLP logic is entirely contained within QuicSentPacketManager, so the |
| 730 // send algorithm does not need to be consulted. | 740 // send algorithm does not need to be consulted. |
| 731 if (pending_timer_transmission_count_ > 0) { | 741 if (pending_timer_transmission_count_ > 0) { |
| 732 return QuicTime::Delta::Zero(); | 742 return QuicTime::Delta::Zero(); |
| 733 } | 743 } |
| 744 if (unacked_packets_.bytes_in_flight() >= receive_buffer_bytes_) { |
| 745 return QuicTime::Delta::Infinite(); |
| 746 } |
| 734 return send_algorithm_->TimeUntilSend( | 747 return send_algorithm_->TimeUntilSend( |
| 735 now, unacked_packets_.bytes_in_flight(), retransmittable); | 748 now, unacked_packets_.bytes_in_flight(), retransmittable); |
| 736 } | 749 } |
| 737 | 750 |
| 738 // Uses a 25ms delayed ack timer. Also helps with better signaling | 751 // Uses a 25ms delayed ack timer. Also helps with better signaling |
| 739 // in low-bandwidth (< ~384 kbps), where an ack is sent per packet. | 752 // in low-bandwidth (< ~384 kbps), where an ack is sent per packet. |
| 740 // Ensures that the Delayed Ack timer is always set to a value lesser | 753 // Ensures that the Delayed Ack timer is always set to a value lesser |
| 741 // than the retransmission timer's minimum value (MinRTO). We want the | 754 // than the retransmission timer's minimum value (MinRTO). We want the |
| 742 // delayed ack to get back to the QUIC peer before the sender's | 755 // delayed ack to get back to the QUIC peer before the sender's |
| 743 // retransmission timer triggers. Since we do not know the | 756 // retransmission timer triggers. Since we do not know the |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as | 882 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as |
| 870 // the default granularity of the Linux kernel's FQ qdisc. | 883 // the default granularity of the Linux kernel's FQ qdisc. |
| 871 using_pacing_ = true; | 884 using_pacing_ = true; |
| 872 send_algorithm_.reset( | 885 send_algorithm_.reset( |
| 873 new PacingSender(send_algorithm_.release(), | 886 new PacingSender(send_algorithm_.release(), |
| 874 QuicTime::Delta::FromMilliseconds(1), | 887 QuicTime::Delta::FromMilliseconds(1), |
| 875 kInitialUnpacedBurst)); | 888 kInitialUnpacedBurst)); |
| 876 } | 889 } |
| 877 | 890 |
| 878 } // namespace net | 891 } // namespace net |
| OLD | NEW |