| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 UpdatePacketInformationReceivedByPeer(ack_frame); | 190 UpdatePacketInformationReceivedByPeer(ack_frame); |
| 191 // We rely on delta_time_largest_observed to compute an RTT estimate, so | 191 // We rely on delta_time_largest_observed to compute an RTT estimate, so |
| 192 // we only update rtt when the largest observed gets acked. | 192 // we only update rtt when the largest observed gets acked. |
| 193 bool largest_observed_acked = MaybeUpdateRTT(ack_frame, ack_receive_time); | 193 bool largest_observed_acked = MaybeUpdateRTT(ack_frame, ack_receive_time); |
| 194 DCHECK_GE(ack_frame.largest_observed, unacked_packets_.largest_observed()); | 194 DCHECK_GE(ack_frame.largest_observed, unacked_packets_.largest_observed()); |
| 195 unacked_packets_.IncreaseLargestObserved(ack_frame.largest_observed); | 195 unacked_packets_.IncreaseLargestObserved(ack_frame.largest_observed); |
| 196 | 196 |
| 197 HandleAckForSentPackets(ack_frame); | 197 HandleAckForSentPackets(ack_frame); |
| 198 InvokeLossDetection(ack_receive_time); | 198 InvokeLossDetection(ack_receive_time); |
| 199 MaybeInvokeCongestionEvent(largest_observed_acked, bytes_in_flight); | 199 MaybeInvokeCongestionEvent(largest_observed_acked, bytes_in_flight); |
| 200 unacked_packets_.RemoveObsoletePackets(); |
| 200 | 201 |
| 201 sustained_bandwidth_recorder_.RecordEstimate( | 202 sustained_bandwidth_recorder_.RecordEstimate( |
| 202 send_algorithm_->InRecovery(), | 203 send_algorithm_->InRecovery(), |
| 203 send_algorithm_->InSlowStart(), | 204 send_algorithm_->InSlowStart(), |
| 204 send_algorithm_->BandwidthEstimate(), | 205 send_algorithm_->BandwidthEstimate(), |
| 205 ack_receive_time, | 206 ack_receive_time, |
| 206 clock_->WallNow(), | 207 clock_->WallNow(), |
| 207 rtt_stats_.SmoothedRtt()); | 208 rtt_stats_.SmoothedRtt()); |
| 208 | 209 |
| 209 // If we have received a truncated ack, then we need to clear out some | 210 // If we have received a truncated ack, then we need to clear out some |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); | 254 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); |
| 254 } | 255 } |
| 255 } | 256 } |
| 256 | 257 |
| 257 void QuicSentPacketManager::HandleAckForSentPackets( | 258 void QuicSentPacketManager::HandleAckForSentPackets( |
| 258 const QuicAckFrame& ack_frame) { | 259 const QuicAckFrame& ack_frame) { |
| 259 // Go through the packets we have not received an ack for and see if this | 260 // Go through the packets we have not received an ack for and see if this |
| 260 // incoming_ack shows they've been seen by the peer. | 261 // incoming_ack shows they've been seen by the peer. |
| 261 QuicTime::Delta delta_largest_observed = | 262 QuicTime::Delta delta_largest_observed = |
| 262 ack_frame.delta_time_largest_observed; | 263 ack_frame.delta_time_largest_observed; |
| 263 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 264 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); |
| 264 while (it != unacked_packets_.end()) { | 265 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
| 265 QuicPacketSequenceNumber sequence_number = it->first; | 266 it != unacked_packets_.end(); ++it, ++sequence_number) { |
| 266 if (sequence_number > ack_frame.largest_observed) { | 267 if (sequence_number > ack_frame.largest_observed) { |
| 267 // These packets are still in flight. | 268 // These packets are still in flight. |
| 268 break; | 269 break; |
| 269 } | 270 } |
| 270 | 271 |
| 271 if (IsAwaitingPacket(ack_frame, sequence_number)) { | 272 if (ContainsKey(ack_frame.missing_packets, sequence_number)) { |
| 272 // Consider it multiple nacks when there is a gap between the missing | 273 // Consider it multiple nacks when there is a gap between the missing |
| 273 // packet and the largest observed, since the purpose of a nack | 274 // packet and the largest observed, since the purpose of a nack |
| 274 // threshold is to tolerate re-ordering. This handles both StretchAcks | 275 // threshold is to tolerate re-ordering. This handles both StretchAcks |
| 275 // and Forward Acks. | 276 // and Forward Acks. |
| 276 // The nack count only increases when the largest observed increases. | 277 // The nack count only increases when the largest observed increases. |
| 277 size_t min_nacks = ack_frame.largest_observed - sequence_number; | 278 size_t min_nacks = ack_frame.largest_observed - sequence_number; |
| 278 // Truncated acks can nack the largest observed, so use a min of 1. | 279 // Truncated acks can nack the largest observed, so use a min of 1. |
| 279 if (min_nacks == 0) { | 280 if (min_nacks == 0) { |
| 280 min_nacks = 1; | 281 min_nacks = 1; |
| 281 } | 282 } |
| 282 unacked_packets_.NackPacket(sequence_number, min_nacks); | 283 unacked_packets_.NackPacket(sequence_number, min_nacks); |
| 283 ++it; | |
| 284 continue; | 284 continue; |
| 285 } | 285 } |
| 286 // Packet was acked, so remove it from our unacked packet list. | 286 // Packet was acked, so remove it from our unacked packet list. |
| 287 DVLOG(1) << ENDPOINT << "Got an ack for packet " << sequence_number; | 287 DVLOG(1) << ENDPOINT << "Got an ack for packet " << sequence_number; |
| 288 // If data is associated with the most recent transmission of this | 288 // If data is associated with the most recent transmission of this |
| 289 // packet, then inform the caller. | 289 // packet, then inform the caller. |
| 290 if (it->second.in_flight) { | 290 if (it->in_flight) { |
| 291 packets_acked_[sequence_number] = it->second; | 291 packets_acked_[sequence_number] = *it; |
| 292 } | 292 } |
| 293 it = MarkPacketHandled(it, delta_largest_observed); | 293 MarkPacketHandled(sequence_number, *it, delta_largest_observed); |
| 294 } | 294 } |
| 295 | 295 |
| 296 // Discard any retransmittable frames associated with revived packets. | 296 // Discard any retransmittable frames associated with revived packets. |
| 297 for (SequenceNumberSet::const_iterator revived_it = | 297 for (SequenceNumberSet::const_iterator revived_it = |
| 298 ack_frame.revived_packets.begin(); | 298 ack_frame.revived_packets.begin(); |
| 299 revived_it != ack_frame.revived_packets.end(); ++revived_it) { | 299 revived_it != ack_frame.revived_packets.end(); ++revived_it) { |
| 300 MarkPacketRevived(*revived_it, delta_largest_observed); | 300 MarkPacketRevived(*revived_it, delta_largest_observed); |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 | 303 |
| 304 bool QuicSentPacketManager::HasRetransmittableFrames( | 304 bool QuicSentPacketManager::HasRetransmittableFrames( |
| 305 QuicPacketSequenceNumber sequence_number) const { | 305 QuicPacketSequenceNumber sequence_number) const { |
| 306 return unacked_packets_.HasRetransmittableFrames(sequence_number); | 306 return unacked_packets_.HasRetransmittableFrames(sequence_number); |
| 307 } | 307 } |
| 308 | 308 |
| 309 void QuicSentPacketManager::RetransmitUnackedPackets( | 309 void QuicSentPacketManager::RetransmitUnackedPackets( |
| 310 RetransmissionType retransmission_type) { | 310 RetransmissionType retransmission_type) { |
| 311 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 311 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); |
| 312 while (it != unacked_packets_.end()) { | 312 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
| 313 const RetransmittableFrames* frames = it->second.retransmittable_frames; | 313 it != unacked_packets_.end(); ++it, ++sequence_number) { |
| 314 const RetransmittableFrames* frames = it->retransmittable_frames; |
| 314 // TODO(ianswett): Consider adding a new retransmission type which removes | 315 // TODO(ianswett): Consider adding a new retransmission type which removes |
| 315 // all these old packets from unacked and retransmits them as new sequence | 316 // all these old packets from unacked and retransmits them as new sequence |
| 316 // numbers with no connection to the previous ones. | 317 // numbers with no connection to the previous ones. |
| 317 if (frames != NULL && (retransmission_type == ALL_PACKETS || | 318 if (frames != NULL && (retransmission_type == ALL_PACKETS || |
| 318 frames->encryption_level() == ENCRYPTION_INITIAL)) { | 319 frames->encryption_level() == ENCRYPTION_INITIAL)) { |
| 319 MarkForRetransmission(it->first, ALL_UNACKED_RETRANSMISSION); | 320 MarkForRetransmission(sequence_number, ALL_UNACKED_RETRANSMISSION); |
| 320 } | 321 } |
| 321 ++it; | |
| 322 } | 322 } |
| 323 } | 323 } |
| 324 | 324 |
| 325 void QuicSentPacketManager::NeuterUnencryptedPackets() { | 325 void QuicSentPacketManager::NeuterUnencryptedPackets() { |
| 326 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 326 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); |
| 327 while (it != unacked_packets_.end()) { | 327 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
| 328 const RetransmittableFrames* frames = it->second.retransmittable_frames; | 328 it != unacked_packets_.end(); ++it, ++sequence_number) { |
| 329 QuicPacketSequenceNumber sequence_number = it->first; | 329 const RetransmittableFrames* frames = it->retransmittable_frames; |
| 330 ++it; | |
| 331 if (frames != NULL && frames->encryption_level() == ENCRYPTION_NONE) { | 330 if (frames != NULL && frames->encryption_level() == ENCRYPTION_NONE) { |
| 332 // Once you're forward secure, no unencrypted packets will be sent, crypto | 331 // Once you're forward secure, no unencrypted packets will be sent, crypto |
| 333 // or otherwise. Unencrypted packets are neutered and abandoned, to ensure | 332 // or otherwise. Unencrypted packets are neutered and abandoned, to ensure |
| 334 // they are not retransmitted or considered lost from a congestion control | 333 // they are not retransmitted or considered lost from a congestion control |
| 335 // perspective. | 334 // perspective. |
| 336 pending_retransmissions_.erase(sequence_number); | 335 pending_retransmissions_.erase(sequence_number); |
| 337 unacked_packets_.RemoveFromInFlight(sequence_number); | 336 unacked_packets_.RemoveFromInFlight(sequence_number); |
| 338 // RemoveRetransmittibility is safe because only the newest sequence | |
| 339 // number can have frames. | |
| 340 unacked_packets_.RemoveRetransmittability(sequence_number); | 337 unacked_packets_.RemoveRetransmittability(sequence_number); |
| 341 } | 338 } |
| 342 } | 339 } |
| 343 } | 340 } |
| 344 | 341 |
| 345 void QuicSentPacketManager::MarkForRetransmission( | 342 void QuicSentPacketManager::MarkForRetransmission( |
| 346 QuicPacketSequenceNumber sequence_number, | 343 QuicPacketSequenceNumber sequence_number, |
| 347 TransmissionType transmission_type) { | 344 TransmissionType transmission_type) { |
| 348 const TransmissionInfo& transmission_info = | 345 const TransmissionInfo& transmission_info = |
| 349 unacked_packets_.GetTransmissionInfo(sequence_number); | 346 unacked_packets_.GetTransmissionInfo(sequence_number); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 373 it != pending_retransmissions_.end(); ++it) { | 370 it != pending_retransmissions_.end(); ++it) { |
| 374 DCHECK_EQ(it->second, RTO_RETRANSMISSION); | 371 DCHECK_EQ(it->second, RTO_RETRANSMISSION); |
| 375 unacked_packets_.RestoreInFlight(it->first); | 372 unacked_packets_.RestoreInFlight(it->first); |
| 376 } | 373 } |
| 377 pending_retransmissions_.clear(); | 374 pending_retransmissions_.clear(); |
| 378 send_algorithm_->RevertRetransmissionTimeout(); | 375 send_algorithm_->RevertRetransmissionTimeout(); |
| 379 first_rto_transmission_ = 0; | 376 first_rto_transmission_ = 0; |
| 380 ++stats_->spurious_rto_count; | 377 ++stats_->spurious_rto_count; |
| 381 } | 378 } |
| 382 for (SequenceNumberSet::const_iterator | 379 for (SequenceNumberSet::const_iterator |
| 383 it = all_transmissions.upper_bound(acked_sequence_number), | 380 it = all_transmissions.upper_bound(acked_sequence_number), |
| 384 end = all_transmissions.end(); | 381 end = all_transmissions.end(); |
| 385 it != end; | 382 it != end; |
| 386 ++it) { | 383 ++it) { |
| 387 const TransmissionInfo& retransmit_info = | 384 const TransmissionInfo& retransmit_info = |
| 388 unacked_packets_.GetTransmissionInfo(*it); | 385 unacked_packets_.GetTransmissionInfo(*it); |
| 389 | 386 |
| 390 stats_->bytes_spuriously_retransmitted += retransmit_info.bytes_sent; | 387 stats_->bytes_spuriously_retransmitted += retransmit_info.bytes_sent; |
| 391 ++stats_->packets_spuriously_retransmitted; | 388 ++stats_->packets_spuriously_retransmitted; |
| 392 if (debug_delegate_ != NULL) { | 389 if (debug_delegate_ != NULL) { |
| 393 debug_delegate_->OnSpuriousPacketRetransmition( | 390 debug_delegate_->OnSpuriousPacketRetransmition( |
| 394 retransmit_info.transmission_type, | 391 retransmit_info.transmission_type, |
| 395 retransmit_info.bytes_sent); | 392 retransmit_info.bytes_sent); |
| 396 } | 393 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 // The AckNotifierManager needs to be notified for revived packets, | 446 // The AckNotifierManager needs to be notified for revived packets, |
| 450 // since it indicates the packet arrived from the appliction's perspective. | 447 // since it indicates the packet arrived from the appliction's perspective. |
| 451 if (transmission_info.retransmittable_frames) { | 448 if (transmission_info.retransmittable_frames) { |
| 452 ack_notifier_manager_.OnPacketAcked( | 449 ack_notifier_manager_.OnPacketAcked( |
| 453 newest_transmission, delta_largest_observed); | 450 newest_transmission, delta_largest_observed); |
| 454 } | 451 } |
| 455 | 452 |
| 456 unacked_packets_.RemoveRetransmittability(sequence_number); | 453 unacked_packets_.RemoveRetransmittability(sequence_number); |
| 457 } | 454 } |
| 458 | 455 |
| 459 QuicUnackedPacketMap::const_iterator QuicSentPacketManager::MarkPacketHandled( | 456 void QuicSentPacketManager::MarkPacketHandled( |
| 460 QuicUnackedPacketMap::const_iterator it, | 457 QuicPacketSequenceNumber sequence_number, |
| 458 const TransmissionInfo& info, |
| 461 QuicTime::Delta delta_largest_observed) { | 459 QuicTime::Delta delta_largest_observed) { |
| 462 LOG_IF(DFATAL, it == unacked_packets_.end()) | |
| 463 << "MarkPacketHandled must be passed a valid iterator entry."; | |
| 464 const QuicPacketSequenceNumber sequence_number = it->first; | |
| 465 const TransmissionInfo& transmission_info = it->second; | |
| 466 | |
| 467 QuicPacketSequenceNumber newest_transmission = | 460 QuicPacketSequenceNumber newest_transmission = |
| 468 *transmission_info.all_transmissions->rbegin(); | 461 *info.all_transmissions->rbegin(); |
| 469 // Remove the most recent packet, if it is pending retransmission. | 462 // Remove the most recent packet, if it is pending retransmission. |
| 470 pending_retransmissions_.erase(newest_transmission); | 463 pending_retransmissions_.erase(newest_transmission); |
| 471 | 464 |
| 472 // Notify observers about the ACKed packet. | 465 // Notify observers about the ACKed packet. |
| 473 { | 466 { |
| 474 // The AckNotifierManager needs to be notified about the most recent | 467 // The AckNotifierManager needs to be notified about the most recent |
| 475 // transmission, since that's the one only one it tracks. | 468 // transmission, since that's the one only one it tracks. |
| 476 ack_notifier_manager_.OnPacketAcked(newest_transmission, | 469 ack_notifier_manager_.OnPacketAcked(newest_transmission, |
| 477 delta_largest_observed); | 470 delta_largest_observed); |
| 478 if (newest_transmission != sequence_number) { | 471 if (newest_transmission != sequence_number) { |
| 479 RecordSpuriousRetransmissions(*transmission_info.all_transmissions, | 472 RecordSpuriousRetransmissions(*info.all_transmissions, sequence_number); |
| 480 sequence_number); | |
| 481 } | 473 } |
| 482 } | 474 } |
| 483 | 475 |
| 484 // Two cases for MarkPacketHandled: | 476 // Two cases for MarkPacketHandled: |
| 485 // 1) Handle the most recent or a crypto packet, so remove all transmissions. | 477 // 1) Handle the most recent or a crypto packet, so remove all transmissions. |
| 486 // 2) Handle old transmission, keep all other pending transmissions, | 478 // 2) Handle old transmission, keep all other pending transmissions, |
| 487 // but disassociate them from one another. | 479 // but disassociate them from one another. |
| 488 | 480 |
| 489 // If it's a crypto handshake packet, discard it and all retransmissions, | 481 // If it's a crypto handshake packet, discard it and all retransmissions, |
| 490 // since they won't be acked now that one has been processed. | 482 // since they won't be acked now that one has been processed. |
| 491 // TODO(ianswett): Instead of handling all crypto packets in a special way, | 483 // TODO(ianswett): Instead of handling all crypto packets in a special way, |
| 492 // only handle NULL encrypted packets in a special way. | 484 // only handle NULL encrypted packets in a special way. |
| 493 if (HasCryptoHandshake( | 485 if (HasCryptoHandshake( |
| 494 unacked_packets_.GetTransmissionInfo(newest_transmission))) { | 486 unacked_packets_.GetTransmissionInfo(newest_transmission))) { |
| 495 unacked_packets_.RemoveFromInFlight(newest_transmission); | 487 unacked_packets_.RemoveFromInFlight(newest_transmission); |
| 496 } | 488 } |
| 497 unacked_packets_.RemoveFromInFlight(sequence_number); | 489 unacked_packets_.RemoveFromInFlight(sequence_number); |
| 498 unacked_packets_.RemoveRetransmittability(sequence_number); | 490 unacked_packets_.RemoveRetransmittability(sequence_number); |
| 499 | |
| 500 QuicUnackedPacketMap::const_iterator next_unacked = unacked_packets_.begin(); | |
| 501 while (next_unacked != unacked_packets_.end() && | |
| 502 next_unacked->first <= sequence_number) { | |
| 503 ++next_unacked; | |
| 504 } | |
| 505 return next_unacked; | |
| 506 } | 491 } |
| 507 | 492 |
| 508 bool QuicSentPacketManager::IsUnacked( | 493 bool QuicSentPacketManager::IsUnacked( |
| 509 QuicPacketSequenceNumber sequence_number) const { | 494 QuicPacketSequenceNumber sequence_number) const { |
| 510 return unacked_packets_.IsUnacked(sequence_number); | 495 return unacked_packets_.IsUnacked(sequence_number); |
| 511 } | 496 } |
| 512 | 497 |
| 513 bool QuicSentPacketManager::HasUnackedPackets() const { | 498 bool QuicSentPacketManager::HasUnackedPackets() const { |
| 514 return unacked_packets_.HasUnackedPackets(); | 499 return unacked_packets_.HasUnackedPackets(); |
| 515 } | 500 } |
| 516 | 501 |
| 517 QuicPacketSequenceNumber | 502 QuicPacketSequenceNumber |
| 518 QuicSentPacketManager::GetLeastUnackedSentPacket() const { | 503 QuicSentPacketManager::GetLeastUnackedSentPacket() const { |
| 519 return unacked_packets_.GetLeastUnackedSentPacket(); | 504 return unacked_packets_.GetLeastUnacked(); |
| 520 } | 505 } |
| 521 | 506 |
| 522 bool QuicSentPacketManager::OnPacketSent( | 507 bool QuicSentPacketManager::OnPacketSent( |
| 523 QuicPacketSequenceNumber sequence_number, | 508 QuicPacketSequenceNumber sequence_number, |
| 524 QuicTime sent_time, | 509 QuicTime sent_time, |
| 525 QuicByteCount bytes, | 510 QuicByteCount bytes, |
| 526 TransmissionType transmission_type, | 511 TransmissionType transmission_type, |
| 527 HasRetransmittableData has_retransmittable_data) { | 512 HasRetransmittableData has_retransmittable_data) { |
| 528 DCHECK_LT(0u, sequence_number); | 513 DCHECK_LT(0u, sequence_number); |
| 529 DCHECK(unacked_packets_.IsUnacked(sequence_number)); | 514 DCHECK(unacked_packets_.IsUnacked(sequence_number)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 } | 579 } |
| 595 } | 580 } |
| 596 | 581 |
| 597 void QuicSentPacketManager::RetransmitCryptoPackets() { | 582 void QuicSentPacketManager::RetransmitCryptoPackets() { |
| 598 DCHECK_EQ(HANDSHAKE_MODE, GetRetransmissionMode()); | 583 DCHECK_EQ(HANDSHAKE_MODE, GetRetransmissionMode()); |
| 599 // TODO(ianswett): Typical TCP implementations only retransmit 5 times. | 584 // TODO(ianswett): Typical TCP implementations only retransmit 5 times. |
| 600 consecutive_crypto_retransmission_count_ = | 585 consecutive_crypto_retransmission_count_ = |
| 601 min(kMaxHandshakeRetransmissionBackoffs, | 586 min(kMaxHandshakeRetransmissionBackoffs, |
| 602 consecutive_crypto_retransmission_count_ + 1); | 587 consecutive_crypto_retransmission_count_ + 1); |
| 603 bool packet_retransmitted = false; | 588 bool packet_retransmitted = false; |
| 589 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); |
| 604 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 590 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
| 605 it != unacked_packets_.end(); ++it) { | 591 it != unacked_packets_.end(); ++it, ++sequence_number) { |
| 606 QuicPacketSequenceNumber sequence_number = it->first; | |
| 607 const RetransmittableFrames* frames = it->second.retransmittable_frames; | |
| 608 // Only retransmit frames which are in flight, and therefore have been sent. | 592 // Only retransmit frames which are in flight, and therefore have been sent. |
| 609 if (!it->second.in_flight || frames == NULL || | 593 if (!it->in_flight || it->retransmittable_frames == NULL || |
| 610 frames->HasCryptoHandshake() != IS_HANDSHAKE) { | 594 it->retransmittable_frames->HasCryptoHandshake() != IS_HANDSHAKE) { |
| 611 continue; | 595 continue; |
| 612 } | 596 } |
| 613 packet_retransmitted = true; | 597 packet_retransmitted = true; |
| 614 MarkForRetransmission(sequence_number, HANDSHAKE_RETRANSMISSION); | 598 MarkForRetransmission(sequence_number, HANDSHAKE_RETRANSMISSION); |
| 615 ++pending_timer_transmission_count_; | 599 ++pending_timer_transmission_count_; |
| 616 } | 600 } |
| 617 DCHECK(packet_retransmitted) << "No crypto packets found to retransmit."; | 601 DCHECK(packet_retransmitted) << "No crypto packets found to retransmit."; |
| 618 } | 602 } |
| 619 | 603 |
| 620 bool QuicSentPacketManager::MaybeRetransmitTailLossProbe() { | 604 bool QuicSentPacketManager::MaybeRetransmitTailLossProbe() { |
| 621 if (pending_timer_transmission_count_ == 0) { | 605 if (pending_timer_transmission_count_ == 0) { |
| 622 return false; | 606 return false; |
| 623 } | 607 } |
| 608 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); |
| 624 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 609 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
| 625 it != unacked_packets_.end(); ++it) { | 610 it != unacked_packets_.end(); ++it, ++sequence_number) { |
| 626 QuicPacketSequenceNumber sequence_number = it->first; | |
| 627 const RetransmittableFrames* frames = it->second.retransmittable_frames; | |
| 628 // Only retransmit frames which are in flight, and therefore have been sent. | 611 // Only retransmit frames which are in flight, and therefore have been sent. |
| 629 if (!it->second.in_flight || frames == NULL) { | 612 if (!it->in_flight || it->retransmittable_frames == NULL) { |
| 630 continue; | 613 continue; |
| 631 } | 614 } |
| 632 if (!handshake_confirmed_) { | 615 if (!handshake_confirmed_) { |
| 633 DCHECK_NE(IS_HANDSHAKE, frames->HasCryptoHandshake()); | 616 DCHECK_NE(IS_HANDSHAKE, it->retransmittable_frames->HasCryptoHandshake()); |
| 634 } | 617 } |
| 635 MarkForRetransmission(sequence_number, TLP_RETRANSMISSION); | 618 MarkForRetransmission(sequence_number, TLP_RETRANSMISSION); |
| 636 return true; | 619 return true; |
| 637 } | 620 } |
| 638 DLOG(FATAL) | 621 DLOG(FATAL) |
| 639 << "No retransmittable packets, so RetransmitOldestPacket failed."; | 622 << "No retransmittable packets, so RetransmitOldestPacket failed."; |
| 640 return false; | 623 return false; |
| 641 } | 624 } |
| 642 | 625 |
| 643 void QuicSentPacketManager::RetransmitAllPackets() { | 626 void QuicSentPacketManager::RetransmitAllPackets() { |
| 644 DVLOG(1) << "RetransmitAllPackets() called with " | 627 DVLOG(1) << "RetransmitAllPackets() called with " |
| 645 << unacked_packets_.GetNumUnackedPackets() << " unacked packets."; | 628 << unacked_packets_.GetNumUnackedPacketsDebugOnly() |
| 629 << " unacked packets."; |
| 646 // Request retransmission of all retransmittable packets when the RTO | 630 // Request retransmission of all retransmittable packets when the RTO |
| 647 // fires, and let the congestion manager decide how many to send | 631 // fires, and let the congestion manager decide how many to send |
| 648 // immediately and the remaining packets will be queued. | 632 // immediately and the remaining packets will be queued. |
| 649 // Abandon any non-retransmittable packets that are sufficiently old. | 633 // Abandon any non-retransmittable packets that are sufficiently old. |
| 650 bool packets_retransmitted = false; | 634 bool packets_retransmitted = false; |
| 651 QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 635 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); |
| 652 while (it != unacked_packets_.end()) { | 636 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
| 653 const RetransmittableFrames* frames = it->second.retransmittable_frames; | 637 it != unacked_packets_.end(); ++it, ++sequence_number) { |
| 654 QuicPacketSequenceNumber sequence_number = it->first; | 638 if (it->retransmittable_frames != NULL) { |
| 655 ++it; | |
| 656 if (frames != NULL) { | |
| 657 packets_retransmitted = true; | 639 packets_retransmitted = true; |
| 658 MarkForRetransmission(sequence_number, RTO_RETRANSMISSION); | 640 MarkForRetransmission(sequence_number, RTO_RETRANSMISSION); |
| 659 } else { | 641 } else { |
| 660 unacked_packets_.RemoveFromInFlight(sequence_number); | 642 unacked_packets_.RemoveFromInFlight(sequence_number); |
| 661 } | 643 } |
| 662 } | 644 } |
| 663 | 645 |
| 664 send_algorithm_->OnRetransmissionTimeout(packets_retransmitted); | 646 send_algorithm_->OnRetransmissionTimeout(packets_retransmitted); |
| 665 if (packets_retransmitted) { | 647 if (packets_retransmitted) { |
| 666 if (consecutive_rto_count_ == 0) { | 648 if (consecutive_rto_count_ == 0) { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 | 875 |
| 894 // Set up a pacing sender with a 5 millisecond alarm granularity. | 876 // Set up a pacing sender with a 5 millisecond alarm granularity. |
| 895 using_pacing_ = true; | 877 using_pacing_ = true; |
| 896 send_algorithm_.reset( | 878 send_algorithm_.reset( |
| 897 new PacingSender(send_algorithm_.release(), | 879 new PacingSender(send_algorithm_.release(), |
| 898 QuicTime::Delta::FromMilliseconds(5), | 880 QuicTime::Delta::FromMilliseconds(5), |
| 899 kInitialUnpacedBurst)); | 881 kInitialUnpacedBurst)); |
| 900 } | 882 } |
| 901 | 883 |
| 902 } // namespace net | 884 } // namespace net |
| OLD | NEW |