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

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

Issue 667763003: Landing Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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_connection.h ('k') | net/quic/quic_connection_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 (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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 is_server), 189 is_server),
190 helper_(helper), 190 helper_(helper),
191 writer_(writer_factory.Create(this)), 191 writer_(writer_factory.Create(this)),
192 owns_writer_(owns_writer), 192 owns_writer_(owns_writer),
193 encryption_level_(ENCRYPTION_NONE), 193 encryption_level_(ENCRYPTION_NONE),
194 clock_(helper->GetClock()), 194 clock_(helper->GetClock()),
195 random_generator_(helper->GetRandomGenerator()), 195 random_generator_(helper->GetRandomGenerator()),
196 connection_id_(connection_id), 196 connection_id_(connection_id),
197 peer_address_(address), 197 peer_address_(address),
198 migrating_peer_port_(0), 198 migrating_peer_port_(0),
199 last_packet_decrypted_(false),
199 last_packet_revived_(false), 200 last_packet_revived_(false),
200 last_size_(0), 201 last_size_(0),
201 last_decrypted_packet_level_(ENCRYPTION_NONE), 202 last_decrypted_packet_level_(ENCRYPTION_NONE),
202 largest_seen_packet_with_ack_(0), 203 largest_seen_packet_with_ack_(0),
203 largest_seen_packet_with_stop_waiting_(0), 204 largest_seen_packet_with_stop_waiting_(0),
204 max_undecryptable_packets_(0), 205 max_undecryptable_packets_(0),
205 pending_version_negotiation_packet_(false), 206 pending_version_negotiation_packet_(false),
206 received_packet_manager_(&stats_), 207 received_packet_manager_(&stats_),
207 ack_queued_(false), 208 ack_queued_(false),
208 num_packets_received_since_last_ack_sent_(0), 209 num_packets_received_since_last_ack_sent_(0),
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 version) != available_versions.end()) { 285 version) != available_versions.end()) {
285 framer_.set_version(version); 286 framer_.set_version(version);
286 return true; 287 return true;
287 } 288 }
288 } 289 }
289 290
290 return false; 291 return false;
291 } 292 }
292 293
293 void QuicConnection::OnError(QuicFramer* framer) { 294 void QuicConnection::OnError(QuicFramer* framer) {
294 // Packets that we cannot decrypt are dropped. 295 // Packets that we can not or have not decrypted are dropped.
295 // TODO(rch): add stats to measure this. 296 // TODO(rch): add stats to measure this.
296 if (!connected_ || framer->error() == QUIC_DECRYPTION_FAILURE) { 297 if (FLAGS_quic_drop_junk_packets) {
297 return; 298 if (!connected_ || last_packet_decrypted_ == false) {
299 return;
300 }
301 } else {
302 if (!connected_ || framer->error() == QUIC_DECRYPTION_FAILURE) {
303 return;
304 }
298 } 305 }
299 SendConnectionCloseWithDetails(framer->error(), framer->detailed_error()); 306 SendConnectionCloseWithDetails(framer->error(), framer->detailed_error());
300 } 307 }
301 308
302 void QuicConnection::OnPacket() { 309 void QuicConnection::OnPacket() {
303 DCHECK(last_stream_frames_.empty() && 310 DCHECK(last_stream_frames_.empty() &&
304 last_ack_frames_.empty() && 311 last_ack_frames_.empty() &&
305 last_congestion_frames_.empty() && 312 last_congestion_frames_.empty() &&
306 last_stop_waiting_frames_.empty() && 313 last_stop_waiting_frames_.empty() &&
307 last_rst_frames_.empty() && 314 last_rst_frames_.empty() &&
308 last_goaway_frames_.empty() && 315 last_goaway_frames_.empty() &&
309 last_window_update_frames_.empty() && 316 last_window_update_frames_.empty() &&
310 last_blocked_frames_.empty() && 317 last_blocked_frames_.empty() &&
311 last_ping_frames_.empty() && 318 last_ping_frames_.empty() &&
312 last_close_frames_.empty()); 319 last_close_frames_.empty());
320 last_packet_decrypted_ = false;
321 last_packet_revived_ = false;
313 } 322 }
314 323
315 void QuicConnection::OnPublicResetPacket( 324 void QuicConnection::OnPublicResetPacket(
316 const QuicPublicResetPacket& packet) { 325 const QuicPublicResetPacket& packet) {
317 if (debug_visitor_.get() != nullptr) { 326 if (debug_visitor_.get() != nullptr) {
318 debug_visitor_->OnPublicResetPacket(packet); 327 debug_visitor_->OnPublicResetPacket(packet);
319 } 328 }
320 CloseConnection(QUIC_PUBLIC_RESET, true); 329 CloseConnection(QUIC_PUBLIC_RESET, true);
321 330
322 DVLOG(1) << ENDPOINT << "Connection " << connection_id() 331 DVLOG(1) << ENDPOINT << "Connection " << connection_id()
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 const QuicPacketPublicHeader& header) { 437 const QuicPacketPublicHeader& header) {
429 return true; 438 return true;
430 } 439 }
431 440
432 bool QuicConnection::OnUnauthenticatedHeader(const QuicPacketHeader& header) { 441 bool QuicConnection::OnUnauthenticatedHeader(const QuicPacketHeader& header) {
433 return true; 442 return true;
434 } 443 }
435 444
436 void QuicConnection::OnDecryptedPacket(EncryptionLevel level) { 445 void QuicConnection::OnDecryptedPacket(EncryptionLevel level) {
437 last_decrypted_packet_level_ = level; 446 last_decrypted_packet_level_ = level;
447 last_packet_decrypted_ = true;
438 } 448 }
439 449
440 bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) { 450 bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) {
441 if (debug_visitor_.get() != nullptr) { 451 if (debug_visitor_.get() != nullptr) {
442 debug_visitor_->OnPacketHeader(header); 452 debug_visitor_->OnPacketHeader(header);
443 } 453 }
444 454
445 if (!ProcessValidatedPacket()) { 455 if (!ProcessValidatedPacket()) {
446 return false; 456 return false;
447 } 457 }
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 1085
1076 void QuicConnection::SendBlocked(QuicStreamId id) { 1086 void QuicConnection::SendBlocked(QuicStreamId id) {
1077 // Opportunistically bundle an ack with this outgoing packet. 1087 // Opportunistically bundle an ack with this outgoing packet.
1078 ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK); 1088 ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK);
1079 packet_generator_.AddControlFrame(QuicFrame(new QuicBlockedFrame(id))); 1089 packet_generator_.AddControlFrame(QuicFrame(new QuicBlockedFrame(id)));
1080 } 1090 }
1081 1091
1082 const QuicConnectionStats& QuicConnection::GetStats() { 1092 const QuicConnectionStats& QuicConnection::GetStats() {
1083 // Update rtt and estimated bandwidth. 1093 // Update rtt and estimated bandwidth.
1084 stats_.min_rtt_us = 1094 stats_.min_rtt_us =
1085 sent_packet_manager_.GetRttStats()->min_rtt().ToMicroseconds(); 1095 sent_packet_manager_.GetRttStats()->MinRtt().ToMicroseconds();
1086 stats_.srtt_us = 1096 stats_.srtt_us =
1087 sent_packet_manager_.GetRttStats()->SmoothedRtt().ToMicroseconds(); 1097 sent_packet_manager_.GetRttStats()->SmoothedRtt().ToMicroseconds();
1088 stats_.estimated_bandwidth = 1098 stats_.estimated_bandwidth =
1089 sent_packet_manager_.BandwidthEstimate().ToBytesPerSecond(); 1099 sent_packet_manager_.BandwidthEstimate().ToBytesPerSecond();
1090 stats_.congestion_window = sent_packet_manager_.GetCongestionWindow(); 1100 stats_.congestion_window = sent_packet_manager_.GetCongestionWindow();
1091 stats_.slow_start_threshold = sent_packet_manager_.GetSlowStartThreshold(); 1101 stats_.slow_start_threshold = sent_packet_manager_.GetSlowStartThreshold();
1092 stats_.max_packet_size = packet_generator_.max_packet_length(); 1102 stats_.max_packet_size = packet_generator_.max_packet_length();
1093 return stats_; 1103 return stats_;
1094 } 1104 }
1095 1105
1096 void QuicConnection::ProcessUdpPacket(const IPEndPoint& self_address, 1106 void QuicConnection::ProcessUdpPacket(const IPEndPoint& self_address,
1097 const IPEndPoint& peer_address, 1107 const IPEndPoint& peer_address,
1098 const QuicEncryptedPacket& packet) { 1108 const QuicEncryptedPacket& packet) {
1099 if (!connected_) { 1109 if (!connected_) {
1100 return; 1110 return;
1101 } 1111 }
1102 if (debug_visitor_.get() != nullptr) { 1112 if (debug_visitor_.get() != nullptr) {
1103 debug_visitor_->OnPacketReceived(self_address, peer_address, packet); 1113 debug_visitor_->OnPacketReceived(self_address, peer_address, packet);
1104 } 1114 }
1105 last_packet_revived_ = false;
1106 last_size_ = packet.length(); 1115 last_size_ = packet.length();
1107 1116
1108 CheckForAddressMigration(self_address, peer_address); 1117 CheckForAddressMigration(self_address, peer_address);
1109 1118
1110 stats_.bytes_received += packet.length(); 1119 stats_.bytes_received += packet.length();
1111 ++stats_.packets_received; 1120 ++stats_.packets_received;
1112 1121
1113 if (!framer_.ProcessPacket(packet)) { 1122 if (!framer_.ProcessPacket(packet)) {
1114 // If we are unable to decrypt this packet, it might be 1123 // If we are unable to decrypt this packet, it might be
1115 // because the CHLO or SHLO packet was lost. 1124 // because the CHLO or SHLO packet was lost.
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 ++stats_.packets_revived; 1723 ++stats_.packets_revived;
1715 framer_.ProcessRevivedPacket(&revived_header, 1724 framer_.ProcessRevivedPacket(&revived_header,
1716 StringPiece(revived_payload, len)); 1725 StringPiece(revived_payload, len));
1717 } 1726 }
1718 1727
1719 QuicFecGroup* QuicConnection::GetFecGroup() { 1728 QuicFecGroup* QuicConnection::GetFecGroup() {
1720 QuicFecGroupNumber fec_group_num = last_header_.fec_group; 1729 QuicFecGroupNumber fec_group_num = last_header_.fec_group;
1721 if (fec_group_num == 0) { 1730 if (fec_group_num == 0) {
1722 return nullptr; 1731 return nullptr;
1723 } 1732 }
1724 if (group_map_.count(fec_group_num) == 0) { 1733 if (!ContainsKey(group_map_, fec_group_num)) {
1725 if (group_map_.size() >= kMaxFecGroups) { // Too many groups 1734 if (group_map_.size() >= kMaxFecGroups) { // Too many groups
1726 if (fec_group_num < group_map_.begin()->first) { 1735 if (fec_group_num < group_map_.begin()->first) {
1727 // The group being requested is a group we've seen before and deleted. 1736 // The group being requested is a group we've seen before and deleted.
1728 // Don't recreate it. 1737 // Don't recreate it.
1729 return nullptr; 1738 return nullptr;
1730 } 1739 }
1731 // Clear the lowest group number. 1740 // Clear the lowest group number.
1732 delete group_map_.begin()->second; 1741 delete group_map_.begin()->second;
1733 group_map_.erase(group_map_.begin()); 1742 group_map_.erase(group_map_.begin());
1734 } 1743 }
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 } 2040 }
2032 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { 2041 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) {
2033 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { 2042 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) {
2034 return true; 2043 return true;
2035 } 2044 }
2036 } 2045 }
2037 return false; 2046 return false;
2038 } 2047 }
2039 2048
2040 } // namespace net 2049 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698