OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2009 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 static const int kOnlyLocalPorts = cricket::PORTALLOCATOR_DISABLE_STUN | | 48 static const int kOnlyLocalPorts = cricket::PORTALLOCATOR_DISABLE_STUN | |
49 cricket::PORTALLOCATOR_DISABLE_RELAY | | 49 cricket::PORTALLOCATOR_DISABLE_RELAY | |
50 cricket::PORTALLOCATOR_DISABLE_TCP; | 50 cricket::PORTALLOCATOR_DISABLE_TCP; |
51 static const int LOW_RTT = 20; | 51 static const int LOW_RTT = 20; |
52 // Addresses on the public internet. | 52 // Addresses on the public internet. |
53 static const SocketAddress kPublicAddrs[2] = | 53 static const SocketAddress kPublicAddrs[2] = |
54 { SocketAddress("11.11.11.11", 0), SocketAddress("22.22.22.22", 0) }; | 54 { SocketAddress("11.11.11.11", 0), SocketAddress("22.22.22.22", 0) }; |
55 // IPv6 Addresses on the public internet. | 55 // IPv6 Addresses on the public internet. |
56 static const SocketAddress kIPv6PublicAddrs[2] = { | 56 static const SocketAddress kIPv6PublicAddrs[2] = { |
57 SocketAddress("2400:4030:1:2c00:be30:abcd:efab:cdef", 0), | 57 SocketAddress("2400:4030:1:2c00:be30:abcd:efab:cdef", 0), |
58 SocketAddress("2620:0:1000:1b03:2e41:38ff:fea6:f2a4", 0) | 58 SocketAddress("2600:0:1000:1b03:2e41:38ff:fea6:f2a4", 0)}; |
59 }; | |
60 // For configuring multihomed clients. | 59 // For configuring multihomed clients. |
61 static const SocketAddress kAlternateAddrs[2] = { | 60 static const SocketAddress kAlternateAddrs[2] = { |
62 SocketAddress("101.101.101.101", 0), SocketAddress("202.202.202.202", 0)}; | 61 SocketAddress("101.101.101.101", 0), SocketAddress("202.202.202.202", 0)}; |
| 62 static const SocketAddress kIPv6AlternateAddrs[2] = { |
| 63 SocketAddress("2401:4030:1:2c00:be30:abcd:efab:cdef", 0), |
| 64 SocketAddress("2601:0:1000:1b03:2e41:38ff:fea6:f2a4", 0)}; |
63 // Addresses for HTTP proxy servers. | 65 // Addresses for HTTP proxy servers. |
64 static const SocketAddress kHttpsProxyAddrs[2] = | 66 static const SocketAddress kHttpsProxyAddrs[2] = |
65 { SocketAddress("11.11.11.1", 443), SocketAddress("22.22.22.1", 443) }; | 67 { SocketAddress("11.11.11.1", 443), SocketAddress("22.22.22.1", 443) }; |
66 // Addresses for SOCKS proxy servers. | 68 // Addresses for SOCKS proxy servers. |
67 static const SocketAddress kSocksProxyAddrs[2] = | 69 static const SocketAddress kSocksProxyAddrs[2] = |
68 { SocketAddress("11.11.11.1", 1080), SocketAddress("22.22.22.1", 1080) }; | 70 { SocketAddress("11.11.11.1", 1080), SocketAddress("22.22.22.1", 1080) }; |
69 // Internal addresses for NAT boxes. | 71 // Internal addresses for NAT boxes. |
70 static const SocketAddress kNatAddrs[2] = | 72 static const SocketAddress kNatAddrs[2] = |
71 { SocketAddress("192.168.1.1", 0), SocketAddress("192.168.2.1", 0) }; | 73 { SocketAddress("192.168.1.1", 0), SocketAddress("192.168.2.1", 0) }; |
72 // Private addresses inside the NAT private networks. | 74 // Private addresses inside the NAT private networks. |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 | 424 |
423 Endpoint* GetEndpoint(int endpoint) { | 425 Endpoint* GetEndpoint(int endpoint) { |
424 if (endpoint == 0) { | 426 if (endpoint == 0) { |
425 return &ep1_; | 427 return &ep1_; |
426 } else if (endpoint == 1) { | 428 } else if (endpoint == 1) { |
427 return &ep2_; | 429 return &ep2_; |
428 } else { | 430 } else { |
429 return NULL; | 431 return NULL; |
430 } | 432 } |
431 } | 433 } |
432 PortAllocator* GetAllocator(int endpoint) { | 434 BasicPortAllocator* GetAllocator(int endpoint) { |
433 return GetEndpoint(endpoint)->allocator_.get(); | 435 return GetEndpoint(endpoint)->allocator_.get(); |
434 } | 436 } |
435 webrtc::FakeMetricsObserver* GetMetricsObserver(int endpoint) { | 437 webrtc::FakeMetricsObserver* GetMetricsObserver(int endpoint) { |
436 return GetEndpoint(endpoint)->metrics_observer_; | 438 return GetEndpoint(endpoint)->metrics_observer_; |
437 } | 439 } |
438 void AddAddress(int endpoint, const SocketAddress& addr) { | 440 void AddAddress(int endpoint, const SocketAddress& addr) { |
439 GetEndpoint(endpoint)->network_manager_.AddInterface(addr); | 441 GetEndpoint(endpoint)->network_manager_.AddInterface(addr); |
440 } | 442 } |
441 void AddAddress(int endpoint, | 443 void AddAddress(int endpoint, |
442 const SocketAddress& addr, | 444 const SocketAddress& addr, |
(...skipping 1637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2080 ConfigureEndpoints(NAT_FULL_CONE, NAT_FULL_CONE, NAT_FULL_CONE); | 2082 ConfigureEndpoints(NAT_FULL_CONE, NAT_FULL_CONE, NAT_FULL_CONE); |
2081 Test( | 2083 Test( |
2082 P2PTransportChannelTestBase::Result("prflx", "udp", "stun", "udp", 1000)); | 2084 P2PTransportChannelTestBase::Result("prflx", "udp", "stun", "udp", 1000)); |
2083 } | 2085 } |
2084 | 2086 |
2085 // Test what happens when we have multiple available pathways. | 2087 // Test what happens when we have multiple available pathways. |
2086 // In the future we will try different RTTs and configs for the different | 2088 // In the future we will try different RTTs and configs for the different |
2087 // interfaces, so that we can simulate a user with Ethernet and VPN networks. | 2089 // interfaces, so that we can simulate a user with Ethernet and VPN networks. |
2088 class P2PTransportChannelMultihomedTest : public P2PTransportChannelTestBase { | 2090 class P2PTransportChannelMultihomedTest : public P2PTransportChannelTestBase { |
2089 public: | 2091 public: |
2090 const cricket::Connection* GetConnectionWithRemoteAddress( | 2092 const Connection* GetConnectionWithRemoteAddress( |
2091 cricket::P2PTransportChannel* channel, | 2093 P2PTransportChannel* channel, |
2092 const SocketAddress& address) { | 2094 const SocketAddress& address) { |
2093 for (cricket::Connection* conn : channel->connections()) { | 2095 for (Connection* conn : channel->connections()) { |
2094 if (conn->remote_candidate().address().EqualIPs(address)) { | 2096 if (conn->remote_candidate().address().EqualIPs(address)) { |
2095 return conn; | 2097 return conn; |
2096 } | 2098 } |
2097 } | 2099 } |
2098 return nullptr; | 2100 return nullptr; |
2099 } | 2101 } |
2100 | 2102 |
2101 cricket::Connection* GetConnectionWithLocalAddress( | 2103 Connection* GetConnectionWithLocalAddress(P2PTransportChannel* channel, |
2102 cricket::P2PTransportChannel* channel, | 2104 const SocketAddress& address) { |
2103 const SocketAddress& address) { | 2105 for (Connection* conn : channel->connections()) { |
2104 for (cricket::Connection* conn : channel->connections()) { | |
2105 if (conn->local_candidate().address().EqualIPs(address)) { | 2106 if (conn->local_candidate().address().EqualIPs(address)) { |
2106 return conn; | 2107 return conn; |
2107 } | 2108 } |
2108 } | 2109 } |
2109 return nullptr; | 2110 return nullptr; |
2110 } | 2111 } |
2111 | 2112 |
2112 void DestroyAllButBestConnection(cricket::P2PTransportChannel* channel) { | 2113 Connection* GetConnection(P2PTransportChannel* channel, |
2113 const cricket::Connection* selected_connection = | 2114 const SocketAddress& local, |
2114 channel->selected_connection(); | 2115 const SocketAddress& remote) { |
2115 for (cricket::Connection* conn : channel->connections()) { | 2116 for (Connection* conn : channel->connections()) { |
| 2117 if (conn->local_candidate().address().EqualIPs(local) && |
| 2118 conn->remote_candidate().address().EqualIPs(remote)) { |
| 2119 return conn; |
| 2120 } |
| 2121 } |
| 2122 return nullptr; |
| 2123 } |
| 2124 |
| 2125 void DestroyAllButBestConnection(P2PTransportChannel* channel) { |
| 2126 const Connection* selected_connection = channel->selected_connection(); |
| 2127 for (Connection* conn : channel->connections()) { |
2116 if (conn != selected_connection) { | 2128 if (conn != selected_connection) { |
2117 conn->Destroy(); | 2129 conn->Destroy(); |
2118 } | 2130 } |
2119 } | 2131 } |
2120 } | 2132 } |
2121 }; | 2133 }; |
2122 | 2134 |
2123 // Test that we can establish connectivity when both peers are multihomed. | 2135 // Test that we can establish connectivity when both peers are multihomed. |
2124 TEST_F(P2PTransportChannelMultihomedTest, DISABLED_TestBasic) { | 2136 TEST_F(P2PTransportChannelMultihomedTest, DISABLED_TestBasic) { |
2125 AddAddress(0, kPublicAddrs[0]); | 2137 AddAddress(0, kPublicAddrs[0]); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2227 kMediumTimeout, clock); | 2239 kMediumTimeout, clock); |
2228 EXPECT_TRUE( | 2240 EXPECT_TRUE( |
2229 LocalCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[0])); | 2241 LocalCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[0])); |
2230 EXPECT_TRUE(RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 2242 EXPECT_TRUE(RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
2231 EXPECT_TRUE( | 2243 EXPECT_TRUE( |
2232 RemoteCandidate(ep2_ch1())->address().EqualIPs(kAlternateAddrs[0])); | 2244 RemoteCandidate(ep2_ch1())->address().EqualIPs(kAlternateAddrs[0])); |
2233 | 2245 |
2234 DestroyChannels(); | 2246 DestroyChannels(); |
2235 } | 2247 } |
2236 | 2248 |
| 2249 // Tests that we can quickly switch links if an interface goes down when |
| 2250 // there are many connections. |
| 2251 TEST_F(P2PTransportChannelMultihomedTest, TestFailoverWithManyConnections) { |
| 2252 rtc::ScopedFakeClock clock; |
| 2253 test_turn_server()->AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); |
| 2254 RelayServerConfig turn_server(RELAY_TURN); |
| 2255 turn_server.credentials = kRelayCredentials; |
| 2256 turn_server.ports.push_back( |
| 2257 ProtocolAddress(kTurnTcpIntAddr, PROTO_TCP, false)); |
| 2258 GetAllocator(0)->AddTurnServer(turn_server); |
| 2259 GetAllocator(1)->AddTurnServer(turn_server); |
| 2260 // Enable IPv6 |
| 2261 SetAllocatorFlags(0, PORTALLOCATOR_ENABLE_IPV6); |
| 2262 SetAllocatorFlags(1, PORTALLOCATOR_ENABLE_IPV6); |
| 2263 SetAllocationStepDelay(0, kMinimumStepDelay); |
| 2264 SetAllocationStepDelay(1, kMinimumStepDelay); |
| 2265 |
| 2266 auto& wifi = kPublicAddrs; |
| 2267 auto& cellular = kAlternateAddrs; |
| 2268 auto& wifiIpv6 = kIPv6PublicAddrs; |
| 2269 auto& cellularIpv6 = kIPv6AlternateAddrs; |
| 2270 AddAddress(0, wifi[0], "wifi0", rtc::ADAPTER_TYPE_WIFI); |
| 2271 AddAddress(0, wifiIpv6[0], "wifi0", rtc::ADAPTER_TYPE_WIFI); |
| 2272 AddAddress(0, cellular[0], "cellular0", rtc::ADAPTER_TYPE_CELLULAR); |
| 2273 AddAddress(0, cellularIpv6[0], "cellular0", rtc::ADAPTER_TYPE_CELLULAR); |
| 2274 AddAddress(1, wifi[1], "wifi1", rtc::ADAPTER_TYPE_WIFI); |
| 2275 AddAddress(1, wifiIpv6[1], "wifi1", rtc::ADAPTER_TYPE_WIFI); |
| 2276 AddAddress(1, cellular[1], "cellular1", rtc::ADAPTER_TYPE_CELLULAR); |
| 2277 AddAddress(1, cellularIpv6[1], "cellular1", rtc::ADAPTER_TYPE_CELLULAR); |
| 2278 |
| 2279 // Set smaller delay on the TCP TURN server so that TCP TURN candidates |
| 2280 // will be created in time. |
| 2281 virtual_socket_server()->SetDelayOnAddress(kTurnTcpIntAddr, 1); |
| 2282 virtual_socket_server()->SetDelayOnAddress(kTurnUdpExtAddr, 1); |
| 2283 virtual_socket_server()->set_delay_mean(500); |
| 2284 virtual_socket_server()->UpdateDelayDistribution(); |
| 2285 |
| 2286 // Make the receiving timeout shorter for testing. |
| 2287 IceConfig config = CreateIceConfig(1000, GATHER_CONTINUALLY); |
| 2288 // Create channels and let them go writable, as usual. |
| 2289 CreateChannels(config, config, true /* ice_renomination */); |
| 2290 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2291 ep2_ch1()->receiving() && |
| 2292 ep2_ch1()->writable(), |
| 2293 kMediumTimeout, clock); |
| 2294 EXPECT_TRUE_SIMULATED_WAIT( |
| 2295 ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection() && |
| 2296 LocalCandidate(ep1_ch1())->address().EqualIPs(wifiIpv6[0]) && |
| 2297 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifiIpv6[1]), |
| 2298 kMediumTimeout, clock); |
| 2299 |
| 2300 // Blackhole any traffic to or from the wifi on endpoint 1. |
| 2301 LOG(LS_INFO) << "Failing over..."; |
| 2302 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, wifi[0]); |
| 2303 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, wifiIpv6[0]); |
| 2304 |
| 2305 // The selected connections may switch, so keep references to them. |
| 2306 const Connection* selected_connection1 = ep1_ch1()->selected_connection(); |
| 2307 const Connection* selected_connection2 = ep2_ch1()->selected_connection(); |
| 2308 EXPECT_TRUE_SIMULATED_WAIT( |
| 2309 !selected_connection1->receiving() && !selected_connection2->receiving(), |
| 2310 kMediumTimeout, clock); |
| 2311 |
| 2312 // Per-network best connections will be pinged at relatively higher rate when |
| 2313 // the selected connection becomes not receiving. |
| 2314 Connection* per_network_best_connection1 = |
| 2315 GetConnection(ep1_ch1(), cellularIpv6[0], wifiIpv6[1]); |
| 2316 ASSERT_NE(nullptr, per_network_best_connection1); |
| 2317 int64_t last_ping_sent1 = per_network_best_connection1->last_ping_sent(); |
| 2318 int num_pings_sent1 = per_network_best_connection1->num_pings_sent(); |
| 2319 EXPECT_TRUE_SIMULATED_WAIT( |
| 2320 num_pings_sent1 < per_network_best_connection1->num_pings_sent(), |
| 2321 kMediumTimeout, clock); |
| 2322 int64_t ping_interval1 = |
| 2323 (per_network_best_connection1->last_ping_sent() - last_ping_sent1) / |
| 2324 (per_network_best_connection1->num_pings_sent() - num_pings_sent1); |
| 2325 constexpr int SCHEDULING_DELAY = 200; |
| 2326 EXPECT_LT( |
| 2327 ping_interval1, |
| 2328 WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL + SCHEDULING_DELAY); |
| 2329 |
| 2330 // It should switch over to use the cellular IPv6 addr on endpoint 1 before |
| 2331 // it timed out on writing. |
| 2332 EXPECT_TRUE_SIMULATED_WAIT( |
| 2333 ep1_ch1()->selected_connection()->receiving() && |
| 2334 ep2_ch1()->selected_connection()->receiving() && |
| 2335 RemoteCandidate(ep2_ch1())->address().EqualIPs(cellularIpv6[0]) && |
| 2336 LocalCandidate(ep1_ch1())->address().EqualIPs(cellularIpv6[0]), |
| 2337 kMediumTimeout, clock); |
| 2338 |
| 2339 DestroyChannels(); |
| 2340 } |
| 2341 |
2237 // Test that when the controlling side switches the selected connection, | 2342 // Test that when the controlling side switches the selected connection, |
2238 // the nomination of the selected connection on the controlled side will | 2343 // the nomination of the selected connection on the controlled side will |
2239 // increase. | 2344 // increase. |
2240 TEST_F(P2PTransportChannelMultihomedTest, TestIceRenomination) { | 2345 TEST_F(P2PTransportChannelMultihomedTest, TestIceRenomination) { |
2241 rtc::ScopedFakeClock clock; | 2346 rtc::ScopedFakeClock clock; |
2242 // Adding alternate address will make sure |kPublicAddrs| has the higher | 2347 // Adding alternate address will make sure |kPublicAddrs| has the higher |
2243 // priority than others. This is due to FakeNetwork::AddInterface method. | 2348 // priority than others. This is due to FakeNetwork::AddInterface method. |
2244 AddAddress(0, kAlternateAddrs[0]); | 2349 AddAddress(0, kAlternateAddrs[0]); |
2245 AddAddress(0, kPublicAddrs[0]); | 2350 AddAddress(0, kPublicAddrs[0]); |
2246 AddAddress(1, kPublicAddrs[1]); | 2351 AddAddress(1, kPublicAddrs[1]); |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2643 CreateChannels(continual_gathering_config, continual_gathering_config); | 2748 CreateChannels(continual_gathering_config, continual_gathering_config); |
2644 SetAllocatorFlags(0, kOnlyLocalPorts); | 2749 SetAllocatorFlags(0, kOnlyLocalPorts); |
2645 SetAllocatorFlags(1, kOnlyLocalPorts); | 2750 SetAllocatorFlags(1, kOnlyLocalPorts); |
2646 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2751 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
2647 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 2752 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
2648 kDefaultTimeout, kDefaultTimeout); | 2753 kDefaultTimeout, kDefaultTimeout); |
2649 | 2754 |
2650 // Add a new wifi interface on end point 2. We should expect a new connection | 2755 // Add a new wifi interface on end point 2. We should expect a new connection |
2651 // to be created and the new one will be the best connection. | 2756 // to be created and the new one will be the best connection. |
2652 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); | 2757 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); |
2653 const cricket::Connection* conn; | 2758 const Connection* conn; |
2654 EXPECT_TRUE_WAIT((conn = ep1_ch1()->selected_connection()) != nullptr && | 2759 EXPECT_TRUE_WAIT((conn = ep1_ch1()->selected_connection()) != nullptr && |
2655 conn->remote_candidate().address().EqualIPs(wifi[1]), | 2760 conn->remote_candidate().address().EqualIPs(wifi[1]), |
2656 kDefaultTimeout); | 2761 kDefaultTimeout); |
2657 EXPECT_TRUE_WAIT((conn = ep2_ch1()->selected_connection()) != nullptr && | 2762 EXPECT_TRUE_WAIT((conn = ep2_ch1()->selected_connection()) != nullptr && |
2658 conn->local_candidate().address().EqualIPs(wifi[1]), | 2763 conn->local_candidate().address().EqualIPs(wifi[1]), |
2659 kDefaultTimeout); | 2764 kDefaultTimeout); |
2660 | 2765 |
2661 // Add a new cellular interface on end point 1, we should expect a new | 2766 // Add a new cellular interface on end point 1, we should expect a new |
2662 // backup connection created using this new interface. | 2767 // backup connection created using this new interface. |
2663 AddAddress(0, cellular[0], "test_cellular0", rtc::ADAPTER_TYPE_CELLULAR); | 2768 AddAddress(0, cellular[0], "test_cellular0", rtc::ADAPTER_TYPE_CELLULAR); |
2664 EXPECT_TRUE_WAIT( | 2769 EXPECT_TRUE_WAIT( |
2665 ep1_ch1()->GetState() == cricket::STATE_COMPLETED && | 2770 ep1_ch1()->GetState() == STATE_COMPLETED && |
2666 (conn = GetConnectionWithLocalAddress(ep1_ch1(), cellular[0])) != | 2771 (conn = GetConnectionWithLocalAddress(ep1_ch1(), cellular[0])) != |
2667 nullptr && | 2772 nullptr && |
2668 conn != ep1_ch1()->selected_connection() && conn->writable(), | 2773 conn != ep1_ch1()->selected_connection() && conn->writable(), |
2669 kDefaultTimeout); | 2774 kDefaultTimeout); |
2670 EXPECT_TRUE_WAIT( | 2775 EXPECT_TRUE_WAIT( |
2671 ep2_ch1()->GetState() == cricket::STATE_COMPLETED && | 2776 ep2_ch1()->GetState() == STATE_COMPLETED && |
2672 (conn = GetConnectionWithRemoteAddress(ep2_ch1(), cellular[0])) != | 2777 (conn = GetConnectionWithRemoteAddress(ep2_ch1(), cellular[0])) != |
2673 nullptr && | 2778 nullptr && |
2674 conn != ep2_ch1()->selected_connection() && conn->receiving(), | 2779 conn != ep2_ch1()->selected_connection() && conn->receiving(), |
2675 kDefaultTimeout); | 2780 kDefaultTimeout); |
2676 | 2781 |
2677 DestroyChannels(); | 2782 DestroyChannels(); |
2678 } | 2783 } |
2679 | 2784 |
2680 // Tests that we can switch links via continual gathering. | 2785 // Tests that we can switch links via continual gathering. |
2681 TEST_F(P2PTransportChannelMultihomedTest, | 2786 TEST_F(P2PTransportChannelMultihomedTest, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2798 ep2_ch1()->selected_connection() && | 2903 ep2_ch1()->selected_connection() && |
2799 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && | 2904 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && |
2800 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1])); | 2905 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1])); |
2801 | 2906 |
2802 // Destroy all backup connections. | 2907 // Destroy all backup connections. |
2803 DestroyAllButBestConnection(ep1_ch1()); | 2908 DestroyAllButBestConnection(ep1_ch1()); |
2804 // Ensure the backup connection is removed first. | 2909 // Ensure the backup connection is removed first. |
2805 EXPECT_TRUE_SIMULATED_WAIT( | 2910 EXPECT_TRUE_SIMULATED_WAIT( |
2806 GetConnectionWithLocalAddress(ep1_ch1(), cellular[0]) == nullptr, | 2911 GetConnectionWithLocalAddress(ep1_ch1(), cellular[0]) == nullptr, |
2807 kDefaultTimeout, clock); | 2912 kDefaultTimeout, clock); |
2808 const cricket::Connection* conn; | 2913 const Connection* conn; |
2809 EXPECT_TRUE_SIMULATED_WAIT( | 2914 EXPECT_TRUE_SIMULATED_WAIT( |
2810 (conn = GetConnectionWithLocalAddress(ep1_ch1(), cellular[0])) != | 2915 (conn = GetConnectionWithLocalAddress(ep1_ch1(), cellular[0])) != |
2811 nullptr && | 2916 nullptr && |
2812 conn != ep1_ch1()->selected_connection() && conn->writable(), | 2917 conn != ep1_ch1()->selected_connection() && conn->writable(), |
2813 kDefaultTimeout, clock); | 2918 kDefaultTimeout, clock); |
2814 | 2919 |
2815 DestroyChannels(); | 2920 DestroyChannels(); |
2816 } | 2921 } |
2817 | 2922 |
2818 // A collection of tests which tests a single P2PTransportChannel by sending | 2923 // A collection of tests which tests a single P2PTransportChannel by sending |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3056 // Stabilizing. | 3161 // Stabilizing. |
3057 | 3162 |
3058 conn->ReceivedPingResponse(LOW_RTT, "id"); | 3163 conn->ReceivedPingResponse(LOW_RTT, "id"); |
3059 int ping_sent_before = conn->num_pings_sent(); | 3164 int ping_sent_before = conn->num_pings_sent(); |
3060 start = clock.TimeNanos(); | 3165 start = clock.TimeNanos(); |
3061 // The connection becomes strong but not stable because we haven't been able | 3166 // The connection becomes strong but not stable because we haven't been able |
3062 // to converge the RTT. | 3167 // to converge the RTT. |
3063 SIMULATED_WAIT(conn->num_pings_sent() == ping_sent_before + 1, kMediumTimeout, | 3168 SIMULATED_WAIT(conn->num_pings_sent() == ping_sent_before + 1, kMediumTimeout, |
3064 clock); | 3169 clock); |
3065 ping_interval_ms = (clock.TimeNanos() - start) / rtc::kNumNanosecsPerMillisec; | 3170 ping_interval_ms = (clock.TimeNanos() - start) / rtc::kNumNanosecsPerMillisec; |
3066 EXPECT_GE(ping_interval_ms, STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL); | 3171 EXPECT_GE(ping_interval_ms, |
3067 EXPECT_LE(ping_interval_ms, | 3172 WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL); |
3068 STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL + SCHEDULING_RANGE); | 3173 EXPECT_LE( |
| 3174 ping_interval_ms, |
| 3175 WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL + SCHEDULING_RANGE); |
3069 | 3176 |
3070 // Stabilized. | 3177 // Stabilized. |
3071 | 3178 |
3072 // The connection becomes stable after receiving more than RTT_RATIO rtt | 3179 // The connection becomes stable after receiving more than RTT_RATIO rtt |
3073 // samples. | 3180 // samples. |
3074 for (int i = 0; i < RTT_RATIO; i++) { | 3181 for (int i = 0; i < RTT_RATIO; i++) { |
3075 conn->ReceivedPingResponse(LOW_RTT, "id"); | 3182 conn->ReceivedPingResponse(LOW_RTT, "id"); |
3076 } | 3183 } |
3077 ping_sent_before = conn->num_pings_sent(); | 3184 ping_sent_before = conn->num_pings_sent(); |
3078 start = clock.TimeNanos(); | 3185 start = clock.TimeNanos(); |
3079 SIMULATED_WAIT(conn->num_pings_sent() == ping_sent_before + 1, kMediumTimeout, | 3186 SIMULATED_WAIT(conn->num_pings_sent() == ping_sent_before + 1, kMediumTimeout, |
3080 clock); | 3187 clock); |
3081 ping_interval_ms = (clock.TimeNanos() - start) / rtc::kNumNanosecsPerMillisec; | 3188 ping_interval_ms = (clock.TimeNanos() - start) / rtc::kNumNanosecsPerMillisec; |
3082 EXPECT_GE(ping_interval_ms, STABLE_WRITABLE_CONNECTION_PING_INTERVAL); | 3189 EXPECT_GE(ping_interval_ms, |
3083 EXPECT_LE(ping_interval_ms, | 3190 STRONG_AND_STABLE_WRITABLE_CONNECTION_PING_INTERVAL); |
3084 STABLE_WRITABLE_CONNECTION_PING_INTERVAL + SCHEDULING_RANGE); | 3191 EXPECT_LE( |
| 3192 ping_interval_ms, |
| 3193 STRONG_AND_STABLE_WRITABLE_CONNECTION_PING_INTERVAL + SCHEDULING_RANGE); |
3085 | 3194 |
3086 // Destabilized. | 3195 // Destabilized. |
3087 | 3196 |
3088 conn->ReceivedPingResponse(LOW_RTT, "id"); | 3197 conn->ReceivedPingResponse(LOW_RTT, "id"); |
3089 // Create a in-flight ping. | 3198 // Create a in-flight ping. |
3090 conn->Ping(clock.TimeNanos() / rtc::kNumNanosecsPerMillisec); | 3199 conn->Ping(clock.TimeNanos() / rtc::kNumNanosecsPerMillisec); |
3091 start = clock.TimeNanos(); | 3200 start = clock.TimeNanos(); |
3092 // In-flight ping timeout and the connection will be unstable. | 3201 // In-flight ping timeout and the connection will be unstable. |
3093 SIMULATED_WAIT( | 3202 SIMULATED_WAIT( |
3094 !conn->stable(clock.TimeNanos() / rtc::kNumNanosecsPerMillisec), | 3203 !conn->stable(clock.TimeNanos() / rtc::kNumNanosecsPerMillisec), |
3095 kMediumTimeout, clock); | 3204 kMediumTimeout, clock); |
3096 int64_t duration_ms = | 3205 int64_t duration_ms = |
3097 (clock.TimeNanos() - start) / rtc::kNumNanosecsPerMillisec; | 3206 (clock.TimeNanos() - start) / rtc::kNumNanosecsPerMillisec; |
3098 EXPECT_GE(duration_ms, 2 * conn->rtt() - RTT_RANGE); | 3207 EXPECT_GE(duration_ms, 2 * conn->rtt() - RTT_RANGE); |
3099 EXPECT_LE(duration_ms, 2 * conn->rtt() + RTT_RANGE); | 3208 EXPECT_LE(duration_ms, 2 * conn->rtt() + RTT_RANGE); |
3100 // The connection become unstable due to not receiving ping responses. | 3209 // The connection become unstable due to not receiving ping responses. |
3101 ping_sent_before = conn->num_pings_sent(); | 3210 ping_sent_before = conn->num_pings_sent(); |
3102 SIMULATED_WAIT(conn->num_pings_sent() == ping_sent_before + 1, kMediumTimeout, | 3211 SIMULATED_WAIT(conn->num_pings_sent() == ping_sent_before + 1, kMediumTimeout, |
3103 clock); | 3212 clock); |
3104 // The interval is expected to be | 3213 // The interval is expected to be |
3105 // STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL. | 3214 // WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL. |
3106 start = clock.TimeNanos(); | 3215 start = clock.TimeNanos(); |
3107 ping_sent_before = conn->num_pings_sent(); | 3216 ping_sent_before = conn->num_pings_sent(); |
3108 SIMULATED_WAIT(conn->num_pings_sent() == ping_sent_before + 1, kMediumTimeout, | 3217 SIMULATED_WAIT(conn->num_pings_sent() == ping_sent_before + 1, kMediumTimeout, |
3109 clock); | 3218 clock); |
3110 ping_interval_ms = (clock.TimeNanos() - start) / rtc::kNumNanosecsPerMillisec; | 3219 ping_interval_ms = (clock.TimeNanos() - start) / rtc::kNumNanosecsPerMillisec; |
3111 EXPECT_GE(ping_interval_ms, STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL); | 3220 EXPECT_GE(ping_interval_ms, |
3112 EXPECT_LE(ping_interval_ms, | 3221 WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL); |
3113 STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL + SCHEDULING_RANGE); | 3222 EXPECT_LE( |
| 3223 ping_interval_ms, |
| 3224 WEAK_OR_STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL + SCHEDULING_RANGE); |
3114 } | 3225 } |
3115 | 3226 |
3116 // Test that we start pinging as soon as we have a connection and remote ICE | 3227 // Test that we start pinging as soon as we have a connection and remote ICE |
3117 // parameters. | 3228 // parameters. |
3118 TEST_F(P2PTransportChannelPingTest, PingingStartedAsSoonAsPossible) { | 3229 TEST_F(P2PTransportChannelPingTest, PingingStartedAsSoonAsPossible) { |
3119 rtc::ScopedFakeClock clock; | 3230 rtc::ScopedFakeClock clock; |
3120 | 3231 |
3121 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 3232 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
3122 P2PTransportChannel ch("TestChannel", 1, &pa); | 3233 P2PTransportChannel ch("TestChannel", 1, &pa); |
3123 ch.SetIceRole(ICEROLE_CONTROLLING); | 3234 ch.SetIceRole(ICEROLE_CONTROLLING); |
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4274 | 4385 |
4275 // TCP Relay/Relay is the next. | 4386 // TCP Relay/Relay is the next. |
4276 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, | 4387 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, |
4277 TCP_PROTOCOL_NAME); | 4388 TCP_PROTOCOL_NAME); |
4278 | 4389 |
4279 // Finally, Local/Relay will be pinged. | 4390 // Finally, Local/Relay will be pinged. |
4280 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); | 4391 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); |
4281 } | 4392 } |
4282 | 4393 |
4283 } // namespace cricket { | 4394 } // namespace cricket { |
OLD | NEW |