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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 if (largest_observed_acked) { | 133 if (largest_observed_acked) { |
134 // Reset all retransmit counters any time a new packet is acked. | 134 // Reset all retransmit counters any time a new packet is acked. |
135 consecutive_rto_count_ = 0; | 135 consecutive_rto_count_ = 0; |
136 consecutive_tlp_count_ = 0; | 136 consecutive_tlp_count_ = 0; |
137 consecutive_crypto_retransmission_count_ = 0; | 137 consecutive_crypto_retransmission_count_ = 0; |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 void QuicSentPacketManager::DiscardUnackedPacket( | 141 void QuicSentPacketManager::DiscardUnackedPacket( |
142 QuicPacketSequenceNumber sequence_number) { | 142 QuicPacketSequenceNumber sequence_number) { |
143 MarkPacketHandled(sequence_number, NOT_RECEIVED_BY_PEER); | 143 MarkPacketHandled(sequence_number, QuicTime::Delta::Zero(), |
| 144 NOT_RECEIVED_BY_PEER); |
144 } | 145 } |
145 | 146 |
146 void QuicSentPacketManager::HandleAckForSentPackets( | 147 void QuicSentPacketManager::HandleAckForSentPackets( |
147 const ReceivedPacketInfo& received_info) { | 148 const ReceivedPacketInfo& received_info) { |
148 // Go through the packets we have not received an ack for and see if this | 149 // Go through the packets we have not received an ack for and see if this |
149 // incoming_ack shows they've been seen by the peer. | 150 // incoming_ack shows they've been seen by the peer. |
150 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 151 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
151 while (it != unacked_packets_.end()) { | 152 while (it != unacked_packets_.end()) { |
152 QuicPacketSequenceNumber sequence_number = it->first; | 153 QuicPacketSequenceNumber sequence_number = it->first; |
153 if (sequence_number > received_info.largest_observed) { | 154 if (sequence_number > received_info.largest_observed) { |
154 // These packets are still in flight. | 155 // These packets are still in flight. |
155 break; | 156 break; |
156 } | 157 } |
157 | 158 |
| 159 QuicTime::Delta delta_largest_observed = |
| 160 received_info.delta_time_largest_observed; |
158 if (IsAwaitingPacket(received_info, sequence_number)) { | 161 if (IsAwaitingPacket(received_info, sequence_number)) { |
159 // Remove any packets not being tracked by the send algorithm, allowing | 162 // Remove any packets not being tracked by the send algorithm, allowing |
160 // the high water mark to be raised if necessary. | 163 // the high water mark to be raised if necessary. |
161 if (QuicUnackedPacketMap::IsSentAndNotPending(it->second)) { | 164 if (QuicUnackedPacketMap::IsSentAndNotPending(it->second)) { |
162 it = MarkPacketHandled(sequence_number, NOT_RECEIVED_BY_PEER); | 165 it = MarkPacketHandled(sequence_number, delta_largest_observed, |
| 166 NOT_RECEIVED_BY_PEER); |
163 } else { | 167 } else { |
164 ++it; | 168 ++it; |
165 } | 169 } |
166 continue; | 170 continue; |
167 } | 171 } |
168 | 172 |
169 // Packet was acked, so remove it from our unacked packet list. | 173 // Packet was acked, so remove it from our unacked packet list. |
170 DVLOG(1) << ENDPOINT <<"Got an ack for packet " << sequence_number; | 174 DVLOG(1) << ENDPOINT <<"Got an ack for packet " << sequence_number; |
171 // If data is associated with the most recent transmission of this | 175 // If data is associated with the most recent transmission of this |
172 // packet, then inform the caller. | 176 // packet, then inform the caller. |
173 it = MarkPacketHandled(sequence_number, RECEIVED_BY_PEER); | 177 it = MarkPacketHandled(sequence_number, delta_largest_observed, |
| 178 RECEIVED_BY_PEER); |
174 } | 179 } |
175 | 180 |
176 // Discard any retransmittable frames associated with revived packets. | 181 // Discard any retransmittable frames associated with revived packets. |
177 for (SequenceNumberSet::const_iterator revived_it = | 182 for (SequenceNumberSet::const_iterator revived_it = |
178 received_info.revived_packets.begin(); | 183 received_info.revived_packets.begin(); |
179 revived_it != received_info.revived_packets.end(); ++revived_it) { | 184 revived_it != received_info.revived_packets.end(); ++revived_it) { |
180 if (unacked_packets_.IsUnacked(*revived_it)) { | 185 if (unacked_packets_.IsUnacked(*revived_it)) { |
181 if (!unacked_packets_.IsPending(*revived_it)) { | 186 if (!unacked_packets_.IsPending(*revived_it)) { |
182 unacked_packets_.RemovePacket(*revived_it); | 187 unacked_packets_.RemovePacket(*revived_it); |
183 } else { | 188 } else { |
(...skipping 19 matching lines...) Expand all Loading... |
203 void QuicSentPacketManager::RetransmitUnackedPackets( | 208 void QuicSentPacketManager::RetransmitUnackedPackets( |
204 RetransmissionType retransmission_type) { | 209 RetransmissionType retransmission_type) { |
205 QuicUnackedPacketMap::const_iterator unacked_it = unacked_packets_.begin(); | 210 QuicUnackedPacketMap::const_iterator unacked_it = unacked_packets_.begin(); |
206 while (unacked_it != unacked_packets_.end()) { | 211 while (unacked_it != unacked_packets_.end()) { |
207 const RetransmittableFrames* frames = | 212 const RetransmittableFrames* frames = |
208 unacked_it->second.retransmittable_frames; | 213 unacked_it->second.retransmittable_frames; |
209 // Only mark it as handled if it can't be retransmitted and there are no | 214 // Only mark it as handled if it can't be retransmitted and there are no |
210 // pending retransmissions which would be cleared. | 215 // pending retransmissions which would be cleared. |
211 if (frames == NULL && unacked_it->second.all_transmissions->size() == 1 && | 216 if (frames == NULL && unacked_it->second.all_transmissions->size() == 1 && |
212 retransmission_type == ALL_PACKETS) { | 217 retransmission_type == ALL_PACKETS) { |
213 unacked_it = MarkPacketHandled(unacked_it->first, NOT_RECEIVED_BY_PEER); | 218 unacked_it = MarkPacketHandled(unacked_it->first, QuicTime::Delta::Zero(), |
| 219 NOT_RECEIVED_BY_PEER); |
214 continue; | 220 continue; |
215 } | 221 } |
216 // If it had no other transmissions, we handle it above. If it has | 222 // If it had no other transmissions, we handle it above. If it has |
217 // other transmissions, one of them must have retransmittable frames, | 223 // other transmissions, one of them must have retransmittable frames, |
218 // so that gets resolved the same way as other retransmissions. | 224 // so that gets resolved the same way as other retransmissions. |
219 // TODO(ianswett): Consider adding a new retransmission type which removes | 225 // TODO(ianswett): Consider adding a new retransmission type which removes |
220 // all these old packets from unacked and retransmits them as new sequence | 226 // all these old packets from unacked and retransmits them as new sequence |
221 // numbers with no connection to the previous ones. | 227 // numbers with no connection to the previous ones. |
222 if (frames != NULL && (retransmission_type == ALL_PACKETS || | 228 if (frames != NULL && (retransmission_type == ALL_PACKETS || |
223 frames->encryption_level() == ENCRYPTION_INITIAL)) { | 229 frames->encryption_level() == ENCRYPTION_INITIAL)) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 const QuicUnackedPacketMap::TransmissionInfo& transmission_info = | 277 const QuicUnackedPacketMap::TransmissionInfo& transmission_info = |
272 unacked_packets_.GetTransmissionInfo(sequence_number); | 278 unacked_packets_.GetTransmissionInfo(sequence_number); |
273 DCHECK(transmission_info.retransmittable_frames); | 279 DCHECK(transmission_info.retransmittable_frames); |
274 | 280 |
275 return PendingRetransmission(sequence_number, | 281 return PendingRetransmission(sequence_number, |
276 transmission_type, | 282 transmission_type, |
277 *transmission_info.retransmittable_frames, | 283 *transmission_info.retransmittable_frames, |
278 transmission_info.sequence_number_length); | 284 transmission_info.sequence_number_length); |
279 } | 285 } |
280 | 286 |
281 QuicUnackedPacketMap::const_iterator | 287 QuicUnackedPacketMap::const_iterator QuicSentPacketManager::MarkPacketHandled( |
282 QuicSentPacketManager::MarkPacketHandled( | |
283 QuicPacketSequenceNumber sequence_number, | 288 QuicPacketSequenceNumber sequence_number, |
284 ReceivedByPeer received_by_peer) { | 289 QuicTime::Delta delta_largest_observed, ReceivedByPeer received_by_peer) { |
285 if (!unacked_packets_.IsUnacked(sequence_number)) { | 290 if (!unacked_packets_.IsUnacked(sequence_number)) { |
286 LOG(DFATAL) << "Packet is not unacked: " << sequence_number; | 291 LOG(DFATAL) << "Packet is not unacked: " << sequence_number; |
287 return unacked_packets_.end(); | 292 return unacked_packets_.end(); |
288 } | 293 } |
289 const QuicUnackedPacketMap::TransmissionInfo& transmission_info = | 294 const QuicUnackedPacketMap::TransmissionInfo& transmission_info = |
290 unacked_packets_.GetTransmissionInfo(sequence_number); | 295 unacked_packets_.GetTransmissionInfo(sequence_number); |
291 // If this packet is pending, remove it and inform the send algorithm. | 296 // If this packet is pending, remove it and inform the send algorithm. |
292 if (transmission_info.pending) { | 297 if (transmission_info.pending) { |
293 if (received_by_peer == RECEIVED_BY_PEER) { | 298 if (received_by_peer == RECEIVED_BY_PEER) { |
294 send_algorithm_->OnPacketAcked(sequence_number, | 299 send_algorithm_->OnPacketAcked(sequence_number, |
295 transmission_info.bytes_sent); | 300 transmission_info.bytes_sent); |
296 } else { | 301 } else { |
297 // It's been abandoned. | 302 // It's been abandoned. |
298 send_algorithm_->OnPacketAbandoned(sequence_number, | 303 send_algorithm_->OnPacketAbandoned(sequence_number, |
299 transmission_info.bytes_sent); | 304 transmission_info.bytes_sent); |
300 } | 305 } |
301 unacked_packets_.SetNotPending(sequence_number); | 306 unacked_packets_.SetNotPending(sequence_number); |
302 } | 307 } |
303 | 308 |
304 SequenceNumberSet all_transmissions = *transmission_info.all_transmissions; | 309 SequenceNumberSet all_transmissions = *transmission_info.all_transmissions; |
305 SequenceNumberSet::reverse_iterator all_transmissions_it = | 310 SequenceNumberSet::reverse_iterator all_transmissions_it = |
306 all_transmissions.rbegin(); | 311 all_transmissions.rbegin(); |
307 QuicPacketSequenceNumber newest_transmission = *all_transmissions_it; | 312 QuicPacketSequenceNumber newest_transmission = *all_transmissions_it; |
308 if (newest_transmission != sequence_number) { | 313 if (newest_transmission != sequence_number) { |
309 ++stats_->packets_spuriously_retransmitted; | 314 ++stats_->packets_spuriously_retransmitted; |
310 } | 315 } |
311 | 316 |
312 // The AckNotifierManager needs to be notified about the most recent | 317 // The AckNotifierManager needs to be notified about the most recent |
313 // transmission, since that's the one only one it tracks. | 318 // transmission, since that's the one only one it tracks. |
314 ack_notifier_manager_.OnPacketAcked(newest_transmission); | 319 ack_notifier_manager_.OnPacketAcked(newest_transmission, |
| 320 delta_largest_observed); |
315 | 321 |
316 bool has_crypto_handshake = HasCryptoHandshake( | 322 bool has_crypto_handshake = HasCryptoHandshake( |
317 unacked_packets_.GetTransmissionInfo(newest_transmission)); | 323 unacked_packets_.GetTransmissionInfo(newest_transmission)); |
318 while (all_transmissions_it != all_transmissions.rend()) { | 324 while (all_transmissions_it != all_transmissions.rend()) { |
319 QuicPacketSequenceNumber previous_transmission = *all_transmissions_it; | 325 QuicPacketSequenceNumber previous_transmission = *all_transmissions_it; |
320 const QuicUnackedPacketMap::TransmissionInfo& transmission_info = | 326 const QuicUnackedPacketMap::TransmissionInfo& transmission_info = |
321 unacked_packets_.GetTransmissionInfo(previous_transmission); | 327 unacked_packets_.GetTransmissionInfo(previous_transmission); |
322 if (ContainsKey(pending_retransmissions_, previous_transmission)) { | 328 if (ContainsKey(pending_retransmissions_, previous_transmission)) { |
323 // Don't bother retransmitting this packet, if it has been | 329 // Don't bother retransmitting this packet, if it has been |
324 // marked for retransmission. | 330 // marked for retransmission. |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 return; | 740 return; |
735 } | 741 } |
736 | 742 |
737 using_pacing_ = true; | 743 using_pacing_ = true; |
738 send_algorithm_.reset( | 744 send_algorithm_.reset( |
739 new PacingSender(send_algorithm_.release(), | 745 new PacingSender(send_algorithm_.release(), |
740 QuicTime::Delta::FromMicroseconds(1))); | 746 QuicTime::Delta::FromMicroseconds(1))); |
741 } | 747 } |
742 | 748 |
743 } // namespace net | 749 } // namespace net |
OLD | NEW |