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

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

Issue 908623002: Revert of Landing Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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_connection.h ('k') | net/quic/quic_dispatcher.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 (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 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 QuicFrame(new QuicWindowUpdateFrame(id, byte_offset))); 1116 QuicFrame(new QuicWindowUpdateFrame(id, byte_offset)));
1117 } 1117 }
1118 1118
1119 void QuicConnection::SendBlocked(QuicStreamId id) { 1119 void QuicConnection::SendBlocked(QuicStreamId id) {
1120 // Opportunistically bundle an ack with this outgoing packet. 1120 // Opportunistically bundle an ack with this outgoing packet.
1121 ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK); 1121 ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK);
1122 packet_generator_.AddControlFrame(QuicFrame(new QuicBlockedFrame(id))); 1122 packet_generator_.AddControlFrame(QuicFrame(new QuicBlockedFrame(id)));
1123 } 1123 }
1124 1124
1125 const QuicConnectionStats& QuicConnection::GetStats() { 1125 const QuicConnectionStats& QuicConnection::GetStats() {
1126 const RttStats* rtt_stats = sent_packet_manager_.GetRttStats(); 1126 if (!FLAGS_quic_use_initial_rtt_for_stats) {
1127 stats_.min_rtt_us =
1128 sent_packet_manager_.GetRttStats()->min_rtt().ToMicroseconds();
1129 stats_.srtt_us =
1130 sent_packet_manager_.GetRttStats()->smoothed_rtt().ToMicroseconds();
1131 } else {
1132 const RttStats* rtt_stats = sent_packet_manager_.GetRttStats();
1127 1133
1128 // Update rtt and estimated bandwidth. 1134 // Update rtt and estimated bandwidth.
1129 QuicTime::Delta min_rtt = rtt_stats->min_rtt(); 1135 QuicTime::Delta min_rtt = rtt_stats->min_rtt();
1130 if (min_rtt.IsZero()) { 1136 if (min_rtt.IsZero()) {
1131 // If min RTT has not been set, use initial RTT instead. 1137 // If min RTT has not been set, use initial RTT instead.
1132 min_rtt = QuicTime::Delta::FromMicroseconds(rtt_stats->initial_rtt_us()); 1138 min_rtt = QuicTime::Delta::FromMicroseconds(rtt_stats->initial_rtt_us());
1139 }
1140 stats_.min_rtt_us = min_rtt.ToMicroseconds();
1141
1142 QuicTime::Delta srtt = rtt_stats->smoothed_rtt();
1143 if (srtt.IsZero()) {
1144 // If SRTT has not been set, use initial RTT instead.
1145 srtt = QuicTime::Delta::FromMicroseconds(rtt_stats->initial_rtt_us());
1146 }
1147 stats_.srtt_us = srtt.ToMicroseconds();
1133 } 1148 }
1134 stats_.min_rtt_us = min_rtt.ToMicroseconds();
1135
1136 QuicTime::Delta srtt = rtt_stats->smoothed_rtt();
1137 if (srtt.IsZero()) {
1138 // If SRTT has not been set, use initial RTT instead.
1139 srtt = QuicTime::Delta::FromMicroseconds(rtt_stats->initial_rtt_us());
1140 }
1141 stats_.srtt_us = srtt.ToMicroseconds();
1142 1149
1143 stats_.estimated_bandwidth = sent_packet_manager_.BandwidthEstimate(); 1150 stats_.estimated_bandwidth = sent_packet_manager_.BandwidthEstimate();
1144 stats_.max_packet_size = packet_generator_.max_packet_length(); 1151 stats_.max_packet_size = packet_generator_.max_packet_length();
1145 return stats_; 1152 return stats_;
1146 } 1153 }
1147 1154
1148 void QuicConnection::ProcessUdpPacket(const IPEndPoint& self_address, 1155 void QuicConnection::ProcessUdpPacket(const IPEndPoint& self_address,
1149 const IPEndPoint& peer_address, 1156 const IPEndPoint& peer_address,
1150 const QuicEncryptedPacket& packet) { 1157 const QuicEncryptedPacket& packet) {
1151 if (!connected_) { 1158 if (!connected_) {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 packet->serialized_packet.packet = nullptr; 1396 packet->serialized_packet.packet = nullptr;
1390 return true; 1397 return true;
1391 } 1398 }
1392 1399
1393 bool QuicConnection::WritePacketInner(QueuedPacket* packet) { 1400 bool QuicConnection::WritePacketInner(QueuedPacket* packet) {
1394 if (ShouldDiscardPacket(*packet)) { 1401 if (ShouldDiscardPacket(*packet)) {
1395 ++stats_.packets_discarded; 1402 ++stats_.packets_discarded;
1396 return true; 1403 return true;
1397 } 1404 }
1398 // Connection close packets are encrypted and saved, so don't exit early. 1405 // Connection close packets are encrypted and saved, so don't exit early.
1399 const bool is_connection_close = IsConnectionClose(*packet); 1406 if (writer_->IsWriteBlocked() && !IsConnectionClose(*packet)) {
1400 if (writer_->IsWriteBlocked() && !is_connection_close) {
1401 return false; 1407 return false;
1402 } 1408 }
1403 1409
1404 QuicPacketSequenceNumber sequence_number = 1410 QuicPacketSequenceNumber sequence_number =
1405 packet->serialized_packet.sequence_number; 1411 packet->serialized_packet.sequence_number;
1406 DCHECK_LE(sequence_number_of_last_sent_packet_, sequence_number); 1412 DCHECK_LE(sequence_number_of_last_sent_packet_, sequence_number);
1407 sequence_number_of_last_sent_packet_ = sequence_number; 1413 sequence_number_of_last_sent_packet_ = sequence_number;
1408 1414
1409 QuicEncryptedPacket* encrypted = framer_.EncryptPacket( 1415 QuicEncryptedPacket* encrypted = framer_.EncryptPacket(
1410 packet->encryption_level, 1416 packet->encryption_level,
1411 sequence_number, 1417 sequence_number,
1412 *packet->serialized_packet.packet); 1418 *packet->serialized_packet.packet);
1413 if (encrypted == nullptr) { 1419 if (encrypted == nullptr) {
1414 LOG(DFATAL) << ENDPOINT << "Failed to encrypt packet number " 1420 LOG(DFATAL) << ENDPOINT << "Failed to encrypt packet number "
1415 << sequence_number; 1421 << sequence_number;
1416 // CloseConnection does not send close packet, so no infinite loop here. 1422 // CloseConnection does not send close packet, so no infinite loop here.
1417 CloseConnection(QUIC_ENCRYPTION_FAILURE, false); 1423 CloseConnection(QUIC_ENCRYPTION_FAILURE, false);
1418 return false; 1424 return false;
1419 } 1425 }
1420 1426
1421 // Connection close packets are eventually owned by TimeWaitListManager. 1427 // Connection close packets are eventually owned by TimeWaitListManager.
1422 // Others are deleted at the end of this call. 1428 // Others are deleted at the end of this call.
1423 scoped_ptr<QuicEncryptedPacket> encrypted_deleter; 1429 scoped_ptr<QuicEncryptedPacket> encrypted_deleter;
1424 if (is_connection_close) { 1430 if (IsConnectionClose(*packet)) {
1425 DCHECK(connection_close_packet_.get() == nullptr); 1431 DCHECK(connection_close_packet_.get() == nullptr);
1426 connection_close_packet_.reset(encrypted); 1432 connection_close_packet_.reset(encrypted);
1427 // This assures we won't try to write *forced* packets when blocked. 1433 // This assures we won't try to write *forced* packets when blocked.
1428 // Return true to stop processing. 1434 // Return true to stop processing.
1429 if (writer_->IsWriteBlocked()) { 1435 if (writer_->IsWriteBlocked()) {
1430 visitor_->OnWriteBlocked(); 1436 visitor_->OnWriteBlocked();
1431 return true; 1437 return true;
1432 } 1438 }
1433 } else { 1439 } else {
1434 encrypted_deleter.reset(encrypted); 1440 encrypted_deleter.reset(encrypted);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 1535
1530 stats_.bytes_sent += result.bytes_written; 1536 stats_.bytes_sent += result.bytes_written;
1531 ++stats_.packets_sent; 1537 ++stats_.packets_sent;
1532 if (packet->transmission_type != NOT_RETRANSMISSION) { 1538 if (packet->transmission_type != NOT_RETRANSMISSION) {
1533 stats_.bytes_retransmitted += result.bytes_written; 1539 stats_.bytes_retransmitted += result.bytes_written;
1534 ++stats_.packets_retransmitted; 1540 ++stats_.packets_retransmitted;
1535 } 1541 }
1536 1542
1537 if (result.status == WRITE_STATUS_ERROR) { 1543 if (result.status == WRITE_STATUS_ERROR) {
1538 OnWriteError(result.error_code); 1544 OnWriteError(result.error_code);
1539 DLOG(ERROR) << ENDPOINT << "failed writing " << encrypted->length()
1540 << "bytes "
1541 << " from host " << self_address().ToStringWithoutPort()
1542 << " to address " << peer_address().ToString();
1543 return false; 1545 return false;
1544 } 1546 }
1545 1547
1546 return true; 1548 return true;
1547 } 1549 }
1548 1550
1549 bool QuicConnection::ShouldDiscardPacket(const QueuedPacket& packet) { 1551 bool QuicConnection::ShouldDiscardPacket(const QueuedPacket& packet) {
1550 if (!connected_) { 1552 if (!connected_) {
1551 DVLOG(1) << ENDPOINT 1553 DVLOG(1) << ENDPOINT
1552 << "Not sending packet as connection is disconnected."; 1554 << "Not sending packet as connection is disconnected.";
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 // Retransmitted packets retransmittable frames are owned by the unacked 2097 // Retransmitted packets retransmittable frames are owned by the unacked
2096 // packet map, but are not present in the serialized packet. 2098 // packet map, but are not present in the serialized packet.
2097 if (packet.transmission_type != NOT_RETRANSMISSION || 2099 if (packet.transmission_type != NOT_RETRANSMISSION ||
2098 packet.serialized_packet.retransmittable_frames != nullptr) { 2100 packet.serialized_packet.retransmittable_frames != nullptr) {
2099 return HAS_RETRANSMITTABLE_DATA; 2101 return HAS_RETRANSMITTABLE_DATA;
2100 } else { 2102 } else {
2101 return NO_RETRANSMITTABLE_DATA; 2103 return NO_RETRANSMITTABLE_DATA;
2102 } 2104 }
2103 } 2105 }
2104 2106
2105 bool QuicConnection::IsConnectionClose(const QueuedPacket& packet) { 2107 bool QuicConnection::IsConnectionClose(
2106 const RetransmittableFrames* retransmittable_frames = 2108 QueuedPacket packet) {
2109 RetransmittableFrames* retransmittable_frames =
2107 packet.serialized_packet.retransmittable_frames; 2110 packet.serialized_packet.retransmittable_frames;
2108 if (retransmittable_frames == nullptr) { 2111 if (!retransmittable_frames) {
2109 return false; 2112 return false;
2110 } 2113 }
2111 for (const QuicFrame& frame : retransmittable_frames->frames()) { 2114 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) {
2112 if (frame.type == CONNECTION_CLOSE_FRAME) { 2115 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) {
2113 return true; 2116 return true;
2114 } 2117 }
2115 } 2118 }
2116 return false; 2119 return false;
2117 } 2120 }
2118 2121
2119 } // namespace net 2122 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698