Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(775)

Side by Side Diff: net/quic/quic_sent_packet_manager.cc

Issue 605163004: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0925
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_sent_packet_manager.h ('k') | net/quic/quic_sent_packet_manager_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
110 QuicTime::Delta::FromSeconds(FLAGS_quic_recent_min_rtt_window_s)); 110 QuicTime::Delta::FromSeconds(FLAGS_quic_recent_min_rtt_window_s));
111 } 111 }
112 send_algorithm_.reset( 112 send_algorithm_.reset(
113 SendAlgorithmInterface::Create(clock_, &rtt_stats_, kBBR, stats_)); 113 SendAlgorithmInterface::Create(clock_, &rtt_stats_, kBBR, stats_));
114 } 114 }
115 if (config.HasReceivedConnectionOptions() && 115 if (config.HasReceivedConnectionOptions() &&
116 ContainsQuicTag(config.ReceivedConnectionOptions(), kRENO)) { 116 ContainsQuicTag(config.ReceivedConnectionOptions(), kRENO)) {
117 send_algorithm_.reset( 117 send_algorithm_.reset(
118 SendAlgorithmInterface::Create(clock_, &rtt_stats_, kReno, stats_)); 118 SendAlgorithmInterface::Create(clock_, &rtt_stats_, kReno, stats_));
119 } 119 }
120 if (is_server_) { 120 if (HasClientSentConnectionOption(config, kPACE)) {
121 if (config.HasReceivedConnectionOptions() &&
122 ContainsQuicTag(config.ReceivedConnectionOptions(), kPACE)) {
123 EnablePacing();
124 }
125 } else if (config.HasSendConnectionOptions() &&
126 ContainsQuicTag(config.SendConnectionOptions(), kPACE)) {
127 EnablePacing(); 121 EnablePacing();
128 } 122 }
129 // TODO(ianswett): Remove the "HasReceivedLossDetection" branch once 123 if (HasClientSentConnectionOption(config, k1CON)) {
130 // the ConnectionOptions code is live everywhere. 124 send_algorithm_->SetNumEmulatedConnections(1);
125 }
131 if (config.HasReceivedConnectionOptions() && 126 if (config.HasReceivedConnectionOptions() &&
132 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { 127 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) {
133 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); 128 loss_algorithm_.reset(LossDetectionInterface::Create(kTime));
134 } 129 }
135 send_algorithm_->SetFromConfig(config, is_server_); 130 send_algorithm_->SetFromConfig(config, is_server_);
136 131
137 if (network_change_visitor_ != NULL) { 132 if (network_change_visitor_ != NULL) {
138 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); 133 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow());
139 } 134 }
140 } 135 }
141 136
142 // TODO(ianswett): Combine this method with OnPacketSent once packets are always 137 bool QuicSentPacketManager::HasClientSentConnectionOption(
143 // sent in order and the connection tracks RetransmittableFrames for longer. 138 const QuicConfig& config, QuicTag tag) const {
144 void QuicSentPacketManager::OnSerializedPacket( 139 if (is_server_) {
145 const SerializedPacket& serialized_packet) { 140 if (config.HasReceivedConnectionOptions() &&
146 if (serialized_packet.retransmittable_frames) { 141 ContainsQuicTag(config.ReceivedConnectionOptions(), tag)) {
147 ack_notifier_manager_.OnSerializedPacket(serialized_packet); 142 return true;
143 }
144 } else if (config.HasSendConnectionOptions() &&
145 ContainsQuicTag(config.SendConnectionOptions(), tag)) {
146 return true;
148 } 147 }
149 unacked_packets_.AddPacket(serialized_packet); 148 return false;
150
151 if (debug_delegate_ != NULL) {
152 // TODO(ianswett): Merge calls in the debug delegate.
153 debug_delegate_->OnSerializedPacket(serialized_packet);
154 }
155 } 149 }
156 150
157 void QuicSentPacketManager::OnRetransmittedPacket( 151 void QuicSentPacketManager::OnRetransmittedPacket(
158 QuicPacketSequenceNumber old_sequence_number, 152 QuicPacketSequenceNumber old_sequence_number,
159 QuicPacketSequenceNumber new_sequence_number) { 153 QuicPacketSequenceNumber new_sequence_number) {
160 TransmissionType transmission_type; 154 TransmissionType transmission_type;
161 PendingRetransmissionMap::iterator it = 155 PendingRetransmissionMap::iterator it =
162 pending_retransmissions_.find(old_sequence_number); 156 pending_retransmissions_.find(old_sequence_number);
163 if (it != pending_retransmissions_.end()) { 157 if (it != pending_retransmissions_.end()) {
164 transmission_type = it->second; 158 transmission_type = it->second;
165 pending_retransmissions_.erase(it); 159 pending_retransmissions_.erase(it);
166 } else { 160 } else {
167 DLOG(DFATAL) << "Expected sequence number to be in " 161 DLOG(DFATAL) << "Expected sequence number to be in "
168 "pending_retransmissions_. sequence_number: " << old_sequence_number; 162 "pending_retransmissions_. sequence_number: " << old_sequence_number;
169 transmission_type = NOT_RETRANSMISSION; 163 transmission_type = NOT_RETRANSMISSION;
170 } 164 }
171 165
172 // A notifier may be waiting to hear about ACKs for the original sequence 166 // A notifier may be waiting to hear about ACKs for the original sequence
173 // number. Inform them that the sequence number has changed. 167 // number. Inform them that the sequence number has changed.
174 ack_notifier_manager_.UpdateSequenceNumber(old_sequence_number, 168 ack_notifier_manager_.UpdateSequenceNumber(old_sequence_number,
175 new_sequence_number); 169 new_sequence_number);
176 170
177 unacked_packets_.OnRetransmittedPacket(old_sequence_number, 171 unacked_packets_.OnRetransmittedPacket(old_sequence_number,
178 new_sequence_number, 172 new_sequence_number,
179 transmission_type); 173 transmission_type);
180
181 if (debug_delegate_ != NULL) {
182 debug_delegate_->OnRetransmittedPacket(old_sequence_number,
183 new_sequence_number,
184 transmission_type,
185 clock_->ApproximateNow());
186 }
187 } 174 }
188 175
189 void QuicSentPacketManager::OnIncomingAck(const QuicAckFrame& ack_frame, 176 void QuicSentPacketManager::OnIncomingAck(const QuicAckFrame& ack_frame,
190 QuicTime ack_receive_time) { 177 QuicTime ack_receive_time) {
191 QuicByteCount bytes_in_flight = unacked_packets_.bytes_in_flight(); 178 QuicByteCount bytes_in_flight = unacked_packets_.bytes_in_flight();
192 179
193 UpdatePacketInformationReceivedByPeer(ack_frame); 180 UpdatePacketInformationReceivedByPeer(ack_frame);
194 // We rely on delta_time_largest_observed to compute an RTT estimate, so 181 // We rely on delta_time_largest_observed to compute an RTT estimate, so
195 // we only update rtt when the largest observed gets acked. 182 // we only update rtt when the largest observed gets acked.
196 bool largest_observed_acked = MaybeUpdateRTT(ack_frame, ack_receive_time); 183 bool largest_observed_acked = MaybeUpdateRTT(ack_frame, ack_receive_time);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 SerializedPacket* serialized_packet, 494 SerializedPacket* serialized_packet,
508 QuicPacketSequenceNumber original_sequence_number, 495 QuicPacketSequenceNumber original_sequence_number,
509 QuicTime sent_time, 496 QuicTime sent_time,
510 QuicByteCount bytes, 497 QuicByteCount bytes,
511 TransmissionType transmission_type, 498 TransmissionType transmission_type,
512 HasRetransmittableData has_retransmittable_data) { 499 HasRetransmittableData has_retransmittable_data) {
513 QuicPacketSequenceNumber sequence_number = serialized_packet->sequence_number; 500 QuicPacketSequenceNumber sequence_number = serialized_packet->sequence_number;
514 DCHECK_LT(0u, sequence_number); 501 DCHECK_LT(0u, sequence_number);
515 DCHECK(!unacked_packets_.IsUnacked(sequence_number)); 502 DCHECK(!unacked_packets_.IsUnacked(sequence_number));
516 LOG_IF(DFATAL, bytes == 0) << "Cannot send empty packets."; 503 LOG_IF(DFATAL, bytes == 0) << "Cannot send empty packets.";
504 if (debug_delegate_ != NULL) {
505 debug_delegate_->OnSentPacket(*serialized_packet,
506 original_sequence_number,
507 sent_time,
508 bytes,
509 transmission_type);
510 }
511
517 if (original_sequence_number == 0) { 512 if (original_sequence_number == 0) {
518 OnSerializedPacket(*serialized_packet); 513 if (serialized_packet->retransmittable_frames) {
514 ack_notifier_manager_.OnSerializedPacket(*serialized_packet);
515 }
516 unacked_packets_.AddPacket(*serialized_packet);
519 serialized_packet->retransmittable_frames = NULL; 517 serialized_packet->retransmittable_frames = NULL;
520 } else { 518 } else {
521 OnRetransmittedPacket(original_sequence_number, sequence_number); 519 OnRetransmittedPacket(original_sequence_number, sequence_number);
522 } 520 }
523 521
524 if (pending_timer_transmission_count_ > 0) { 522 if (pending_timer_transmission_count_ > 0) {
525 --pending_timer_transmission_count_; 523 --pending_timer_transmission_count_;
526 } 524 }
527 525
528 if (unacked_packets_.bytes_in_flight() == 0) { 526 if (unacked_packets_.bytes_in_flight() == 0) {
529 // TODO(ianswett): Consider being less aggressive to force a new 527 // TODO(ianswett): Consider being less aggressive to force a new
530 // recent_min_rtt, likely by not discarding a relatively new sample. 528 // recent_min_rtt, likely by not discarding a relatively new sample.
531 DVLOG(1) << "Sampling a new recent min rtt within 2 samples. currently:" 529 DVLOG(1) << "Sampling a new recent min rtt within 2 samples. currently:"
532 << rtt_stats_.recent_min_rtt().ToMilliseconds() << "ms"; 530 << rtt_stats_.recent_min_rtt().ToMilliseconds() << "ms";
533 rtt_stats_.SampleNewRecentMinRtt(kNumMinRttSamplesAfterQuiescence); 531 rtt_stats_.SampleNewRecentMinRtt(kNumMinRttSamplesAfterQuiescence);
534 } 532 }
535 533
536 // Only track packets as in flight that the send algorithm wants us to track. 534 // Only track packets as in flight that the send algorithm wants us to track.
537 const bool in_flight = 535 const bool in_flight =
538 send_algorithm_->OnPacketSent(sent_time, 536 send_algorithm_->OnPacketSent(sent_time,
539 unacked_packets_.bytes_in_flight(), 537 unacked_packets_.bytes_in_flight(),
540 sequence_number, 538 sequence_number,
541 bytes, 539 bytes,
542 has_retransmittable_data); 540 has_retransmittable_data);
543 unacked_packets_.SetSent(sequence_number, sent_time, bytes, in_flight); 541 unacked_packets_.SetSent(sequence_number, sent_time, bytes, in_flight);
544 542
545 if (debug_delegate_ != NULL) {
546 debug_delegate_->OnSentPacket(
547 sequence_number, sent_time, bytes, transmission_type);
548 }
549
550 // Reset the retransmission timer anytime a pending packet is sent. 543 // Reset the retransmission timer anytime a pending packet is sent.
551 return in_flight; 544 return in_flight;
552 } 545 }
553 546
554 void QuicSentPacketManager::OnRetransmissionTimeout() { 547 void QuicSentPacketManager::OnRetransmissionTimeout() {
555 DCHECK(unacked_packets_.HasInFlightPackets()); 548 DCHECK(unacked_packets_.HasInFlightPackets());
556 DCHECK_EQ(0u, pending_timer_transmission_count_); 549 DCHECK_EQ(0u, pending_timer_transmission_count_);
557 // Handshake retransmission, timer based loss detection, TLP, and RTO are 550 // Handshake retransmission, timer based loss detection, TLP, and RTO are
558 // implemented with a single alarm. The handshake alarm is set when the 551 // implemented with a single alarm. The handshake alarm is set when the
559 // handshake has not completed, the loss alarm is set when the loss detection 552 // handshake has not completed, the loss alarm is set when the loss detection
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 878
886 // Set up a pacing sender with a 5 millisecond alarm granularity. 879 // Set up a pacing sender with a 5 millisecond alarm granularity.
887 using_pacing_ = true; 880 using_pacing_ = true;
888 send_algorithm_.reset( 881 send_algorithm_.reset(
889 new PacingSender(send_algorithm_.release(), 882 new PacingSender(send_algorithm_.release(),
890 QuicTime::Delta::FromMilliseconds(5), 883 QuicTime::Delta::FromMilliseconds(5),
891 kInitialUnpacedBurst)); 884 kInitialUnpacedBurst));
892 } 885 }
893 886
894 } // namespace net 887 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager.h ('k') | net/quic/quic_sent_packet_manager_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698