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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
91 | 91 |
92 QuicSentPacketManager::~QuicSentPacketManager() { | 92 QuicSentPacketManager::~QuicSentPacketManager() { |
93 } | 93 } |
94 | 94 |
95 void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) { | 95 void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) { |
96 if (config.HasReceivedInitialRoundTripTimeUs() && | 96 if (config.HasReceivedInitialRoundTripTimeUs() && |
97 config.ReceivedInitialRoundTripTimeUs() > 0) { | 97 config.ReceivedInitialRoundTripTimeUs() > 0) { |
98 rtt_stats_.set_initial_rtt_us(min(kMaxInitialRoundTripTimeUs, | 98 rtt_stats_.set_initial_rtt_us(min(kMaxInitialRoundTripTimeUs, |
99 config.ReceivedInitialRoundTripTimeUs())); | 99 config.ReceivedInitialRoundTripTimeUs())); |
| 100 } else if (config.HasInitialRoundTripTimeUsToSend()) { |
| 101 rtt_stats_.set_initial_rtt_us( |
| 102 min(kMaxInitialRoundTripTimeUs, |
| 103 config.GetInitialRoundTripTimeUsToSend())); |
100 } | 104 } |
101 // TODO(ianswett): BBR is currently a server only feature. | 105 // TODO(ianswett): BBR is currently a server only feature. |
102 if (config.HasReceivedConnectionOptions() && | 106 if (config.HasReceivedConnectionOptions() && |
103 ContainsQuicTag(config.ReceivedConnectionOptions(), kTBBR)) { | 107 ContainsQuicTag(config.ReceivedConnectionOptions(), kTBBR)) { |
104 if (FLAGS_quic_recent_min_rtt_window_s > 0) { | 108 if (FLAGS_quic_recent_min_rtt_window_s > 0) { |
105 rtt_stats_.set_recent_min_rtt_window( | 109 rtt_stats_.set_recent_min_rtt_window( |
106 QuicTime::Delta::FromSeconds(FLAGS_quic_recent_min_rtt_window_s)); | 110 QuicTime::Delta::FromSeconds(FLAGS_quic_recent_min_rtt_window_s)); |
107 } | 111 } |
108 send_algorithm_.reset( | 112 send_algorithm_.reset( |
109 SendAlgorithmInterface::Create(clock_, &rtt_stats_, kBBR, stats_)); | 113 SendAlgorithmInterface::Create(clock_, &rtt_stats_, kBBR, stats_)); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 MarkPacketRevived(*revived_it, delta_largest_observed); | 307 MarkPacketRevived(*revived_it, delta_largest_observed); |
304 } | 308 } |
305 } | 309 } |
306 | 310 |
307 bool QuicSentPacketManager::HasRetransmittableFrames( | 311 bool QuicSentPacketManager::HasRetransmittableFrames( |
308 QuicPacketSequenceNumber sequence_number) const { | 312 QuicPacketSequenceNumber sequence_number) const { |
309 return unacked_packets_.HasRetransmittableFrames(sequence_number); | 313 return unacked_packets_.HasRetransmittableFrames(sequence_number); |
310 } | 314 } |
311 | 315 |
312 void QuicSentPacketManager::RetransmitUnackedPackets( | 316 void QuicSentPacketManager::RetransmitUnackedPackets( |
313 RetransmissionType retransmission_type) { | 317 TransmissionType retransmission_type) { |
| 318 DCHECK(retransmission_type == ALL_UNACKED_RETRANSMISSION || |
| 319 retransmission_type == ALL_INITIAL_RETRANSMISSION); |
314 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); | 320 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); |
315 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 321 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
316 it != unacked_packets_.end(); ++it, ++sequence_number) { | 322 it != unacked_packets_.end(); ++it, ++sequence_number) { |
317 const RetransmittableFrames* frames = it->retransmittable_frames; | 323 const RetransmittableFrames* frames = it->retransmittable_frames; |
318 // TODO(ianswett): Consider adding a new retransmission type which removes | 324 if (frames != NULL && (retransmission_type == ALL_UNACKED_RETRANSMISSION || |
319 // all these old packets from unacked and retransmits them as new sequence | |
320 // numbers with no connection to the previous ones. | |
321 if (frames != NULL && (retransmission_type == ALL_PACKETS || | |
322 frames->encryption_level() == ENCRYPTION_INITIAL)) { | 325 frames->encryption_level() == ENCRYPTION_INITIAL)) { |
323 MarkForRetransmission(sequence_number, ALL_UNACKED_RETRANSMISSION); | 326 MarkForRetransmission(sequence_number, retransmission_type); |
324 } | 327 } |
325 } | 328 } |
326 } | 329 } |
327 | 330 |
328 void QuicSentPacketManager::NeuterUnencryptedPackets() { | 331 void QuicSentPacketManager::NeuterUnencryptedPackets() { |
329 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); | 332 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); |
330 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); | 333 for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin(); |
331 it != unacked_packets_.end(); ++it, ++sequence_number) { | 334 it != unacked_packets_.end(); ++it, ++sequence_number) { |
332 const RetransmittableFrames* frames = it->retransmittable_frames; | 335 const RetransmittableFrames* frames = it->retransmittable_frames; |
333 if (frames != NULL && frames->encryption_level() == ENCRYPTION_NONE) { | 336 if (frames != NULL && frames->encryption_level() == ENCRYPTION_NONE) { |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 bool QuicSentPacketManager::MaybeUpdateRTT( | 713 bool QuicSentPacketManager::MaybeUpdateRTT( |
711 const QuicAckFrame& ack_frame, | 714 const QuicAckFrame& ack_frame, |
712 const QuicTime& ack_receive_time) { | 715 const QuicTime& ack_receive_time) { |
713 if (!unacked_packets_.IsUnacked(ack_frame.largest_observed)) { | 716 if (!unacked_packets_.IsUnacked(ack_frame.largest_observed)) { |
714 return false; | 717 return false; |
715 } | 718 } |
716 // We calculate the RTT based on the highest ACKed sequence number, the lower | 719 // We calculate the RTT based on the highest ACKed sequence number, the lower |
717 // sequence numbers will include the ACK aggregation delay. | 720 // sequence numbers will include the ACK aggregation delay. |
718 const TransmissionInfo& transmission_info = | 721 const TransmissionInfo& transmission_info = |
719 unacked_packets_.GetTransmissionInfo(ack_frame.largest_observed); | 722 unacked_packets_.GetTransmissionInfo(ack_frame.largest_observed); |
720 // Don't update the RTT if it hasn't been sent. | 723 // Ensure the packet has a valid sent time. |
721 if (transmission_info.sent_time == QuicTime::Zero()) { | 724 if (transmission_info.sent_time == QuicTime::Zero()) { |
| 725 LOG(DFATAL) << "Acked packet has zero sent time, largest_observed:" |
| 726 << ack_frame.largest_observed; |
722 return false; | 727 return false; |
723 } | 728 } |
724 | 729 |
725 QuicTime::Delta send_delta = | 730 QuicTime::Delta send_delta = |
726 ack_receive_time.Subtract(transmission_info.sent_time); | 731 ack_receive_time.Subtract(transmission_info.sent_time); |
727 rtt_stats_.UpdateRtt( | 732 rtt_stats_.UpdateRtt( |
728 send_delta, ack_frame.delta_time_largest_observed, ack_receive_time); | 733 send_delta, ack_frame.delta_time_largest_observed, ack_receive_time); |
729 return true; | 734 return true; |
730 } | 735 } |
731 | 736 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 | 877 |
873 // Set up a pacing sender with a 5 millisecond alarm granularity. | 878 // Set up a pacing sender with a 5 millisecond alarm granularity. |
874 using_pacing_ = true; | 879 using_pacing_ = true; |
875 send_algorithm_.reset( | 880 send_algorithm_.reset( |
876 new PacingSender(send_algorithm_.release(), | 881 new PacingSender(send_algorithm_.release(), |
877 QuicTime::Delta::FromMilliseconds(5), | 882 QuicTime::Delta::FromMilliseconds(5), |
878 kInitialUnpacedBurst)); | 883 kInitialUnpacedBurst)); |
879 } | 884 } |
880 | 885 |
881 } // namespace net | 886 } // namespace net |
OLD | NEW |