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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 return true; | 188 return true; |
189 } | 189 } |
190 return false; | 190 return false; |
191 } | 191 } |
192 | 192 |
193 void QuicSentPacketManager::OnIncomingAck(const QuicAckFrame& ack_frame, | 193 void QuicSentPacketManager::OnIncomingAck(const QuicAckFrame& ack_frame, |
194 QuicTime ack_receive_time) { | 194 QuicTime ack_receive_time) { |
195 QuicByteCount bytes_in_flight = unacked_packets_.bytes_in_flight(); | 195 QuicByteCount bytes_in_flight = unacked_packets_.bytes_in_flight(); |
196 | 196 |
197 UpdatePacketInformationReceivedByPeer(ack_frame); | 197 UpdatePacketInformationReceivedByPeer(ack_frame); |
198 // We rely on delta_time_largest_observed to compute an RTT estimate, so | 198 bool rtt_updated = MaybeUpdateRTT(ack_frame, ack_receive_time); |
199 // we only update rtt when the largest observed gets acked. | |
200 bool largest_observed_acked = MaybeUpdateRTT(ack_frame, ack_receive_time); | |
201 DCHECK_GE(ack_frame.largest_observed, unacked_packets_.largest_observed()); | 199 DCHECK_GE(ack_frame.largest_observed, unacked_packets_.largest_observed()); |
202 unacked_packets_.IncreaseLargestObserved(ack_frame.largest_observed); | 200 unacked_packets_.IncreaseLargestObserved(ack_frame.largest_observed); |
203 | 201 |
204 HandleAckForSentPackets(ack_frame); | 202 HandleAckForSentPackets(ack_frame); |
205 InvokeLossDetection(ack_receive_time); | 203 InvokeLossDetection(ack_receive_time); |
206 MaybeInvokeCongestionEvent(largest_observed_acked, bytes_in_flight); | 204 MaybeInvokeCongestionEvent(rtt_updated, bytes_in_flight); |
207 unacked_packets_.RemoveObsoletePackets(); | 205 unacked_packets_.RemoveObsoletePackets(); |
208 | 206 |
209 sustained_bandwidth_recorder_.RecordEstimate( | 207 sustained_bandwidth_recorder_.RecordEstimate( |
210 send_algorithm_->InRecovery(), | 208 send_algorithm_->InRecovery(), |
211 send_algorithm_->InSlowStart(), | 209 send_algorithm_->InSlowStart(), |
212 send_algorithm_->BandwidthEstimate(), | 210 send_algorithm_->BandwidthEstimate(), |
213 ack_receive_time, | 211 ack_receive_time, |
214 clock_->WallNow(), | 212 clock_->WallNow(), |
215 rtt_stats_.smoothed_rtt()); | 213 rtt_stats_.smoothed_rtt()); |
216 | 214 |
217 // If we have received a truncated ack, then we need to clear out some | 215 // If we have received a truncated ack, then we need to clear out some |
218 // previous transmissions to allow the peer to actually ACK new packets. | 216 // previous transmissions to allow the peer to actually ACK new packets. |
219 if (ack_frame.is_truncated) { | 217 if (ack_frame.is_truncated) { |
220 unacked_packets_.ClearAllPreviousRetransmissions(); | 218 unacked_packets_.ClearAllPreviousRetransmissions(); |
221 } | 219 } |
222 | 220 |
223 // Anytime we are making forward progress and have a new RTT estimate, reset | 221 // Anytime we are making forward progress and have a new RTT estimate, reset |
224 // the backoff counters. | 222 // the backoff counters. |
225 if (largest_observed_acked) { | 223 if (rtt_updated) { |
226 // Reset all retransmit counters any time a new packet is acked. | 224 // Reset all retransmit counters any time a new packet is acked. |
227 consecutive_rto_count_ = 0; | 225 consecutive_rto_count_ = 0; |
228 consecutive_tlp_count_ = 0; | 226 consecutive_tlp_count_ = 0; |
229 consecutive_crypto_retransmission_count_ = 0; | 227 consecutive_crypto_retransmission_count_ = 0; |
230 } | 228 } |
231 | 229 |
232 if (debug_delegate_ != nullptr) { | 230 if (debug_delegate_ != nullptr) { |
233 debug_delegate_->OnIncomingAck(ack_frame, | 231 debug_delegate_->OnIncomingAck(ack_frame, ack_receive_time, |
234 ack_receive_time, | |
235 unacked_packets_.largest_observed(), | 232 unacked_packets_.largest_observed(), |
236 largest_observed_acked, | 233 rtt_updated, GetLeastUnacked()); |
237 GetLeastUnacked()); | |
238 } | 234 } |
239 } | 235 } |
240 | 236 |
241 void QuicSentPacketManager::UpdatePacketInformationReceivedByPeer( | 237 void QuicSentPacketManager::UpdatePacketInformationReceivedByPeer( |
242 const QuicAckFrame& ack_frame) { | 238 const QuicAckFrame& ack_frame) { |
243 if (ack_frame.missing_packets.empty()) { | 239 if (ack_frame.missing_packets.empty()) { |
244 least_packet_awaited_by_peer_ = ack_frame.largest_observed + 1; | 240 least_packet_awaited_by_peer_ = ack_frame.largest_observed + 1; |
245 } else { | 241 } else { |
246 least_packet_awaited_by_peer_ = *(ack_frame.missing_packets.begin()); | 242 least_packet_awaited_by_peer_ = *(ack_frame.missing_packets.begin()); |
247 } | 243 } |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 // a packet whose previous transmission has been acked, a packet that has | 739 // a packet whose previous transmission has been acked, a packet that has |
744 // been TLP retransmitted, or an FEC packet. | 740 // been TLP retransmitted, or an FEC packet. |
745 unacked_packets_.RemoveFromInFlight(sequence_number); | 741 unacked_packets_.RemoveFromInFlight(sequence_number); |
746 } | 742 } |
747 } | 743 } |
748 } | 744 } |
749 | 745 |
750 bool QuicSentPacketManager::MaybeUpdateRTT( | 746 bool QuicSentPacketManager::MaybeUpdateRTT( |
751 const QuicAckFrame& ack_frame, | 747 const QuicAckFrame& ack_frame, |
752 const QuicTime& ack_receive_time) { | 748 const QuicTime& ack_receive_time) { |
| 749 // We rely on delta_time_largest_observed to compute an RTT estimate, so we |
| 750 // only update rtt when the largest observed gets acked. |
| 751 // NOTE: If ack is a truncated ack, then the largest observed is in fact |
| 752 // unacked, and may cause an RTT sample to be taken. |
753 if (!unacked_packets_.IsUnacked(ack_frame.largest_observed)) { | 753 if (!unacked_packets_.IsUnacked(ack_frame.largest_observed)) { |
754 return false; | 754 return false; |
755 } | 755 } |
756 // We calculate the RTT based on the highest ACKed sequence number, the lower | 756 // We calculate the RTT based on the highest ACKed sequence number, the lower |
757 // sequence numbers will include the ACK aggregation delay. | 757 // sequence numbers will include the ACK aggregation delay. |
758 const TransmissionInfo& transmission_info = | 758 const TransmissionInfo& transmission_info = |
759 unacked_packets_.GetTransmissionInfo(ack_frame.largest_observed); | 759 unacked_packets_.GetTransmissionInfo(ack_frame.largest_observed); |
760 // Ensure the packet has a valid sent time. | 760 // Ensure the packet has a valid sent time. |
761 if (transmission_info.sent_time == QuicTime::Zero()) { | 761 if (transmission_info.sent_time == QuicTime::Zero()) { |
762 LOG(DFATAL) << "Acked packet has zero sent time, largest_observed:" | 762 LOG(DFATAL) << "Acked packet has zero sent time, largest_observed:" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as | 933 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as |
934 // the default granularity of the Linux kernel's FQ qdisc. | 934 // the default granularity of the Linux kernel's FQ qdisc. |
935 using_pacing_ = true; | 935 using_pacing_ = true; |
936 send_algorithm_.reset( | 936 send_algorithm_.reset( |
937 new PacingSender(send_algorithm_.release(), | 937 new PacingSender(send_algorithm_.release(), |
938 QuicTime::Delta::FromMilliseconds(1), | 938 QuicTime::Delta::FromMilliseconds(1), |
939 kInitialUnpacedBurst)); | 939 kInitialUnpacedBurst)); |
940 } | 940 } |
941 | 941 |
942 } // namespace net | 942 } // namespace net |
OLD | NEW |