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

Unified Diff: webrtc/p2p/base/port.cc

Issue 1944003002: Increase the stun ping interval. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: First Serveral pings are sent at faster rate. Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/p2p/base/port.cc
diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc
index fbc64f2e0a784175a2f1f94ae25bac4aca3b710a..0c60da4c699d8ad98b44b858d5db06debd7e9da8 100644
--- a/webrtc/p2p/base/port.cc
+++ b/webrtc/p2p/base/port.cc
@@ -75,6 +75,9 @@ const int RTT_RATIO = 3; // 3 : 1
// The delay before we begin checking if this port is useless.
const int kPortTimeoutDelay = 30 * 1000; // 30 seconds
+
+// First N Pings are sent at a fast rate.
+const int kFirstNPingsWithFastRate = 10;
}
namespace cricket {
@@ -809,7 +812,8 @@ Connection::Connection(Port* port,
reported_(false),
state_(STATE_WAITING),
receiving_timeout_(WEAK_CONNECTION_RECEIVE_TIMEOUT),
- time_created_ms_(rtc::TimeMillis()) {
+ time_created_ms_(rtc::TimeMillis()),
+ ping_sent_count_(0) {
// All of our connections start in WAITING state.
// TODO(mallinath) - Start connections from STATE_FROZEN.
// Wire up to send stun packets
@@ -1125,6 +1129,7 @@ void Connection::Ping(int64_t now) {
<< ", id=" << rtc::hex_encode(req->id());
requests_.Send(req);
state_ = STATE_INPROGRESS;
+ ping_sent_count_++;
}
void Connection::ReceivedPing() {
@@ -1353,6 +1358,10 @@ int64_t Connection::last_received() const {
std::max(last_ping_received_, last_ping_response_received_));
}
+bool Connection::NeedToPingFast() {
+ return ping_sent_count_ <= kFirstNPingsWithFastRate;
+}
+
size_t Connection::recv_bytes_second() {
return round(recv_rate_tracker_.ComputeRate());
}

Powered by Google App Engine
This is Rietveld 408576698