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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 DCHECK(retransmission_type == ALL_UNACKED_RETRANSMISSION || | 316 DCHECK(retransmission_type == ALL_UNACKED_RETRANSMISSION || |
317 retransmission_type == ALL_INITIAL_RETRANSMISSION); | 317 retransmission_type == ALL_INITIAL_RETRANSMISSION); |
318 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); | 318 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); |
319 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 319 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
320 it != unacked_packets_.end(); ++it, ++sequence_number) { | 320 it != unacked_packets_.end(); ++it, ++sequence_number) { |
321 const RetransmittableFrames* frames = it->retransmittable_frames; | 321 const RetransmittableFrames* frames = it->retransmittable_frames; |
322 if (frames != nullptr && | 322 if (frames != nullptr && |
323 (retransmission_type == ALL_UNACKED_RETRANSMISSION || | 323 (retransmission_type == ALL_UNACKED_RETRANSMISSION || |
324 frames->encryption_level() == ENCRYPTION_INITIAL)) { | 324 frames->encryption_level() == ENCRYPTION_INITIAL)) { |
325 MarkForRetransmission(sequence_number, retransmission_type); | 325 MarkForRetransmission(sequence_number, retransmission_type); |
| 326 } else if (it->is_fec_packet) { |
| 327 // Remove FEC packets from the packet map, since we can't retransmit them. |
| 328 unacked_packets_.RemoveFromInFlight(sequence_number); |
326 } | 329 } |
327 } | 330 } |
328 } | 331 } |
329 | 332 |
330 void QuicSentPacketManager::NeuterUnencryptedPackets() { | 333 void QuicSentPacketManager::NeuterUnencryptedPackets() { |
331 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); | 334 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); |
332 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 335 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
333 it != unacked_packets_.end(); ++it, ++sequence_number) { | 336 it != unacked_packets_.end(); ++it, ++sequence_number) { |
334 const RetransmittableFrames* frames = it->retransmittable_frames; | 337 const RetransmittableFrames* frames = it->retransmittable_frames; |
335 if (frames != nullptr && frames->encryption_level() == ENCRYPTION_NONE) { | 338 if (frames != nullptr && frames->encryption_level() == ENCRYPTION_NONE) { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 | 545 |
543 if (unacked_packets_.bytes_in_flight() == 0) { | 546 if (unacked_packets_.bytes_in_flight() == 0) { |
544 // TODO(ianswett): Consider being less aggressive to force a new | 547 // TODO(ianswett): Consider being less aggressive to force a new |
545 // recent_min_rtt, likely by not discarding a relatively new sample. | 548 // recent_min_rtt, likely by not discarding a relatively new sample. |
546 DVLOG(1) << "Sampling a new recent min rtt within 2 samples. currently:" | 549 DVLOG(1) << "Sampling a new recent min rtt within 2 samples. currently:" |
547 << rtt_stats_.recent_min_rtt().ToMilliseconds() << "ms"; | 550 << rtt_stats_.recent_min_rtt().ToMilliseconds() << "ms"; |
548 rtt_stats_.SampleNewRecentMinRtt(kNumMinRttSamplesAfterQuiescence); | 551 rtt_stats_.SampleNewRecentMinRtt(kNumMinRttSamplesAfterQuiescence); |
549 } | 552 } |
550 | 553 |
551 // Only track packets as in flight that the send algorithm wants us to track. | 554 // Only track packets as in flight that the send algorithm wants us to track. |
| 555 // Since FEC packets should also be counted towards the congestion window, |
| 556 // consider them as retransmittable for the purposes of congestion control. |
| 557 HasRetransmittableData has_congestion_controlled_data = |
| 558 serialized_packet->packet->is_fec_packet() ? |
| 559 HAS_RETRANSMITTABLE_DATA : has_retransmittable_data; |
552 const bool in_flight = | 560 const bool in_flight = |
553 send_algorithm_->OnPacketSent(sent_time, | 561 send_algorithm_->OnPacketSent(sent_time, |
554 unacked_packets_.bytes_in_flight(), | 562 unacked_packets_.bytes_in_flight(), |
555 sequence_number, | 563 sequence_number, |
556 bytes, | 564 bytes, |
557 has_retransmittable_data); | 565 has_congestion_controlled_data); |
| 566 |
558 unacked_packets_.AddSentPacket(*serialized_packet, | 567 unacked_packets_.AddSentPacket(*serialized_packet, |
559 original_sequence_number, | 568 original_sequence_number, |
560 transmission_type, | 569 transmission_type, |
561 sent_time, | 570 sent_time, |
562 bytes, | 571 bytes, |
563 in_flight); | 572 in_flight); |
564 | 573 |
565 // Take ownership of the retransmittable frames before exiting. | 574 // Take ownership of the retransmittable frames before exiting. |
566 serialized_packet->retransmittable_frames = nullptr; | 575 serialized_packet->retransmittable_frames = nullptr; |
567 // Reset the retransmission timer anytime a pending packet is sent. | 576 // Reset the retransmission timer anytime a pending packet is sent. |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as | 928 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as |
920 // the default granularity of the Linux kernel's FQ qdisc. | 929 // the default granularity of the Linux kernel's FQ qdisc. |
921 using_pacing_ = true; | 930 using_pacing_ = true; |
922 send_algorithm_.reset( | 931 send_algorithm_.reset( |
923 new PacingSender(send_algorithm_.release(), | 932 new PacingSender(send_algorithm_.release(), |
924 QuicTime::Delta::FromMilliseconds(1), | 933 QuicTime::Delta::FromMilliseconds(1), |
925 kInitialUnpacedBurst)); | 934 kInitialUnpacedBurst)); |
926 } | 935 } |
927 | 936 |
928 } // namespace net | 937 } // namespace net |
OLD | NEW |