| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 380 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 |