From 330fbee5d870d7519a3067fe191117545f310c0c Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Fri, 12 Apr 2019 10:02:31 +0200 Subject: [PATCH] Make ExtraICEPing send slightly fewer extras This patch introduces a minor tweak to how often the extra ice pings are sent. - never send if non of the candidates is relay - only send (extra) if it was more than 100ms since you sent a ping. The motivation for this is that we measured an regression of 0.05% in call setup success rate. Bug: webrtc:10273 Change-Id: Icff36297d57030853a9ff8d4f74aaf6c84051d26 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132702 Reviewed-by: Jeroen de Borst Reviewed-by: Rasmus Brandt Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/master@{#27601} --- p2p/base/port.cc | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/p2p/base/port.cc b/p2p/base/port.cc index d6d402ef57..645cc650cf 100644 --- a/p2p/base/port.cc +++ b/p2p/base/port.cc @@ -155,6 +155,8 @@ const int RTT_RATIO = 3; // 3 : 1 // it to a little higher than a total STUN timeout. const int kPortTimeoutDelay = cricket::STUN_TOTAL_TIMEOUT + 5000; +constexpr int64_t kMinExtraPingDelayMs = 100; + } // namespace namespace cricket { @@ -1331,8 +1333,26 @@ void Connection::HandleBindingRequest(IceMessage* msg) { ReceivedPing(); if (webrtc::field_trial::IsEnabled("WebRTC-ExtraICEPing") && last_ping_response_received_ == 0) { - RTC_LOG(LS_INFO) << ToString() << "WebRTC-ExtraICEPing/Sending extra ping"; - Ping(rtc::TimeMillis()); + if (local_candidate().type() == RELAY_PORT_TYPE || + local_candidate().type() == PRFLX_PORT_TYPE || + remote_candidate().type() == RELAY_PORT_TYPE || + remote_candidate().type() == PRFLX_PORT_TYPE) { + const int64_t now = rtc::TimeMillis(); + if (last_ping_sent_ + kMinExtraPingDelayMs <= now) { + RTC_LOG(LS_INFO) << ToString() + << "WebRTC-ExtraICEPing/Sending extra ping" + << " last_ping_sent_: " << last_ping_sent_ + << " now: " << now + << " (diff: " << (now - last_ping_sent_) << ")"; + Ping(now); + } else { + RTC_LOG(LS_INFO) << ToString() + << "WebRTC-ExtraICEPing/Not sending extra ping" + << " last_ping_sent_: " << last_ping_sent_ + << " now: " << now + << " (diff: " << (now - last_ping_sent_) << ")"; + } + } } const rtc::SocketAddress& remote_addr = remote_candidate_.address();