Increase the stun ping interval.
Writable connections are pinged at a slower rate. The function IsPingable will filter out the writable connections. The interval for slower ping rate by default is WRITABLE_CONNECTION_PING_INTERVAL(2500ms) and can be set with the configuration. BUG=webrtc:1161 Review-Url: https://codereview.webrtc.org/1944003002 Cr-Commit-Position: refs/heads/master@{#12736}
This commit is contained in:
parent
6ba3b1976f
commit
8f7a5aad55
@ -217,10 +217,8 @@ static const int STRONG_PING_INTERVAL = 1000 * PING_PACKET_SIZE / 1000;
|
||||
// writable or not receiving.
|
||||
const int WEAK_PING_INTERVAL = 1000 * PING_PACKET_SIZE / 10000;
|
||||
|
||||
// If the current best connection is both writable and receiving, then we will
|
||||
// also try hard to make sure it is pinged at this rate (a little less than
|
||||
// 2 * STRONG_PING_INTERVAL).
|
||||
static const int MAX_CURRENT_STRONG_INTERVAL = 900; // ms
|
||||
// Writable connections are pinged at a slower rate.
|
||||
static const int WRITABLE_CONNECTION_PING_INTERVAL = 2500; // ms
|
||||
|
||||
static const int MIN_CHECK_RECEIVING_INTERVAL = 50; // ms
|
||||
|
||||
@ -250,7 +248,7 @@ P2PTransportChannel::P2PTransportChannel(const std::string& transport_name,
|
||||
0 /* backup_connection_ping_interval */,
|
||||
false /* gather_continually */,
|
||||
false /* prioritize_most_likely_candidate_pairs */,
|
||||
MAX_CURRENT_STRONG_INTERVAL /* max_strong_interval */) {
|
||||
WRITABLE_CONNECTION_PING_INTERVAL) {
|
||||
uint32_t weak_ping_interval = ::strtoul(
|
||||
webrtc::field_trial::FindFullName("WebRTC-StunInterPacketDelay").c_str(),
|
||||
nullptr, 10);
|
||||
@ -433,11 +431,13 @@ void P2PTransportChannel::SetIceConfig(const IceConfig& config) {
|
||||
LOG(LS_INFO) << "Set ping most likely connection to "
|
||||
<< config_.prioritize_most_likely_candidate_pairs;
|
||||
|
||||
if (config.max_strong_interval >= 0 &&
|
||||
config_.max_strong_interval != config.max_strong_interval) {
|
||||
config_.max_strong_interval = config.max_strong_interval;
|
||||
LOG(LS_INFO) << "Set max strong interval to "
|
||||
<< config_.max_strong_interval;
|
||||
if (config.writable_connection_ping_interval >= 0 &&
|
||||
config_.writable_connection_ping_interval !=
|
||||
config.writable_connection_ping_interval) {
|
||||
config_.writable_connection_ping_interval =
|
||||
config.writable_connection_ping_interval;
|
||||
LOG(LS_INFO) << "Set writable_connection_ping_interval to "
|
||||
<< config_.writable_connection_ping_interval;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1307,6 +1307,7 @@ void P2PTransportChannel::OnCheckAndPing() {
|
||||
MarkConnectionPinged(conn);
|
||||
}
|
||||
}
|
||||
|
||||
int delay = std::min(ping_interval, check_receiving_interval_);
|
||||
thread()->PostDelayed(delay, this, MSG_CHECK_AND_PING);
|
||||
}
|
||||
@ -1348,6 +1349,13 @@ bool P2PTransportChannel::IsPingable(Connection* conn, int64_t now) {
|
||||
return (now >= conn->last_ping_response_received() +
|
||||
config_.backup_connection_ping_interval);
|
||||
}
|
||||
|
||||
// Writable connections are pinged at a slower rate.
|
||||
if (conn->writable()) {
|
||||
return (now >=
|
||||
conn->last_ping_sent() + config_.writable_connection_ping_interval);
|
||||
}
|
||||
|
||||
return conn->active();
|
||||
}
|
||||
|
||||
@ -1363,7 +1371,8 @@ Connection* P2PTransportChannel::FindNextPingableConnection() {
|
||||
Connection* conn_to_ping = nullptr;
|
||||
if (best_connection_ && best_connection_->connected() &&
|
||||
best_connection_->writable() &&
|
||||
(best_connection_->last_ping_sent() + config_.max_strong_interval <=
|
||||
(best_connection_->last_ping_sent() +
|
||||
config_.writable_connection_ping_interval <=
|
||||
now)) {
|
||||
conn_to_ping = best_connection_;
|
||||
} else {
|
||||
|
||||
@ -2696,13 +2696,14 @@ class P2PTransportChannelMostLikelyToWorkFirstTest
|
||||
|
||||
cricket::P2PTransportChannel& StartTransportChannel(
|
||||
bool prioritize_most_likely_to_work,
|
||||
int max_strong_interval) {
|
||||
int writable_connection_ping_interval) {
|
||||
channel_.reset(
|
||||
new cricket::P2PTransportChannel("checks", 1, nullptr, allocator()));
|
||||
cricket::IceConfig config = channel_->config();
|
||||
config.prioritize_most_likely_candidate_pairs =
|
||||
prioritize_most_likely_to_work;
|
||||
config.max_strong_interval = max_strong_interval;
|
||||
config.writable_connection_ping_interval =
|
||||
writable_connection_ping_interval;
|
||||
channel_->SetIceConfig(config);
|
||||
PrepareChannel(channel_.get());
|
||||
channel_->Connect();
|
||||
|
||||
@ -154,23 +154,22 @@ struct IceConfig {
|
||||
// is writable yet.
|
||||
bool prioritize_most_likely_candidate_pairs = false;
|
||||
|
||||
// If the current best connection is both writable and receiving,
|
||||
// then we will also try hard to make sure it is pinged at this rate
|
||||
// (Default value is a little less than 2 * STRONG_PING_INTERVAL).
|
||||
int max_strong_interval = -1;
|
||||
// Writable connections are pinged at a slower rate.
|
||||
int writable_connection_ping_interval = -1;
|
||||
|
||||
IceConfig() {}
|
||||
IceConfig(int receiving_timeout_ms,
|
||||
int backup_connection_ping_interval,
|
||||
bool gather_continually,
|
||||
bool prioritize_most_likely_candidate_pairs,
|
||||
int max_strong_interval_ms)
|
||||
int writable_connection_ping_interval_ms)
|
||||
: receiving_timeout(receiving_timeout_ms),
|
||||
backup_connection_ping_interval(backup_connection_ping_interval),
|
||||
gather_continually(gather_continually),
|
||||
prioritize_most_likely_candidate_pairs(
|
||||
prioritize_most_likely_candidate_pairs),
|
||||
max_strong_interval(max_strong_interval_ms) {}
|
||||
writable_connection_ping_interval(
|
||||
writable_connection_ping_interval_ms) {}
|
||||
};
|
||||
|
||||
bool BadTransportDescription(const std::string& desc, std::string* err_desc);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user