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

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

Issue 159143007: Log QUIC public reset client address mismatch to a histogram. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Address review comments Created 6 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_connection_logger.h ('k') | net/quic/quic_crypto_client_stream_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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_connection_logger.h" 5 #include "net/quic/quic_connection_logger.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/sparse_histogram.h" 10 #include "base/metrics/sparse_histogram.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "net/base/net_log.h" 13 #include "net/base/net_log.h"
14 #include "net/quic/crypto/crypto_handshake_message.h" 14 #include "net/quic/crypto/crypto_handshake_message.h"
15 #include "net/quic/crypto/crypto_protocol.h"
16 #include "net/quic/quic_socket_address_coder.h"
15 17
18 using base::StringPiece;
16 using std::string; 19 using std::string;
17 20
18 namespace net { 21 namespace net {
19 22
20 namespace { 23 namespace {
21 24
22 base::Value* NetLogQuicPacketCallback(const IPEndPoint* self_address, 25 base::Value* NetLogQuicPacketCallback(const IPEndPoint* self_address,
23 const IPEndPoint* peer_address, 26 const IPEndPoint* peer_address,
24 size_t packet_size, 27 size_t packet_size,
25 NetLog::LogLevel /* log_level */) { 28 NetLog::LogLevel /* log_level */) {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 dict->SetInteger("quic_error", error); 191 dict->SetInteger("quic_error", error);
189 dict->SetBoolean("from_peer", from_peer); 192 dict->SetBoolean("from_peer", from_peer);
190 return dict; 193 return dict;
191 } 194 }
192 195
193 void UpdatePacketGapSentHistogram(size_t num_consecutive_missing_packets) { 196 void UpdatePacketGapSentHistogram(size_t num_consecutive_missing_packets) {
194 UMA_HISTOGRAM_COUNTS("Net.QuicSession.PacketGapSent", 197 UMA_HISTOGRAM_COUNTS("Net.QuicSession.PacketGapSent",
195 num_consecutive_missing_packets); 198 num_consecutive_missing_packets);
196 } 199 }
197 200
201 void UpdatePublicResetAddressMismatchHistogram(
202 const IPEndPoint& server_hello_address,
203 const IPEndPoint& public_reset_address) {
204 enum {
205 // The addresses don't match.
206 kAddressMismatch_base = 0,
207 kAddressMismatch_v4_v4 = 0,
208 kAddressMismatch_v6_v6 = 1,
209 kAddressMismatch_v4_v6 = 2,
210 kAddressMismatch_v6_v4 = 3,
211
212 // The addresses match, but the ports don't match.
213 kPortMismatch_base = 4,
214 kPortMismatch_v4_v4 = 4,
215 kPortMismatch_v6_v6 = 5,
216
217 kAddressAndPortMatch_base = 6,
218 kAddressAndPortMatch_v4_v4 = 6,
219 kAddressAndPortMatch_v6_v6 = 7,
220
221 kBoundaryValue,
222 };
223
224 // We are seemingly talking to an older server that does not support the
225 // feature, so we can't report the results in the histogram.
226 if (server_hello_address.address().empty() ||
227 public_reset_address.address().empty()) {
228 return;
229 }
230
231 int sample;
232 if (server_hello_address.address() != public_reset_address.address()) {
233 sample = kAddressMismatch_base;
234 } else if (server_hello_address.port() != public_reset_address.port()) {
235 sample = kPortMismatch_base;
236 } else {
237 sample = kAddressAndPortMatch_base;
238 }
239
240 // Add an offset to |sample|:
241 // v4_v4: add 0
242 // v6_v6: add 1
243 // v4_v6: add 2
244 // v6_v4: add 3
245 bool first_ipv4 =
246 (server_hello_address.address().size() == kIPv4AddressSize);
247 bool second_ipv4 =
248 (public_reset_address.address().size() == kIPv4AddressSize);
249 if (first_ipv4 != second_ipv4) {
250 CHECK_EQ(sample, kAddressMismatch_base);
251 sample += 2;
252 }
253 if (!first_ipv4) {
254 sample += 1;
255 }
256 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.PublicResetAddressMismatch",
257 sample, kBoundaryValue);
258 }
259
198 } // namespace 260 } // namespace
199 261
200 QuicConnectionLogger::QuicConnectionLogger(const BoundNetLog& net_log) 262 QuicConnectionLogger::QuicConnectionLogger(const BoundNetLog& net_log)
201 : net_log_(net_log), 263 : net_log_(net_log),
202 last_received_packet_sequence_number_(0), 264 last_received_packet_sequence_number_(0),
203 largest_received_packet_sequence_number_(0), 265 largest_received_packet_sequence_number_(0),
204 largest_received_missing_packet_sequence_number_(0), 266 largest_received_missing_packet_sequence_number_(0),
205 out_of_order_recieved_packet_count_(0), 267 out_of_order_recieved_packet_count_(0),
206 num_truncated_acks_sent_(0), 268 num_truncated_acks_sent_(0),
207 num_truncated_acks_received_(0) { 269 num_truncated_acks_received_(0) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 void QuicConnectionLogger::OnConnectionCloseFrame( 448 void QuicConnectionLogger::OnConnectionCloseFrame(
387 const QuicConnectionCloseFrame& frame) { 449 const QuicConnectionCloseFrame& frame) {
388 net_log_.AddEvent( 450 net_log_.AddEvent(
389 NetLog::TYPE_QUIC_SESSION_CONNECTION_CLOSE_FRAME_RECEIVED, 451 NetLog::TYPE_QUIC_SESSION_CONNECTION_CLOSE_FRAME_RECEIVED,
390 base::Bind(&NetLogQuicConnectionCloseFrameCallback, &frame)); 452 base::Bind(&NetLogQuicConnectionCloseFrameCallback, &frame));
391 } 453 }
392 454
393 void QuicConnectionLogger::OnPublicResetPacket( 455 void QuicConnectionLogger::OnPublicResetPacket(
394 const QuicPublicResetPacket& packet) { 456 const QuicPublicResetPacket& packet) {
395 net_log_.AddEvent(NetLog::TYPE_QUIC_SESSION_PUBLIC_RESET_PACKET_RECEIVED); 457 net_log_.AddEvent(NetLog::TYPE_QUIC_SESSION_PUBLIC_RESET_PACKET_RECEIVED);
458 UpdatePublicResetAddressMismatchHistogram(client_address_,
459 packet.client_address);
396 } 460 }
397 461
398 void QuicConnectionLogger::OnVersionNegotiationPacket( 462 void QuicConnectionLogger::OnVersionNegotiationPacket(
399 const QuicVersionNegotiationPacket& packet) { 463 const QuicVersionNegotiationPacket& packet) {
400 net_log_.AddEvent( 464 net_log_.AddEvent(
401 NetLog::TYPE_QUIC_SESSION_VERSION_NEGOTIATION_PACKET_RECEIVED, 465 NetLog::TYPE_QUIC_SESSION_VERSION_NEGOTIATION_PACKET_RECEIVED,
402 base::Bind(&NetLogQuicVersionNegotiationPacketCallback, &packet)); 466 base::Bind(&NetLogQuicVersionNegotiationPacketCallback, &packet));
403 } 467 }
404 468
405 void QuicConnectionLogger::OnRevivedPacket( 469 void QuicConnectionLogger::OnRevivedPacket(
406 const QuicPacketHeader& revived_header, 470 const QuicPacketHeader& revived_header,
407 base::StringPiece payload) { 471 base::StringPiece payload) {
408 net_log_.AddEvent( 472 net_log_.AddEvent(
409 NetLog::TYPE_QUIC_SESSION_PACKET_HEADER_REVIVED, 473 NetLog::TYPE_QUIC_SESSION_PACKET_HEADER_REVIVED,
410 base::Bind(&NetLogQuicPacketHeaderCallback, &revived_header)); 474 base::Bind(&NetLogQuicPacketHeaderCallback, &revived_header));
411 } 475 }
412 476
413 void QuicConnectionLogger::OnCryptoHandshakeMessageReceived( 477 void QuicConnectionLogger::OnCryptoHandshakeMessageReceived(
414 const CryptoHandshakeMessage& message) { 478 const CryptoHandshakeMessage& message) {
415 net_log_.AddEvent( 479 net_log_.AddEvent(
416 NetLog::TYPE_QUIC_SESSION_CRYPTO_HANDSHAKE_MESSAGE_RECEIVED, 480 NetLog::TYPE_QUIC_SESSION_CRYPTO_HANDSHAKE_MESSAGE_RECEIVED,
417 base::Bind(&NetLogQuicCryptoHandshakeMessageCallback, &message)); 481 base::Bind(&NetLogQuicCryptoHandshakeMessageCallback, &message));
482
483 if (message.tag() == kSHLO) {
484 StringPiece address;
485 QuicSocketAddressCoder decoder;
486 if (message.GetStringPiece(kCADR, &address) &&
487 decoder.Decode(address.data(), address.size())) {
488 client_address_ = IPEndPoint(decoder.ip(), decoder.port());
489 }
490 }
418 } 491 }
419 492
420 void QuicConnectionLogger::OnCryptoHandshakeMessageSent( 493 void QuicConnectionLogger::OnCryptoHandshakeMessageSent(
421 const CryptoHandshakeMessage& message) { 494 const CryptoHandshakeMessage& message) {
422 net_log_.AddEvent( 495 net_log_.AddEvent(
423 NetLog::TYPE_QUIC_SESSION_CRYPTO_HANDSHAKE_MESSAGE_SENT, 496 NetLog::TYPE_QUIC_SESSION_CRYPTO_HANDSHAKE_MESSAGE_SENT,
424 base::Bind(&NetLogQuicCryptoHandshakeMessageCallback, &message)); 497 base::Bind(&NetLogQuicCryptoHandshakeMessageCallback, &message));
425 } 498 }
426 499
427 void QuicConnectionLogger::OnConnectionClosed(QuicErrorCode error, 500 void QuicConnectionLogger::OnConnectionClosed(QuicErrorCode error,
428 bool from_peer) { 501 bool from_peer) {
429 net_log_.AddEvent( 502 net_log_.AddEvent(
430 NetLog::TYPE_QUIC_SESSION_CLOSED, 503 NetLog::TYPE_QUIC_SESSION_CLOSED,
431 base::Bind(&NetLogQuicOnConnectionClosedCallback, error, from_peer)); 504 base::Bind(&NetLogQuicOnConnectionClosedCallback, error, from_peer));
432 } 505 }
433 506
434 void QuicConnectionLogger::OnSuccessfulVersionNegotiation( 507 void QuicConnectionLogger::OnSuccessfulVersionNegotiation(
435 const QuicVersion& version) { 508 const QuicVersion& version) {
436 string quic_version = QuicVersionToString(version); 509 string quic_version = QuicVersionToString(version);
437 net_log_.AddEvent(NetLog::TYPE_QUIC_SESSION_VERSION_NEGOTIATED, 510 net_log_.AddEvent(NetLog::TYPE_QUIC_SESSION_VERSION_NEGOTIATED,
438 NetLog::StringCallback("version", &quic_version)); 511 NetLog::StringCallback("version", &quic_version));
439 } 512 }
440 513
441 } // namespace net 514 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection_logger.h ('k') | net/quic/quic_crypto_client_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698