Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/net/network_stats.h" | 5 #include "chrome/browser/net/network_stats.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 static const uint32 kPacketNumberLength = 10; | 77 static const uint32 kPacketNumberLength = 10; |
| 78 | 78 |
| 79 // This specifies the starting position of the <encoded_payload> in | 79 // This specifies the starting position of the <encoded_payload> in |
| 80 // "echo response". | 80 // "echo response". |
| 81 static const uint32 kEncodedPayloadStart = kKeyEnd; | 81 static const uint32 kEncodedPayloadStart = kKeyEnd; |
| 82 | 82 |
| 83 // HistogramPortSelector and kPorts should be kept in sync. Port 999999 is | 83 // HistogramPortSelector and kPorts should be kept in sync. Port 999999 is |
| 84 // used by the unit tests. | 84 // used by the unit tests. |
| 85 static const int32 kPorts[] = {6121, 999999}; | 85 static const int32 kPorts[] = {6121, 999999}; |
| 86 | 86 |
| 87 // Maximum number of packets that can be sent to the server for packet loss | 87 // Maximum number of packets that can be sent to the server for packet loss |
|
jar (doing other things)
2012/09/14 22:34:54
nit: Change comment to:
Number of packets that a
ramant (doing other things)
2012/09/14 23:39:08
Done.
| |
| 88 // correlation test. | 88 // correlation test. |
| 89 static const uint32 kMaximumCorrelationPackets = 6; | 89 static const uint32 kMaximumCorrelationPackets = 6; |
| 90 | 90 |
| 91 // Maximum number of packets that can be sent to the server. | 91 // Maximum number of packets that can be sent to the server. |
| 92 static const uint32 kMaximumSequentialPackets = 21; | 92 static const uint32 kMaximumSequentialPackets = 21; |
| 93 | 93 |
| 94 // This specifies the maximum message (payload) size. | 94 // This specifies the maximum message (payload) size. |
| 95 static const uint32 kMaxMessage = kMaximumSequentialPackets * 2048; | 95 static const uint32 kMaxMessage = kMaximumSequentialPackets * 2048; |
| 96 | 96 |
| 97 // NetworkStats methods and members. | 97 // NetworkStats methods and members. |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 676 net::CompletionCallback callback = finished_callback_; | 676 net::CompletionCallback callback = finished_callback_; |
| 677 finished_callback_.Reset(); | 677 finished_callback_.Reset(); |
| 678 callback.Run(result); | 678 callback.Run(result); |
| 679 } | 679 } |
| 680 } | 680 } |
| 681 | 681 |
| 682 void NetworkStats::RecordHistograms(const ProtocolValue& protocol, | 682 void NetworkStats::RecordHistograms(const ProtocolValue& protocol, |
| 683 const Status& status, | 683 const Status& status, |
| 684 int result) { | 684 int result) { |
| 685 if (packets_to_send_ != kMaximumSequentialPackets && | 685 if (packets_to_send_ != kMaximumSequentialPackets && |
| 686 packets_to_send_ != kMaximumCorrelationPackets) { | 686 packets_to_send_ != kMaximumCorrelationPackets) { |
|
jar (doing other things)
2012/09/14 22:34:54
This line can probably be deleted (you can leave 6
ramant (doing other things)
2012/09/14 23:39:08
Done.
| |
| 687 return; | 687 return; |
| 688 } | 688 } |
| 689 | 689 |
| 690 std::string load_size_string = base::StringPrintf("%dB", load_size_); | 690 std::string load_size_string = base::StringPrintf("%dB", load_size_); |
| 691 | 691 |
| 692 if (packets_to_send_ == kMaximumCorrelationPackets) { | 692 RecordPacketLossSeriesHistograms(protocol, load_size_string, status, result); |
| 693 RecordPacketLossSeriesHistograms( | 693 if (packets_to_send_ == kMaximumCorrelationPackets) |
| 694 protocol, load_size_string, status, result); | |
| 695 return; | 694 return; |
|
jar (doing other things)
2012/09/14 22:34:54
No longer needed.
ramant (doing other things)
2012/09/14 23:39:08
Done.
| |
| 696 } | |
| 697 | 695 |
| 698 for (uint32 i = 0; i < 3; i++) | 696 for (uint32 i = 0; i < 3; i++) |
| 699 RecordRTTHistograms(protocol, load_size_string, i); | 697 RecordRTTHistograms(protocol, load_size_string, i); |
| 700 | 698 |
| 701 RecordRTTHistograms(protocol, load_size_string, 9); | 699 RecordRTTHistograms(protocol, load_size_string, 9); |
| 702 RecordRTTHistograms(protocol, load_size_string, 19); | 700 RecordRTTHistograms(protocol, load_size_string, 19); |
| 703 | 701 |
| 704 RecordAcksReceivedHistograms(load_size_string); | 702 RecordAcksReceivedHistograms(load_size_string); |
| 705 } | 703 } |
| 706 | 704 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 771 base::Histogram::kUmaTargetedHistogramFlag); | 769 base::Histogram::kUmaTargetedHistogramFlag); |
| 772 acks_received_count_histogram->Add(count); | 770 acks_received_count_histogram->Add(count); |
| 773 } | 771 } |
| 774 } | 772 } |
| 775 | 773 |
| 776 void NetworkStats::RecordPacketLossSeriesHistograms( | 774 void NetworkStats::RecordPacketLossSeriesHistograms( |
| 777 const ProtocolValue& protocol, | 775 const ProtocolValue& protocol, |
| 778 const std::string& load_size_string, | 776 const std::string& load_size_string, |
| 779 const Status& status, | 777 const Status& status, |
| 780 int result) { | 778 int result) { |
| 781 DCHECK_EQ(packets_to_send_, kMaximumCorrelationPackets); | |
| 782 | |
| 783 const char* test_name = TestName(); | 779 const char* test_name = TestName(); |
| 784 | 780 |
| 785 // Build "NetConnectivity3.Send6.SeriesAcked.<port>.<load_size>" histogram | 781 // Build "NetConnectivity3.Send6.SeriesAcked.<port>.<load_size>" histogram |
| 786 // name. Total number of histograms are 5*2. | 782 // name. Total number of histograms are 5*2. |
| 787 std::string series_acked_histogram_name = base::StringPrintf( | 783 std::string series_acked_histogram_name = base::StringPrintf( |
| 788 "NetConnectivity3.%s.Send6.SeriesAcked.%d.%s", | 784 "NetConnectivity3.%s.Send6.SeriesAcked.%d.%s", |
| 789 test_name, | 785 test_name, |
| 790 kPorts[histogram_port_], | 786 kPorts[histogram_port_], |
| 791 load_size_string.c_str()); | 787 load_size_string.c_str()); |
| 792 // Build "NetConnectivity3.Send6.PacketsSent.<port>.<load_size>" histogram | 788 // Build "NetConnectivity3.Send6.PacketsSent.<port>.<load_size>" histogram |
| 793 // name. Total number of histograms are 5*2. | 789 // name. Total number of histograms are 5*2. |
| 794 std::string packets_sent_histogram_name = base::StringPrintf( | 790 std::string packets_sent_histogram_name = base::StringPrintf( |
| 795 "NetConnectivity3.%s.Send6.PacketsSent.%d.%s", | 791 "NetConnectivity3.%s.Send6.PacketsSent.%d.%s", |
| 796 test_name, | 792 test_name, |
| 797 kPorts[histogram_port_], | 793 kPorts[histogram_port_], |
| 798 load_size_string.c_str()); | 794 load_size_string.c_str()); |
| 799 | 795 |
| 796 uint32 six_packets_received_mask = | |
|
jar (doing other things)
2012/09/14 22:34:54
nit: suggest correlated_packet_mask
This way, the
ramant (doing other things)
2012/09/14 23:39:08
Done.
| |
| 797 ((1 << kMaximumCorrelationPackets) - 1) & packets_received_mask_; | |
| 798 | |
| 800 // If we are running without a proxy, we'll generate 2 distinct histograms in | 799 // If we are running without a proxy, we'll generate 2 distinct histograms in |
| 801 // each case, one will have the ".NoProxy" suffix. | 800 // each case, one will have the ".NoProxy" suffix. |
| 802 size_t histogram_count = has_proxy_server_ ? 1 : 2; | 801 size_t histogram_count = has_proxy_server_ ? 1 : 2; |
| 803 for (size_t i = 0; i < histogram_count; i++) { | 802 for (size_t i = 0; i < histogram_count; i++) { |
| 804 // For packet loss test, just record packet loss data. | 803 // For packet loss test, just record packet loss data. |
| 805 base::Histogram* series_acked_histogram = base::LinearHistogram::FactoryGet( | 804 base::Histogram* series_acked_histogram = base::LinearHistogram::FactoryGet( |
| 806 series_acked_histogram_name, | 805 series_acked_histogram_name, |
| 807 1, | 806 1, |
| 808 2 << kMaximumCorrelationPackets, | 807 2 << kMaximumCorrelationPackets, |
|
jar (doing other things)
2012/09/14 22:34:54
I think this and the next line can use (with plus
ramant (doing other things)
2012/09/14 23:39:08
Done.
| |
| 809 (2 << kMaximumCorrelationPackets) + 1, | 808 (2 << kMaximumCorrelationPackets) + 1, |
| 810 base::Histogram::kUmaTargetedHistogramFlag); | 809 base::Histogram::kUmaTargetedHistogramFlag); |
| 811 series_acked_histogram->Add(packets_received_mask_); | 810 series_acked_histogram->Add(six_packets_received_mask); |
| 812 series_acked_histogram_name.append(".NoProxy"); | 811 series_acked_histogram_name.append(".NoProxy"); |
| 813 | 812 |
| 814 base::Histogram* packets_sent_histogram = | 813 base::Histogram* packets_sent_histogram = |
| 815 base::Histogram::FactoryGet( | 814 base::Histogram::FactoryGet( |
| 816 packets_sent_histogram_name, | 815 packets_sent_histogram_name, |
| 817 1, kMaximumCorrelationPackets, kMaximumCorrelationPackets + 1, | 816 1, kMaximumCorrelationPackets, kMaximumCorrelationPackets + 1, |
|
jar (doing other things)
2012/09/14 22:34:54
We might not need this anymore, as we'll get it as
ramant (doing other things)
2012/09/14 23:39:08
Done.
| |
| 818 base::Histogram::kUmaTargetedHistogramFlag); | 817 base::Histogram::kUmaTargetedHistogramFlag); |
| 819 packets_sent_histogram->Add(packets_sent_); | 818 packets_sent_histogram->Add(packets_sent_); |
| 820 packets_sent_histogram_name.append(".NoProxy"); | 819 packets_sent_histogram_name.append(".NoProxy"); |
| 821 } | 820 } |
| 822 } | 821 } |
| 823 | 822 |
| 824 void NetworkStats::RecordRTTHistograms(const ProtocolValue& protocol, | 823 void NetworkStats::RecordRTTHistograms(const ProtocolValue& protocol, |
| 825 const std::string& load_size_string, | 824 const std::string& load_size_string, |
| 826 uint32 index) { | 825 uint32 index) { |
| 827 DCHECK_GE(index, 0u); | 826 DCHECK_GE(index, 0u); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1007 const net::HostPortPair& server_address, | 1006 const net::HostPortPair& server_address, |
| 1008 NetworkStats::HistogramPortSelector histogram_port, | 1007 NetworkStats::HistogramPortSelector histogram_port, |
| 1009 bool has_proxy_server) { | 1008 bool has_proxy_server) { |
| 1010 int experiment_to_run = base::RandInt(1, 4); | 1009 int experiment_to_run = base::RandInt(1, 4); |
| 1011 switch (experiment_to_run) { | 1010 switch (experiment_to_run) { |
| 1012 case 1: | 1011 case 1: |
| 1013 { | 1012 { |
| 1014 NetworkStats* udp_stats_client = new NetworkStats(); | 1013 NetworkStats* udp_stats_client = new NetworkStats(); |
| 1015 udp_stats_client->Start( | 1014 udp_stats_client->Start( |
| 1016 host_resolver, server_address, histogram_port, has_proxy_server, | 1015 host_resolver, server_address, histogram_port, has_proxy_server, |
| 1017 kLargeTestBytesToSend, kMaximumCorrelationPackets, | 1016 kLargeTestBytesToSend, kMaximumCorrelationPackets, |
|
jar (doing other things)
2012/09/14 22:34:54
We probably don't need this test anymore. Line 10
ramant (doing other things)
2012/09/14 23:39:08
Done.
| |
| 1018 net::CompletionCallback()); | 1017 net::CompletionCallback()); |
| 1019 } | 1018 } |
| 1020 break; | 1019 break; |
| 1021 case 2: | 1020 case 2: |
| 1022 { | 1021 { |
| 1023 NetworkStats* udp_stats_client = new NetworkStats(); | 1022 NetworkStats* udp_stats_client = new NetworkStats(); |
| 1024 udp_stats_client->Start( | 1023 udp_stats_client->Start( |
| 1025 host_resolver, server_address, histogram_port, has_proxy_server, | 1024 host_resolver, server_address, histogram_port, has_proxy_server, |
| 1026 kSmallTestBytesToSend, kMaximumSequentialPackets, | 1025 kSmallTestBytesToSend, kMaximumSequentialPackets, |
| 1027 net::CompletionCallback()); | 1026 net::CompletionCallback()); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1042 udp_stats_client->Start( | 1041 udp_stats_client->Start( |
| 1043 host_resolver, server_address, histogram_port, has_proxy_server, | 1042 host_resolver, server_address, histogram_port, has_proxy_server, |
| 1044 kLargeTestBytesToSend, kMaximumSequentialPackets, | 1043 kLargeTestBytesToSend, kMaximumSequentialPackets, |
| 1045 net::CompletionCallback()); | 1044 net::CompletionCallback()); |
| 1046 } | 1045 } |
| 1047 break; | 1046 break; |
| 1048 } | 1047 } |
| 1049 } | 1048 } |
| 1050 | 1049 |
| 1051 } // namespace chrome_browser_net | 1050 } // namespace chrome_browser_net |
| OLD | NEW |