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_(NULL), | 74 debug_delegate_(NULL), |
75 network_change_visitor_(NULL), | 75 network_change_visitor_(NULL), |
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 largest_observed_(0), | |
82 least_packet_awaited_by_peer_(1), | 81 least_packet_awaited_by_peer_(1), |
83 first_rto_transmission_(0), | 82 first_rto_transmission_(0), |
84 consecutive_rto_count_(0), | 83 consecutive_rto_count_(0), |
85 consecutive_tlp_count_(0), | 84 consecutive_tlp_count_(0), |
86 consecutive_crypto_retransmission_count_(0), | 85 consecutive_crypto_retransmission_count_(0), |
87 pending_timer_transmission_count_(0), | 86 pending_timer_transmission_count_(0), |
88 max_tail_loss_probes_(kDefaultMaxTailLossProbes), | 87 max_tail_loss_probes_(kDefaultMaxTailLossProbes), |
89 using_pacing_(false), | 88 using_pacing_(false), |
90 handshake_confirmed_(false) { | 89 handshake_confirmed_(false) { |
91 } | 90 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 } | 181 } |
183 | 182 |
184 void QuicSentPacketManager::OnIncomingAck(const QuicAckFrame& ack_frame, | 183 void QuicSentPacketManager::OnIncomingAck(const QuicAckFrame& ack_frame, |
185 QuicTime ack_receive_time) { | 184 QuicTime ack_receive_time) { |
186 QuicByteCount bytes_in_flight = unacked_packets_.bytes_in_flight(); | 185 QuicByteCount bytes_in_flight = unacked_packets_.bytes_in_flight(); |
187 | 186 |
188 UpdatePacketInformationReceivedByPeer(ack_frame); | 187 UpdatePacketInformationReceivedByPeer(ack_frame); |
189 // We rely on delta_time_largest_observed to compute an RTT estimate, so | 188 // We rely on delta_time_largest_observed to compute an RTT estimate, so |
190 // we only update rtt when the largest observed gets acked. | 189 // we only update rtt when the largest observed gets acked. |
191 bool largest_observed_acked = MaybeUpdateRTT(ack_frame, ack_receive_time); | 190 bool largest_observed_acked = MaybeUpdateRTT(ack_frame, ack_receive_time); |
192 if (largest_observed_ < ack_frame.largest_observed) { | 191 DCHECK_GE(ack_frame.largest_observed, unacked_packets_.largest_observed()); |
193 largest_observed_ = ack_frame.largest_observed; | 192 unacked_packets_.IncreaseLargestObserved(ack_frame.largest_observed); |
194 unacked_packets_.IncreaseLargestObserved(largest_observed_); | 193 |
195 } | |
196 HandleAckForSentPackets(ack_frame); | 194 HandleAckForSentPackets(ack_frame); |
197 InvokeLossDetection(ack_receive_time); | 195 InvokeLossDetection(ack_receive_time); |
198 MaybeInvokeCongestionEvent(largest_observed_acked, bytes_in_flight); | 196 MaybeInvokeCongestionEvent(largest_observed_acked, bytes_in_flight); |
199 | 197 |
200 sustained_bandwidth_recorder_.RecordEstimate( | 198 sustained_bandwidth_recorder_.RecordEstimate( |
201 send_algorithm_->InRecovery(), | 199 send_algorithm_->InRecovery(), |
202 send_algorithm_->InSlowStart(), | 200 send_algorithm_->InSlowStart(), |
203 send_algorithm_->BandwidthEstimate(), | 201 send_algorithm_->BandwidthEstimate(), |
204 ack_receive_time, | 202 ack_receive_time, |
205 clock_->WallNow(), | 203 clock_->WallNow(), |
(...skipping 11 matching lines...) Expand all Loading... |
217 if (largest_observed_acked) { | 215 if (largest_observed_acked) { |
218 // Reset all retransmit counters any time a new packet is acked. | 216 // Reset all retransmit counters any time a new packet is acked. |
219 consecutive_rto_count_ = 0; | 217 consecutive_rto_count_ = 0; |
220 consecutive_tlp_count_ = 0; | 218 consecutive_tlp_count_ = 0; |
221 consecutive_crypto_retransmission_count_ = 0; | 219 consecutive_crypto_retransmission_count_ = 0; |
222 } | 220 } |
223 | 221 |
224 if (debug_delegate_ != NULL) { | 222 if (debug_delegate_ != NULL) { |
225 debug_delegate_->OnIncomingAck(ack_frame, | 223 debug_delegate_->OnIncomingAck(ack_frame, |
226 ack_receive_time, | 224 ack_receive_time, |
227 largest_observed_, | 225 unacked_packets_.largest_observed(), |
228 largest_observed_acked, | 226 largest_observed_acked, |
229 GetLeastUnackedSentPacket()); | 227 GetLeastUnackedSentPacket()); |
230 } | 228 } |
231 } | 229 } |
232 | 230 |
233 void QuicSentPacketManager::UpdatePacketInformationReceivedByPeer( | 231 void QuicSentPacketManager::UpdatePacketInformationReceivedByPeer( |
234 const QuicAckFrame& ack_frame) { | 232 const QuicAckFrame& ack_frame) { |
235 if (ack_frame.missing_packets.empty()) { | 233 if (ack_frame.missing_packets.empty()) { |
236 least_packet_awaited_by_peer_ = ack_frame.largest_observed + 1; | 234 least_packet_awaited_by_peer_ = ack_frame.largest_observed + 1; |
237 } else { | 235 } else { |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 const QuicCongestionFeedbackFrame& frame, | 691 const QuicCongestionFeedbackFrame& frame, |
694 const QuicTime& feedback_receive_time) { | 692 const QuicTime& feedback_receive_time) { |
695 send_algorithm_->OnIncomingQuicCongestionFeedbackFrame( | 693 send_algorithm_->OnIncomingQuicCongestionFeedbackFrame( |
696 frame, feedback_receive_time); | 694 frame, feedback_receive_time); |
697 } | 695 } |
698 | 696 |
699 void QuicSentPacketManager::InvokeLossDetection(QuicTime time) { | 697 void QuicSentPacketManager::InvokeLossDetection(QuicTime time) { |
700 SequenceNumberSet lost_packets = | 698 SequenceNumberSet lost_packets = |
701 loss_algorithm_->DetectLostPackets(unacked_packets_, | 699 loss_algorithm_->DetectLostPackets(unacked_packets_, |
702 time, | 700 time, |
703 largest_observed_, | 701 unacked_packets_.largest_observed(), |
704 rtt_stats_); | 702 rtt_stats_); |
705 for (SequenceNumberSet::const_iterator it = lost_packets.begin(); | 703 for (SequenceNumberSet::const_iterator it = lost_packets.begin(); |
706 it != lost_packets.end(); ++it) { | 704 it != lost_packets.end(); ++it) { |
707 QuicPacketSequenceNumber sequence_number = *it; | 705 QuicPacketSequenceNumber sequence_number = *it; |
708 const TransmissionInfo& transmission_info = | 706 const TransmissionInfo& transmission_info = |
709 unacked_packets_.GetTransmissionInfo(sequence_number); | 707 unacked_packets_.GetTransmissionInfo(sequence_number); |
710 // TODO(ianswett): If it's expected the FEC packet may repair the loss, it | 708 // TODO(ianswett): If it's expected the FEC packet may repair the loss, it |
711 // should be recorded as a loss to the send algorithm, but not retransmitted | 709 // should be recorded as a loss to the send algorithm, but not retransmitted |
712 // until it's known whether the FEC packet arrived. | 710 // until it's known whether the FEC packet arrived. |
713 ++stats_->packets_lost; | 711 ++stats_->packets_lost; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 | 889 |
892 // Set up a pacing sender with a 5 millisecond alarm granularity. | 890 // Set up a pacing sender with a 5 millisecond alarm granularity. |
893 using_pacing_ = true; | 891 using_pacing_ = true; |
894 send_algorithm_.reset( | 892 send_algorithm_.reset( |
895 new PacingSender(send_algorithm_.release(), | 893 new PacingSender(send_algorithm_.release(), |
896 QuicTime::Delta::FromMilliseconds(5), | 894 QuicTime::Delta::FromMilliseconds(5), |
897 kInitialUnpacedBurst)); | 895 kInitialUnpacedBurst)); |
898 } | 896 } |
899 | 897 |
900 } // namespace net | 898 } // namespace net |
OLD | NEW |