| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 max(kMinInitialRoundTripTimeUs, | 111 max(kMinInitialRoundTripTimeUs, |
| 112 min(kMaxInitialRoundTripTimeUs, | 112 min(kMaxInitialRoundTripTimeUs, |
| 113 config.ReceivedInitialRoundTripTimeUs()))); | 113 config.ReceivedInitialRoundTripTimeUs()))); |
| 114 } else if (config.HasInitialRoundTripTimeUsToSend() && | 114 } else if (config.HasInitialRoundTripTimeUsToSend() && |
| 115 config.GetInitialRoundTripTimeUsToSend() > 0) { | 115 config.GetInitialRoundTripTimeUsToSend() > 0) { |
| 116 rtt_stats_.set_initial_rtt_us( | 116 rtt_stats_.set_initial_rtt_us( |
| 117 max(kMinInitialRoundTripTimeUs, | 117 max(kMinInitialRoundTripTimeUs, |
| 118 min(kMaxInitialRoundTripTimeUs, | 118 min(kMaxInitialRoundTripTimeUs, |
| 119 config.GetInitialRoundTripTimeUsToSend()))); | 119 config.GetInitialRoundTripTimeUsToSend()))); |
| 120 } | 120 } |
| 121 // Initial RTT may have changed. | |
| 122 if (network_change_visitor_ != nullptr) { | |
| 123 network_change_visitor_->OnRttChange(); | |
| 124 } | |
| 125 // TODO(ianswett): BBR is currently a server only feature. | 121 // TODO(ianswett): BBR is currently a server only feature. |
| 126 if (FLAGS_quic_allow_bbr && config.HasReceivedConnectionOptions() && | 122 if (FLAGS_quic_allow_bbr && config.HasReceivedConnectionOptions() && |
| 127 ContainsQuicTag(config.ReceivedConnectionOptions(), kTBBR)) { | 123 ContainsQuicTag(config.ReceivedConnectionOptions(), kTBBR)) { |
| 128 if (FLAGS_quic_recent_min_rtt_window_s > 0) { | 124 if (FLAGS_quic_recent_min_rtt_window_s > 0) { |
| 129 rtt_stats_.set_recent_min_rtt_window( | 125 rtt_stats_.set_recent_min_rtt_window( |
| 130 QuicTime::Delta::FromSeconds(FLAGS_quic_recent_min_rtt_window_s)); | 126 QuicTime::Delta::FromSeconds(FLAGS_quic_recent_min_rtt_window_s)); |
| 131 } | 127 } |
| 132 send_algorithm_.reset(SendAlgorithmInterface::Create( | 128 send_algorithm_.reset(SendAlgorithmInterface::Create( |
| 133 clock_, &rtt_stats_, kBBR, stats_, initial_congestion_window_)); | 129 clock_, &rtt_stats_, kBBR, stats_, initial_congestion_window_)); |
| 134 } | 130 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 receive_buffer_bytes_ = | 174 receive_buffer_bytes_ = |
| 179 max(kMinSocketReceiveBuffer, | 175 max(kMinSocketReceiveBuffer, |
| 180 static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer())); | 176 static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer())); |
| 181 QuicByteCount max_cwnd_bytes = static_cast<QuicByteCount>( | 177 QuicByteCount max_cwnd_bytes = static_cast<QuicByteCount>( |
| 182 receive_buffer_bytes_ * kConservativeReceiveBufferFraction); | 178 receive_buffer_bytes_ * kConservativeReceiveBufferFraction); |
| 183 send_algorithm_->SetMaxCongestionWindow(max_cwnd_bytes); | 179 send_algorithm_->SetMaxCongestionWindow(max_cwnd_bytes); |
| 184 } | 180 } |
| 185 send_algorithm_->SetFromConfig(config, perspective_); | 181 send_algorithm_->SetFromConfig(config, perspective_); |
| 186 | 182 |
| 187 if (network_change_visitor_ != nullptr) { | 183 if (network_change_visitor_ != nullptr) { |
| 188 network_change_visitor_->OnCongestionWindowChange(); | 184 network_change_visitor_->OnCongestionChange(); |
| 189 } | 185 } |
| 190 } | 186 } |
| 191 | 187 |
| 192 void QuicSentPacketManager::ResumeConnectionState( | 188 void QuicSentPacketManager::ResumeConnectionState( |
| 193 const CachedNetworkParameters& cached_network_params, | 189 const CachedNetworkParameters& cached_network_params, |
| 194 bool max_bandwidth_resumption) { | 190 bool max_bandwidth_resumption) { |
| 195 if (cached_network_params.has_min_rtt_ms()) { | 191 if (cached_network_params.has_min_rtt_ms()) { |
| 196 uint32_t initial_rtt_us = | 192 uint32_t initial_rtt_us = |
| 197 kNumMicrosPerMilli * cached_network_params.min_rtt_ms(); | 193 kNumMicrosPerMilli * cached_network_params.min_rtt_ms(); |
| 198 rtt_stats_.set_initial_rtt_us( | 194 rtt_stats_.set_initial_rtt_us( |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 bool rtt_updated, | 279 bool rtt_updated, |
| 284 QuicByteCount bytes_in_flight) { | 280 QuicByteCount bytes_in_flight) { |
| 285 if (!rtt_updated && packets_acked_.empty() && packets_lost_.empty()) { | 281 if (!rtt_updated && packets_acked_.empty() && packets_lost_.empty()) { |
| 286 return; | 282 return; |
| 287 } | 283 } |
| 288 send_algorithm_->OnCongestionEvent(rtt_updated, bytes_in_flight, | 284 send_algorithm_->OnCongestionEvent(rtt_updated, bytes_in_flight, |
| 289 packets_acked_, packets_lost_); | 285 packets_acked_, packets_lost_); |
| 290 packets_acked_.clear(); | 286 packets_acked_.clear(); |
| 291 packets_lost_.clear(); | 287 packets_lost_.clear(); |
| 292 if (network_change_visitor_ != nullptr) { | 288 if (network_change_visitor_ != nullptr) { |
| 293 network_change_visitor_->OnCongestionWindowChange(); | 289 network_change_visitor_->OnCongestionChange(); |
| 294 } | 290 } |
| 295 } | 291 } |
| 296 | 292 |
| 297 void QuicSentPacketManager::HandleAckForSentPackets( | 293 void QuicSentPacketManager::HandleAckForSentPackets( |
| 298 const QuicAckFrame& ack_frame) { | 294 const QuicAckFrame& ack_frame) { |
| 299 // Go through the packets we have not received an ack for and see if this | 295 // Go through the packets we have not received an ack for and see if this |
| 300 // incoming_ack shows they've been seen by the peer. | 296 // incoming_ack shows they've been seen by the peer. |
| 301 QuicTime::Delta ack_delay_time = ack_frame.ack_delay_time; | 297 QuicTime::Delta ack_delay_time = ack_frame.ack_delay_time; |
| 302 QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); | 298 QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); |
| 303 for (QuicUnackedPacketMap::iterator it = unacked_packets_.begin(); | 299 for (QuicUnackedPacketMap::iterator it = unacked_packets_.begin(); |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 if (transmission_info.sent_time == QuicTime::Zero()) { | 761 if (transmission_info.sent_time == QuicTime::Zero()) { |
| 766 QUIC_BUG << "Acked packet has zero sent time, largest_observed:" | 762 QUIC_BUG << "Acked packet has zero sent time, largest_observed:" |
| 767 << ack_frame.largest_observed; | 763 << ack_frame.largest_observed; |
| 768 return false; | 764 return false; |
| 769 } | 765 } |
| 770 | 766 |
| 771 QuicTime::Delta send_delta = | 767 QuicTime::Delta send_delta = |
| 772 ack_receive_time.Subtract(transmission_info.sent_time); | 768 ack_receive_time.Subtract(transmission_info.sent_time); |
| 773 rtt_stats_.UpdateRtt(send_delta, ack_frame.ack_delay_time, ack_receive_time); | 769 rtt_stats_.UpdateRtt(send_delta, ack_frame.ack_delay_time, ack_receive_time); |
| 774 | 770 |
| 775 if (network_change_visitor_ != nullptr) { | |
| 776 network_change_visitor_->OnRttChange(); | |
| 777 } | |
| 778 | |
| 779 return true; | 771 return true; |
| 780 } | 772 } |
| 781 | 773 |
| 782 QuicTime::Delta QuicSentPacketManager::TimeUntilSend( | 774 QuicTime::Delta QuicSentPacketManager::TimeUntilSend( |
| 783 QuicTime now, | 775 QuicTime now, |
| 784 HasRetransmittableData retransmittable) { | 776 HasRetransmittableData retransmittable) { |
| 785 // The TLP logic is entirely contained within QuicSentPacketManager, so the | 777 // The TLP logic is entirely contained within QuicSentPacketManager, so the |
| 786 // send algorithm does not need to be consulted. | 778 // send algorithm does not need to be consulted. |
| 787 if (pending_timer_transmission_count_ > 0) { | 779 if (pending_timer_transmission_count_ > 0) { |
| 788 return QuicTime::Delta::Zero(); | 780 return QuicTime::Delta::Zero(); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 TransmissionInfo* QuicSentPacketManager::GetMutableTransmissionInfo( | 975 TransmissionInfo* QuicSentPacketManager::GetMutableTransmissionInfo( |
| 984 QuicPacketNumber packet_number) { | 976 QuicPacketNumber packet_number) { |
| 985 return unacked_packets_.GetMutableTransmissionInfo(packet_number); | 977 return unacked_packets_.GetMutableTransmissionInfo(packet_number); |
| 986 } | 978 } |
| 987 | 979 |
| 988 void QuicSentPacketManager::RemoveObsoletePackets() { | 980 void QuicSentPacketManager::RemoveObsoletePackets() { |
| 989 unacked_packets_.RemoveObsoletePackets(); | 981 unacked_packets_.RemoveObsoletePackets(); |
| 990 } | 982 } |
| 991 | 983 |
| 992 } // namespace net | 984 } // namespace net |
| OLD | NEW |