Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: webrtc/p2p/stunprober/main.cc

Issue 1166013002: Better determination of Symmetric NAT (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/p2p/stunprober/stunprober.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 private: 100 private:
101 AsyncCallback callback_; 101 AsyncCallback callback_;
102 rtc::SocketAddress addr_; 102 rtc::SocketAddress addr_;
103 std::vector<rtc::SocketAddress>* result_; 103 std::vector<rtc::SocketAddress>* result_;
104 104
105 // Not using smart ptr here as this requires specific release pattern. 105 // Not using smart ptr here as this requires specific release pattern.
106 rtc::AsyncResolver* resolver_; 106 rtc::AsyncResolver* resolver_;
107 }; 107 };
108 108
109 std::string HistogramName(bool behind_nat, 109 const char* PrintNatType(stunprober::NatType type) {
110 bool is_src_port_shared, 110 switch (type) {
111 int interval_ms, 111 case stunprober::NATTYPE_NONE:
112 std::string suffix) { 112 return "Not behind a NAT";
113 char output[1000]; 113 case stunprober::NATTYPE_UNKNOWN:
114 rtc::sprintfn(output, sizeof(output), "NetConnectivity6.%s.%s.%dms.%s", 114 return "Unknown NAT type";
115 behind_nat ? "NAT" : "NoNAT", 115 case stunprober::NATTYPE_SYMMETRIC:
116 is_src_port_shared ? "SrcPortShared" : "SrcPortUnique", 116 return "Symmetric NAT";
117 interval_ms, suffix.c_str()); 117 case stunprober::NATTYPE_NON_SYMMETRIC:
118 return std::string(output); 118 return "Non-Symmetric NAT";
119 default:
120 return "Invalid";
121 }
119 } 122 }
120 123
121 void PrintStats(StunProber* prober) { 124 void PrintStats(StunProber* prober) {
122 StunProber::Stats stats; 125 StunProber::Stats stats;
123 if (!prober->GetStats(&stats)) { 126 if (!prober->GetStats(&stats)) {
124 LOG(LS_WARNING) << "Results are inconclusive."; 127 LOG(LS_WARNING) << "Results are inconclusive.";
125 return; 128 return;
126 } 129 }
127 130
128 LOG(LS_INFO) << "Shared Socket Mode: " << stats.shared_socket_mode; 131 LOG(LS_INFO) << "Shared Socket Mode: " << stats.shared_socket_mode;
129 LOG(LS_INFO) << "Requests sent: " << stats.num_request_sent; 132 LOG(LS_INFO) << "Requests sent: " << stats.num_request_sent;
130 LOG(LS_INFO) << "Responses received: " << stats.num_response_received; 133 LOG(LS_INFO) << "Responses received: " << stats.num_response_received;
131 LOG(LS_INFO) << "Target interval (ns): " << stats.target_request_interval_ns; 134 LOG(LS_INFO) << "Target interval (ns): " << stats.target_request_interval_ns;
132 LOG(LS_INFO) << "Actual interval (ns): " << stats.actual_request_interval_ns; 135 LOG(LS_INFO) << "Actual interval (ns): " << stats.actual_request_interval_ns;
133 LOG(LS_INFO) << "Behind NAT: " << stats.behind_nat; 136 LOG(LS_INFO) << "NAT Type: " << PrintNatType(stats.nat_type);
134 if (stats.behind_nat) {
135 LOG(LS_INFO) << "NAT is symmetrical: " << (stats.srflx_addrs.size() > 1);
136 }
137 LOG(LS_INFO) << "Host IP: " << stats.host_ip; 137 LOG(LS_INFO) << "Host IP: " << stats.host_ip;
138 LOG(LS_INFO) << "Server-reflexive ips: "; 138 LOG(LS_INFO) << "Server-reflexive ips: ";
139 for (auto& ip : stats.srflx_addrs) { 139 for (auto& ip : stats.srflx_addrs) {
140 LOG(LS_INFO) << "\t" << ip; 140 LOG(LS_INFO) << "\t" << ip;
141 } 141 }
142 142
143 std::string histogram_name = HistogramName( 143 LOG(LS_INFO) << "Success Precent: " << stats.success_percent;
144 stats.behind_nat, FLAG_shared_socket, FLAG_interval, "SuccessPercent"); 144 LOG(LS_INFO) << "Response Latency:" << stats.average_rtt_ms;
145
146 LOG(LS_INFO) << "Histogram '" << histogram_name.c_str()
147 << "' = " << stats.success_percent;
148
149 histogram_name = HistogramName(stats.behind_nat, FLAG_shared_socket,
150 FLAG_interval, "ResponseLatency");
151
152 LOG(LS_INFO) << "Histogram '" << histogram_name.c_str()
153 << "' = " << stats.average_rtt_ms << " ms";
154 } 145 }
155 146
156 void StopTrial(rtc::Thread* thread, StunProber* prober, int result) { 147 void StopTrial(rtc::Thread* thread, StunProber* prober, int result) {
157 thread->Quit(); 148 thread->Quit();
158 if (prober) { 149 if (prober) {
159 LOG(LS_INFO) << "Result: " << result; 150 LOG(LS_INFO) << "Result: " << result;
160 if (result == StunProber::SUCCESS) { 151 if (result == StunProber::SUCCESS) {
161 PrintStats(prober); 152 PrintStats(prober);
162 } 153 }
163 } 154 }
(...skipping 27 matching lines...) Expand all
191 new SocketFactory(), new TaskRunner()); 182 new SocketFactory(), new TaskRunner());
192 auto finish_callback = 183 auto finish_callback =
193 [thread, prober](int result) { StopTrial(thread, prober, result); }; 184 [thread, prober](int result) { StopTrial(thread, prober, result); };
194 prober->Start(server_addresses, FLAG_shared_socket, FLAG_interval, 185 prober->Start(server_addresses, FLAG_shared_socket, FLAG_interval,
195 FLAG_pings_per_ip, FLAG_timeout, 186 FLAG_pings_per_ip, FLAG_timeout,
196 AsyncCallback(finish_callback)); 187 AsyncCallback(finish_callback));
197 thread->Run(); 188 thread->Run();
198 delete prober; 189 delete prober;
199 return 0; 190 return 0;
200 } 191 }
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/stunprober/stunprober.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698