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

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

Issue 76723002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compilation error Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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/quic_connection.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 284
285 return false; 285 return false;
286 } 286 }
287 287
288 void QuicConnection::OnError(QuicFramer* framer) { 288 void QuicConnection::OnError(QuicFramer* framer) {
289 // Packets that we cannot decrypt are dropped. 289 // Packets that we cannot decrypt are dropped.
290 // TODO(rch): add stats to measure this. 290 // TODO(rch): add stats to measure this.
291 if (!connected_ || framer->error() == QUIC_DECRYPTION_FAILURE) { 291 if (!connected_ || framer->error() == QUIC_DECRYPTION_FAILURE) {
292 return; 292 return;
293 } 293 }
294 SendConnectionClose(framer->error()); 294 SendConnectionCloseWithDetails(framer->error(), framer->detailed_error());
295 } 295 }
296 296
297 void QuicConnection::OnPacket() { 297 void QuicConnection::OnPacket() {
298 DCHECK(last_stream_frames_.empty() && 298 DCHECK(last_stream_frames_.empty() &&
299 last_goaway_frames_.empty() && 299 last_goaway_frames_.empty() &&
300 last_rst_frames_.empty() && 300 last_rst_frames_.empty() &&
301 last_ack_frames_.empty() && 301 last_ack_frames_.empty() &&
302 last_congestion_frames_.empty()); 302 last_congestion_frames_.empty());
303 } 303 }
304 304
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 sent_packet_manager_.OnIncomingAck(incoming_ack.received_info, 542 sent_packet_manager_.OnIncomingAck(incoming_ack.received_info,
543 received_truncated_ack_); 543 received_truncated_ack_);
544 544
545 // Get the updated least unacked sequence number. 545 // Get the updated least unacked sequence number.
546 QuicPacketSequenceNumber least_unacked_sent_after = 546 QuicPacketSequenceNumber least_unacked_sent_after =
547 sent_packet_manager_.GetLeastUnackedSentPacket(); 547 sent_packet_manager_.GetLeastUnackedSentPacket();
548 548
549 // Used to set RTO and FEC alarms. 549 // Used to set RTO and FEC alarms.
550 QuicTime::Delta retransmission_delay = 550 QuicTime::Delta retransmission_delay =
551 congestion_manager_.GetRetransmissionDelay( 551 congestion_manager_.GetRetransmissionDelay(
552 sent_packet_manager_.GetNumUnackedPackets(), 0); 552 sent_packet_manager_.GetNumRetransmittablePackets(), 0);
553 553
554 // If there are outstanding packets, and the least unacked sequence number 554 // If there are outstanding packets, and the least unacked sequence number
555 // has increased after processing this latest AckFrame, then reschedule the 555 // has increased after processing this latest AckFrame, then reschedule the
556 // retransmission timer. 556 // retransmission timer.
557 if (sent_packet_manager_.HasUnackedPackets() && 557 if (sent_packet_manager_.HasUnackedPackets() &&
558 least_unacked_sent_before < least_unacked_sent_after) { 558 least_unacked_sent_before < least_unacked_sent_after) {
559 if (retransmission_alarm_->IsSet()) { 559 if (retransmission_alarm_->IsSet()) {
560 retransmission_alarm_->Cancel(); 560 retransmission_alarm_->Cancel();
561 } 561 }
562 retransmission_alarm_->Set( 562 retransmission_alarm_->Set(
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 } 1192 }
1193 1193
1194 // Do not set the retransmission alarm if we're already handling one, since 1194 // Do not set the retransmission alarm if we're already handling one, since
1195 // it will be reset when OnRetransmissionTimeout completes. 1195 // it will be reset when OnRetransmissionTimeout completes.
1196 if (retransmission_alarm_->IsSet()) { 1196 if (retransmission_alarm_->IsSet()) {
1197 return; 1197 return;
1198 } 1198 }
1199 1199
1200 QuicTime::Delta retransmission_delay = 1200 QuicTime::Delta retransmission_delay =
1201 congestion_manager_.GetRetransmissionDelay( 1201 congestion_manager_.GetRetransmissionDelay(
1202 sent_packet_manager_.GetNumUnackedPackets(), consecutive_rto_count_); 1202 sent_packet_manager_.GetNumRetransmittablePackets(),
1203 consecutive_rto_count_);
1203 retransmission_alarm_->Set( 1204 retransmission_alarm_->Set(
1204 clock_->ApproximateNow().Add(retransmission_delay)); 1205 clock_->ApproximateNow().Add(retransmission_delay));
1205 } 1206 }
1206 1207
1207 void QuicConnection::SetupAbandonFecTimer( 1208 void QuicConnection::SetupAbandonFecTimer(
1208 QuicPacketSequenceNumber sequence_number) { 1209 QuicPacketSequenceNumber sequence_number) {
1209 if (abandon_fec_alarm_->IsSet()) { 1210 if (abandon_fec_alarm_->IsSet()) {
1210 return; 1211 return;
1211 } 1212 }
1212 QuicTime::Delta retransmission_delay = 1213 QuicTime::Delta retransmission_delay =
1213 congestion_manager_.GetRetransmissionDelay( 1214 congestion_manager_.GetRetransmissionDelay(
1214 sent_packet_manager_.GetNumUnackedPackets(), consecutive_rto_count_); 1215 sent_packet_manager_.GetNumRetransmittablePackets(),
1216 consecutive_rto_count_);
1215 abandon_fec_alarm_->Set(clock_->ApproximateNow().Add(retransmission_delay)); 1217 abandon_fec_alarm_->Set(clock_->ApproximateNow().Add(retransmission_delay));
1216 } 1218 }
1217 1219
1218 bool QuicConnection::WritePacket(EncryptionLevel level, 1220 bool QuicConnection::WritePacket(EncryptionLevel level,
1219 QuicPacketSequenceNumber sequence_number, 1221 QuicPacketSequenceNumber sequence_number,
1220 QuicPacket* packet, 1222 QuicPacket* packet,
1221 TransmissionType transmission_type, 1223 TransmissionType transmission_type,
1222 HasRetransmittableData retransmittable, 1224 HasRetransmittableData retransmittable,
1223 IsHandshake handshake, 1225 IsHandshake handshake,
1224 Force forced) { 1226 Force forced) {
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 if (!retransmission_alarm_->IsSet()) { 1555 if (!retransmission_alarm_->IsSet()) {
1554 WriteIfNotBlocked(); 1556 WriteIfNotBlocked();
1555 } 1557 }
1556 } 1558 }
1557 1559
1558 QuicTime QuicConnection::OnAbandonFecTimeout() { 1560 QuicTime QuicConnection::OnAbandonFecTimeout() {
1559 // Abandon all the FEC packets older than the current RTO, then reschedule 1561 // Abandon all the FEC packets older than the current RTO, then reschedule
1560 // the alarm if there are more pending fec packets. 1562 // the alarm if there are more pending fec packets.
1561 QuicTime::Delta retransmission_delay = 1563 QuicTime::Delta retransmission_delay =
1562 congestion_manager_.GetRetransmissionDelay( 1564 congestion_manager_.GetRetransmissionDelay(
1563 sent_packet_manager_.GetNumUnackedPackets(), consecutive_rto_count_); 1565 sent_packet_manager_.GetNumRetransmittablePackets(),
1566 consecutive_rto_count_);
1564 QuicTime max_send_time = 1567 QuicTime max_send_time =
1565 clock_->ApproximateNow().Subtract(retransmission_delay); 1568 clock_->ApproximateNow().Subtract(retransmission_delay);
1566 bool abandoned_packet = false; 1569 bool abandoned_packet = false;
1567 while (sent_packet_manager_.HasUnackedFecPackets()) { 1570 while (sent_packet_manager_.HasUnackedFecPackets()) {
1568 QuicPacketSequenceNumber oldest_unacked_fec = 1571 QuicPacketSequenceNumber oldest_unacked_fec =
1569 sent_packet_manager_.GetLeastUnackedFecPacket(); 1572 sent_packet_manager_.GetLeastUnackedFecPacket();
1570 QuicTime fec_sent_time = 1573 QuicTime fec_sent_time =
1571 sent_packet_manager_.GetFecSentTime(oldest_unacked_fec); 1574 sent_packet_manager_.GetFecSentTime(oldest_unacked_fec);
1572 if (fec_sent_time > max_send_time) { 1575 if (fec_sent_time > max_send_time) {
1573 return fec_sent_time.Add(retransmission_delay); 1576 return fec_sent_time.Add(retransmission_delay);
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1851 QuicConnection* connection, 1854 QuicConnection* connection,
1852 bool include_ack) 1855 bool include_ack)
1853 : connection_(connection), 1856 : connection_(connection),
1854 already_in_batch_mode_(connection->packet_generator_.InBatchMode()) { 1857 already_in_batch_mode_(connection->packet_generator_.InBatchMode()) {
1855 // Move generator into batch mode. If caller wants us to include an ack, 1858 // Move generator into batch mode. If caller wants us to include an ack,
1856 // check the delayed-ack timer to see if there's ack info to be sent. 1859 // check the delayed-ack timer to see if there's ack info to be sent.
1857 if (!already_in_batch_mode_) { 1860 if (!already_in_batch_mode_) {
1858 DVLOG(1) << "Entering Batch Mode."; 1861 DVLOG(1) << "Entering Batch Mode.";
1859 connection_->packet_generator_.StartBatchOperations(); 1862 connection_->packet_generator_.StartBatchOperations();
1860 } 1863 }
1861 if (FLAGS_bundle_ack_with_outgoing_packet && 1864 if (include_ack && connection_->ack_alarm_->IsSet()) {
1862 include_ack && connection_->ack_alarm_->IsSet()) {
1863 DVLOG(1) << "Bundling ack with outgoing packet."; 1865 DVLOG(1) << "Bundling ack with outgoing packet.";
1864 connection_->SendAck(); 1866 connection_->SendAck();
1865 } 1867 }
1866 } 1868 }
1867 1869
1868 QuicConnection::ScopedPacketBundler::~ScopedPacketBundler() { 1870 QuicConnection::ScopedPacketBundler::~ScopedPacketBundler() {
1869 // If we changed the generator's batch state, restore original batch state. 1871 // If we changed the generator's batch state, restore original batch state.
1870 if (!already_in_batch_mode_) { 1872 if (!already_in_batch_mode_) {
1871 DVLOG(1) << "Leaving Batch Mode."; 1873 DVLOG(1) << "Leaving Batch Mode.";
1872 connection_->packet_generator_.FinishBatchOperations(); 1874 connection_->packet_generator_.FinishBatchOperations();
1873 } 1875 }
1874 DCHECK_EQ(already_in_batch_mode_, 1876 DCHECK_EQ(already_in_batch_mode_,
1875 connection_->packet_generator_.InBatchMode()); 1877 connection_->packet_generator_.InBatchMode());
1876 } 1878 }
1877 1879
1878 } // namespace net 1880 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/send_algorithm_interface.cc ('k') | net/quic/quic_connection_helper_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698