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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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), | 81 largest_observed_(0), |
| 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 } |
91 | 92 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 new_sequence_number, | 173 new_sequence_number, |
173 transmission_type, | 174 transmission_type, |
174 clock_->ApproximateNow()); | 175 clock_->ApproximateNow()); |
175 } | 176 } |
176 } | 177 } |
177 | 178 |
178 void QuicSentPacketManager::OnIncomingAck(const QuicAckFrame& ack_frame, | 179 void QuicSentPacketManager::OnIncomingAck(const QuicAckFrame& ack_frame, |
179 QuicTime ack_receive_time) { | 180 QuicTime ack_receive_time) { |
180 QuicByteCount bytes_in_flight = unacked_packets_.bytes_in_flight(); | 181 QuicByteCount bytes_in_flight = unacked_packets_.bytes_in_flight(); |
181 | 182 |
| 183 UpdatePacketInformationReceivedByPeer(ack_frame); |
182 // We rely on delta_time_largest_observed to compute an RTT estimate, so | 184 // We rely on delta_time_largest_observed to compute an RTT estimate, so |
183 // we only update rtt when the largest observed gets acked. | 185 // we only update rtt when the largest observed gets acked. |
184 bool largest_observed_acked = MaybeUpdateRTT(ack_frame, ack_receive_time); | 186 bool largest_observed_acked = MaybeUpdateRTT(ack_frame, ack_receive_time); |
185 if (largest_observed_ < ack_frame.largest_observed) { | 187 if (largest_observed_ < ack_frame.largest_observed) { |
186 largest_observed_ = ack_frame.largest_observed; | 188 largest_observed_ = ack_frame.largest_observed; |
187 unacked_packets_.IncreaseLargestObserved(largest_observed_); | 189 unacked_packets_.IncreaseLargestObserved(largest_observed_); |
188 } | 190 } |
189 HandleAckForSentPackets(ack_frame); | 191 HandleAckForSentPackets(ack_frame); |
190 InvokeLossDetection(ack_receive_time); | 192 InvokeLossDetection(ack_receive_time); |
191 MaybeInvokeCongestionEvent(largest_observed_acked, bytes_in_flight); | 193 MaybeInvokeCongestionEvent(largest_observed_acked, bytes_in_flight); |
(...skipping 24 matching lines...) Expand all Loading... |
216 | 218 |
217 if (debug_delegate_ != NULL) { | 219 if (debug_delegate_ != NULL) { |
218 debug_delegate_->OnIncomingAck(ack_frame, | 220 debug_delegate_->OnIncomingAck(ack_frame, |
219 ack_receive_time, | 221 ack_receive_time, |
220 largest_observed_, | 222 largest_observed_, |
221 largest_observed_acked, | 223 largest_observed_acked, |
222 GetLeastUnackedSentPacket()); | 224 GetLeastUnackedSentPacket()); |
223 } | 225 } |
224 } | 226 } |
225 | 227 |
| 228 void QuicSentPacketManager::UpdatePacketInformationReceivedByPeer( |
| 229 const QuicAckFrame& ack_frame) { |
| 230 if (ack_frame.missing_packets.empty()) { |
| 231 least_packet_awaited_by_peer_ = ack_frame.largest_observed + 1; |
| 232 } else { |
| 233 least_packet_awaited_by_peer_ = *(ack_frame.missing_packets.begin()); |
| 234 } |
| 235 } |
| 236 |
226 void QuicSentPacketManager::MaybeInvokeCongestionEvent( | 237 void QuicSentPacketManager::MaybeInvokeCongestionEvent( |
227 bool rtt_updated, QuicByteCount bytes_in_flight) { | 238 bool rtt_updated, QuicByteCount bytes_in_flight) { |
228 if (!rtt_updated && packets_acked_.empty() && packets_lost_.empty()) { | 239 if (!rtt_updated && packets_acked_.empty() && packets_lost_.empty()) { |
229 return; | 240 return; |
230 } | 241 } |
231 send_algorithm_->OnCongestionEvent(rtt_updated, bytes_in_flight, | 242 send_algorithm_->OnCongestionEvent(rtt_updated, bytes_in_flight, |
232 packets_acked_, packets_lost_); | 243 packets_acked_, packets_lost_); |
233 packets_acked_.clear(); | 244 packets_acked_.clear(); |
234 packets_lost_.clear(); | 245 packets_lost_.clear(); |
235 if (network_change_visitor_ != NULL) { | 246 if (network_change_visitor_ != NULL) { |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 | 890 |
880 // Set up a pacing sender with a 5 millisecond alarm granularity. | 891 // Set up a pacing sender with a 5 millisecond alarm granularity. |
881 using_pacing_ = true; | 892 using_pacing_ = true; |
882 send_algorithm_.reset( | 893 send_algorithm_.reset( |
883 new PacingSender(send_algorithm_.release(), | 894 new PacingSender(send_algorithm_.release(), |
884 QuicTime::Delta::FromMilliseconds(5), | 895 QuicTime::Delta::FromMilliseconds(5), |
885 kInitialUnpacedBurst)); | 896 kInitialUnpacedBurst)); |
886 } | 897 } |
887 | 898 |
888 } // namespace net | 899 } // namespace net |
OLD | NEW |