| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 consecutive_rto_count_ = 0; | 221 consecutive_rto_count_ = 0; |
| 222 consecutive_tlp_count_ = 0; | 222 consecutive_tlp_count_ = 0; |
| 223 consecutive_crypto_retransmission_count_ = 0; | 223 consecutive_crypto_retransmission_count_ = 0; |
| 224 } | 224 } |
| 225 | 225 |
| 226 if (debug_delegate_ != NULL) { | 226 if (debug_delegate_ != NULL) { |
| 227 debug_delegate_->OnIncomingAck(ack_frame, | 227 debug_delegate_->OnIncomingAck(ack_frame, |
| 228 ack_receive_time, | 228 ack_receive_time, |
| 229 unacked_packets_.largest_observed(), | 229 unacked_packets_.largest_observed(), |
| 230 largest_observed_acked, | 230 largest_observed_acked, |
| 231 GetLeastUnackedSentPacket()); | 231 GetLeastUnacked()); |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 | 234 |
| 235 void QuicSentPacketManager::UpdatePacketInformationReceivedByPeer( | 235 void QuicSentPacketManager::UpdatePacketInformationReceivedByPeer( |
| 236 const QuicAckFrame& ack_frame) { | 236 const QuicAckFrame& ack_frame) { |
| 237 if (ack_frame.missing_packets.empty()) { | 237 if (ack_frame.missing_packets.empty()) { |
| 238 least_packet_awaited_by_peer_ = ack_frame.largest_observed + 1; | 238 least_packet_awaited_by_peer_ = ack_frame.largest_observed + 1; |
| 239 } else { | 239 } else { |
| 240 least_packet_awaited_by_peer_ = *(ack_frame.missing_packets.begin()); | 240 least_packet_awaited_by_peer_ = *(ack_frame.missing_packets.begin()); |
| 241 } | 241 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 263 ack_frame.delta_time_largest_observed; | 263 ack_frame.delta_time_largest_observed; |
| 264 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); | 264 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); |
| 265 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 265 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
| 266 it != unacked_packets_.end(); ++it, ++sequence_number) { | 266 it != unacked_packets_.end(); ++it, ++sequence_number) { |
| 267 if (sequence_number > ack_frame.largest_observed) { | 267 if (sequence_number > ack_frame.largest_observed) { |
| 268 // These packets are still in flight. | 268 // These packets are still in flight. |
| 269 break; | 269 break; |
| 270 } | 270 } |
| 271 | 271 |
| 272 if (ContainsKey(ack_frame.missing_packets, sequence_number)) { | 272 if (ContainsKey(ack_frame.missing_packets, sequence_number)) { |
| 273 // Don't continue to increase the nack count for packets not in flight. |
| 274 if (!it->in_flight) { |
| 275 continue; |
| 276 } |
| 273 // Consider it multiple nacks when there is a gap between the missing | 277 // Consider it multiple nacks when there is a gap between the missing |
| 274 // packet and the largest observed, since the purpose of a nack | 278 // packet and the largest observed, since the purpose of a nack |
| 275 // threshold is to tolerate re-ordering. This handles both StretchAcks | 279 // threshold is to tolerate re-ordering. This handles both StretchAcks |
| 276 // and Forward Acks. | 280 // and Forward Acks. |
| 277 // The nack count only increases when the largest observed increases. | 281 // The nack count only increases when the largest observed increases. |
| 278 size_t min_nacks = ack_frame.largest_observed - sequence_number; | 282 size_t min_nacks = ack_frame.largest_observed - sequence_number; |
| 279 // Truncated acks can nack the largest observed, so use a min of 1. | 283 // Truncated acks can nack the largest observed, so use a min of 1. |
| 280 if (min_nacks == 0) { | 284 if (min_nacks == 0) { |
| 281 min_nacks = 1; | 285 min_nacks = 1; |
| 282 } | 286 } |
| 283 unacked_packets_.NackPacket(sequence_number, min_nacks); | 287 unacked_packets_.NackPacket(sequence_number, min_nacks); |
| 284 continue; | 288 continue; |
| 285 } | 289 } |
| 286 // Packet was acked, so remove it from our unacked packet list. | 290 // Packet was acked, so remove it from our unacked packet list. |
| 287 DVLOG(1) << ENDPOINT << "Got an ack for packet " << sequence_number; | 291 DVLOG(1) << ENDPOINT << "Got an ack for packet " << sequence_number; |
| 288 // If data is associated with the most recent transmission of this | 292 // If data is associated with the most recent transmission of this |
| 289 // packet, then inform the caller. | 293 // packet, then inform the caller. |
| 290 if (it->in_flight) { | 294 if (it->in_flight) { |
| 291 packets_acked_[sequence_number] = *it; | 295 packets_acked_.push_back(make_pair(sequence_number, *it)); |
| 292 } | 296 } |
| 293 MarkPacketHandled(sequence_number, *it, delta_largest_observed); | 297 MarkPacketHandled(sequence_number, *it, delta_largest_observed); |
| 294 } | 298 } |
| 295 | 299 |
| 296 // Discard any retransmittable frames associated with revived packets. | 300 // Discard any retransmittable frames associated with revived packets. |
| 297 for (SequenceNumberSet::const_iterator revived_it = | 301 for (SequenceNumberSet::const_iterator revived_it = |
| 298 ack_frame.revived_packets.begin(); | 302 ack_frame.revived_packets.begin(); |
| 299 revived_it != ack_frame.revived_packets.end(); ++revived_it) { | 303 revived_it != ack_frame.revived_packets.end(); ++revived_it) { |
| 300 MarkPacketRevived(*revived_it, delta_largest_observed); | 304 MarkPacketRevived(*revived_it, delta_largest_observed); |
| 301 } | 305 } |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 bool QuicSentPacketManager::IsUnacked( | 491 bool QuicSentPacketManager::IsUnacked( |
| 488 QuicPacketSequenceNumber sequence_number) const { | 492 QuicPacketSequenceNumber sequence_number) const { |
| 489 return unacked_packets_.IsUnacked(sequence_number); | 493 return unacked_packets_.IsUnacked(sequence_number); |
| 490 } | 494 } |
| 491 | 495 |
| 492 bool QuicSentPacketManager::HasUnackedPackets() const { | 496 bool QuicSentPacketManager::HasUnackedPackets() const { |
| 493 return unacked_packets_.HasUnackedPackets(); | 497 return unacked_packets_.HasUnackedPackets(); |
| 494 } | 498 } |
| 495 | 499 |
| 496 QuicPacketSequenceNumber | 500 QuicPacketSequenceNumber |
| 497 QuicSentPacketManager::GetLeastUnackedSentPacket() const { | 501 QuicSentPacketManager::GetLeastUnacked() const { |
| 498 return unacked_packets_.GetLeastUnacked(); | 502 return unacked_packets_.GetLeastUnacked(); |
| 499 } | 503 } |
| 500 | 504 |
| 501 bool QuicSentPacketManager::OnPacketSent( | 505 bool QuicSentPacketManager::OnPacketSent( |
| 502 QuicPacketSequenceNumber sequence_number, | 506 QuicPacketSequenceNumber sequence_number, |
| 503 QuicTime sent_time, | 507 QuicTime sent_time, |
| 504 QuicByteCount bytes, | 508 QuicByteCount bytes, |
| 505 TransmissionType transmission_type, | 509 TransmissionType transmission_type, |
| 506 HasRetransmittableData has_retransmittable_data) { | 510 HasRetransmittableData has_retransmittable_data) { |
| 507 DCHECK_LT(0u, sequence_number); | 511 DCHECK_LT(0u, sequence_number); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 rtt_stats_); | 686 rtt_stats_); |
| 683 for (SequenceNumberSet::const_iterator it = lost_packets.begin(); | 687 for (SequenceNumberSet::const_iterator it = lost_packets.begin(); |
| 684 it != lost_packets.end(); ++it) { | 688 it != lost_packets.end(); ++it) { |
| 685 QuicPacketSequenceNumber sequence_number = *it; | 689 QuicPacketSequenceNumber sequence_number = *it; |
| 686 const TransmissionInfo& transmission_info = | 690 const TransmissionInfo& transmission_info = |
| 687 unacked_packets_.GetTransmissionInfo(sequence_number); | 691 unacked_packets_.GetTransmissionInfo(sequence_number); |
| 688 // TODO(ianswett): If it's expected the FEC packet may repair the loss, it | 692 // TODO(ianswett): If it's expected the FEC packet may repair the loss, it |
| 689 // should be recorded as a loss to the send algorithm, but not retransmitted | 693 // should be recorded as a loss to the send algorithm, but not retransmitted |
| 690 // until it's known whether the FEC packet arrived. | 694 // until it's known whether the FEC packet arrived. |
| 691 ++stats_->packets_lost; | 695 ++stats_->packets_lost; |
| 692 packets_lost_[sequence_number] = transmission_info; | 696 packets_lost_.push_back(make_pair(sequence_number, transmission_info)); |
| 693 DVLOG(1) << ENDPOINT << "Lost packet " << sequence_number; | 697 DVLOG(1) << ENDPOINT << "Lost packet " << sequence_number; |
| 694 | 698 |
| 695 if (transmission_info.retransmittable_frames != NULL) { | 699 if (transmission_info.retransmittable_frames != NULL) { |
| 696 MarkForRetransmission(sequence_number, LOSS_RETRANSMISSION); | 700 MarkForRetransmission(sequence_number, LOSS_RETRANSMISSION); |
| 697 } else { | 701 } else { |
| 698 // Since we will not retransmit this, we need to remove it from | 702 // Since we will not retransmit this, we need to remove it from |
| 699 // unacked_packets_. This is either the current transmission of | 703 // unacked_packets_. This is either the current transmission of |
| 700 // a packet whose previous transmission has been acked, a packet that has | 704 // a packet whose previous transmission has been acked, a packet that has |
| 701 // been TLP retransmitted, or an FEC packet. | 705 // been TLP retransmitted, or an FEC packet. |
| 702 unacked_packets_.RemoveFromInFlight(sequence_number); | 706 unacked_packets_.RemoveFromInFlight(sequence_number); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 | 873 |
| 870 // Set up a pacing sender with a 5 millisecond alarm granularity. | 874 // Set up a pacing sender with a 5 millisecond alarm granularity. |
| 871 using_pacing_ = true; | 875 using_pacing_ = true; |
| 872 send_algorithm_.reset( | 876 send_algorithm_.reset( |
| 873 new PacingSender(send_algorithm_.release(), | 877 new PacingSender(send_algorithm_.release(), |
| 874 QuicTime::Delta::FromMilliseconds(5), | 878 QuicTime::Delta::FromMilliseconds(5), |
| 875 kInitialUnpacedBurst)); | 879 kInitialUnpacedBurst)); |
| 876 } | 880 } |
| 877 | 881 |
| 878 } // namespace net | 882 } // namespace net |
| OLD | NEW |