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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 max(kMinInitialRoundTripTimeUs, | 110 max(kMinInitialRoundTripTimeUs, |
111 min(kMaxInitialRoundTripTimeUs, | 111 min(kMaxInitialRoundTripTimeUs, |
112 config.ReceivedInitialRoundTripTimeUs()))); | 112 config.ReceivedInitialRoundTripTimeUs()))); |
113 } else if (config.HasInitialRoundTripTimeUsToSend() && | 113 } else if (config.HasInitialRoundTripTimeUsToSend() && |
114 config.GetInitialRoundTripTimeUsToSend() > 0) { | 114 config.GetInitialRoundTripTimeUsToSend() > 0) { |
115 rtt_stats_.set_initial_rtt_us( | 115 rtt_stats_.set_initial_rtt_us( |
116 max(kMinInitialRoundTripTimeUs, | 116 max(kMinInitialRoundTripTimeUs, |
117 min(kMaxInitialRoundTripTimeUs, | 117 min(kMaxInitialRoundTripTimeUs, |
118 config.GetInitialRoundTripTimeUsToSend()))); | 118 config.GetInitialRoundTripTimeUsToSend()))); |
119 } | 119 } |
| 120 // Initial RTT may have changed. |
| 121 if (network_change_visitor_ != nullptr) { |
| 122 network_change_visitor_->OnRttChange(); |
| 123 } |
120 // TODO(ianswett): BBR is currently a server only feature. | 124 // TODO(ianswett): BBR is currently a server only feature. |
121 if (FLAGS_quic_allow_bbr && | 125 if (FLAGS_quic_allow_bbr && |
122 config.HasReceivedConnectionOptions() && | 126 config.HasReceivedConnectionOptions() && |
123 ContainsQuicTag(config.ReceivedConnectionOptions(), kTBBR)) { | 127 ContainsQuicTag(config.ReceivedConnectionOptions(), kTBBR)) { |
124 if (FLAGS_quic_recent_min_rtt_window_s > 0) { | 128 if (FLAGS_quic_recent_min_rtt_window_s > 0) { |
125 rtt_stats_.set_recent_min_rtt_window( | 129 rtt_stats_.set_recent_min_rtt_window( |
126 QuicTime::Delta::FromSeconds(FLAGS_quic_recent_min_rtt_window_s)); | 130 QuicTime::Delta::FromSeconds(FLAGS_quic_recent_min_rtt_window_s)); |
127 } | 131 } |
128 send_algorithm_.reset(SendAlgorithmInterface::Create( | 132 send_algorithm_.reset(SendAlgorithmInterface::Create( |
129 clock_, &rtt_stats_, kBBR, stats_, initial_congestion_window_)); | 133 clock_, &rtt_stats_, kBBR, stats_, initial_congestion_window_)); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 } | 411 } |
408 } | 412 } |
409 } | 413 } |
410 | 414 |
411 bool QuicSentPacketManager::HasPendingRetransmissions() const { | 415 bool QuicSentPacketManager::HasPendingRetransmissions() const { |
412 return !pending_retransmissions_.empty(); | 416 return !pending_retransmissions_.empty(); |
413 } | 417 } |
414 | 418 |
415 QuicSentPacketManager::PendingRetransmission | 419 QuicSentPacketManager::PendingRetransmission |
416 QuicSentPacketManager::NextPendingRetransmission() { | 420 QuicSentPacketManager::NextPendingRetransmission() { |
417 DCHECK(!pending_retransmissions_.empty()); | 421 LOG_IF(DFATAL, pending_retransmissions_.empty()) |
| 422 << "Unexpected call to PendingRetransmissions() with empty pending " |
| 423 << "retransmission list. Corrupted memory usage imminent."; |
418 QuicPacketSequenceNumber sequence_number = | 424 QuicPacketSequenceNumber sequence_number = |
419 pending_retransmissions_.begin()->first; | 425 pending_retransmissions_.begin()->first; |
420 TransmissionType transmission_type = pending_retransmissions_.begin()->second; | 426 TransmissionType transmission_type = pending_retransmissions_.begin()->second; |
421 if (unacked_packets_.HasPendingCryptoPackets()) { | 427 if (unacked_packets_.HasPendingCryptoPackets()) { |
422 // Ensure crypto packets are retransmitted before other packets. | 428 // Ensure crypto packets are retransmitted before other packets. |
423 PendingRetransmissionMap::const_iterator it = | 429 PendingRetransmissionMap::const_iterator it = |
424 pending_retransmissions_.begin(); | 430 pending_retransmissions_.begin(); |
425 do { | 431 do { |
426 if (HasCryptoHandshake(unacked_packets_.GetTransmissionInfo(it->first))) { | 432 if (HasCryptoHandshake(unacked_packets_.GetTransmissionInfo(it->first))) { |
427 sequence_number = it->first; | 433 sequence_number = it->first; |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 if (transmission_info.sent_time == QuicTime::Zero()) { | 774 if (transmission_info.sent_time == QuicTime::Zero()) { |
769 LOG(DFATAL) << "Acked packet has zero sent time, largest_observed:" | 775 LOG(DFATAL) << "Acked packet has zero sent time, largest_observed:" |
770 << ack_frame.largest_observed; | 776 << ack_frame.largest_observed; |
771 return false; | 777 return false; |
772 } | 778 } |
773 | 779 |
774 QuicTime::Delta send_delta = | 780 QuicTime::Delta send_delta = |
775 ack_receive_time.Subtract(transmission_info.sent_time); | 781 ack_receive_time.Subtract(transmission_info.sent_time); |
776 rtt_stats_.UpdateRtt( | 782 rtt_stats_.UpdateRtt( |
777 send_delta, ack_frame.delta_time_largest_observed, ack_receive_time); | 783 send_delta, ack_frame.delta_time_largest_observed, ack_receive_time); |
| 784 |
| 785 if (network_change_visitor_ != nullptr) { |
| 786 network_change_visitor_->OnRttChange(); |
| 787 } |
| 788 |
778 return true; | 789 return true; |
779 } | 790 } |
780 | 791 |
781 QuicTime::Delta QuicSentPacketManager::TimeUntilSend( | 792 QuicTime::Delta QuicSentPacketManager::TimeUntilSend( |
782 QuicTime now, | 793 QuicTime now, |
783 HasRetransmittableData retransmittable) { | 794 HasRetransmittableData retransmittable) { |
784 // The TLP logic is entirely contained within QuicSentPacketManager, so the | 795 // The TLP logic is entirely contained within QuicSentPacketManager, so the |
785 // send algorithm does not need to be consulted. | 796 // send algorithm does not need to be consulted. |
786 if (pending_timer_transmission_count_ > 0) { | 797 if (pending_timer_transmission_count_ > 0) { |
787 return QuicTime::Delta::Zero(); | 798 return QuicTime::Delta::Zero(); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as | 951 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as |
941 // the default granularity of the Linux kernel's FQ qdisc. | 952 // the default granularity of the Linux kernel's FQ qdisc. |
942 using_pacing_ = true; | 953 using_pacing_ = true; |
943 send_algorithm_.reset( | 954 send_algorithm_.reset( |
944 new PacingSender(send_algorithm_.release(), | 955 new PacingSender(send_algorithm_.release(), |
945 QuicTime::Delta::FromMilliseconds(1), | 956 QuicTime::Delta::FromMilliseconds(1), |
946 kInitialUnpacedBurst)); | 957 kInitialUnpacedBurst)); |
947 } | 958 } |
948 | 959 |
949 } // namespace net | 960 } // namespace net |
OLD | NEW |