| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/congestion_control/quic_congestion_manager.h" | 5 #include "net/quic/congestion_control/quic_congestion_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 receive_algorithm_(ReceiveAlgorithmInterface::Create(clock, type)), | 41 receive_algorithm_(ReceiveAlgorithmInterface::Create(clock, type)), |
| 42 send_algorithm_(SendAlgorithmInterface::Create(clock, type)), | 42 send_algorithm_(SendAlgorithmInterface::Create(clock, type)), |
| 43 largest_missing_(0), | 43 largest_missing_(0), |
| 44 current_rtt_(QuicTime::Delta::Infinite()) { | 44 current_rtt_(QuicTime::Delta::Infinite()) { |
| 45 } | 45 } |
| 46 | 46 |
| 47 QuicCongestionManager::~QuicCongestionManager() { | 47 QuicCongestionManager::~QuicCongestionManager() { |
| 48 STLDeleteValues(&packet_history_map_); | 48 STLDeleteValues(&packet_history_map_); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void QuicCongestionManager::SentPacket(QuicPacketSequenceNumber sequence_number, | 51 void QuicCongestionManager::SentPacket( |
| 52 QuicTime sent_time, | 52 QuicPacketSequenceNumber sequence_number, |
| 53 QuicByteCount bytes, | 53 QuicTime sent_time, |
| 54 Retransmission retransmission) { | 54 QuicByteCount bytes, |
| 55 Retransmission retransmission, |
| 56 HasRetransmittableData has_retransmittable_data) { |
| 55 DCHECK(!ContainsKey(pending_packets_, sequence_number)); | 57 DCHECK(!ContainsKey(pending_packets_, sequence_number)); |
| 56 send_algorithm_->SentPacket(sent_time, sequence_number, bytes, | |
| 57 retransmission); | |
| 58 | 58 |
| 59 packet_history_map_[sequence_number] = | 59 if (send_algorithm_->SentPacket(sent_time, sequence_number, bytes, |
| 60 new class SendAlgorithmInterface::SentPacket(bytes, sent_time); | 60 retransmission, has_retransmittable_data)) { |
| 61 pending_packets_[sequence_number] = bytes; | 61 packet_history_map_[sequence_number] = |
| 62 CleanupPacketHistory(); | 62 new class SendAlgorithmInterface::SentPacket(bytes, sent_time); |
| 63 pending_packets_[sequence_number] = bytes; |
| 64 CleanupPacketHistory(); |
| 65 } |
| 63 } | 66 } |
| 64 | 67 |
| 65 // Called when a packet is timed out. | 68 // Called when a packet is timed out. |
| 66 void QuicCongestionManager::AbandoningPacket( | 69 void QuicCongestionManager::AbandoningPacket( |
| 67 QuicPacketSequenceNumber sequence_number) { | 70 QuicPacketSequenceNumber sequence_number) { |
| 68 PendingPacketsMap::iterator it = pending_packets_.find(sequence_number); | 71 PendingPacketsMap::iterator it = pending_packets_.find(sequence_number); |
| 69 if (it != pending_packets_.end()) { | 72 if (it != pending_packets_.end()) { |
| 70 // Shouldn't this report loss as well? (decrease cgst window). | 73 // Shouldn't this report loss as well? (decrease cgst window). |
| 71 send_algorithm_->AbandoningPacket(sequence_number, it->second); | 74 send_algorithm_->AbandoningPacket(sequence_number, it->second); |
| 72 pending_packets_.erase(it); | 75 pending_packets_.erase(it); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 152 } |
| 150 | 153 |
| 151 const QuicTime::Delta QuicCongestionManager::rtt() { | 154 const QuicTime::Delta QuicCongestionManager::rtt() { |
| 152 return current_rtt_; | 155 return current_rtt_; |
| 153 } | 156 } |
| 154 | 157 |
| 155 const QuicTime::Delta QuicCongestionManager::DefaultRetransmissionTime() { | 158 const QuicTime::Delta QuicCongestionManager::DefaultRetransmissionTime() { |
| 156 return QuicTime::Delta::FromMilliseconds(kDefaultRetransmissionTimeMs); | 159 return QuicTime::Delta::FromMilliseconds(kDefaultRetransmissionTimeMs); |
| 157 } | 160 } |
| 158 | 161 |
| 162 // Ensures that the Delayed Ack timer is always set to a value lesser |
| 163 // than the retransmission timer's minimum value (MinRTO). We want the |
| 164 // delayed ack to get back to the QUIC peer before the sender's |
| 165 // retransmission timer triggers. Since we do not know the |
| 166 // reverse-path one-way delay, we assume equal delays for forward and |
| 167 // reverse paths, and ensure that the timer is set to less than half |
| 168 // of the MinRTO. |
| 169 // There may be a value in making this delay adaptive with the help of |
| 170 // the sender and a signaling mechanism -- if the sender uses a |
| 171 // different MinRTO, we may get spurious retransmissions. May not have |
| 172 // any benefits, but if the delayed ack becomes a significant source |
| 173 // of (likely, tail) latency, then consider such a mechanism. |
| 174 |
| 175 const QuicTime::Delta QuicCongestionManager::DelayedAckTime() { |
| 176 return QuicTime::Delta::FromMilliseconds(kMinRetransmissionTimeMs/2); |
| 177 } |
| 178 |
| 159 const QuicTime::Delta QuicCongestionManager::GetRetransmissionDelay( | 179 const QuicTime::Delta QuicCongestionManager::GetRetransmissionDelay( |
| 160 size_t unacked_packets_count, | 180 size_t unacked_packets_count, |
| 161 size_t number_retransmissions) { | 181 size_t number_retransmissions) { |
| 162 QuicTime::Delta retransmission_delay = send_algorithm_->RetransmissionDelay(); | 182 QuicTime::Delta retransmission_delay = send_algorithm_->RetransmissionDelay(); |
| 163 if (retransmission_delay.IsZero()) { | 183 if (retransmission_delay.IsZero()) { |
| 164 // We are in the initial state, use default timeout values. | 184 // We are in the initial state, use default timeout values. |
| 165 if (unacked_packets_count <= kTailDropWindowSize) { | 185 if (unacked_packets_count <= kTailDropWindowSize) { |
| 166 if (number_retransmissions <= kTailDropMaxRetransmissions) { | 186 if (number_retransmissions <= kTailDropMaxRetransmissions) { |
| 167 return QuicTime::Delta::FromMilliseconds(kDefaultRetransmissionTimeMs); | 187 return QuicTime::Delta::FromMilliseconds(kDefaultRetransmissionTimeMs); |
| 168 } | 188 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 if (now.Subtract(history_it->second->SendTimestamp()) <= kHistoryPeriod) { | 225 if (now.Subtract(history_it->second->SendTimestamp()) <= kHistoryPeriod) { |
| 206 return; | 226 return; |
| 207 } | 227 } |
| 208 delete history_it->second; | 228 delete history_it->second; |
| 209 packet_history_map_.erase(history_it); | 229 packet_history_map_.erase(history_it); |
| 210 history_it = packet_history_map_.begin(); | 230 history_it = packet_history_map_.begin(); |
| 211 } | 231 } |
| 212 } | 232 } |
| 213 | 233 |
| 214 } // namespace net | 234 } // namespace net |
| OLD | NEW |