Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: net/quic/quic_sent_packet_manager.cc

Issue 612323013: QUIC - (no behavior change) s/NULL/nullptr/g in .../quic/... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_sent_packet_manager.h ('k') | net/quic/quic_sent_packet_manager_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 static const size_t kDefaultMaxTailLossProbes = 2; 43 static const size_t kDefaultMaxTailLossProbes = 2;
44 static const int64 kMinTailLossProbeTimeoutMs = 10; 44 static const int64 kMinTailLossProbeTimeoutMs = 10;
45 45
46 // Number of samples before we force a new recent min rtt to be captured. 46 // Number of samples before we force a new recent min rtt to be captured.
47 static const size_t kNumMinRttSamplesAfterQuiescence = 2; 47 static const size_t kNumMinRttSamplesAfterQuiescence = 2;
48 48
49 // Number of unpaced packets to send after quiescence. 49 // Number of unpaced packets to send after quiescence.
50 static const size_t kInitialUnpacedBurst = 10; 50 static const size_t kInitialUnpacedBurst = 10;
51 51
52 bool HasCryptoHandshake(const TransmissionInfo& transmission_info) { 52 bool HasCryptoHandshake(const TransmissionInfo& transmission_info) {
53 if (transmission_info.retransmittable_frames == NULL) { 53 if (transmission_info.retransmittable_frames == nullptr) {
54 return false; 54 return false;
55 } 55 }
56 return transmission_info.retransmittable_frames->HasCryptoHandshake() == 56 return transmission_info.retransmittable_frames->HasCryptoHandshake() ==
57 IS_HANDSHAKE; 57 IS_HANDSHAKE;
58 } 58 }
59 59
60 } // namespace 60 } // namespace
61 61
62 #define ENDPOINT (is_server_ ? "Server: " : " Client: ") 62 #define ENDPOINT (is_server_ ? "Server: " : " Client: ")
63 63
64 QuicSentPacketManager::QuicSentPacketManager( 64 QuicSentPacketManager::QuicSentPacketManager(
65 bool is_server, 65 bool is_server,
66 const QuicClock* clock, 66 const QuicClock* clock,
67 QuicConnectionStats* stats, 67 QuicConnectionStats* stats,
68 CongestionControlType congestion_control_type, 68 CongestionControlType congestion_control_type,
69 LossDetectionType loss_type) 69 LossDetectionType loss_type)
70 : unacked_packets_(), 70 : unacked_packets_(),
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_(nullptr),
75 network_change_visitor_(NULL), 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 least_packet_awaited_by_peer_(1), 81 least_packet_awaited_by_peer_(1),
82 first_rto_transmission_(0), 82 first_rto_transmission_(0),
83 consecutive_rto_count_(0), 83 consecutive_rto_count_(0),
84 consecutive_tlp_count_(0), 84 consecutive_tlp_count_(0),
85 consecutive_crypto_retransmission_count_(0), 85 consecutive_crypto_retransmission_count_(0),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 122 }
123 if (HasClientSentConnectionOption(config, k1CON)) { 123 if (HasClientSentConnectionOption(config, k1CON)) {
124 send_algorithm_->SetNumEmulatedConnections(1); 124 send_algorithm_->SetNumEmulatedConnections(1);
125 } 125 }
126 if (config.HasReceivedConnectionOptions() && 126 if (config.HasReceivedConnectionOptions() &&
127 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { 127 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) {
128 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); 128 loss_algorithm_.reset(LossDetectionInterface::Create(kTime));
129 } 129 }
130 send_algorithm_->SetFromConfig(config, is_server_); 130 send_algorithm_->SetFromConfig(config, is_server_);
131 131
132 if (network_change_visitor_ != NULL) { 132 if (network_change_visitor_ != nullptr) {
133 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); 133 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow());
134 } 134 }
135 } 135 }
136 136
137 bool QuicSentPacketManager::HasClientSentConnectionOption( 137 bool QuicSentPacketManager::HasClientSentConnectionOption(
138 const QuicConfig& config, QuicTag tag) const { 138 const QuicConfig& config, QuicTag tag) const {
139 if (is_server_) { 139 if (is_server_) {
140 if (config.HasReceivedConnectionOptions() && 140 if (config.HasReceivedConnectionOptions() &&
141 ContainsQuicTag(config.ReceivedConnectionOptions(), tag)) { 141 ContainsQuicTag(config.ReceivedConnectionOptions(), tag)) {
142 return true; 142 return true;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 205
206 // Anytime we are making forward progress and have a new RTT estimate, reset 206 // Anytime we are making forward progress and have a new RTT estimate, reset
207 // the backoff counters. 207 // the backoff counters.
208 if (largest_observed_acked) { 208 if (largest_observed_acked) {
209 // Reset all retransmit counters any time a new packet is acked. 209 // Reset all retransmit counters any time a new packet is acked.
210 consecutive_rto_count_ = 0; 210 consecutive_rto_count_ = 0;
211 consecutive_tlp_count_ = 0; 211 consecutive_tlp_count_ = 0;
212 consecutive_crypto_retransmission_count_ = 0; 212 consecutive_crypto_retransmission_count_ = 0;
213 } 213 }
214 214
215 if (debug_delegate_ != NULL) { 215 if (debug_delegate_ != nullptr) {
216 debug_delegate_->OnIncomingAck(ack_frame, 216 debug_delegate_->OnIncomingAck(ack_frame,
217 ack_receive_time, 217 ack_receive_time,
218 unacked_packets_.largest_observed(), 218 unacked_packets_.largest_observed(),
219 largest_observed_acked, 219 largest_observed_acked,
220 GetLeastUnacked()); 220 GetLeastUnacked());
221 } 221 }
222 } 222 }
223 223
224 void QuicSentPacketManager::UpdatePacketInformationReceivedByPeer( 224 void QuicSentPacketManager::UpdatePacketInformationReceivedByPeer(
225 const QuicAckFrame& ack_frame) { 225 const QuicAckFrame& ack_frame) {
226 if (ack_frame.missing_packets.empty()) { 226 if (ack_frame.missing_packets.empty()) {
227 least_packet_awaited_by_peer_ = ack_frame.largest_observed + 1; 227 least_packet_awaited_by_peer_ = ack_frame.largest_observed + 1;
228 } else { 228 } else {
229 least_packet_awaited_by_peer_ = *(ack_frame.missing_packets.begin()); 229 least_packet_awaited_by_peer_ = *(ack_frame.missing_packets.begin());
230 } 230 }
231 } 231 }
232 232
233 void QuicSentPacketManager::MaybeInvokeCongestionEvent( 233 void QuicSentPacketManager::MaybeInvokeCongestionEvent(
234 bool rtt_updated, QuicByteCount bytes_in_flight) { 234 bool rtt_updated, QuicByteCount bytes_in_flight) {
235 if (!rtt_updated && packets_acked_.empty() && packets_lost_.empty()) { 235 if (!rtt_updated && packets_acked_.empty() && packets_lost_.empty()) {
236 return; 236 return;
237 } 237 }
238 send_algorithm_->OnCongestionEvent(rtt_updated, bytes_in_flight, 238 send_algorithm_->OnCongestionEvent(rtt_updated, bytes_in_flight,
239 packets_acked_, packets_lost_); 239 packets_acked_, packets_lost_);
240 packets_acked_.clear(); 240 packets_acked_.clear();
241 packets_lost_.clear(); 241 packets_lost_.clear();
242 if (network_change_visitor_ != NULL) { 242 if (network_change_visitor_ != nullptr) {
243 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); 243 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow());
244 } 244 }
245 } 245 }
246 246
247 void QuicSentPacketManager::HandleAckForSentPackets( 247 void QuicSentPacketManager::HandleAckForSentPackets(
248 const QuicAckFrame& ack_frame) { 248 const QuicAckFrame& ack_frame) {
249 // Go through the packets we have not received an ack for and see if this 249 // Go through the packets we have not received an ack for and see if this
250 // incoming_ack shows they've been seen by the peer. 250 // incoming_ack shows they've been seen by the peer.
251 QuicTime::Delta delta_largest_observed = 251 QuicTime::Delta delta_largest_observed =
252 ack_frame.delta_time_largest_observed; 252 ack_frame.delta_time_largest_observed;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 300 }
301 301
302 void QuicSentPacketManager::RetransmitUnackedPackets( 302 void QuicSentPacketManager::RetransmitUnackedPackets(
303 TransmissionType retransmission_type) { 303 TransmissionType retransmission_type) {
304 DCHECK(retransmission_type == ALL_UNACKED_RETRANSMISSION || 304 DCHECK(retransmission_type == ALL_UNACKED_RETRANSMISSION ||
305 retransmission_type == ALL_INITIAL_RETRANSMISSION); 305 retransmission_type == ALL_INITIAL_RETRANSMISSION);
306 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); 306 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked();
307 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); 307 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
308 it != unacked_packets_.end(); ++it, ++sequence_number) { 308 it != unacked_packets_.end(); ++it, ++sequence_number) {
309 const RetransmittableFrames* frames = it->retransmittable_frames; 309 const RetransmittableFrames* frames = it->retransmittable_frames;
310 if (frames != NULL && (retransmission_type == ALL_UNACKED_RETRANSMISSION || 310 if (frames != nullptr &&
311 frames->encryption_level() == ENCRYPTION_INITIAL)) { 311 (retransmission_type == ALL_UNACKED_RETRANSMISSION ||
312 frames->encryption_level() == ENCRYPTION_INITIAL)) {
312 MarkForRetransmission(sequence_number, retransmission_type); 313 MarkForRetransmission(sequence_number, retransmission_type);
313 } 314 }
314 } 315 }
315 } 316 }
316 317
317 void QuicSentPacketManager::NeuterUnencryptedPackets() { 318 void QuicSentPacketManager::NeuterUnencryptedPackets() {
318 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); 319 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked();
319 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); 320 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
320 it != unacked_packets_.end(); ++it, ++sequence_number) { 321 it != unacked_packets_.end(); ++it, ++sequence_number) {
321 const RetransmittableFrames* frames = it->retransmittable_frames; 322 const RetransmittableFrames* frames = it->retransmittable_frames;
322 if (frames != NULL && frames->encryption_level() == ENCRYPTION_NONE) { 323 if (frames != nullptr && frames->encryption_level() == ENCRYPTION_NONE) {
323 // Once you're forward secure, no unencrypted packets will be sent, crypto 324 // Once you're forward secure, no unencrypted packets will be sent, crypto
324 // or otherwise. Unencrypted packets are neutered and abandoned, to ensure 325 // or otherwise. Unencrypted packets are neutered and abandoned, to ensure
325 // they are not retransmitted or considered lost from a congestion control 326 // they are not retransmitted or considered lost from a congestion control
326 // perspective. 327 // perspective.
327 pending_retransmissions_.erase(sequence_number); 328 pending_retransmissions_.erase(sequence_number);
328 unacked_packets_.RemoveFromInFlight(sequence_number); 329 unacked_packets_.RemoveFromInFlight(sequence_number);
329 unacked_packets_.RemoveRetransmittability(sequence_number); 330 unacked_packets_.RemoveRetransmittability(sequence_number);
330 } 331 }
331 } 332 }
332 } 333 }
333 334
334 void QuicSentPacketManager::MarkForRetransmission( 335 void QuicSentPacketManager::MarkForRetransmission(
335 QuicPacketSequenceNumber sequence_number, 336 QuicPacketSequenceNumber sequence_number,
336 TransmissionType transmission_type) { 337 TransmissionType transmission_type) {
337 const TransmissionInfo& transmission_info = 338 const TransmissionInfo& transmission_info =
338 unacked_packets_.GetTransmissionInfo(sequence_number); 339 unacked_packets_.GetTransmissionInfo(sequence_number);
339 LOG_IF(DFATAL, transmission_info.retransmittable_frames == NULL); 340 LOG_IF(DFATAL, transmission_info.retransmittable_frames == nullptr);
340 if (transmission_type != TLP_RETRANSMISSION) { 341 if (transmission_type != TLP_RETRANSMISSION) {
341 unacked_packets_.RemoveFromInFlight(sequence_number); 342 unacked_packets_.RemoveFromInFlight(sequence_number);
342 } 343 }
343 // TODO(ianswett): Currently the RTO can fire while there are pending NACK 344 // TODO(ianswett): Currently the RTO can fire while there are pending NACK
344 // retransmissions for the same data, which is not ideal. 345 // retransmissions for the same data, which is not ideal.
345 if (ContainsKey(pending_retransmissions_, sequence_number)) { 346 if (ContainsKey(pending_retransmissions_, sequence_number)) {
346 return; 347 return;
347 } 348 }
348 349
349 pending_retransmissions_[sequence_number] = transmission_type; 350 pending_retransmissions_[sequence_number] = transmission_type;
(...skipping 19 matching lines...) Expand all
369 ++stats_->spurious_rto_count; 370 ++stats_->spurious_rto_count;
370 } 371 }
371 for (SequenceNumberList::const_reverse_iterator it = 372 for (SequenceNumberList::const_reverse_iterator it =
372 all_transmissions.rbegin(); 373 all_transmissions.rbegin();
373 it != all_transmissions.rend() && *it > acked_sequence_number; ++it) { 374 it != all_transmissions.rend() && *it > acked_sequence_number; ++it) {
374 const TransmissionInfo& retransmit_info = 375 const TransmissionInfo& retransmit_info =
375 unacked_packets_.GetTransmissionInfo(*it); 376 unacked_packets_.GetTransmissionInfo(*it);
376 377
377 stats_->bytes_spuriously_retransmitted += retransmit_info.bytes_sent; 378 stats_->bytes_spuriously_retransmitted += retransmit_info.bytes_sent;
378 ++stats_->packets_spuriously_retransmitted; 379 ++stats_->packets_spuriously_retransmitted;
379 if (debug_delegate_ != NULL) { 380 if (debug_delegate_ != nullptr) {
380 debug_delegate_->OnSpuriousPacketRetransmition( 381 debug_delegate_->OnSpuriousPacketRetransmition(
381 retransmit_info.transmission_type, 382 retransmit_info.transmission_type,
382 retransmit_info.bytes_sent); 383 retransmit_info.bytes_sent);
383 } 384 }
384 } 385 }
385 } 386 }
386 387
387 bool QuicSentPacketManager::HasPendingRetransmissions() const { 388 bool QuicSentPacketManager::HasPendingRetransmissions() const {
388 return !pending_retransmissions_.empty(); 389 return !pending_retransmissions_.empty();
389 } 390 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 void QuicSentPacketManager::MarkPacketRevived( 422 void QuicSentPacketManager::MarkPacketRevived(
422 QuicPacketSequenceNumber sequence_number, 423 QuicPacketSequenceNumber sequence_number,
423 QuicTime::Delta delta_largest_observed) { 424 QuicTime::Delta delta_largest_observed) {
424 if (!unacked_packets_.IsUnacked(sequence_number)) { 425 if (!unacked_packets_.IsUnacked(sequence_number)) {
425 return; 426 return;
426 } 427 }
427 428
428 const TransmissionInfo& transmission_info = 429 const TransmissionInfo& transmission_info =
429 unacked_packets_.GetTransmissionInfo(sequence_number); 430 unacked_packets_.GetTransmissionInfo(sequence_number);
430 QuicPacketSequenceNumber newest_transmission = 431 QuicPacketSequenceNumber newest_transmission =
431 transmission_info.all_transmissions == NULL ? 432 transmission_info.all_transmissions == nullptr
432 sequence_number : *transmission_info.all_transmissions->rbegin(); 433 ? sequence_number
434 : *transmission_info.all_transmissions->rbegin();
433 // This packet has been revived at the receiver. If we were going to 435 // This packet has been revived at the receiver. If we were going to
434 // retransmit it, do not retransmit it anymore. 436 // retransmit it, do not retransmit it anymore.
435 pending_retransmissions_.erase(newest_transmission); 437 pending_retransmissions_.erase(newest_transmission);
436 438
437 // The AckNotifierManager needs to be notified for revived packets, 439 // The AckNotifierManager needs to be notified for revived packets,
438 // since it indicates the packet arrived from the appliction's perspective. 440 // since it indicates the packet arrived from the appliction's perspective.
439 if (transmission_info.retransmittable_frames) { 441 if (transmission_info.retransmittable_frames) {
440 ack_notifier_manager_.OnPacketAcked( 442 ack_notifier_manager_.OnPacketAcked(
441 newest_transmission, delta_largest_observed); 443 newest_transmission, delta_largest_observed);
442 } 444 }
443 445
444 unacked_packets_.RemoveRetransmittability(sequence_number); 446 unacked_packets_.RemoveRetransmittability(sequence_number);
445 } 447 }
446 448
447 void QuicSentPacketManager::MarkPacketHandled( 449 void QuicSentPacketManager::MarkPacketHandled(
448 QuicPacketSequenceNumber sequence_number, 450 QuicPacketSequenceNumber sequence_number,
449 const TransmissionInfo& info, 451 const TransmissionInfo& info,
450 QuicTime::Delta delta_largest_observed) { 452 QuicTime::Delta delta_largest_observed) {
451 QuicPacketSequenceNumber newest_transmission = 453 QuicPacketSequenceNumber newest_transmission =
452 info.all_transmissions == NULL ? 454 info.all_transmissions == nullptr ? sequence_number
453 sequence_number : *info.all_transmissions->rbegin(); 455 : *info.all_transmissions->rbegin();
454 // Remove the most recent packet, if it is pending retransmission. 456 // Remove the most recent packet, if it is pending retransmission.
455 pending_retransmissions_.erase(newest_transmission); 457 pending_retransmissions_.erase(newest_transmission);
456 458
457 // The AckNotifierManager needs to be notified about the most recent 459 // The AckNotifierManager needs to be notified about the most recent
458 // transmission, since that's the one only one it tracks. 460 // transmission, since that's the one only one it tracks.
459 ack_notifier_manager_.OnPacketAcked(newest_transmission, 461 ack_notifier_manager_.OnPacketAcked(newest_transmission,
460 delta_largest_observed); 462 delta_largest_observed);
461 if (newest_transmission != sequence_number) { 463 if (newest_transmission != sequence_number) {
462 RecordSpuriousRetransmissions(*info.all_transmissions, sequence_number); 464 RecordSpuriousRetransmissions(*info.all_transmissions, sequence_number);
463 // Remove the most recent packet from flight if it's a crypto handshake 465 // Remove the most recent packet from flight if it's a crypto handshake
464 // packet, since they won't be acked now that one has been processed. 466 // packet, since they won't be acked now that one has been processed.
465 // Other crypto handshake packets won't be in flight, only the newest 467 // Other crypto handshake packets won't be in flight, only the newest
466 // transmission of a crypto packet is in flight at once. 468 // transmission of a crypto packet is in flight at once.
467 // TODO(ianswett): Instead of handling all crypto packets special, 469 // TODO(ianswett): Instead of handling all crypto packets special,
468 // only handle NULL encrypted packets in a special way. 470 // only handle nullptr encrypted packets in a special way.
469 if (HasCryptoHandshake( 471 if (HasCryptoHandshake(
470 unacked_packets_.GetTransmissionInfo(newest_transmission))) { 472 unacked_packets_.GetTransmissionInfo(newest_transmission))) {
471 unacked_packets_.RemoveFromInFlight(newest_transmission); 473 unacked_packets_.RemoveFromInFlight(newest_transmission);
472 } 474 }
473 } 475 }
474 476
475 unacked_packets_.RemoveFromInFlight(sequence_number); 477 unacked_packets_.RemoveFromInFlight(sequence_number);
476 unacked_packets_.RemoveRetransmittability(sequence_number); 478 unacked_packets_.RemoveRetransmittability(sequence_number);
477 } 479 }
478 480
(...skipping 15 matching lines...) Expand all
494 SerializedPacket* serialized_packet, 496 SerializedPacket* serialized_packet,
495 QuicPacketSequenceNumber original_sequence_number, 497 QuicPacketSequenceNumber original_sequence_number,
496 QuicTime sent_time, 498 QuicTime sent_time,
497 QuicByteCount bytes, 499 QuicByteCount bytes,
498 TransmissionType transmission_type, 500 TransmissionType transmission_type,
499 HasRetransmittableData has_retransmittable_data) { 501 HasRetransmittableData has_retransmittable_data) {
500 QuicPacketSequenceNumber sequence_number = serialized_packet->sequence_number; 502 QuicPacketSequenceNumber sequence_number = serialized_packet->sequence_number;
501 DCHECK_LT(0u, sequence_number); 503 DCHECK_LT(0u, sequence_number);
502 DCHECK(!unacked_packets_.IsUnacked(sequence_number)); 504 DCHECK(!unacked_packets_.IsUnacked(sequence_number));
503 LOG_IF(DFATAL, bytes == 0) << "Cannot send empty packets."; 505 LOG_IF(DFATAL, bytes == 0) << "Cannot send empty packets.";
504 if (debug_delegate_ != NULL) { 506 if (debug_delegate_ != nullptr) {
505 debug_delegate_->OnSentPacket(*serialized_packet, 507 debug_delegate_->OnSentPacket(*serialized_packet,
506 original_sequence_number, 508 original_sequence_number,
507 sent_time, 509 sent_time,
508 bytes, 510 bytes,
509 transmission_type); 511 transmission_type);
510 } 512 }
511 513
512 if (original_sequence_number == 0) { 514 if (original_sequence_number == 0) {
513 if (serialized_packet->retransmittable_frames) { 515 if (serialized_packet->retransmittable_frames) {
514 ack_notifier_manager_.OnSerializedPacket(*serialized_packet); 516 ack_notifier_manager_.OnSerializedPacket(*serialized_packet);
515 } 517 }
516 unacked_packets_.AddPacket(*serialized_packet); 518 unacked_packets_.AddPacket(*serialized_packet);
517 serialized_packet->retransmittable_frames = NULL; 519 serialized_packet->retransmittable_frames = nullptr;
518 } else { 520 } else {
519 OnRetransmittedPacket(original_sequence_number, sequence_number); 521 OnRetransmittedPacket(original_sequence_number, sequence_number);
520 } 522 }
521 523
522 if (pending_timer_transmission_count_ > 0) { 524 if (pending_timer_transmission_count_ > 0) {
523 --pending_timer_transmission_count_; 525 --pending_timer_transmission_count_;
524 } 526 }
525 527
526 if (unacked_packets_.bytes_in_flight() == 0) { 528 if (unacked_packets_.bytes_in_flight() == 0) {
527 // TODO(ianswett): Consider being less aggressive to force a new 529 // TODO(ianswett): Consider being less aggressive to force a new
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 DCHECK_EQ(HANDSHAKE_MODE, GetRetransmissionMode()); 586 DCHECK_EQ(HANDSHAKE_MODE, GetRetransmissionMode());
585 // TODO(ianswett): Typical TCP implementations only retransmit 5 times. 587 // TODO(ianswett): Typical TCP implementations only retransmit 5 times.
586 consecutive_crypto_retransmission_count_ = 588 consecutive_crypto_retransmission_count_ =
587 min(kMaxHandshakeRetransmissionBackoffs, 589 min(kMaxHandshakeRetransmissionBackoffs,
588 consecutive_crypto_retransmission_count_ + 1); 590 consecutive_crypto_retransmission_count_ + 1);
589 bool packet_retransmitted = false; 591 bool packet_retransmitted = false;
590 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); 592 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked();
591 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); 593 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
592 it != unacked_packets_.end(); ++it, ++sequence_number) { 594 it != unacked_packets_.end(); ++it, ++sequence_number) {
593 // Only retransmit frames which are in flight, and therefore have been sent. 595 // Only retransmit frames which are in flight, and therefore have been sent.
594 if (!it->in_flight || it->retransmittable_frames == NULL || 596 if (!it->in_flight || it->retransmittable_frames == nullptr ||
595 it->retransmittable_frames->HasCryptoHandshake() != IS_HANDSHAKE) { 597 it->retransmittable_frames->HasCryptoHandshake() != IS_HANDSHAKE) {
596 continue; 598 continue;
597 } 599 }
598 packet_retransmitted = true; 600 packet_retransmitted = true;
599 MarkForRetransmission(sequence_number, HANDSHAKE_RETRANSMISSION); 601 MarkForRetransmission(sequence_number, HANDSHAKE_RETRANSMISSION);
600 ++pending_timer_transmission_count_; 602 ++pending_timer_transmission_count_;
601 } 603 }
602 DCHECK(packet_retransmitted) << "No crypto packets found to retransmit."; 604 DCHECK(packet_retransmitted) << "No crypto packets found to retransmit.";
603 } 605 }
604 606
605 bool QuicSentPacketManager::MaybeRetransmitTailLossProbe() { 607 bool QuicSentPacketManager::MaybeRetransmitTailLossProbe() {
606 if (pending_timer_transmission_count_ == 0) { 608 if (pending_timer_transmission_count_ == 0) {
607 return false; 609 return false;
608 } 610 }
609 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); 611 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked();
610 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); 612 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
611 it != unacked_packets_.end(); ++it, ++sequence_number) { 613 it != unacked_packets_.end(); ++it, ++sequence_number) {
612 // Only retransmit frames which are in flight, and therefore have been sent. 614 // Only retransmit frames which are in flight, and therefore have been sent.
613 if (!it->in_flight || it->retransmittable_frames == NULL) { 615 if (!it->in_flight || it->retransmittable_frames == nullptr) {
614 continue; 616 continue;
615 } 617 }
616 if (!handshake_confirmed_) { 618 if (!handshake_confirmed_) {
617 DCHECK_NE(IS_HANDSHAKE, it->retransmittable_frames->HasCryptoHandshake()); 619 DCHECK_NE(IS_HANDSHAKE, it->retransmittable_frames->HasCryptoHandshake());
618 } 620 }
619 MarkForRetransmission(sequence_number, TLP_RETRANSMISSION); 621 MarkForRetransmission(sequence_number, TLP_RETRANSMISSION);
620 return true; 622 return true;
621 } 623 }
622 DLOG(FATAL) 624 DLOG(FATAL)
623 << "No retransmittable packets, so RetransmitOldestPacket failed."; 625 << "No retransmittable packets, so RetransmitOldestPacket failed.";
624 return false; 626 return false;
625 } 627 }
626 628
627 void QuicSentPacketManager::RetransmitAllPackets() { 629 void QuicSentPacketManager::RetransmitAllPackets() {
628 DVLOG(1) << "RetransmitAllPackets() called with " 630 DVLOG(1) << "RetransmitAllPackets() called with "
629 << unacked_packets_.GetNumUnackedPacketsDebugOnly() 631 << unacked_packets_.GetNumUnackedPacketsDebugOnly()
630 << " unacked packets."; 632 << " unacked packets.";
631 // Request retransmission of all retransmittable packets when the RTO 633 // Request retransmission of all retransmittable packets when the RTO
632 // fires, and let the congestion manager decide how many to send 634 // fires, and let the congestion manager decide how many to send
633 // immediately and the remaining packets will be queued. 635 // immediately and the remaining packets will be queued.
634 // Abandon any non-retransmittable packets that are sufficiently old. 636 // Abandon any non-retransmittable packets that are sufficiently old.
635 bool packets_retransmitted = false; 637 bool packets_retransmitted = false;
636 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); 638 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked();
637 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); 639 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
638 it != unacked_packets_.end(); ++it, ++sequence_number) { 640 it != unacked_packets_.end(); ++it, ++sequence_number) {
639 if (it->retransmittable_frames != NULL) { 641 if (it->retransmittable_frames != nullptr) {
640 packets_retransmitted = true; 642 packets_retransmitted = true;
641 MarkForRetransmission(sequence_number, RTO_RETRANSMISSION); 643 MarkForRetransmission(sequence_number, RTO_RETRANSMISSION);
642 } else { 644 } else {
643 unacked_packets_.RemoveFromInFlight(sequence_number); 645 unacked_packets_.RemoveFromInFlight(sequence_number);
644 } 646 }
645 } 647 }
646 648
647 send_algorithm_->OnRetransmissionTimeout(packets_retransmitted); 649 send_algorithm_->OnRetransmissionTimeout(packets_retransmitted);
648 if (packets_retransmitted) { 650 if (packets_retransmitted) {
649 if (consecutive_rto_count_ == 0) { 651 if (consecutive_rto_count_ == 0) {
650 first_rto_transmission_ = unacked_packets_.largest_sent_packet() + 1; 652 first_rto_transmission_ = unacked_packets_.largest_sent_packet() + 1;
651 } 653 }
652 ++consecutive_rto_count_; 654 ++consecutive_rto_count_;
653 } 655 }
654 656
655 if (network_change_visitor_ != NULL) { 657 if (network_change_visitor_ != nullptr) {
656 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); 658 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow());
657 } 659 }
658 } 660 }
659 661
660 QuicSentPacketManager::RetransmissionTimeoutMode 662 QuicSentPacketManager::RetransmissionTimeoutMode
661 QuicSentPacketManager::GetRetransmissionMode() const { 663 QuicSentPacketManager::GetRetransmissionMode() const {
662 DCHECK(unacked_packets_.HasInFlightPackets()); 664 DCHECK(unacked_packets_.HasInFlightPackets());
663 if (!handshake_confirmed_ && unacked_packets_.HasPendingCryptoPackets()) { 665 if (!handshake_confirmed_ && unacked_packets_.HasPendingCryptoPackets()) {
664 return HANDSHAKE_MODE; 666 return HANDSHAKE_MODE;
665 } 667 }
(...skipping 26 matching lines...) Expand all
692 QuicPacketSequenceNumber sequence_number = *it; 694 QuicPacketSequenceNumber sequence_number = *it;
693 const TransmissionInfo& transmission_info = 695 const TransmissionInfo& transmission_info =
694 unacked_packets_.GetTransmissionInfo(sequence_number); 696 unacked_packets_.GetTransmissionInfo(sequence_number);
695 // TODO(ianswett): If it's expected the FEC packet may repair the loss, it 697 // TODO(ianswett): If it's expected the FEC packet may repair the loss, it
696 // should be recorded as a loss to the send algorithm, but not retransmitted 698 // should be recorded as a loss to the send algorithm, but not retransmitted
697 // until it's known whether the FEC packet arrived. 699 // until it's known whether the FEC packet arrived.
698 ++stats_->packets_lost; 700 ++stats_->packets_lost;
699 packets_lost_.push_back(make_pair(sequence_number, transmission_info)); 701 packets_lost_.push_back(make_pair(sequence_number, transmission_info));
700 DVLOG(1) << ENDPOINT << "Lost packet " << sequence_number; 702 DVLOG(1) << ENDPOINT << "Lost packet " << sequence_number;
701 703
702 if (transmission_info.retransmittable_frames != NULL) { 704 if (transmission_info.retransmittable_frames != nullptr) {
703 MarkForRetransmission(sequence_number, LOSS_RETRANSMISSION); 705 MarkForRetransmission(sequence_number, LOSS_RETRANSMISSION);
704 } else { 706 } else {
705 // Since we will not retransmit this, we need to remove it from 707 // Since we will not retransmit this, we need to remove it from
706 // unacked_packets_. This is either the current transmission of 708 // unacked_packets_. This is either the current transmission of
707 // a packet whose previous transmission has been acked, a packet that has 709 // a packet whose previous transmission has been acked, a packet that has
708 // been TLP retransmitted, or an FEC packet. 710 // been TLP retransmitted, or an FEC packet.
709 unacked_packets_.RemoveFromInFlight(sequence_number); 711 unacked_packets_.RemoveFromInFlight(sequence_number);
710 } 712 }
711 } 713 }
712 } 714 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 880
879 // Set up a pacing sender with a 5 millisecond alarm granularity. 881 // Set up a pacing sender with a 5 millisecond alarm granularity.
880 using_pacing_ = true; 882 using_pacing_ = true;
881 send_algorithm_.reset( 883 send_algorithm_.reset(
882 new PacingSender(send_algorithm_.release(), 884 new PacingSender(send_algorithm_.release(),
883 QuicTime::Delta::FromMilliseconds(5), 885 QuicTime::Delta::FromMilliseconds(5),
884 kInitialUnpacedBurst)); 886 kInitialUnpacedBurst));
885 } 887 }
886 888
887 } // namespace net 889 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager.h ('k') | net/quic/quic_sent_packet_manager_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698