Chromium Code Reviews| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 static const int kOnlyLocalPorts = cricket::PORTALLOCATOR_DISABLE_STUN | | 44 static const int kOnlyLocalPorts = cricket::PORTALLOCATOR_DISABLE_STUN | |
| 45 cricket::PORTALLOCATOR_DISABLE_RELAY | | 45 cricket::PORTALLOCATOR_DISABLE_RELAY | |
| 46 cricket::PORTALLOCATOR_DISABLE_TCP; | 46 cricket::PORTALLOCATOR_DISABLE_TCP; |
| 47 static const int LOW_RTT = 20; | 47 static const int LOW_RTT = 20; |
| 48 // Addresses on the public internet. | 48 // Addresses on the public internet. |
| 49 static const SocketAddress kPublicAddrs[2] = | 49 static const SocketAddress kPublicAddrs[2] = |
| 50 { SocketAddress("11.11.11.11", 0), SocketAddress("22.22.22.22", 0) }; | 50 { SocketAddress("11.11.11.11", 0), SocketAddress("22.22.22.22", 0) }; |
| 51 // IPv6 Addresses on the public internet. | 51 // IPv6 Addresses on the public internet. |
| 52 static const SocketAddress kIPv6PublicAddrs[2] = { | 52 static const SocketAddress kIPv6PublicAddrs[2] = { |
| 53 SocketAddress("2400:4030:1:2c00:be30:abcd:efab:cdef", 0), | 53 SocketAddress("2400:4030:1:2c00:be30:abcd:efab:cdef", 0), |
| 54 SocketAddress("2620:0:1000:1b03:2e41:38ff:fea6:f2a4", 0) | 54 SocketAddress("2600:0:1000:1b03:2e41:38ff:fea6:f2a4", 0)}; |
| 55 }; | |
| 56 // For configuring multihomed clients. | 55 // For configuring multihomed clients. |
| 57 static const SocketAddress kAlternateAddrs[2] = { | 56 static const SocketAddress kAlternateAddrs[2] = { |
| 58 SocketAddress("101.101.101.101", 0), SocketAddress("202.202.202.202", 0)}; | 57 SocketAddress("101.101.101.101", 0), SocketAddress("202.202.202.202", 0)}; |
| 58 static const SocketAddress kIPv6AlternateAddrs[2] = { | |
| 59 SocketAddress("2401:4030:1:2c00:be30:abcd:efab:cdef", 0), | |
| 60 SocketAddress("2601:0:1000:1b03:2e41:38ff:fea6:f2a4", 0)}; | |
| 59 // Addresses for HTTP proxy servers. | 61 // Addresses for HTTP proxy servers. |
| 60 static const SocketAddress kHttpsProxyAddrs[2] = | 62 static const SocketAddress kHttpsProxyAddrs[2] = |
| 61 { SocketAddress("11.11.11.1", 443), SocketAddress("22.22.22.1", 443) }; | 63 { SocketAddress("11.11.11.1", 443), SocketAddress("22.22.22.1", 443) }; |
| 62 // Addresses for SOCKS proxy servers. | 64 // Addresses for SOCKS proxy servers. |
| 63 static const SocketAddress kSocksProxyAddrs[2] = | 65 static const SocketAddress kSocksProxyAddrs[2] = |
| 64 { SocketAddress("11.11.11.1", 1080), SocketAddress("22.22.22.1", 1080) }; | 66 { SocketAddress("11.11.11.1", 1080), SocketAddress("22.22.22.1", 1080) }; |
| 65 // Internal addresses for NAT boxes. | 67 // Internal addresses for NAT boxes. |
| 66 static const SocketAddress kNatAddrs[2] = | 68 static const SocketAddress kNatAddrs[2] = |
| 67 { SocketAddress("192.168.1.1", 0), SocketAddress("192.168.2.1", 0) }; | 69 { SocketAddress("192.168.1.1", 0), SocketAddress("192.168.2.1", 0) }; |
| 68 // Private addresses inside the NAT private networks. | 70 // Private addresses inside the NAT private networks. |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 | 408 |
| 407 Endpoint* GetEndpoint(int endpoint) { | 409 Endpoint* GetEndpoint(int endpoint) { |
| 408 if (endpoint == 0) { | 410 if (endpoint == 0) { |
| 409 return &ep1_; | 411 return &ep1_; |
| 410 } else if (endpoint == 1) { | 412 } else if (endpoint == 1) { |
| 411 return &ep2_; | 413 return &ep2_; |
| 412 } else { | 414 } else { |
| 413 return NULL; | 415 return NULL; |
| 414 } | 416 } |
| 415 } | 417 } |
| 416 PortAllocator* GetAllocator(int endpoint) { | 418 BasicPortAllocator* GetAllocator(int endpoint) { |
| 417 return GetEndpoint(endpoint)->allocator_.get(); | 419 return GetEndpoint(endpoint)->allocator_.get(); |
| 418 } | 420 } |
| 419 void AddAddress(int endpoint, const SocketAddress& addr) { | 421 void AddAddress(int endpoint, const SocketAddress& addr) { |
| 420 GetEndpoint(endpoint)->network_manager_.AddInterface(addr); | 422 GetEndpoint(endpoint)->network_manager_.AddInterface(addr); |
| 421 } | 423 } |
| 422 void AddAddress(int endpoint, | 424 void AddAddress(int endpoint, |
| 423 const SocketAddress& addr, | 425 const SocketAddress& addr, |
| 424 const std::string& ifname, | 426 const std::string& ifname, |
| 425 rtc::AdapterType adapter_type) { | 427 rtc::AdapterType adapter_type) { |
| 426 GetEndpoint(endpoint)->network_manager_.AddInterface(addr, ifname, | 428 GetEndpoint(endpoint)->network_manager_.AddInterface(addr, ifname, |
| (...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1977 3000, clock); | 1979 3000, clock); |
| 1978 EXPECT_TRUE( | 1980 EXPECT_TRUE( |
| 1979 LocalCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[0])); | 1981 LocalCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[0])); |
| 1980 EXPECT_TRUE(RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1982 EXPECT_TRUE(RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
| 1981 EXPECT_TRUE( | 1983 EXPECT_TRUE( |
| 1982 RemoteCandidate(ep2_ch1())->address().EqualIPs(kAlternateAddrs[0])); | 1984 RemoteCandidate(ep2_ch1())->address().EqualIPs(kAlternateAddrs[0])); |
| 1983 | 1985 |
| 1984 DestroyChannels(); | 1986 DestroyChannels(); |
| 1985 } | 1987 } |
| 1986 | 1988 |
| 1989 // Test that we can quickly switch links if an interface goes down when | |
| 1990 // there are many connections. | |
| 1991 TEST_F(P2PTransportChannelMultihomedTest, TestFailoverWithManyConnections) { | |
| 1992 test_turn_server()->AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); | |
| 1993 cricket::RelayServerConfig turn_server(cricket::RELAY_TURN); | |
| 1994 turn_server.credentials = kRelayCredentials; | |
| 1995 turn_server.ports.push_back( | |
| 1996 cricket::ProtocolAddress(kTurnTcpIntAddr, cricket::PROTO_TCP, false)); | |
| 1997 GetAllocator(0)->AddTurnServer(turn_server); | |
| 1998 GetAllocator(1)->AddTurnServer(turn_server); | |
| 1999 // Enable IPv6 | |
| 2000 SetAllocatorFlags(0, PORTALLOCATOR_ENABLE_IPV6); | |
| 2001 SetAllocatorFlags(1, PORTALLOCATOR_ENABLE_IPV6); | |
| 2002 int delay = kMinimumStepDelay; | |
|
Taylor Brandstetter
2016/10/04 02:08:10
nit: Why is this variable needed?
honghaiz3
2016/10/20 23:47:58
Removed
| |
| 2003 SetAllocationStepDelay(0, delay); | |
| 2004 SetAllocationStepDelay(1, delay); | |
| 2005 | |
| 2006 auto& wifi = kPublicAddrs; | |
| 2007 auto& cellular = kAlternateAddrs; | |
| 2008 auto& wifiIpv6 = kIPv6PublicAddrs; | |
| 2009 auto& cellularIpv6 = kIPv6AlternateAddrs; | |
| 2010 AddAddress(0, wifi[0], "wifi0", rtc::ADAPTER_TYPE_WIFI); | |
| 2011 AddAddress(0, wifiIpv6[0], "wifi0", rtc::ADAPTER_TYPE_WIFI); | |
| 2012 AddAddress(0, cellular[0], "cellular0", rtc::ADAPTER_TYPE_CELLULAR); | |
| 2013 AddAddress(0, cellularIpv6[0], "cellular0", rtc::ADAPTER_TYPE_CELLULAR); | |
| 2014 AddAddress(1, wifi[1], "wifi1", rtc::ADAPTER_TYPE_WIFI); | |
| 2015 AddAddress(1, wifiIpv6[1], "wifi1", rtc::ADAPTER_TYPE_WIFI); | |
| 2016 AddAddress(1, cellular[1], "cellular1", rtc::ADAPTER_TYPE_CELLULAR); | |
| 2017 AddAddress(1, cellularIpv6[1], "cellular1", rtc::ADAPTER_TYPE_CELLULAR); | |
| 2018 | |
| 2019 // Set smaller delay on the TCP TURN server so that TCP TURN candidates | |
| 2020 // will be created in time. | |
| 2021 virtual_socket_server()->SetDelayOnAddress(kTurnTcpIntAddr, 1); | |
| 2022 virtual_socket_server()->SetDelayOnAddress(kTurnUdpExtAddr, 1); | |
| 2023 virtual_socket_server()->set_delay_mean(100); | |
| 2024 virtual_socket_server()->set_delay_stddev(100); | |
|
honghaiz3
2016/10/03 21:28:33
The random delay is needed so that the test may fa
Taylor Brandstetter
2016/10/04 02:08:10
If the test will only fail randomly, then if a reg
honghaiz3
2016/10/20 23:47:58
I Find a way to remove the randomness by using lon
| |
| 2025 virtual_socket_server()->UpdateDelayDistribution(); | |
| 2026 | |
| 2027 // Make the receiving timeout shorter for testing. | |
| 2028 IceConfig config = CreateIceConfig(1000, GATHER_CONTINUALLY); | |
| 2029 // Create channels and let them go writable, as usual. | |
| 2030 CreateChannels(config, config, true /* ice_renomination */); | |
| 2031 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | |
| 2032 ep2_ch1()->receiving() && ep2_ch1()->writable(), | |
| 2033 3000); | |
|
Taylor Brandstetter
2016/10/04 02:08:10
Can you use a constant instead of 3000?
honghaiz3
2016/10/20 23:47:58
Done.
| |
| 2034 EXPECT_TRUE_WAIT( | |
| 2035 ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection() && | |
| 2036 LocalCandidate(ep1_ch1())->address().EqualIPs(wifiIpv6[0]) && | |
| 2037 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifiIpv6[1]), | |
| 2038 3000); | |
| 2039 | |
| 2040 // Blackhole any traffic to or from the wifi on endpoint 1. | |
| 2041 LOG(LS_INFO) << "Failing over..."; | |
|
Taylor Brandstetter
2016/10/04 02:08:10
Is this log still necessary?
honghaiz3
2016/10/20 23:47:58
This log is informational. The similar log is also
| |
| 2042 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, wifi[0]); | |
| 2043 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, wifiIpv6[0]); | |
| 2044 | |
| 2045 // The selected connections may switch, so keep references to them. | |
| 2046 const Connection* selected_connection1 = ep1_ch1()->selected_connection(); | |
| 2047 const Connection* selected_connection2 = ep2_ch1()->selected_connection(); | |
| 2048 EXPECT_TRUE_WAIT( | |
| 2049 !selected_connection1->receiving() && !selected_connection2->receiving(), | |
| 2050 3000); | |
| 2051 | |
| 2052 // It should switch over to use the cellular IPv6 addr on endpoint 1 before | |
| 2053 // it timed out on writing. | |
| 2054 EXPECT_TRUE_WAIT( | |
| 2055 ep1_ch1()->selected_connection()->receiving() && | |
| 2056 ep2_ch1()->selected_connection()->receiving() && | |
| 2057 RemoteCandidate(ep2_ch1())->address().EqualIPs(cellularIpv6[0]) && | |
| 2058 LocalCandidate(ep1_ch1())->address().EqualIPs(cellularIpv6[0]), | |
| 2059 3000); | |
| 2060 | |
| 2061 DestroyChannels(); | |
| 2062 } | |
| 2063 | |
| 1987 // Test that when the controlling side switches the selected connection, | 2064 // Test that when the controlling side switches the selected connection, |
| 1988 // the nomination of the selected connection on the controlled side will | 2065 // the nomination of the selected connection on the controlled side will |
| 1989 // increase. | 2066 // increase. |
| 1990 TEST_F(P2PTransportChannelMultihomedTest, TestIceRenomination) { | 2067 TEST_F(P2PTransportChannelMultihomedTest, TestIceRenomination) { |
| 1991 rtc::ScopedFakeClock clock; | 2068 rtc::ScopedFakeClock clock; |
| 1992 // Adding alternate address will make sure |kPublicAddrs| has the higher | 2069 // Adding alternate address will make sure |kPublicAddrs| has the higher |
| 1993 // priority than others. This is due to FakeNetwork::AddInterface method. | 2070 // priority than others. This is due to FakeNetwork::AddInterface method. |
| 1994 AddAddress(0, kAlternateAddrs[0]); | 2071 AddAddress(0, kAlternateAddrs[0]); |
| 1995 AddAddress(0, kPublicAddrs[0]); | 2072 AddAddress(0, kPublicAddrs[0]); |
| 1996 AddAddress(1, kPublicAddrs[1]); | 2073 AddAddress(1, kPublicAddrs[1]); |
| (...skipping 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4000 | 4077 |
| 4001 // TCP Relay/Relay is the next. | 4078 // TCP Relay/Relay is the next. |
| 4002 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, | 4079 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, |
| 4003 TCP_PROTOCOL_NAME); | 4080 TCP_PROTOCOL_NAME); |
| 4004 | 4081 |
| 4005 // Finally, Local/Relay will be pinged. | 4082 // Finally, Local/Relay will be pinged. |
| 4006 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); | 4083 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); |
| 4007 } | 4084 } |
| 4008 | 4085 |
| 4009 } // namespace cricket { | 4086 } // namespace cricket { |
| OLD | NEW |