| OLD | NEW | 
|---|
| 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  Loading... | 
| 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  Loading... | 
| 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_.min_ping_interval != config.min_ping_interval) { | 
|  | 435     config_.min_ping_interval = config.min_ping_interval; | 
|  | 436     LOG(LS_INFO) << "Set min ping interval to " << *config_.min_ping_interval; | 
|  | 437   } | 
| 433 } | 438 } | 
| 434 | 439 | 
| 435 const IceConfig& P2PTransportChannel::config() const { | 440 const IceConfig& P2PTransportChannel::config() const { | 
| 436   return config_; | 441   return config_; | 
| 437 } | 442 } | 
| 438 | 443 | 
| 439 void P2PTransportChannel::SetMetricsObserver( | 444 void P2PTransportChannel::SetMetricsObserver( | 
| 440     webrtc::MetricsObserverInterface* observer) { | 445     webrtc::MetricsObserverInterface* observer) { | 
| 441   metrics_observer_ = observer; | 446   metrics_observer_ = observer; | 
| 442 } | 447 } | 
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1515   UpdateConnectionStates(); | 1520   UpdateConnectionStates(); | 
| 1516   // When the selected connection is not receiving or not writable, or any | 1521   // 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 | 1522   // active connection has not been pinged enough times, use the weak ping | 
| 1518   // interval. | 1523   // interval. | 
| 1519   bool need_more_pings_at_weak_interval = std::any_of( | 1524   bool need_more_pings_at_weak_interval = std::any_of( | 
| 1520       connections_.begin(), connections_.end(), [](Connection* conn) { | 1525       connections_.begin(), connections_.end(), [](Connection* conn) { | 
| 1521         return conn->active() && | 1526         return conn->active() && | 
| 1522                conn->num_pings_sent() < MIN_PINGS_AT_WEAK_PING_INTERVAL; | 1527                conn->num_pings_sent() < MIN_PINGS_AT_WEAK_PING_INTERVAL; | 
| 1523       }); | 1528       }); | 
| 1524   int ping_interval = (weak() || need_more_pings_at_weak_interval) | 1529   int ping_interval = (weak() || need_more_pings_at_weak_interval) | 
| 1525                           ? weak_ping_interval_ | 1530                           ? weak_ping_interval() | 
| 1526                           : STRONG_PING_INTERVAL; | 1531                           : strong_ping_interval(); | 
| 1527   if (rtc::TimeMillis() >= last_ping_sent_ms_ + ping_interval) { | 1532   if (rtc::TimeMillis() >= last_ping_sent_ms_ + ping_interval) { | 
| 1528     Connection* conn = FindNextPingableConnection(); | 1533     Connection* conn = FindNextPingableConnection(); | 
| 1529     if (conn) { | 1534     if (conn) { | 
| 1530       PingConnection(conn); | 1535       PingConnection(conn); | 
| 1531       MarkConnectionPinged(conn); | 1536       MarkConnectionPinged(conn); | 
| 1532     } | 1537     } | 
| 1533   } | 1538   } | 
| 1534   int delay = std::min(ping_interval, check_receiving_interval_); | 1539   int delay = std::min(ping_interval, check_receiving_interval_); | 
| 1535   thread()->PostDelayed(RTC_FROM_HERE, delay, this, MSG_CHECK_AND_PING); | 1540   thread()->PostDelayed(RTC_FROM_HERE, delay, this, MSG_CHECK_AND_PING); | 
| 1536 } | 1541 } | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1600   int interval = CalculateActiveWritablePingInterval(conn, now); | 1605   int interval = CalculateActiveWritablePingInterval(conn, now); | 
| 1601   return conn->last_ping_sent() + interval <= now; | 1606   return conn->last_ping_sent() + interval <= now; | 
| 1602 } | 1607 } | 
| 1603 | 1608 | 
| 1604 int P2PTransportChannel::CalculateActiveWritablePingInterval( | 1609 int P2PTransportChannel::CalculateActiveWritablePingInterval( | 
| 1605     const Connection* conn, | 1610     const Connection* conn, | 
| 1606     int64_t now) const { | 1611     int64_t now) const { | 
| 1607   // Ping each connection at a higher rate at least | 1612   // Ping each connection at a higher rate at least | 
| 1608   // MIN_PINGS_AT_WEAK_PING_INTERVAL times. | 1613   // MIN_PINGS_AT_WEAK_PING_INTERVAL times. | 
| 1609   if (conn->num_pings_sent() < MIN_PINGS_AT_WEAK_PING_INTERVAL) { | 1614   if (conn->num_pings_sent() < MIN_PINGS_AT_WEAK_PING_INTERVAL) { | 
| 1610     return weak_ping_interval_; | 1615     return weak_ping_interval(); | 
| 1611   } | 1616   } | 
| 1612 | 1617 | 
| 1613   int stable_interval = config_.stable_writable_connection_ping_interval; | 1618   int stable_interval = config_.stable_writable_connection_ping_interval; | 
| 1614   int weak_or_stablizing_interval = std::min( | 1619   int weak_or_stablizing_interval = std::min( | 
| 1615       stable_interval, WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL); | 1620       stable_interval, WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL); | 
| 1616   // If the channel is weak or the connection is not stable yet, use the | 1621   // If the channel is weak or the connection is not stable yet, use the | 
| 1617   // weak_or_stablizing_interval. | 1622   // weak_or_stablizing_interval. | 
| 1618   return (!weak() && conn->stable(now)) ? stable_interval | 1623   return (!weak() && conn->stable(now)) ? stable_interval | 
| 1619                                         : weak_or_stablizing_interval; | 1624                                         : weak_or_stablizing_interval; | 
| 1620 } | 1625 } | 
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2034 | 2039 | 
| 2035 void P2PTransportChannel::set_receiving(bool receiving) { | 2040 void P2PTransportChannel::set_receiving(bool receiving) { | 
| 2036   if (receiving_ == receiving) { | 2041   if (receiving_ == receiving) { | 
| 2037     return; | 2042     return; | 
| 2038   } | 2043   } | 
| 2039   receiving_ = receiving; | 2044   receiving_ = receiving; | 
| 2040   SignalReceivingState(this); | 2045   SignalReceivingState(this); | 
| 2041 } | 2046 } | 
| 2042 | 2047 | 
| 2043 }  // namespace cricket | 2048 }  // namespace cricket | 
| OLD | NEW | 
|---|