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_socket_address_coder.h" | 24 #include "net/quic/quic_socket_address_coder.h" |
| 25 #include "net/quic/quic_time.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 |
34 // sequences) of length 2, 3, 4, ... 22. | 35 // sequences) of length 2, 3, 4, ... 22. |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 AddressFamily GetRealAddressFamily(const IPAddressNumber& address) { | 280 AddressFamily GetRealAddressFamily(const IPAddressNumber& address) { |
280 return IsIPv4Mapped(address) ? ADDRESS_FAMILY_IPV4 : | 281 return IsIPv4Mapped(address) ? ADDRESS_FAMILY_IPV4 : |
281 GetAddressFamily(address); | 282 GetAddressFamily(address); |
282 } | 283 } |
283 | 284 |
284 } // namespace | 285 } // namespace |
285 | 286 |
286 QuicConnectionLogger::QuicConnectionLogger( | 287 QuicConnectionLogger::QuicConnectionLogger( |
287 QuicSpdySession* session, | 288 QuicSpdySession* session, |
288 const char* const connection_description, | 289 const char* const connection_description, |
| 290 scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher, |
289 const BoundNetLog& net_log) | 291 const BoundNetLog& net_log) |
290 : net_log_(net_log), | 292 : net_log_(net_log), |
291 session_(session), | 293 session_(session), |
292 last_received_packet_number_(0), | 294 last_received_packet_number_(0), |
293 last_received_packet_size_(0), | 295 last_received_packet_size_(0), |
294 previous_received_packet_size_(0), | 296 previous_received_packet_size_(0), |
295 last_packet_sent_time_(base::TimeTicks()), | 297 last_packet_sent_time_(base::TimeTicks()), |
296 largest_received_packet_number_(0), | 298 largest_received_packet_number_(0), |
297 largest_received_missing_packet_number_(0), | 299 largest_received_missing_packet_number_(0), |
298 num_out_of_order_received_packets_(0), | 300 num_out_of_order_received_packets_(0), |
299 num_out_of_order_large_received_packets_(0), | 301 num_out_of_order_large_received_packets_(0), |
300 num_packets_received_(0), | 302 num_packets_received_(0), |
301 num_truncated_acks_sent_(0), | 303 num_truncated_acks_sent_(0), |
302 num_truncated_acks_received_(0), | 304 num_truncated_acks_received_(0), |
303 num_frames_received_(0), | 305 num_frames_received_(0), |
304 num_duplicate_frames_received_(0), | 306 num_duplicate_frames_received_(0), |
305 num_incorrect_connection_ids_(0), | 307 num_incorrect_connection_ids_(0), |
306 num_undecryptable_packets_(0), | 308 num_undecryptable_packets_(0), |
307 num_duplicate_packets_(0), | 309 num_duplicate_packets_(0), |
308 num_blocked_frames_received_(0), | 310 num_blocked_frames_received_(0), |
309 num_blocked_frames_sent_(0), | 311 num_blocked_frames_sent_(0), |
310 connection_description_(connection_description) {} | 312 connection_description_(connection_description), |
| 313 socket_performance_watcher_(socket_performance_watcher.Pass()) {} |
311 | 314 |
312 QuicConnectionLogger::~QuicConnectionLogger() { | 315 QuicConnectionLogger::~QuicConnectionLogger() { |
313 UMA_HISTOGRAM_COUNTS("Net.QuicSession.OutOfOrderPacketsReceived", | 316 UMA_HISTOGRAM_COUNTS("Net.QuicSession.OutOfOrderPacketsReceived", |
314 num_out_of_order_received_packets_); | 317 num_out_of_order_received_packets_); |
315 UMA_HISTOGRAM_COUNTS("Net.QuicSession.OutOfOrderLargePacketsReceived", | 318 UMA_HISTOGRAM_COUNTS("Net.QuicSession.OutOfOrderLargePacketsReceived", |
316 num_out_of_order_large_received_packets_); | 319 num_out_of_order_large_received_packets_); |
317 UMA_HISTOGRAM_COUNTS("Net.QuicSession.TruncatedAcksSent", | 320 UMA_HISTOGRAM_COUNTS("Net.QuicSession.TruncatedAcksSent", |
318 num_truncated_acks_sent_); | 321 num_truncated_acks_sent_); |
319 UMA_HISTOGRAM_COUNTS("Net.QuicSession.TruncatedAcksReceived", | 322 UMA_HISTOGRAM_COUNTS("Net.QuicSession.TruncatedAcksReceived", |
320 num_truncated_acks_received_); | 323 num_truncated_acks_received_); |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 } | 793 } |
791 } | 794 } |
792 | 795 |
793 float QuicConnectionLogger::ReceivedPacketLossRate() const { | 796 float QuicConnectionLogger::ReceivedPacketLossRate() const { |
794 if (largest_received_packet_number_ <= num_packets_received_) | 797 if (largest_received_packet_number_ <= num_packets_received_) |
795 return 0.0f; | 798 return 0.0f; |
796 float num_received = largest_received_packet_number_ - num_packets_received_; | 799 float num_received = largest_received_packet_number_ - num_packets_received_; |
797 return num_received / largest_received_packet_number_; | 800 return num_received / largest_received_packet_number_; |
798 } | 801 } |
799 | 802 |
| 803 void QuicConnectionLogger::OnRttChanged(QuicTime::Delta rtt) const { |
| 804 // Notify socket performance watcher of the updated RTT value. |
| 805 if (!socket_performance_watcher_) |
| 806 return; |
| 807 |
| 808 int64_t microseconds = rtt.ToMicroseconds(); |
| 809 if (microseconds != 0) { |
| 810 socket_performance_watcher_->OnUpdatedRTTAvailable( |
| 811 base::TimeDelta::FromMicroseconds(rtt.ToMicroseconds())); |
| 812 } |
| 813 } |
| 814 |
800 void QuicConnectionLogger::RecordAggregatePacketLossRate() const { | 815 void QuicConnectionLogger::RecordAggregatePacketLossRate() const { |
801 // For short connections under 22 packets in length, we'll rely on the | 816 // For short connections under 22 packets in length, we'll rely on the |
802 // Net.QuicSession.21CumulativePacketsReceived_* histogram to indicate packet | 817 // Net.QuicSession.21CumulativePacketsReceived_* histogram to indicate packet |
803 // loss rates. This way we avoid tremendously anomalous contributions to our | 818 // loss rates. This way we avoid tremendously anomalous contributions to our |
804 // histogram. (e.g., if we only got 5 packets, but lost 1, we'd otherwise | 819 // histogram. (e.g., if we only got 5 packets, but lost 1, we'd otherwise |
805 // record a 20% loss in this histogram!). We may still get some strange data | 820 // record a 20% loss in this histogram!). We may still get some strange data |
806 // (1 loss in 22 is still high :-/). | 821 // (1 loss in 22 is still high :-/). |
807 if (largest_received_packet_number_ <= 21) | 822 if (largest_received_packet_number_ <= 21) |
808 return; | 823 return; |
809 | 824 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 continue; | 895 continue; |
881 } | 896 } |
882 // Record some overlapping patterns, to get a better picture, since this is | 897 // Record some overlapping patterns, to get a better picture, since this is |
883 // not very expensive. | 898 // not very expensive. |
884 if (i % 3 == 0) | 899 if (i % 3 == 0) |
885 six_packet_histogram->Add(recent_6_mask); | 900 six_packet_histogram->Add(recent_6_mask); |
886 } | 901 } |
887 } | 902 } |
888 | 903 |
889 } // namespace net | 904 } // namespace net |
OLD | NEW |