Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 kAddressAndPortMatch_base = 0, | |
| 206 kAddressAndPortMatch_v4_v4 = 0, | |
|
wtc
2014/02/13 02:04:10
Is it correct for the histogram enumeration to sta
jar (doing other things)
2014/02/13 03:24:48
Perfectly correct.
| |
| 207 kAddressAndPortMatch_v6_v6 = 1, | |
| 208 kAddressAndPortMatch_v4_v6 = 2, | |
| 209 kAddressAndPortMatch_v6_v4 = 3, | |
| 210 | |
| 211 // The addresses match, but the ports don't match. | |
| 212 kPortMismatch_base = 4, | |
| 213 kPortMismatch_v4_v4 = 4, | |
| 214 kPortMismatch_v6_v6 = 5, | |
| 215 kPortMismatch_v4_v6 = 6, | |
| 216 kPortMismatch_v6_v4 = 7, | |
| 217 | |
| 218 // The addresses don't match. | |
| 219 kAddressMismatch_base = 8, | |
| 220 kAddressMismatch_v4_v4 = 8, | |
| 221 kAddressMismatch_v6_v6 = 9, | |
| 222 kAddressMismatch_v4_v6 = 10, | |
| 223 kAddressMismatch_v6_v4 = 11, | |
|
Ryan Hamilton
2014/02/13 04:44:05
An alternative to consider which might make the co
wtc
2014/02/14 00:53:57
Done. (Not in the way you suggested though.)
| |
| 224 | |
| 225 kBoundaryValue, | |
| 226 }; | |
| 227 | |
| 228 // TODO(wtc): should we report these two cases? | |
|
jar (doing other things)
2014/02/13 03:24:48
This is fine IMO. You are seemingly talking to an
wtc
2014/02/14 00:53:57
Done.
| |
| 229 if (server_hello_address.address().empty() || | |
| 230 public_reset_address.address().empty()) { | |
| 231 return; | |
| 232 } | |
| 233 | |
| 234 bool first_ipv4 = | |
| 235 (server_hello_address.address().size() == kIPv4AddressSize); | |
| 236 bool second_ipv4 = | |
| 237 (public_reset_address.address().size() == kIPv4AddressSize); | |
| 238 int offset; | |
| 239 if (first_ipv4 == second_ipv4) { | |
| 240 if (first_ipv4) { | |
| 241 offset = 0; // v4_v4 | |
| 242 } else { | |
| 243 offset = 1; // v6_v6 | |
| 244 } | |
| 245 } else { | |
| 246 if (first_ipv4) { | |
| 247 offset = 2; // v4_v6 | |
| 248 } else { | |
| 249 offset = 3; // v6_v4 | |
| 250 } | |
| 251 } | |
| 252 | |
| 253 int sample; | |
| 254 if (server_hello_address.address() != public_reset_address.address()) { | |
| 255 sample = kAddressMismatch_base; | |
| 256 } else if (server_hello_address.port() != public_reset_address.port()) { | |
| 257 sample = kPortMismatch_base; | |
| 258 } else { | |
| 259 sample = kAddressAndPortMatch_base; | |
| 260 } | |
| 261 sample += offset; | |
| 262 HISTOGRAM_ENUMERATION("Net.QuicSession.PublicResetAddressMismatch", | |
|
wtc
2014/02/13 02:04:10
Is this histogram name OK? All the histograms in t
jar (doing other things)
2014/02/13 03:24:48
Critical is the "UMA" prefix, as otherwise the his
wtc
2014/02/14 00:53:57
Done.
| |
| 263 sample, kBoundaryValue); | |
| 264 } | |
| 265 | |
| 198 } // namespace | 266 } // namespace |
| 199 | 267 |
| 200 QuicConnectionLogger::QuicConnectionLogger(const BoundNetLog& net_log) | 268 QuicConnectionLogger::QuicConnectionLogger(const BoundNetLog& net_log) |
| 201 : net_log_(net_log), | 269 : net_log_(net_log), |
| 202 last_received_packet_sequence_number_(0), | 270 last_received_packet_sequence_number_(0), |
| 203 largest_received_packet_sequence_number_(0), | 271 largest_received_packet_sequence_number_(0), |
| 204 largest_received_missing_packet_sequence_number_(0), | 272 largest_received_missing_packet_sequence_number_(0), |
| 205 out_of_order_recieved_packet_count_(0), | 273 out_of_order_recieved_packet_count_(0), |
| 206 num_truncated_acks_sent_(0), | 274 num_truncated_acks_sent_(0), |
| 207 num_truncated_acks_received_(0) { | 275 num_truncated_acks_received_(0) { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 void QuicConnectionLogger::OnConnectionCloseFrame( | 454 void QuicConnectionLogger::OnConnectionCloseFrame( |
| 387 const QuicConnectionCloseFrame& frame) { | 455 const QuicConnectionCloseFrame& frame) { |
| 388 net_log_.AddEvent( | 456 net_log_.AddEvent( |
| 389 NetLog::TYPE_QUIC_SESSION_CONNECTION_CLOSE_FRAME_RECEIVED, | 457 NetLog::TYPE_QUIC_SESSION_CONNECTION_CLOSE_FRAME_RECEIVED, |
| 390 base::Bind(&NetLogQuicConnectionCloseFrameCallback, &frame)); | 458 base::Bind(&NetLogQuicConnectionCloseFrameCallback, &frame)); |
| 391 } | 459 } |
| 392 | 460 |
| 393 void QuicConnectionLogger::OnPublicResetPacket( | 461 void QuicConnectionLogger::OnPublicResetPacket( |
| 394 const QuicPublicResetPacket& packet) { | 462 const QuicPublicResetPacket& packet) { |
| 395 net_log_.AddEvent(NetLog::TYPE_QUIC_SESSION_PUBLIC_RESET_PACKET_RECEIVED); | 463 net_log_.AddEvent(NetLog::TYPE_QUIC_SESSION_PUBLIC_RESET_PACKET_RECEIVED); |
| 464 UpdatePublicResetAddressMismatchHistogram(client_address_, | |
| 465 packet.client_address); | |
| 396 } | 466 } |
| 397 | 467 |
| 398 void QuicConnectionLogger::OnVersionNegotiationPacket( | 468 void QuicConnectionLogger::OnVersionNegotiationPacket( |
| 399 const QuicVersionNegotiationPacket& packet) { | 469 const QuicVersionNegotiationPacket& packet) { |
| 400 net_log_.AddEvent( | 470 net_log_.AddEvent( |
| 401 NetLog::TYPE_QUIC_SESSION_VERSION_NEGOTIATION_PACKET_RECEIVED, | 471 NetLog::TYPE_QUIC_SESSION_VERSION_NEGOTIATION_PACKET_RECEIVED, |
| 402 base::Bind(&NetLogQuicVersionNegotiationPacketCallback, &packet)); | 472 base::Bind(&NetLogQuicVersionNegotiationPacketCallback, &packet)); |
| 403 } | 473 } |
| 404 | 474 |
| 405 void QuicConnectionLogger::OnRevivedPacket( | 475 void QuicConnectionLogger::OnRevivedPacket( |
| 406 const QuicPacketHeader& revived_header, | 476 const QuicPacketHeader& revived_header, |
| 407 base::StringPiece payload) { | 477 base::StringPiece payload) { |
| 408 net_log_.AddEvent( | 478 net_log_.AddEvent( |
| 409 NetLog::TYPE_QUIC_SESSION_PACKET_HEADER_REVIVED, | 479 NetLog::TYPE_QUIC_SESSION_PACKET_HEADER_REVIVED, |
| 410 base::Bind(&NetLogQuicPacketHeaderCallback, &revived_header)); | 480 base::Bind(&NetLogQuicPacketHeaderCallback, &revived_header)); |
| 411 } | 481 } |
| 412 | 482 |
| 413 void QuicConnectionLogger::OnCryptoHandshakeMessageReceived( | 483 void QuicConnectionLogger::OnCryptoHandshakeMessageReceived( |
| 414 const CryptoHandshakeMessage& message) { | 484 const CryptoHandshakeMessage& message) { |
| 415 net_log_.AddEvent( | 485 net_log_.AddEvent( |
| 416 NetLog::TYPE_QUIC_SESSION_CRYPTO_HANDSHAKE_MESSAGE_RECEIVED, | 486 NetLog::TYPE_QUIC_SESSION_CRYPTO_HANDSHAKE_MESSAGE_RECEIVED, |
| 417 base::Bind(&NetLogQuicCryptoHandshakeMessageCallback, &message)); | 487 base::Bind(&NetLogQuicCryptoHandshakeMessageCallback, &message)); |
| 488 | |
| 489 if (message.tag() == kSHLO) { | |
| 490 StringPiece address; | |
| 491 QuicSocketAddressCoder decoder; | |
| 492 if (message.GetStringPiece(kCADR, &address) && | |
| 493 decoder.Decode(address.data(), address.size())) { | |
| 494 client_address_ = IPEndPoint(decoder.ip(), decoder.port()); | |
| 495 } | |
| 496 } | |
| 418 } | 497 } |
| 419 | 498 |
| 420 void QuicConnectionLogger::OnCryptoHandshakeMessageSent( | 499 void QuicConnectionLogger::OnCryptoHandshakeMessageSent( |
| 421 const CryptoHandshakeMessage& message) { | 500 const CryptoHandshakeMessage& message) { |
| 422 net_log_.AddEvent( | 501 net_log_.AddEvent( |
| 423 NetLog::TYPE_QUIC_SESSION_CRYPTO_HANDSHAKE_MESSAGE_SENT, | 502 NetLog::TYPE_QUIC_SESSION_CRYPTO_HANDSHAKE_MESSAGE_SENT, |
| 424 base::Bind(&NetLogQuicCryptoHandshakeMessageCallback, &message)); | 503 base::Bind(&NetLogQuicCryptoHandshakeMessageCallback, &message)); |
| 425 } | 504 } |
| 426 | 505 |
| 427 void QuicConnectionLogger::OnConnectionClosed(QuicErrorCode error, | 506 void QuicConnectionLogger::OnConnectionClosed(QuicErrorCode error, |
| 428 bool from_peer) { | 507 bool from_peer) { |
| 429 net_log_.AddEvent( | 508 net_log_.AddEvent( |
| 430 NetLog::TYPE_QUIC_SESSION_CLOSED, | 509 NetLog::TYPE_QUIC_SESSION_CLOSED, |
| 431 base::Bind(&NetLogQuicOnConnectionClosedCallback, error, from_peer)); | 510 base::Bind(&NetLogQuicOnConnectionClosedCallback, error, from_peer)); |
| 432 } | 511 } |
| 433 | 512 |
| 434 void QuicConnectionLogger::OnSuccessfulVersionNegotiation( | 513 void QuicConnectionLogger::OnSuccessfulVersionNegotiation( |
| 435 const QuicVersion& version) { | 514 const QuicVersion& version) { |
| 436 string quic_version = QuicVersionToString(version); | 515 string quic_version = QuicVersionToString(version); |
| 437 net_log_.AddEvent(NetLog::TYPE_QUIC_SESSION_VERSION_NEGOTIATED, | 516 net_log_.AddEvent(NetLog::TYPE_QUIC_SESSION_VERSION_NEGOTIATED, |
| 438 NetLog::StringCallback("version", &quic_version)); | 517 NetLog::StringCallback("version", &quic_version)); |
| 439 } | 518 } |
| 440 | 519 |
| 441 } // namespace net | 520 } // namespace net |
| OLD | NEW |