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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/metrics/sparse_histogram.h" | 13 #include "base/metrics/sparse_histogram.h" |
| 14 #include "base/profiler/scoped_tracker.h" | 14 #include "base/profiler/scoped_tracker.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
| 18 #include "net/cert/cert_verify_result.h" | 18 #include "net/cert/cert_verify_result.h" |
| 19 #include "net/cert/x509_certificate.h" | 19 #include "net/cert/x509_certificate.h" |
| 20 #include "net/log/net_log.h" | 20 #include "net/log/net_log.h" |
| 21 #include "net/quic/crypto/crypto_handshake_message.h" | 21 #include "net/quic/crypto/crypto_handshake_message.h" |
| 22 #include "net/quic/crypto/crypto_protocol.h" | 22 #include "net/quic/crypto/crypto_protocol.h" |
| 23 #include "net/quic/quic_address_mismatch.h" | 23 #include "net/quic/quic_address_mismatch.h" |
| 24 #include "net/quic/quic_sent_packet_manager.h" | |
| 24 #include "net/quic/quic_socket_address_coder.h" | 25 #include "net/quic/quic_socket_address_coder.h" |
| 25 | 26 |
| 26 using base::StringPiece; | 27 using base::StringPiece; |
| 27 using std::string; | 28 using std::string; |
| 28 | 29 |
| 29 namespace net { | 30 namespace net { |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 // We have ranges-of-buckets in the cumulative histogram (covering 21 packet | 34 // We have ranges-of-buckets in the cumulative histogram (covering 21 packet |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 AddressFamily GetRealAddressFamily(const IPAddressNumber& address) { | 283 AddressFamily GetRealAddressFamily(const IPAddressNumber& address) { |
| 283 return IsIPv4Mapped(address) ? ADDRESS_FAMILY_IPV4 : | 284 return IsIPv4Mapped(address) ? ADDRESS_FAMILY_IPV4 : |
| 284 GetAddressFamily(address); | 285 GetAddressFamily(address); |
| 285 } | 286 } |
| 286 | 287 |
| 287 } // namespace | 288 } // namespace |
| 288 | 289 |
| 289 QuicConnectionLogger::QuicConnectionLogger( | 290 QuicConnectionLogger::QuicConnectionLogger( |
| 290 QuicSpdySession* session, | 291 QuicSpdySession* session, |
| 291 const char* const connection_description, | 292 const char* const connection_description, |
| 292 const BoundNetLog& net_log) | 293 const BoundNetLog& net_log, |
| 294 QuicConnection* connection, | |
| 295 scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher) | |
| 293 : net_log_(net_log), | 296 : net_log_(net_log), |
| 294 session_(session), | 297 session_(session), |
| 295 last_received_packet_number_(0), | 298 last_received_packet_number_(0), |
| 296 last_received_packet_size_(0), | 299 last_received_packet_size_(0), |
| 297 previous_received_packet_size_(0), | 300 previous_received_packet_size_(0), |
| 298 largest_received_packet_number_(0), | 301 largest_received_packet_number_(0), |
| 299 largest_received_missing_packet_number_(0), | 302 largest_received_missing_packet_number_(0), |
| 300 num_out_of_order_received_packets_(0), | 303 num_out_of_order_received_packets_(0), |
| 301 num_out_of_order_large_received_packets_(0), | 304 num_out_of_order_large_received_packets_(0), |
| 302 num_packets_received_(0), | 305 num_packets_received_(0), |
| 303 num_truncated_acks_sent_(0), | 306 num_truncated_acks_sent_(0), |
| 304 num_truncated_acks_received_(0), | 307 num_truncated_acks_received_(0), |
| 305 num_frames_received_(0), | 308 num_frames_received_(0), |
| 306 num_duplicate_frames_received_(0), | 309 num_duplicate_frames_received_(0), |
| 307 num_incorrect_connection_ids_(0), | 310 num_incorrect_connection_ids_(0), |
| 308 num_undecryptable_packets_(0), | 311 num_undecryptable_packets_(0), |
| 309 num_duplicate_packets_(0), | 312 num_duplicate_packets_(0), |
| 310 num_blocked_frames_received_(0), | 313 num_blocked_frames_received_(0), |
| 311 num_blocked_frames_sent_(0), | 314 num_blocked_frames_sent_(0), |
| 312 connection_description_(connection_description) {} | 315 connection_description_(connection_description), |
| 316 connection_(connection), | |
| 317 socket_performance_watcher_(socket_performance_watcher.Pass()) {} | |
| 313 | 318 |
| 314 QuicConnectionLogger::~QuicConnectionLogger() { | 319 QuicConnectionLogger::~QuicConnectionLogger() { |
| 315 UMA_HISTOGRAM_COUNTS("Net.QuicSession.OutOfOrderPacketsReceived", | 320 UMA_HISTOGRAM_COUNTS("Net.QuicSession.OutOfOrderPacketsReceived", |
| 316 num_out_of_order_received_packets_); | 321 num_out_of_order_received_packets_); |
| 317 UMA_HISTOGRAM_COUNTS("Net.QuicSession.OutOfOrderLargePacketsReceived", | 322 UMA_HISTOGRAM_COUNTS("Net.QuicSession.OutOfOrderLargePacketsReceived", |
| 318 num_out_of_order_large_received_packets_); | 323 num_out_of_order_large_received_packets_); |
| 319 UMA_HISTOGRAM_COUNTS("Net.QuicSession.TruncatedAcksSent", | 324 UMA_HISTOGRAM_COUNTS("Net.QuicSession.TruncatedAcksSent", |
| 320 num_truncated_acks_sent_); | 325 num_truncated_acks_sent_); |
| 321 UMA_HISTOGRAM_COUNTS("Net.QuicSession.TruncatedAcksReceived", | 326 UMA_HISTOGRAM_COUNTS("Net.QuicSession.TruncatedAcksReceived", |
| 322 num_truncated_acks_received_); | 327 num_truncated_acks_received_); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 net_log_.AddEvent( | 457 net_log_.AddEvent( |
| 453 NetLog::TYPE_QUIC_SESSION_PACKET_SENT, | 458 NetLog::TYPE_QUIC_SESSION_PACKET_SENT, |
| 454 base::Bind(&NetLogQuicPacketSentCallback, serialized_packet, | 459 base::Bind(&NetLogQuicPacketSentCallback, serialized_packet, |
| 455 level, transmission_type, packet.length(), sent_time)); | 460 level, transmission_type, packet.length(), sent_time)); |
| 456 } else { | 461 } else { |
| 457 net_log_.AddEvent( | 462 net_log_.AddEvent( |
| 458 NetLog::TYPE_QUIC_SESSION_PACKET_RETRANSMITTED, | 463 NetLog::TYPE_QUIC_SESSION_PACKET_RETRANSMITTED, |
| 459 base::Bind(&NetLogQuicPacketRetransmittedCallback, | 464 base::Bind(&NetLogQuicPacketRetransmittedCallback, |
| 460 original_packet_number, serialized_packet.packet_number)); | 465 original_packet_number, serialized_packet.packet_number)); |
| 461 } | 466 } |
| 467 // Notify socket performance watcher of the updated RTT value. | |
| 468 if (socket_performance_watcher_ && connection_) { | |
|
Ryan Hamilton
2015/09/17 01:59:49
Why would we not have a connection?
tbansal1
2015/09/17 22:23:42
Removed, I was just not sure, so tried to be on th
| |
| 469 socket_performance_watcher_->OnUpdatedRTTAvailable( | |
| 470 base::TimeDelta::FromMicroseconds(connection_->sent_packet_manager() | |
| 471 .GetRttStats() | |
| 472 ->smoothed_rtt() | |
| 473 .ToMicroseconds())); | |
| 474 } | |
| 462 } | 475 } |
| 463 | 476 |
| 464 void QuicConnectionLogger::OnPacketReceived(const IPEndPoint& self_address, | 477 void QuicConnectionLogger::OnPacketReceived(const IPEndPoint& self_address, |
| 465 const IPEndPoint& peer_address, | 478 const IPEndPoint& peer_address, |
| 466 const QuicEncryptedPacket& packet) { | 479 const QuicEncryptedPacket& packet) { |
| 467 if (local_address_from_self_.GetFamily() == ADDRESS_FAMILY_UNSPECIFIED) { | 480 if (local_address_from_self_.GetFamily() == ADDRESS_FAMILY_UNSPECIFIED) { |
| 468 local_address_from_self_ = self_address; | 481 local_address_from_self_ = self_address; |
| 469 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.ConnectionTypeFromSelf", | 482 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.ConnectionTypeFromSelf", |
| 470 GetRealAddressFamily(self_address.address()), | 483 GetRealAddressFamily(self_address.address()), |
| 471 ADDRESS_FAMILY_LAST); | 484 ADDRESS_FAMILY_LAST); |
| 472 } | 485 } |
| 473 | 486 |
| 474 previous_received_packet_size_ = last_received_packet_size_; | 487 previous_received_packet_size_ = last_received_packet_size_; |
| 475 last_received_packet_size_ = packet.length(); | 488 last_received_packet_size_ = packet.length(); |
| 476 net_log_.AddEvent( | 489 net_log_.AddEvent( |
| 477 NetLog::TYPE_QUIC_SESSION_PACKET_RECEIVED, | 490 NetLog::TYPE_QUIC_SESSION_PACKET_RECEIVED, |
| 478 base::Bind(&NetLogQuicPacketCallback, &self_address, &peer_address, | 491 base::Bind(&NetLogQuicPacketCallback, &self_address, &peer_address, |
| 479 packet.length())); | 492 packet.length())); |
| 493 | |
| 494 // Notify socket performance watcher of the updated RTT value. | |
| 495 if (socket_performance_watcher_ && connection_) { | |
| 496 socket_performance_watcher_->OnUpdatedRTTAvailable( | |
| 497 base::TimeDelta::FromMicroseconds(connection_->sent_packet_manager() | |
| 498 .GetRttStats() | |
| 499 ->smoothed_rtt() | |
| 500 .ToMicroseconds())); | |
| 501 } | |
|
Ryan Hamilton
2015/09/17 01:59:49
I think smoothed_rtt() can return Zero. Is that OK
tbansal1
2015/09/17 22:23:42
Added check for zero.
| |
| 480 } | 502 } |
|
Ryan Hamilton
2015/09/17 01:59:49
Looking at this more closely, I see that you're re
tbansal1
2015/09/17 22:23:42
Done. That's much cleaner :)
| |
| 481 | 503 |
| 482 void QuicConnectionLogger::OnUnauthenticatedHeader( | 504 void QuicConnectionLogger::OnUnauthenticatedHeader( |
| 483 const QuicPacketHeader& header) { | 505 const QuicPacketHeader& header) { |
| 484 net_log_.AddEvent( | 506 net_log_.AddEvent( |
| 485 NetLog::TYPE_QUIC_SESSION_UNAUTHENTICATED_PACKET_HEADER_RECEIVED, | 507 NetLog::TYPE_QUIC_SESSION_UNAUTHENTICATED_PACKET_HEADER_RECEIVED, |
| 486 base::Bind(&NetLogQuicPacketHeaderCallback, &header)); | 508 base::Bind(&NetLogQuicPacketHeaderCallback, &header)); |
| 487 } | 509 } |
| 488 | 510 |
| 489 void QuicConnectionLogger::OnIncorrectConnectionId( | 511 void QuicConnectionLogger::OnIncorrectConnectionId( |
| 490 QuicConnectionId connection_id) { | 512 QuicConnectionId connection_id) { |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 872 continue; | 894 continue; |
| 873 } | 895 } |
| 874 // Record some overlapping patterns, to get a better picture, since this is | 896 // Record some overlapping patterns, to get a better picture, since this is |
| 875 // not very expensive. | 897 // not very expensive. |
| 876 if (i % 3 == 0) | 898 if (i % 3 == 0) |
| 877 six_packet_histogram->Add(recent_6_mask); | 899 six_packet_histogram->Add(recent_6_mask); |
| 878 } | 900 } |
| 879 } | 901 } |
| 880 | 902 |
| 881 } // namespace net | 903 } // namespace net |
| OLD | NEW |