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

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

Issue 2670053002: Allow applications to limit the ICE check rate through RTCConfiguration (Closed)
Patch Set: CR feedback Created 3 years, 10 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
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // When the socket is unwritable, we will use 10 Kbps (ignoring IP+UDP headers) 64 // When the socket is unwritable, we will use 10 Kbps (ignoring IP+UDP headers)
65 // for pinging. When the socket is writable, we will use only 1 Kbps because 65 // for pinging. When the socket is writable, we will use only 1 Kbps because
66 // we don't want to degrade the quality on a modem. These numbers should work 66 // we don't want to degrade the quality on a modem. These numbers should work
67 // well on a 28.8K modem, which is the slowest connection on which the voice 67 // well on a 28.8K modem, which is the slowest connection on which the voice
68 // quality is reasonable at all. 68 // quality is reasonable at all.
69 static const int PING_PACKET_SIZE = 60 * 8; 69 static const int PING_PACKET_SIZE = 60 * 8;
70 70
71 // The next two ping intervals are at the channel level. 71 // The next two ping intervals are at the channel level.
72 // STRONG_PING_INTERVAL (480ms) is applied when the selected connection is both 72 // STRONG_PING_INTERVAL (480ms) is applied when the selected connection is both
73 // writable and receiving. 73 // writable and receiving.
74 static const int STRONG_PING_INTERVAL = 1000 * PING_PACKET_SIZE / 1000; 74 const int STRONG_PING_INTERVAL = 1000 * PING_PACKET_SIZE / 1000;
75 // WEAK_PING_INTERVAL (48ms) is applied when the selected connection is either 75 // WEAK_PING_INTERVAL (48ms) is applied when the selected connection is either
76 // not writable or not receiving. 76 // not writable or not receiving.
77 const int WEAK_PING_INTERVAL = 1000 * PING_PACKET_SIZE / 10000; 77 const int WEAK_PING_INTERVAL = 1000 * PING_PACKET_SIZE / 10000;
78 78
79 // The next two ping intervals are at the connection level. 79 // The next two ping intervals are at the connection level.
80 // Writable connections are pinged at a faster rate while the connections are 80 // Writable connections are pinged at a faster rate while the connections are
81 // stabilizing or the channel is weak. 81 // stabilizing or the channel is weak.
82 const int WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL = 900; // ms 82 const int WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL = 900; // ms
83 // Writable connections are pinged at a slower rate once they are stabilized and 83 // Writable connections are pinged at a slower rate once they are stabilized and
84 // the channel is strongly connected. 84 // the channel is strongly connected.
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 config_.receiving_switching_delay = config.receiving_switching_delay; 423 config_.receiving_switching_delay = config.receiving_switching_delay;
424 LOG(LS_INFO) << "Set receiving_switching_delay to" 424 LOG(LS_INFO) << "Set receiving_switching_delay to"
425 << *config_.receiving_switching_delay; 425 << *config_.receiving_switching_delay;
426 } 426 }
427 427
428 if (config_.default_nomination_mode != config.default_nomination_mode) { 428 if (config_.default_nomination_mode != config.default_nomination_mode) {
429 config_.default_nomination_mode = config.default_nomination_mode; 429 config_.default_nomination_mode = config.default_nomination_mode;
430 LOG(LS_INFO) << "Set default nomination mode to " 430 LOG(LS_INFO) << "Set default nomination mode to "
431 << static_cast<int>(config_.default_nomination_mode); 431 << static_cast<int>(config_.default_nomination_mode);
432 } 432 }
433
434 if (config_.ice_check_min_interval != config.ice_check_min_interval) {
435 config_.ice_check_min_interval = config.ice_check_min_interval;
436 LOG(LS_INFO) << "Set min ping interval to "
437 << *config_.ice_check_min_interval;
438 }
433 } 439 }
434 440
435 const IceConfig& P2PTransportChannel::config() const { 441 const IceConfig& P2PTransportChannel::config() const {
436 return config_; 442 return config_;
437 } 443 }
438 444
439 void P2PTransportChannel::SetMetricsObserver( 445 void P2PTransportChannel::SetMetricsObserver(
440 webrtc::MetricsObserverInterface* observer) { 446 webrtc::MetricsObserverInterface* observer) {
441 metrics_observer_ = observer; 447 metrics_observer_ = observer;
442 } 448 }
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 UpdateConnectionStates(); 1521 UpdateConnectionStates();
1516 // When the selected connection is not receiving or not writable, or any 1522 // When the selected connection is not receiving or not writable, or any
1517 // active connection has not been pinged enough times, use the weak ping 1523 // active connection has not been pinged enough times, use the weak ping
1518 // interval. 1524 // interval.
1519 bool need_more_pings_at_weak_interval = std::any_of( 1525 bool need_more_pings_at_weak_interval = std::any_of(
1520 connections_.begin(), connections_.end(), [](Connection* conn) { 1526 connections_.begin(), connections_.end(), [](Connection* conn) {
1521 return conn->active() && 1527 return conn->active() &&
1522 conn->num_pings_sent() < MIN_PINGS_AT_WEAK_PING_INTERVAL; 1528 conn->num_pings_sent() < MIN_PINGS_AT_WEAK_PING_INTERVAL;
1523 }); 1529 });
1524 int ping_interval = (weak() || need_more_pings_at_weak_interval) 1530 int ping_interval = (weak() || need_more_pings_at_weak_interval)
1525 ? weak_ping_interval_ 1531 ? weak_ping_interval()
1526 : STRONG_PING_INTERVAL; 1532 : strong_ping_interval();
1527 if (rtc::TimeMillis() >= last_ping_sent_ms_ + ping_interval) { 1533 if (rtc::TimeMillis() >= last_ping_sent_ms_ + ping_interval) {
1528 Connection* conn = FindNextPingableConnection(); 1534 Connection* conn = FindNextPingableConnection();
1529 if (conn) { 1535 if (conn) {
1530 PingConnection(conn); 1536 PingConnection(conn);
1531 MarkConnectionPinged(conn); 1537 MarkConnectionPinged(conn);
1532 } 1538 }
1533 } 1539 }
1534 int delay = std::min(ping_interval, check_receiving_interval_); 1540 int delay = std::min(ping_interval, check_receiving_interval_);
1535 thread()->PostDelayed(RTC_FROM_HERE, delay, this, MSG_CHECK_AND_PING); 1541 thread()->PostDelayed(RTC_FROM_HERE, delay, this, MSG_CHECK_AND_PING);
1536 } 1542 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 int interval = CalculateActiveWritablePingInterval(conn, now); 1606 int interval = CalculateActiveWritablePingInterval(conn, now);
1601 return conn->last_ping_sent() + interval <= now; 1607 return conn->last_ping_sent() + interval <= now;
1602 } 1608 }
1603 1609
1604 int P2PTransportChannel::CalculateActiveWritablePingInterval( 1610 int P2PTransportChannel::CalculateActiveWritablePingInterval(
1605 const Connection* conn, 1611 const Connection* conn,
1606 int64_t now) const { 1612 int64_t now) const {
1607 // Ping each connection at a higher rate at least 1613 // Ping each connection at a higher rate at least
1608 // MIN_PINGS_AT_WEAK_PING_INTERVAL times. 1614 // MIN_PINGS_AT_WEAK_PING_INTERVAL times.
1609 if (conn->num_pings_sent() < MIN_PINGS_AT_WEAK_PING_INTERVAL) { 1615 if (conn->num_pings_sent() < MIN_PINGS_AT_WEAK_PING_INTERVAL) {
1610 return weak_ping_interval_; 1616 return weak_ping_interval();
1611 } 1617 }
1612 1618
1613 int stable_interval = config_.stable_writable_connection_ping_interval; 1619 int stable_interval = config_.stable_writable_connection_ping_interval;
1614 int weak_or_stablizing_interval = std::min( 1620 int weak_or_stablizing_interval = std::min(
1615 stable_interval, WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL); 1621 stable_interval, WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL);
1616 // If the channel is weak or the connection is not stable yet, use the 1622 // If the channel is weak or the connection is not stable yet, use the
1617 // weak_or_stablizing_interval. 1623 // weak_or_stablizing_interval.
1618 return (!weak() && conn->stable(now)) ? stable_interval 1624 return (!weak() && conn->stable(now)) ? stable_interval
1619 : weak_or_stablizing_interval; 1625 : weak_or_stablizing_interval;
1620 } 1626 }
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 2040
2035 void P2PTransportChannel::set_receiving(bool receiving) { 2041 void P2PTransportChannel::set_receiving(bool receiving) {
2036 if (receiving_ == receiving) { 2042 if (receiving_ == receiving) {
2037 return; 2043 return;
2038 } 2044 }
2039 receiving_ = receiving; 2045 receiving_ = receiving;
2040 SignalReceivingState(this); 2046 SignalReceivingState(this);
2041 } 2047 }
2042 2048
2043 } // namespace cricket 2049 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698