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()); |
} |