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

Side by Side Diff: webrtc/p2p/base/port.cc

Issue 2099563004: Start ICE connectivity checks as soon as the first pair is pingable. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Start pinging when we first have a connection AND ICE credentials. Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 return false; 1226 return false;
1227 } 1227 }
1228 1228
1229 // If it has never received anything and is not actively pinging (pruned), we 1229 // If it has never received anything and is not actively pinging (pruned), we
1230 // keep it around for at least MIN_CONNECTION_LIFETIME to prevent connections 1230 // keep it around for at least MIN_CONNECTION_LIFETIME to prevent connections
1231 // from being pruned too quickly during a network change event when two 1231 // from being pruned too quickly during a network change event when two
1232 // networks would be up simultaneously but only for a brief period. 1232 // networks would be up simultaneously but only for a brief period.
1233 return now > (time_created_ms_ + MIN_CONNECTION_LIFETIME); 1233 return now > (time_created_ms_ + MIN_CONNECTION_LIFETIME);
1234 } 1234 }
1235 1235
1236 bool Connection::stable(int64_t now) { 1236 bool Connection::stable(int64_t now) const {
1237 // A connection is stable if it's RTT has converged and it isn't missing any 1237 // A connection is stable if it's RTT has converged and it isn't missing any
1238 // responses. We should send pings at a higher rate until the RTT converges 1238 // responses. We should send pings at a higher rate until the RTT converges
1239 // and whenever a ping response is missing (so that we can detect 1239 // and whenever a ping response is missing (so that we can detect
1240 // unwritability faster) 1240 // unwritability faster)
1241 return rtt_converged() && !missing_responses(now); 1241 return rtt_converged() && !missing_responses(now);
1242 } 1242 }
1243 1243
1244 std::string Connection::ToDebugId() const { 1244 std::string Connection::ToDebugId() const {
1245 std::stringstream ss; 1245 std::stringstream ss;
1246 ss << std::hex << this; 1246 ss << std::hex << this;
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 new_local_candidate.set_network_cost(local_candidate().network_cost()); 1498 new_local_candidate.set_network_cost(local_candidate().network_cost());
1499 1499
1500 // Change the local candidate of this Connection to the new prflx candidate. 1500 // Change the local candidate of this Connection to the new prflx candidate.
1501 local_candidate_index_ = port_->AddPrflxCandidate(new_local_candidate); 1501 local_candidate_index_ = port_->AddPrflxCandidate(new_local_candidate);
1502 1502
1503 // SignalStateChange to force a re-sort in P2PTransportChannel as this 1503 // SignalStateChange to force a re-sort in P2PTransportChannel as this
1504 // Connection's local candidate has changed. 1504 // Connection's local candidate has changed.
1505 SignalStateChange(this); 1505 SignalStateChange(this);
1506 } 1506 }
1507 1507
1508 bool Connection::rtt_converged() { 1508 bool Connection::rtt_converged() const {
1509 return rtt_samples_ > (RTT_RATIO + 1); 1509 return rtt_samples_ > (RTT_RATIO + 1);
1510 } 1510 }
1511 1511
1512 bool Connection::missing_responses(int64_t now) { 1512 bool Connection::missing_responses(int64_t now) const {
1513 if (pings_since_last_response_.empty()) { 1513 if (pings_since_last_response_.empty()) {
1514 return false; 1514 return false;
1515 } 1515 }
1516 1516
1517 int64_t waiting = now - pings_since_last_response_[0].sent_time; 1517 int64_t waiting = now - pings_since_last_response_[0].sent_time;
1518 return waiting > 2 * rtt(); 1518 return waiting > 2 * rtt();
1519 } 1519 }
1520 1520
1521 ProxyConnection::ProxyConnection(Port* port, 1521 ProxyConnection::ProxyConnection(Port* port,
1522 size_t index, 1522 size_t index,
(...skipping 13 matching lines...) Expand all
1536 ASSERT(sent < 0); 1536 ASSERT(sent < 0);
1537 error_ = port_->GetError(); 1537 error_ = port_->GetError();
1538 stats_.sent_discarded_packets++; 1538 stats_.sent_discarded_packets++;
1539 } else { 1539 } else {
1540 send_rate_tracker_.AddSamples(sent); 1540 send_rate_tracker_.AddSamples(sent);
1541 } 1541 }
1542 return sent; 1542 return sent;
1543 } 1543 }
1544 1544
1545 } // namespace cricket 1545 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698