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 largest_received_packet_number_(0), | 297 largest_received_packet_number_(0), |
296 largest_received_missing_packet_number_(0), | 298 largest_received_missing_packet_number_(0), |
297 num_out_of_order_received_packets_(0), | 299 num_out_of_order_received_packets_(0), |
298 num_out_of_order_large_received_packets_(0), | 300 num_out_of_order_large_received_packets_(0), |
299 num_packets_received_(0), | 301 num_packets_received_(0), |
300 num_truncated_acks_sent_(0), | 302 num_truncated_acks_sent_(0), |
301 num_truncated_acks_received_(0), | 303 num_truncated_acks_received_(0), |
302 num_frames_received_(0), | 304 num_frames_received_(0), |
303 num_duplicate_frames_received_(0), | 305 num_duplicate_frames_received_(0), |
304 num_incorrect_connection_ids_(0), | 306 num_incorrect_connection_ids_(0), |
305 num_undecryptable_packets_(0), | 307 num_undecryptable_packets_(0), |
306 num_duplicate_packets_(0), | 308 num_duplicate_packets_(0), |
307 num_blocked_frames_received_(0), | 309 num_blocked_frames_received_(0), |
308 num_blocked_frames_sent_(0), | 310 num_blocked_frames_sent_(0), |
309 connection_description_(connection_description) {} | 311 connection_description_(connection_description), |
312 socket_performance_watcher_(socket_performance_watcher.Pass()) {} | |
310 | 313 |
311 QuicConnectionLogger::~QuicConnectionLogger() { | 314 QuicConnectionLogger::~QuicConnectionLogger() { |
312 UMA_HISTOGRAM_COUNTS("Net.QuicSession.OutOfOrderPacketsReceived", | 315 UMA_HISTOGRAM_COUNTS("Net.QuicSession.OutOfOrderPacketsReceived", |
313 num_out_of_order_received_packets_); | 316 num_out_of_order_received_packets_); |
314 UMA_HISTOGRAM_COUNTS("Net.QuicSession.OutOfOrderLargePacketsReceived", | 317 UMA_HISTOGRAM_COUNTS("Net.QuicSession.OutOfOrderLargePacketsReceived", |
315 num_out_of_order_large_received_packets_); | 318 num_out_of_order_large_received_packets_); |
316 UMA_HISTOGRAM_COUNTS("Net.QuicSession.TruncatedAcksSent", | 319 UMA_HISTOGRAM_COUNTS("Net.QuicSession.TruncatedAcksSent", |
317 num_truncated_acks_sent_); | 320 num_truncated_acks_sent_); |
318 UMA_HISTOGRAM_COUNTS("Net.QuicSession.TruncatedAcksReceived", | 321 UMA_HISTOGRAM_COUNTS("Net.QuicSession.TruncatedAcksReceived", |
319 num_truncated_acks_received_); | 322 num_truncated_acks_received_); |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
779 } | 782 } |
780 } | 783 } |
781 | 784 |
782 float QuicConnectionLogger::ReceivedPacketLossRate() const { | 785 float QuicConnectionLogger::ReceivedPacketLossRate() const { |
783 if (largest_received_packet_number_ <= num_packets_received_) | 786 if (largest_received_packet_number_ <= num_packets_received_) |
784 return 0.0f; | 787 return 0.0f; |
785 float num_received = largest_received_packet_number_ - num_packets_received_; | 788 float num_received = largest_received_packet_number_ - num_packets_received_; |
786 return num_received / largest_received_packet_number_; | 789 return num_received / largest_received_packet_number_; |
787 } | 790 } |
788 | 791 |
792 void QuicConnectionLogger::OnRttChanged(QuicTime::Delta rtt) const { | |
793 // Notify socket performance watcher of the updated RTT value. | |
794 if (!socket_performance_watcher_) | |
795 return; | |
796 | |
797 long microseconds = rtt.ToMicroseconds(); | |
Ryan Sleevi
2015/09/18 17:36:45
BUG: This should be int64
tbansal1
2015/09/18 17:59:59
Done. Thanks for catching that. This is what I get
| |
798 if (microseconds != 0) { | |
799 socket_performance_watcher_->OnUpdatedRTTAvailable( | |
800 base::TimeDelta::FromMicroseconds(rtt.ToMicroseconds())); | |
801 } | |
802 } | |
803 | |
789 void QuicConnectionLogger::RecordAggregatePacketLossRate() const { | 804 void QuicConnectionLogger::RecordAggregatePacketLossRate() const { |
790 // For short connections under 22 packets in length, we'll rely on the | 805 // For short connections under 22 packets in length, we'll rely on the |
791 // Net.QuicSession.21CumulativePacketsReceived_* histogram to indicate packet | 806 // Net.QuicSession.21CumulativePacketsReceived_* histogram to indicate packet |
792 // loss rates. This way we avoid tremendously anomalous contributions to our | 807 // loss rates. This way we avoid tremendously anomalous contributions to our |
793 // histogram. (e.g., if we only got 5 packets, but lost 1, we'd otherwise | 808 // histogram. (e.g., if we only got 5 packets, but lost 1, we'd otherwise |
794 // record a 20% loss in this histogram!). We may still get some strange data | 809 // record a 20% loss in this histogram!). We may still get some strange data |
795 // (1 loss in 22 is still high :-/). | 810 // (1 loss in 22 is still high :-/). |
796 if (largest_received_packet_number_ <= 21) | 811 if (largest_received_packet_number_ <= 21) |
797 return; | 812 return; |
798 | 813 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
869 continue; | 884 continue; |
870 } | 885 } |
871 // Record some overlapping patterns, to get a better picture, since this is | 886 // Record some overlapping patterns, to get a better picture, since this is |
872 // not very expensive. | 887 // not very expensive. |
873 if (i % 3 == 0) | 888 if (i % 3 == 0) |
874 six_packet_histogram->Add(recent_6_mask); | 889 six_packet_histogram->Add(recent_6_mask); |
875 } | 890 } |
876 } | 891 } |
877 | 892 |
878 } // namespace net | 893 } // namespace net |
OLD | NEW |