| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 if (HasClientSentConnectionOption(config, k1CON)) { | 125 if (HasClientSentConnectionOption(config, k1CON)) { |
| 125 send_algorithm_->SetNumEmulatedConnections(1); | 126 send_algorithm_->SetNumEmulatedConnections(1); |
| 126 } | 127 } |
| 127 if (HasClientSentConnectionOption(config, kNTLP)) { | 128 if (HasClientSentConnectionOption(config, kNTLP)) { |
| 128 max_tail_loss_probes_ = 0; | 129 max_tail_loss_probes_ = 0; |
| 129 } | 130 } |
| 130 if (config.HasReceivedConnectionOptions() && | 131 if (config.HasReceivedConnectionOptions() && |
| 131 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { | 132 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { |
| 132 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); | 133 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); |
| 133 } | 134 } |
| 135 if (config.HasReceivedSocketReceiveBuffer()) { |
| 136 receive_buffer_bytes_ = |
| 137 max(kMinSocketReceiveBuffer, |
| 138 static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer())); |
| 139 } |
| 134 send_algorithm_->SetFromConfig(config, is_server_); | 140 send_algorithm_->SetFromConfig(config, is_server_); |
| 135 | 141 |
| 136 if (network_change_visitor_ != nullptr) { | 142 if (network_change_visitor_ != nullptr) { |
| 137 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); | 143 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); |
| 138 } | 144 } |
| 139 } | 145 } |
| 140 | 146 |
| 141 bool QuicSentPacketManager::HasClientSentConnectionOption( | 147 bool QuicSentPacketManager::HasClientSentConnectionOption( |
| 142 const QuicConfig& config, QuicTag tag) const { | 148 const QuicConfig& config, QuicTag tag) const { |
| 143 if (is_server_) { | 149 if (is_server_) { |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 if (unacked_packets_.HasUnackedRetransmittableFrames()) { | 667 if (unacked_packets_.HasUnackedRetransmittableFrames()) { |
| 662 return TLP_MODE; | 668 return TLP_MODE; |
| 663 } | 669 } |
| 664 } | 670 } |
| 665 return RTO_MODE; | 671 return RTO_MODE; |
| 666 } | 672 } |
| 667 | 673 |
| 668 void QuicSentPacketManager::OnIncomingQuicCongestionFeedbackFrame( | 674 void QuicSentPacketManager::OnIncomingQuicCongestionFeedbackFrame( |
| 669 const QuicCongestionFeedbackFrame& frame, | 675 const QuicCongestionFeedbackFrame& frame, |
| 670 const QuicTime& feedback_receive_time) { | 676 const QuicTime& feedback_receive_time) { |
| 671 send_algorithm_->OnIncomingQuicCongestionFeedbackFrame( | 677 if (frame.type == kTCP) { |
| 672 frame, feedback_receive_time); | 678 receive_buffer_bytes_ = frame.tcp.receive_window; |
| 679 } |
| 673 } | 680 } |
| 674 | 681 |
| 675 void QuicSentPacketManager::InvokeLossDetection(QuicTime time) { | 682 void QuicSentPacketManager::InvokeLossDetection(QuicTime time) { |
| 676 SequenceNumberSet lost_packets = | 683 SequenceNumberSet lost_packets = |
| 677 loss_algorithm_->DetectLostPackets(unacked_packets_, | 684 loss_algorithm_->DetectLostPackets(unacked_packets_, |
| 678 time, | 685 time, |
| 679 unacked_packets_.largest_observed(), | 686 unacked_packets_.largest_observed(), |
| 680 rtt_stats_); | 687 rtt_stats_); |
| 681 for (SequenceNumberSet::const_iterator it = lost_packets.begin(); | 688 for (SequenceNumberSet::const_iterator it = lost_packets.begin(); |
| 682 it != lost_packets.end(); ++it) { | 689 it != lost_packets.end(); ++it) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 } | 734 } |
| 728 | 735 |
| 729 QuicTime::Delta QuicSentPacketManager::TimeUntilSend( | 736 QuicTime::Delta QuicSentPacketManager::TimeUntilSend( |
| 730 QuicTime now, | 737 QuicTime now, |
| 731 HasRetransmittableData retransmittable) { | 738 HasRetransmittableData retransmittable) { |
| 732 // The TLP logic is entirely contained within QuicSentPacketManager, so the | 739 // The TLP logic is entirely contained within QuicSentPacketManager, so the |
| 733 // send algorithm does not need to be consulted. | 740 // send algorithm does not need to be consulted. |
| 734 if (pending_timer_transmission_count_ > 0) { | 741 if (pending_timer_transmission_count_ > 0) { |
| 735 return QuicTime::Delta::Zero(); | 742 return QuicTime::Delta::Zero(); |
| 736 } | 743 } |
| 744 if (unacked_packets_.bytes_in_flight() >= receive_buffer_bytes_) { |
| 745 return QuicTime::Delta::Infinite(); |
| 746 } |
| 737 return send_algorithm_->TimeUntilSend( | 747 return send_algorithm_->TimeUntilSend( |
| 738 now, unacked_packets_.bytes_in_flight(), retransmittable); | 748 now, unacked_packets_.bytes_in_flight(), retransmittable); |
| 739 } | 749 } |
| 740 | 750 |
| 741 // Uses a 25ms delayed ack timer. Also helps with better signaling | 751 // Uses a 25ms delayed ack timer. Also helps with better signaling |
| 742 // 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. |
| 743 // 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 |
| 744 // than the retransmission timer's minimum value (MinRTO). We want the | 754 // than the retransmission timer's minimum value (MinRTO). We want the |
| 745 // 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 |
| 746 // 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... |
| 872 // 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 |
| 873 // the default granularity of the Linux kernel's FQ qdisc. | 883 // the default granularity of the Linux kernel's FQ qdisc. |
| 874 using_pacing_ = true; | 884 using_pacing_ = true; |
| 875 send_algorithm_.reset( | 885 send_algorithm_.reset( |
| 876 new PacingSender(send_algorithm_.release(), | 886 new PacingSender(send_algorithm_.release(), |
| 877 QuicTime::Delta::FromMilliseconds(1), | 887 QuicTime::Delta::FromMilliseconds(1), |
| 878 kInitialUnpacedBurst)); | 888 kInitialUnpacedBurst)); |
| 879 } | 889 } |
| 880 | 890 |
| 881 } // namespace net | 891 } // namespace net |
| OLD | NEW |