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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 max(kMinSocketReceiveBuffer, | 156 max(kMinSocketReceiveBuffer, |
157 static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer())); | 157 static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer())); |
158 } | 158 } |
159 send_algorithm_->SetFromConfig(config, is_server_, using_pacing_); | 159 send_algorithm_->SetFromConfig(config, is_server_, using_pacing_); |
160 | 160 |
161 if (network_change_visitor_ != nullptr) { | 161 if (network_change_visitor_ != nullptr) { |
162 network_change_visitor_->OnCongestionWindowChange(); | 162 network_change_visitor_->OnCongestionWindowChange(); |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
| 166 void QuicSentPacketManager::ResumeConnectionState( |
| 167 const CachedNetworkParameters& cached_network_params) { |
| 168 send_algorithm_->ResumeConnectionState(cached_network_params); |
| 169 } |
| 170 |
166 void QuicSentPacketManager::SetNumOpenStreams(size_t num_streams) { | 171 void QuicSentPacketManager::SetNumOpenStreams(size_t num_streams) { |
167 if (n_connection_simulation_) { | 172 if (n_connection_simulation_) { |
168 // Ensure the number of connections is between 1 and 5. | 173 // Ensure the number of connections is between 1 and 5. |
169 send_algorithm_->SetNumEmulatedConnections( | 174 send_algorithm_->SetNumEmulatedConnections( |
170 min<size_t>(5, max<size_t>(1, num_streams))); | 175 min<size_t>(5, max<size_t>(1, num_streams))); |
171 } | 176 } |
172 } | 177 } |
173 | 178 |
174 bool QuicSentPacketManager::HasClientSentConnectionOption( | 179 bool QuicSentPacketManager::HasClientSentConnectionOption( |
175 const QuicConfig& config, QuicTag tag) const { | 180 const QuicConfig& config, QuicTag tag) const { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 DCHECK(retransmission_type == ALL_UNACKED_RETRANSMISSION || | 321 DCHECK(retransmission_type == ALL_UNACKED_RETRANSMISSION || |
317 retransmission_type == ALL_INITIAL_RETRANSMISSION); | 322 retransmission_type == ALL_INITIAL_RETRANSMISSION); |
318 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); | 323 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); |
319 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 324 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
320 it != unacked_packets_.end(); ++it, ++sequence_number) { | 325 it != unacked_packets_.end(); ++it, ++sequence_number) { |
321 const RetransmittableFrames* frames = it->retransmittable_frames; | 326 const RetransmittableFrames* frames = it->retransmittable_frames; |
322 if (frames != nullptr && | 327 if (frames != nullptr && |
323 (retransmission_type == ALL_UNACKED_RETRANSMISSION || | 328 (retransmission_type == ALL_UNACKED_RETRANSMISSION || |
324 frames->encryption_level() == ENCRYPTION_INITIAL)) { | 329 frames->encryption_level() == ENCRYPTION_INITIAL)) { |
325 MarkForRetransmission(sequence_number, retransmission_type); | 330 MarkForRetransmission(sequence_number, retransmission_type); |
| 331 } else if (it->is_fec_packet) { |
| 332 // Remove FEC packets from the packet map, since we can't retransmit them. |
| 333 unacked_packets_.RemoveFromInFlight(sequence_number); |
326 } | 334 } |
327 } | 335 } |
328 } | 336 } |
329 | 337 |
330 void QuicSentPacketManager::NeuterUnencryptedPackets() { | 338 void QuicSentPacketManager::NeuterUnencryptedPackets() { |
331 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); | 339 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); |
332 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 340 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
333 it != unacked_packets_.end(); ++it, ++sequence_number) { | 341 it != unacked_packets_.end(); ++it, ++sequence_number) { |
334 const RetransmittableFrames* frames = it->retransmittable_frames; | 342 const RetransmittableFrames* frames = it->retransmittable_frames; |
335 if (frames != nullptr && frames->encryption_level() == ENCRYPTION_NONE) { | 343 if (frames != nullptr && frames->encryption_level() == ENCRYPTION_NONE) { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 | 550 |
543 if (unacked_packets_.bytes_in_flight() == 0) { | 551 if (unacked_packets_.bytes_in_flight() == 0) { |
544 // TODO(ianswett): Consider being less aggressive to force a new | 552 // TODO(ianswett): Consider being less aggressive to force a new |
545 // recent_min_rtt, likely by not discarding a relatively new sample. | 553 // recent_min_rtt, likely by not discarding a relatively new sample. |
546 DVLOG(1) << "Sampling a new recent min rtt within 2 samples. currently:" | 554 DVLOG(1) << "Sampling a new recent min rtt within 2 samples. currently:" |
547 << rtt_stats_.recent_min_rtt().ToMilliseconds() << "ms"; | 555 << rtt_stats_.recent_min_rtt().ToMilliseconds() << "ms"; |
548 rtt_stats_.SampleNewRecentMinRtt(kNumMinRttSamplesAfterQuiescence); | 556 rtt_stats_.SampleNewRecentMinRtt(kNumMinRttSamplesAfterQuiescence); |
549 } | 557 } |
550 | 558 |
551 // Only track packets as in flight that the send algorithm wants us to track. | 559 // Only track packets as in flight that the send algorithm wants us to track. |
| 560 // Since FEC packets should also be counted towards the congestion window, |
| 561 // consider them as retransmittable for the purposes of congestion control. |
| 562 HasRetransmittableData has_congestion_controlled_data = |
| 563 serialized_packet->packet->is_fec_packet() ? |
| 564 HAS_RETRANSMITTABLE_DATA : has_retransmittable_data; |
552 const bool in_flight = | 565 const bool in_flight = |
553 send_algorithm_->OnPacketSent(sent_time, | 566 send_algorithm_->OnPacketSent(sent_time, |
554 unacked_packets_.bytes_in_flight(), | 567 unacked_packets_.bytes_in_flight(), |
555 sequence_number, | 568 sequence_number, |
556 bytes, | 569 bytes, |
557 has_retransmittable_data); | 570 has_congestion_controlled_data); |
| 571 |
558 unacked_packets_.AddSentPacket(*serialized_packet, | 572 unacked_packets_.AddSentPacket(*serialized_packet, |
559 original_sequence_number, | 573 original_sequence_number, |
560 transmission_type, | 574 transmission_type, |
561 sent_time, | 575 sent_time, |
562 bytes, | 576 bytes, |
563 in_flight); | 577 in_flight); |
564 | 578 |
565 // Take ownership of the retransmittable frames before exiting. | 579 // Take ownership of the retransmittable frames before exiting. |
566 serialized_packet->retransmittable_frames = nullptr; | 580 serialized_packet->retransmittable_frames = nullptr; |
567 // Reset the retransmission timer anytime a pending packet is sent. | 581 // 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 | 933 // 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. | 934 // the default granularity of the Linux kernel's FQ qdisc. |
921 using_pacing_ = true; | 935 using_pacing_ = true; |
922 send_algorithm_.reset( | 936 send_algorithm_.reset( |
923 new PacingSender(send_algorithm_.release(), | 937 new PacingSender(send_algorithm_.release(), |
924 QuicTime::Delta::FromMilliseconds(1), | 938 QuicTime::Delta::FromMilliseconds(1), |
925 kInitialUnpacedBurst)); | 939 kInitialUnpacedBurst)); |
926 } | 940 } |
927 | 941 |
928 } // namespace net | 942 } // namespace net |
OLD | NEW |