From 833979f7b8a43d7ed41e660dcfc63023d266c3fb Mon Sep 17 00:00:00 2001 From: Jeroen de Borst Date: Thu, 13 Dec 2018 08:25:54 -0800 Subject: [PATCH] Adding metrics for hostname candidate use. These metrics by themselves won't be as useful, unless they can be correlated to the use of the feature 'WebRtcHideLocalIpsWithMdns'. This can be done by running a finch experiment where we turn the feature on for a % of users, we can then compare these metrics for users with and without the feature turned on. A complementary change is required in Chrome: tools/metrics/histograms/enums.xml Bug: webrtc:9605 webrtc:10091 chromium:914452 Change-Id: Ibc6d16dec95a8e3943ce40063c02903769fe1cb4 Reviewed-on: https://webrtc-review.googlesource.com/c/113321 Commit-Queue: Jeroen de Borst Reviewed-by: Steve Anton Reviewed-by: Seth Hampson Cr-Commit-Position: refs/heads/master@{#26003} --- api/umametrics.h | 9 +++++++-- pc/peerconnection.cc | 22 +++++++++++++++++++--- pc/peerconnection_integrationtest.cc | 4 ++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/api/umametrics.h b/api/umametrics.h index 88ab08c1be..239eff3869 100644 --- a/api/umametrics.h +++ b/api/umametrics.h @@ -79,12 +79,17 @@ enum IceCandidatePairType { kIceCandidatePairPrflxSrflx, kIceCandidatePairPrflxRelay, - // The following 4 types tell whether local and remote hosts have private or - // public IP addresses. + // The following 9 types tell whether local and remote hosts have hostname, + // private or public IP addresses. kIceCandidatePairHostPrivateHostPrivate, kIceCandidatePairHostPrivateHostPublic, kIceCandidatePairHostPublicHostPrivate, kIceCandidatePairHostPublicHostPublic, + kIceCandidatePairHostNameHostName, + kIceCandidatePairHostNameHostPrivate, + kIceCandidatePairHostNameHostPublic, + kIceCandidatePairHostPrivateHostName, + kIceCandidatePairHostPublicHostName, kIceCandidatePairMax }; diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc index c9f23020e8..6c92816f83 100644 --- a/pc/peerconnection.cc +++ b/pc/peerconnection.cc @@ -277,16 +277,32 @@ IceCandidatePairType GetIceCandidatePairCounter( const auto& relay = RELAY_PORT_TYPE; const auto& prflx = PRFLX_PORT_TYPE; if (l == host && r == host) { + bool local_hostname = + !local.address().hostname().empty() && local.address().IsUnresolvedIP(); + bool remote_hostname = !remote.address().hostname().empty() && + remote.address().IsUnresolvedIP(); bool local_private = IPIsPrivate(local.address().ipaddr()); bool remote_private = IPIsPrivate(remote.address().ipaddr()); - if (local_private) { - if (remote_private) { + if (local_hostname) { + if (remote_hostname) { + return kIceCandidatePairHostNameHostName; + } else if (remote_private) { + return kIceCandidatePairHostNameHostPrivate; + } else { + return kIceCandidatePairHostNameHostPublic; + } + } else if (local_private) { + if (remote_hostname) { + return kIceCandidatePairHostPrivateHostName; + } else if (remote_private) { return kIceCandidatePairHostPrivateHostPrivate; } else { return kIceCandidatePairHostPrivateHostPublic; } } else { - if (remote_private) { + if (remote_hostname) { + return kIceCandidatePairHostPublicHostName; + } else if (remote_private) { return kIceCandidatePairHostPublicHostPrivate; } else { return kIceCandidatePairHostPublicHostPublic; diff --git a/pc/peerconnection_integrationtest.cc b/pc/peerconnection_integrationtest.cc index fa1fb23486..c296e4c7d7 100644 --- a/pc/peerconnection_integrationtest.cc +++ b/pc/peerconnection_integrationtest.cc @@ -3674,6 +3674,10 @@ TEST_P(PeerConnectionIntegrationTest, caller()->ice_connection_state(), kDefaultTimeout); EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected, callee()->ice_connection_state(), kDefaultTimeout); + + EXPECT_EQ(1, webrtc::metrics::NumEvents( + "WebRTC.PeerConnection.CandidatePairType_UDP", + webrtc::kIceCandidatePairHostNameHostName)); } // Test that firewalling the ICE connection causes the clients to identify the