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" |
11 #include "net/quic/congestion_control/pacing_sender.h" | 11 #include "net/quic/congestion_control/pacing_sender.h" |
12 #include "net/quic/crypto/crypto_protocol.h" | 12 #include "net/quic/crypto/crypto_protocol.h" |
13 #include "net/quic/quic_ack_notifier_manager.h" | 13 #include "net/quic/quic_ack_notifier_manager.h" |
14 #include "net/quic/quic_connection_stats.h" | 14 #include "net/quic/quic_connection_stats.h" |
15 #include "net/quic/quic_flags.h" | 15 #include "net/quic/quic_flags.h" |
16 #include "net/quic/quic_utils_chromium.h" | 16 #include "net/quic/quic_utils_chromium.h" |
17 | 17 |
18 using std::make_pair; | |
19 using std::max; | 18 using std::max; |
20 using std::min; | 19 using std::min; |
21 | 20 |
22 namespace net { | 21 namespace net { |
23 | 22 |
24 // The length of the recent min rtt window in seconds. Windowing is disabled for | 23 // The length of the recent min rtt window in seconds. Windowing is disabled for |
25 // values less than or equal to 0. | 24 // values less than or equal to 0. |
26 int32 FLAGS_quic_recent_min_rtt_window_s = 60; | 25 int32 FLAGS_quic_recent_min_rtt_window_s = 60; |
27 | 26 |
28 namespace { | 27 namespace { |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 min_nacks = 1; | 321 min_nacks = 1; |
323 } | 322 } |
324 unacked_packets_.NackPacket(sequence_number, min_nacks); | 323 unacked_packets_.NackPacket(sequence_number, min_nacks); |
325 continue; | 324 continue; |
326 } | 325 } |
327 // Packet was acked, so remove it from our unacked packet list. | 326 // Packet was acked, so remove it from our unacked packet list. |
328 DVLOG(1) << ENDPOINT << "Got an ack for packet " << sequence_number; | 327 DVLOG(1) << ENDPOINT << "Got an ack for packet " << sequence_number; |
329 // If data is associated with the most recent transmission of this | 328 // If data is associated with the most recent transmission of this |
330 // packet, then inform the caller. | 329 // packet, then inform the caller. |
331 if (it->in_flight) { | 330 if (it->in_flight) { |
332 packets_acked_.push_back(make_pair(sequence_number, *it)); | 331 packets_acked_.push_back(std::make_pair(sequence_number, *it)); |
333 } | 332 } |
334 MarkPacketHandled(sequence_number, *it, delta_largest_observed); | 333 MarkPacketHandled(sequence_number, *it, delta_largest_observed); |
335 } | 334 } |
336 | 335 |
337 // Discard any retransmittable frames associated with revived packets. | 336 // Discard any retransmittable frames associated with revived packets. |
338 for (SequenceNumberSet::const_iterator revived_it = | 337 for (SequenceNumberSet::const_iterator revived_it = |
339 ack_frame.revived_packets.begin(); | 338 ack_frame.revived_packets.begin(); |
340 revived_it != ack_frame.revived_packets.end(); ++revived_it) { | 339 revived_it != ack_frame.revived_packets.end(); ++revived_it) { |
341 MarkPacketRevived(*revived_it, delta_largest_observed); | 340 MarkPacketRevived(*revived_it, delta_largest_observed); |
342 } | 341 } |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 QuicPacketSequenceNumber original_sequence_number, | 553 QuicPacketSequenceNumber original_sequence_number, |
555 QuicTime sent_time, | 554 QuicTime sent_time, |
556 QuicByteCount bytes, | 555 QuicByteCount bytes, |
557 TransmissionType transmission_type, | 556 TransmissionType transmission_type, |
558 HasRetransmittableData has_retransmittable_data) { | 557 HasRetransmittableData has_retransmittable_data) { |
559 QuicPacketSequenceNumber sequence_number = serialized_packet->sequence_number; | 558 QuicPacketSequenceNumber sequence_number = serialized_packet->sequence_number; |
560 DCHECK_LT(0u, sequence_number); | 559 DCHECK_LT(0u, sequence_number); |
561 DCHECK(!unacked_packets_.IsUnacked(sequence_number)); | 560 DCHECK(!unacked_packets_.IsUnacked(sequence_number)); |
562 LOG_IF(DFATAL, bytes == 0) << "Cannot send empty packets."; | 561 LOG_IF(DFATAL, bytes == 0) << "Cannot send empty packets."; |
563 | 562 |
564 if (original_sequence_number == 0) { | 563 if (original_sequence_number != 0) { |
565 if (!FLAGS_quic_ack_notifier_informed_on_serialized && | |
566 serialized_packet->retransmittable_frames) { | |
567 ack_notifier_manager_.OnSerializedPacket(*serialized_packet); | |
568 } | |
569 } else { | |
570 PendingRetransmissionMap::iterator it = | 564 PendingRetransmissionMap::iterator it = |
571 pending_retransmissions_.find(original_sequence_number); | 565 pending_retransmissions_.find(original_sequence_number); |
572 if (it != pending_retransmissions_.end()) { | 566 if (it != pending_retransmissions_.end()) { |
573 pending_retransmissions_.erase(it); | 567 pending_retransmissions_.erase(it); |
574 } else { | 568 } else { |
575 DLOG(DFATAL) << "Expected sequence number to be in " | 569 DLOG(DFATAL) << "Expected sequence number to be in " |
576 << "pending_retransmissions_. sequence_number: " | 570 << "pending_retransmissions_. sequence_number: " |
577 << original_sequence_number; | 571 << original_sequence_number; |
578 } | 572 } |
579 // Inform the ack notifier of retransmissions so it can calculate the | 573 // Inform the ack notifier of retransmissions so it can calculate the |
(...skipping 11 matching lines...) Expand all Loading... |
591 // recent_min_rtt, likely by not discarding a relatively new sample. | 585 // recent_min_rtt, likely by not discarding a relatively new sample. |
592 DVLOG(1) << "Sampling a new recent min rtt within 2 samples. currently:" | 586 DVLOG(1) << "Sampling a new recent min rtt within 2 samples. currently:" |
593 << rtt_stats_.recent_min_rtt().ToMilliseconds() << "ms"; | 587 << rtt_stats_.recent_min_rtt().ToMilliseconds() << "ms"; |
594 rtt_stats_.SampleNewRecentMinRtt(kNumMinRttSamplesAfterQuiescence); | 588 rtt_stats_.SampleNewRecentMinRtt(kNumMinRttSamplesAfterQuiescence); |
595 } | 589 } |
596 | 590 |
597 // Only track packets as in flight that the send algorithm wants us to track. | 591 // Only track packets as in flight that the send algorithm wants us to track. |
598 // Since FEC packets should also be counted towards the congestion window, | 592 // Since FEC packets should also be counted towards the congestion window, |
599 // consider them as retransmittable for the purposes of congestion control. | 593 // consider them as retransmittable for the purposes of congestion control. |
600 HasRetransmittableData has_congestion_controlled_data = | 594 HasRetransmittableData has_congestion_controlled_data = |
601 serialized_packet->packet->is_fec_packet() ? | 595 serialized_packet->is_fec_packet ? HAS_RETRANSMITTABLE_DATA |
602 HAS_RETRANSMITTABLE_DATA : has_retransmittable_data; | 596 : has_retransmittable_data; |
603 const bool in_flight = | 597 const bool in_flight = |
604 send_algorithm_->OnPacketSent(sent_time, | 598 send_algorithm_->OnPacketSent(sent_time, |
605 unacked_packets_.bytes_in_flight(), | 599 unacked_packets_.bytes_in_flight(), |
606 sequence_number, | 600 sequence_number, |
607 bytes, | 601 bytes, |
608 has_congestion_controlled_data); | 602 has_congestion_controlled_data); |
609 | 603 |
610 unacked_packets_.AddSentPacket(*serialized_packet, | 604 unacked_packets_.AddSentPacket(*serialized_packet, |
611 original_sequence_number, | 605 original_sequence_number, |
612 transmission_type, | 606 transmission_type, |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 rtt_stats_); | 780 rtt_stats_); |
787 for (SequenceNumberSet::const_iterator it = lost_packets.begin(); | 781 for (SequenceNumberSet::const_iterator it = lost_packets.begin(); |
788 it != lost_packets.end(); ++it) { | 782 it != lost_packets.end(); ++it) { |
789 QuicPacketSequenceNumber sequence_number = *it; | 783 QuicPacketSequenceNumber sequence_number = *it; |
790 const TransmissionInfo& transmission_info = | 784 const TransmissionInfo& transmission_info = |
791 unacked_packets_.GetTransmissionInfo(sequence_number); | 785 unacked_packets_.GetTransmissionInfo(sequence_number); |
792 // TODO(ianswett): If it's expected the FEC packet may repair the loss, it | 786 // TODO(ianswett): If it's expected the FEC packet may repair the loss, it |
793 // should be recorded as a loss to the send algorithm, but not retransmitted | 787 // should be recorded as a loss to the send algorithm, but not retransmitted |
794 // until it's known whether the FEC packet arrived. | 788 // until it's known whether the FEC packet arrived. |
795 ++stats_->packets_lost; | 789 ++stats_->packets_lost; |
796 packets_lost_.push_back(make_pair(sequence_number, transmission_info)); | 790 packets_lost_.push_back(std::make_pair(sequence_number, transmission_info)); |
797 DVLOG(1) << ENDPOINT << "Lost packet " << sequence_number; | 791 DVLOG(1) << ENDPOINT << "Lost packet " << sequence_number; |
798 | 792 |
799 if (transmission_info.retransmittable_frames != nullptr) { | 793 if (transmission_info.retransmittable_frames != nullptr) { |
800 MarkForRetransmission(sequence_number, LOSS_RETRANSMISSION); | 794 MarkForRetransmission(sequence_number, LOSS_RETRANSMISSION); |
801 } else { | 795 } else { |
802 // Since we will not retransmit this, we need to remove it from | 796 // Since we will not retransmit this, we need to remove it from |
803 // unacked_packets_. This is either the current transmission of | 797 // unacked_packets_. This is either the current transmission of |
804 // a packet whose previous transmission has been acked, a packet that has | 798 // a packet whose previous transmission has been acked, a packet that has |
805 // been TLP retransmitted, or an FEC packet. | 799 // been TLP retransmitted, or an FEC packet. |
806 unacked_packets_.RemoveFromInFlight(sequence_number); | 800 unacked_packets_.RemoveFromInFlight(sequence_number); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as | 1004 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as |
1011 // the default granularity of the Linux kernel's FQ qdisc. | 1005 // the default granularity of the Linux kernel's FQ qdisc. |
1012 using_pacing_ = true; | 1006 using_pacing_ = true; |
1013 send_algorithm_.reset( | 1007 send_algorithm_.reset( |
1014 new PacingSender(send_algorithm_.release(), | 1008 new PacingSender(send_algorithm_.release(), |
1015 QuicTime::Delta::FromMilliseconds(1), | 1009 QuicTime::Delta::FromMilliseconds(1), |
1016 kInitialUnpacedBurst)); | 1010 kInitialUnpacedBurst)); |
1017 } | 1011 } |
1018 | 1012 |
1019 } // namespace net | 1013 } // namespace net |
OLD | NEW |