| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 bool ready_to_send_ = false; | 298 bool ready_to_send_ = false; |
| 299 }; | 299 }; |
| 300 | 300 |
| 301 ChannelData* GetChannelData(TransportChannel* channel) { | 301 ChannelData* GetChannelData(TransportChannel* channel) { |
| 302 if (ep1_.HasChannel(channel)) | 302 if (ep1_.HasChannel(channel)) |
| 303 return ep1_.GetChannelData(channel); | 303 return ep1_.GetChannelData(channel); |
| 304 else | 304 else |
| 305 return ep2_.GetChannelData(channel); | 305 return ep2_.GetChannelData(channel); |
| 306 } | 306 } |
| 307 | 307 |
| 308 void CreateChannels(int num) { | 308 void CreateChannels(int num, |
| 309 const IceConfig& ep1_config, |
| 310 const IceConfig& ep2_config) { |
| 309 std::string ice_ufrag_ep1_cd1_ch = kIceUfrag[0]; | 311 std::string ice_ufrag_ep1_cd1_ch = kIceUfrag[0]; |
| 310 std::string ice_pwd_ep1_cd1_ch = kIcePwd[0]; | 312 std::string ice_pwd_ep1_cd1_ch = kIcePwd[0]; |
| 311 std::string ice_ufrag_ep2_cd1_ch = kIceUfrag[1]; | 313 std::string ice_ufrag_ep2_cd1_ch = kIceUfrag[1]; |
| 312 std::string ice_pwd_ep2_cd1_ch = kIcePwd[1]; | 314 std::string ice_pwd_ep2_cd1_ch = kIcePwd[1]; |
| 313 ep1_.cd1_.ch_.reset(CreateChannel( | 315 ep1_.cd1_.ch_.reset(CreateChannel( |
| 314 0, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep1_cd1_ch, | 316 0, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep1_cd1_ch, |
| 315 ice_pwd_ep1_cd1_ch, ice_ufrag_ep2_cd1_ch, ice_pwd_ep2_cd1_ch)); | 317 ice_pwd_ep1_cd1_ch, ice_ufrag_ep2_cd1_ch, ice_pwd_ep2_cd1_ch)); |
| 316 ep2_.cd1_.ch_.reset(CreateChannel( | 318 ep2_.cd1_.ch_.reset(CreateChannel( |
| 317 1, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep2_cd1_ch, | 319 1, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep2_cd1_ch, |
| 318 ice_pwd_ep2_cd1_ch, ice_ufrag_ep1_cd1_ch, ice_pwd_ep1_cd1_ch)); | 320 ice_pwd_ep2_cd1_ch, ice_ufrag_ep1_cd1_ch, ice_pwd_ep1_cd1_ch)); |
| 321 ep1_.cd1_.ch_->SetIceConfig(ep1_config); |
| 322 ep2_.cd1_.ch_->SetIceConfig(ep2_config); |
| 319 ep1_.cd1_.ch_->MaybeStartGathering(); | 323 ep1_.cd1_.ch_->MaybeStartGathering(); |
| 320 ep2_.cd1_.ch_->MaybeStartGathering(); | 324 ep2_.cd1_.ch_->MaybeStartGathering(); |
| 321 if (num == 2) { | 325 if (num == 2) { |
| 322 std::string ice_ufrag_ep1_cd2_ch = kIceUfrag[2]; | 326 std::string ice_ufrag_ep1_cd2_ch = kIceUfrag[2]; |
| 323 std::string ice_pwd_ep1_cd2_ch = kIcePwd[2]; | 327 std::string ice_pwd_ep1_cd2_ch = kIcePwd[2]; |
| 324 std::string ice_ufrag_ep2_cd2_ch = kIceUfrag[3]; | 328 std::string ice_ufrag_ep2_cd2_ch = kIceUfrag[3]; |
| 325 std::string ice_pwd_ep2_cd2_ch = kIcePwd[3]; | 329 std::string ice_pwd_ep2_cd2_ch = kIcePwd[3]; |
| 326 ep1_.cd2_.ch_.reset(CreateChannel( | 330 ep1_.cd2_.ch_.reset(CreateChannel( |
| 327 0, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep1_cd2_ch, | 331 0, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep1_cd2_ch, |
| 328 ice_pwd_ep1_cd2_ch, ice_ufrag_ep2_cd2_ch, ice_pwd_ep2_cd2_ch)); | 332 ice_pwd_ep1_cd2_ch, ice_ufrag_ep2_cd2_ch, ice_pwd_ep2_cd2_ch)); |
| 329 ep2_.cd2_.ch_.reset(CreateChannel( | 333 ep2_.cd2_.ch_.reset(CreateChannel( |
| 330 1, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep2_cd2_ch, | 334 1, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep2_cd2_ch, |
| 331 ice_pwd_ep2_cd2_ch, ice_ufrag_ep1_cd2_ch, ice_pwd_ep1_cd2_ch)); | 335 ice_pwd_ep2_cd2_ch, ice_ufrag_ep1_cd2_ch, ice_pwd_ep1_cd2_ch)); |
| 336 ep1_.cd2_.ch_->SetIceConfig(ep1_config); |
| 337 ep2_.cd2_.ch_->SetIceConfig(ep2_config); |
| 332 ep1_.cd2_.ch_->MaybeStartGathering(); | 338 ep1_.cd2_.ch_->MaybeStartGathering(); |
| 333 ep2_.cd2_.ch_->MaybeStartGathering(); | 339 ep2_.cd2_.ch_->MaybeStartGathering(); |
| 334 } | 340 } |
| 335 } | 341 } |
| 342 |
| 343 void CreateChannels(int num) { |
| 344 IceConfig default_config; |
| 345 CreateChannels(num, default_config, default_config); |
| 346 } |
| 347 |
| 336 P2PTransportChannel* CreateChannel(int endpoint, | 348 P2PTransportChannel* CreateChannel(int endpoint, |
| 337 int component, | 349 int component, |
| 338 const std::string& local_ice_ufrag, | 350 const std::string& local_ice_ufrag, |
| 339 const std::string& local_ice_pwd, | 351 const std::string& local_ice_pwd, |
| 340 const std::string& remote_ice_ufrag, | 352 const std::string& remote_ice_ufrag, |
| 341 const std::string& remote_ice_pwd) { | 353 const std::string& remote_ice_pwd) { |
| 342 P2PTransportChannel* channel = new P2PTransportChannel( | 354 P2PTransportChannel* channel = new P2PTransportChannel( |
| 343 "test content name", component, GetAllocator(endpoint)); | 355 "test content name", component, GetAllocator(endpoint)); |
| 344 channel->SignalReadyToSend.connect( | 356 channel->SignalReadyToSend.connect( |
| 345 this, &P2PTransportChannelTestBase::OnReadyToSend); | 357 this, &P2PTransportChannelTestBase::OnReadyToSend); |
| (...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 DestroyChannels(); | 1578 DestroyChannels(); |
| 1567 } | 1579 } |
| 1568 | 1580 |
| 1569 // Test that if continual gathering is set to true, ICE gathering state will | 1581 // Test that if continual gathering is set to true, ICE gathering state will |
| 1570 // not change to "Complete", and vice versa. | 1582 // not change to "Complete", and vice versa. |
| 1571 TEST_F(P2PTransportChannelTest, TestContinualGathering) { | 1583 TEST_F(P2PTransportChannelTest, TestContinualGathering) { |
| 1572 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1584 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
| 1573 kDefaultPortAllocatorFlags); | 1585 kDefaultPortAllocatorFlags); |
| 1574 SetAllocationStepDelay(0, kDefaultStepDelay); | 1586 SetAllocationStepDelay(0, kDefaultStepDelay); |
| 1575 SetAllocationStepDelay(1, kDefaultStepDelay); | 1587 SetAllocationStepDelay(1, kDefaultStepDelay); |
| 1576 CreateChannels(1); | 1588 IceConfig continual_gathering_config = |
| 1577 IceConfig config = CreateIceConfig(1000, GATHER_CONTINUALLY); | 1589 CreateIceConfig(1000, GATHER_CONTINUALLY); |
| 1578 ep1_ch1()->SetIceConfig(config); | |
| 1579 // By default, ep2 does not gather continually. | 1590 // By default, ep2 does not gather continually. |
| 1591 IceConfig default_config; |
| 1592 CreateChannels(1, continual_gathering_config, default_config); |
| 1580 | 1593 |
| 1581 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && | 1594 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && |
| 1582 ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1595 ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1583 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1596 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 1584 1000, 1000); | 1597 1000, 1000); |
| 1585 WAIT(IceGatheringState::kIceGatheringComplete == ep1_ch1()->gathering_state(), | 1598 WAIT(IceGatheringState::kIceGatheringComplete == ep1_ch1()->gathering_state(), |
| 1586 1000); | 1599 1000); |
| 1587 EXPECT_EQ(IceGatheringState::kIceGatheringGathering, | 1600 EXPECT_EQ(IceGatheringState::kIceGatheringGathering, |
| 1588 ep1_ch1()->gathering_state()); | 1601 ep1_ch1()->gathering_state()); |
| 1589 // By now, ep2 should have completed gathering. | 1602 // By now, ep2 should have completed gathering. |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1901 AddAddress(0, kPublicAddrs[0]); | 1914 AddAddress(0, kPublicAddrs[0]); |
| 1902 // Adding alternate address will make sure |kPublicAddrs| has the higher | 1915 // Adding alternate address will make sure |kPublicAddrs| has the higher |
| 1903 // priority than others. This is due to FakeNetwork::AddInterface method. | 1916 // priority than others. This is due to FakeNetwork::AddInterface method. |
| 1904 AddAddress(1, kAlternateAddrs[1]); | 1917 AddAddress(1, kAlternateAddrs[1]); |
| 1905 AddAddress(1, kPublicAddrs[1]); | 1918 AddAddress(1, kPublicAddrs[1]); |
| 1906 | 1919 |
| 1907 // Use only local ports for simplicity. | 1920 // Use only local ports for simplicity. |
| 1908 SetAllocatorFlags(0, kOnlyLocalPorts); | 1921 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 1909 SetAllocatorFlags(1, kOnlyLocalPorts); | 1922 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 1910 | 1923 |
| 1924 // Make the receiving timeout shorter for testing. |
| 1925 IceConfig config = CreateIceConfig(1000, GATHER_ONCE); |
| 1911 // Create channels and let them go writable, as usual. | 1926 // Create channels and let them go writable, as usual. |
| 1912 CreateChannels(1); | 1927 CreateChannels(1, config, config); |
| 1913 | 1928 |
| 1914 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1929 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1915 ep2_ch1()->receiving() && | 1930 ep2_ch1()->receiving() && |
| 1916 ep2_ch1()->writable(), | 1931 ep2_ch1()->writable(), |
| 1917 3000, clock); | 1932 3000, clock); |
| 1918 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 1933 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 1919 ep2_ch1()->selected_connection() && | 1934 ep2_ch1()->selected_connection() && |
| 1920 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1935 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 1921 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1936 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
| 1922 | 1937 |
| 1923 // Make the receiving timeout shorter for testing. | |
| 1924 IceConfig config = CreateIceConfig(1000, GATHER_ONCE); | |
| 1925 ep1_ch1()->SetIceConfig(config); | |
| 1926 ep2_ch1()->SetIceConfig(config); | |
| 1927 | |
| 1928 // Blackhole any traffic to or from the public addrs. | 1938 // Blackhole any traffic to or from the public addrs. |
| 1929 LOG(LS_INFO) << "Failing over..."; | 1939 LOG(LS_INFO) << "Failing over..."; |
| 1930 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, kPublicAddrs[1]); | 1940 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, kPublicAddrs[1]); |
| 1931 // The selected connections may switch, so keep references to them. | 1941 // The selected connections may switch, so keep references to them. |
| 1932 const Connection* selected_connection1 = ep1_ch1()->selected_connection(); | 1942 const Connection* selected_connection1 = ep1_ch1()->selected_connection(); |
| 1933 const Connection* selected_connection2 = ep2_ch1()->selected_connection(); | 1943 const Connection* selected_connection2 = ep2_ch1()->selected_connection(); |
| 1934 // We should detect loss of receiving within 1 second or so. | 1944 // We should detect loss of receiving within 1 second or so. |
| 1935 EXPECT_TRUE_SIMULATED_WAIT( | 1945 EXPECT_TRUE_SIMULATED_WAIT( |
| 1936 !selected_connection1->receiving() && !selected_connection2->receiving(), | 1946 !selected_connection1->receiving() && !selected_connection2->receiving(), |
| 1937 3000, clock); | 1947 3000, clock); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1957 // Adding alternate address will make sure |kPublicAddrs| has the higher | 1967 // Adding alternate address will make sure |kPublicAddrs| has the higher |
| 1958 // priority than others. This is due to FakeNetwork::AddInterface method. | 1968 // priority than others. This is due to FakeNetwork::AddInterface method. |
| 1959 AddAddress(0, kAlternateAddrs[0]); | 1969 AddAddress(0, kAlternateAddrs[0]); |
| 1960 AddAddress(0, kPublicAddrs[0]); | 1970 AddAddress(0, kPublicAddrs[0]); |
| 1961 AddAddress(1, kPublicAddrs[1]); | 1971 AddAddress(1, kPublicAddrs[1]); |
| 1962 | 1972 |
| 1963 // Use only local ports for simplicity. | 1973 // Use only local ports for simplicity. |
| 1964 SetAllocatorFlags(0, kOnlyLocalPorts); | 1974 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 1965 SetAllocatorFlags(1, kOnlyLocalPorts); | 1975 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 1966 | 1976 |
| 1977 // Make the receiving timeout shorter for testing. |
| 1978 IceConfig config = CreateIceConfig(1000, GATHER_ONCE); |
| 1967 // Create channels and let them go writable, as usual. | 1979 // Create channels and let them go writable, as usual. |
| 1968 CreateChannels(1); | 1980 CreateChannels(1, config, config); |
| 1969 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1981 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1970 ep2_ch1()->receiving() && | 1982 ep2_ch1()->receiving() && |
| 1971 ep2_ch1()->writable(), | 1983 ep2_ch1()->writable(), |
| 1972 3000, clock); | 1984 3000, clock); |
| 1973 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 1985 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 1974 ep2_ch1()->selected_connection() && | 1986 ep2_ch1()->selected_connection() && |
| 1975 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1987 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 1976 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1988 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
| 1977 | 1989 |
| 1978 // Make the receiving timeout shorter for testing. | |
| 1979 IceConfig config = CreateIceConfig(1000, GATHER_ONCE); | |
| 1980 ep1_ch1()->SetIceConfig(config); | |
| 1981 ep2_ch1()->SetIceConfig(config); | |
| 1982 | |
| 1983 // Blackhole any traffic to or from the public addrs. | 1990 // Blackhole any traffic to or from the public addrs. |
| 1984 LOG(LS_INFO) << "Failing over..."; | 1991 LOG(LS_INFO) << "Failing over..."; |
| 1985 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, kPublicAddrs[0]); | 1992 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, kPublicAddrs[0]); |
| 1986 // The selected connections will switch, so keep references to them. | 1993 // The selected connections will switch, so keep references to them. |
| 1987 const Connection* selected_connection1 = ep1_ch1()->selected_connection(); | 1994 const Connection* selected_connection1 = ep1_ch1()->selected_connection(); |
| 1988 const Connection* selected_connection2 = ep2_ch1()->selected_connection(); | 1995 const Connection* selected_connection2 = ep2_ch1()->selected_connection(); |
| 1989 // We should detect loss of receiving within 1 second or so. | 1996 // We should detect loss of receiving within 1 second or so. |
| 1990 EXPECT_TRUE_SIMULATED_WAIT( | 1997 EXPECT_TRUE_SIMULATED_WAIT( |
| 1991 !selected_connection1->receiving() && !selected_connection2->receiving(), | 1998 !selected_connection1->receiving() && !selected_connection2->receiving(), |
| 1992 3000, clock); | 1999 3000, clock); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2013 // Adding alternate address will make sure |kPublicAddrs| has the higher | 2020 // Adding alternate address will make sure |kPublicAddrs| has the higher |
| 2014 // priority than others. This is due to FakeNetwork::AddInterface method. | 2021 // priority than others. This is due to FakeNetwork::AddInterface method. |
| 2015 AddAddress(0, kAlternateAddrs[0]); | 2022 AddAddress(0, kAlternateAddrs[0]); |
| 2016 AddAddress(0, kPublicAddrs[0]); | 2023 AddAddress(0, kPublicAddrs[0]); |
| 2017 AddAddress(1, kPublicAddrs[1]); | 2024 AddAddress(1, kPublicAddrs[1]); |
| 2018 | 2025 |
| 2019 // Use only local ports for simplicity. | 2026 // Use only local ports for simplicity. |
| 2020 SetAllocatorFlags(0, kOnlyLocalPorts); | 2027 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2021 SetAllocatorFlags(1, kOnlyLocalPorts); | 2028 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2022 | 2029 |
| 2030 // Make the receiving timeout shorter for testing. |
| 2031 IceConfig config = CreateIceConfig(1000, GATHER_ONCE); |
| 2023 // Create channels and let them go writable, as usual. | 2032 // Create channels and let them go writable, as usual. |
| 2024 CreateChannels(1); | 2033 CreateChannels(1, config, config); |
| 2025 ep1_ch1()->set_remote_supports_renomination(true); | 2034 ep1_ch1()->set_remote_supports_renomination(true); |
| 2026 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2035 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2027 ep2_ch1()->receiving() && | 2036 ep2_ch1()->receiving() && |
| 2028 ep2_ch1()->writable(), | 2037 ep2_ch1()->writable(), |
| 2029 3000, clock); | 2038 3000, clock); |
| 2030 EXPECT_TRUE_SIMULATED_WAIT( | 2039 EXPECT_TRUE_SIMULATED_WAIT( |
| 2031 ep2_ch1()->selected_connection()->remote_nomination() > 0 && | 2040 ep2_ch1()->selected_connection()->remote_nomination() > 0 && |
| 2032 ep1_ch1()->selected_connection()->acked_nomination() > 0, | 2041 ep1_ch1()->selected_connection()->acked_nomination() > 0, |
| 2033 kDefaultTimeout, clock); | 2042 kDefaultTimeout, clock); |
| 2034 const Connection* selected_connection1 = ep1_ch1()->selected_connection(); | 2043 const Connection* selected_connection1 = ep1_ch1()->selected_connection(); |
| 2035 Connection* selected_connection2 = | 2044 Connection* selected_connection2 = |
| 2036 const_cast<Connection*>(ep2_ch1()->selected_connection()); | 2045 const_cast<Connection*>(ep2_ch1()->selected_connection()); |
| 2037 uint32_t remote_nomination2 = selected_connection2->remote_nomination(); | 2046 uint32_t remote_nomination2 = selected_connection2->remote_nomination(); |
| 2038 // |selected_connection2| should not be nominated any more since the previous | 2047 // |selected_connection2| should not be nominated any more since the previous |
| 2039 // nomination has been acknowledged. | 2048 // nomination has been acknowledged. |
| 2040 ConnectSignalNominated(selected_connection2); | 2049 ConnectSignalNominated(selected_connection2); |
| 2041 SIMULATED_WAIT(nominated(), 3000, clock); | 2050 SIMULATED_WAIT(nominated(), 3000, clock); |
| 2042 EXPECT_FALSE(nominated()); | 2051 EXPECT_FALSE(nominated()); |
| 2043 | 2052 |
| 2044 // Make the receiving timeout shorter for testing. | |
| 2045 IceConfig config = CreateIceConfig(1000, GATHER_ONCE); | |
| 2046 ep1_ch1()->SetIceConfig(config); | |
| 2047 ep2_ch1()->SetIceConfig(config); | |
| 2048 | |
| 2049 // Blackhole any traffic to or from the public addrs. | 2053 // Blackhole any traffic to or from the public addrs. |
| 2050 LOG(LS_INFO) << "Failing over..."; | 2054 LOG(LS_INFO) << "Failing over..."; |
| 2051 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, kPublicAddrs[0]); | 2055 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, kPublicAddrs[0]); |
| 2052 | 2056 |
| 2053 // The selected connection on the controlling side should switch. | 2057 // The selected connection on the controlling side should switch. |
| 2054 EXPECT_TRUE_SIMULATED_WAIT( | 2058 EXPECT_TRUE_SIMULATED_WAIT( |
| 2055 ep1_ch1()->selected_connection() != selected_connection1, 3000, clock); | 2059 ep1_ch1()->selected_connection() != selected_connection1, 3000, clock); |
| 2056 // The connection on the controlled side should be nominated again | 2060 // The connection on the controlled side should be nominated again |
| 2057 // and have an increased nomination. | 2061 // and have an increased nomination. |
| 2058 EXPECT_TRUE_SIMULATED_WAIT( | 2062 EXPECT_TRUE_SIMULATED_WAIT( |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2355 | 2359 |
| 2356 // Tests that when a network interface becomes inactive, if Continual Gathering | 2360 // Tests that when a network interface becomes inactive, if Continual Gathering |
| 2357 // policy is GATHER_CONTINUALLY, the ports associated with that network | 2361 // policy is GATHER_CONTINUALLY, the ports associated with that network |
| 2358 // will be removed from the port list of the channel, and the respective | 2362 // will be removed from the port list of the channel, and the respective |
| 2359 // remote candidates on the other participant will be removed eventually. | 2363 // remote candidates on the other participant will be removed eventually. |
| 2360 TEST_F(P2PTransportChannelMultihomedTest, TestNetworkBecomesInactive) { | 2364 TEST_F(P2PTransportChannelMultihomedTest, TestNetworkBecomesInactive) { |
| 2361 rtc::ScopedFakeClock clock; | 2365 rtc::ScopedFakeClock clock; |
| 2362 AddAddress(0, kPublicAddrs[0]); | 2366 AddAddress(0, kPublicAddrs[0]); |
| 2363 AddAddress(1, kPublicAddrs[1]); | 2367 AddAddress(1, kPublicAddrs[1]); |
| 2364 // Create channels and let them go writable, as usual. | 2368 // Create channels and let them go writable, as usual. |
| 2365 CreateChannels(1); | 2369 IceConfig ep1_config = CreateIceConfig(2000, GATHER_CONTINUALLY); |
| 2366 ep1_ch1()->SetIceConfig(CreateIceConfig(2000, GATHER_CONTINUALLY)); | 2370 IceConfig ep2_config = CreateIceConfig(2000, GATHER_ONCE); |
| 2367 ep2_ch1()->SetIceConfig(CreateIceConfig(2000, GATHER_ONCE)); | 2371 CreateChannels(1, ep1_config, ep2_config); |
| 2368 | 2372 |
| 2369 SetAllocatorFlags(0, kOnlyLocalPorts); | 2373 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2370 SetAllocatorFlags(1, kOnlyLocalPorts); | 2374 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2371 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2375 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2372 ep2_ch1()->receiving() && | 2376 ep2_ch1()->receiving() && |
| 2373 ep2_ch1()->writable(), | 2377 ep2_ch1()->writable(), |
| 2374 kDefaultTimeout, clock); | 2378 kDefaultTimeout, clock); |
| 2375 // More than one port has been created. | 2379 // More than one port has been created. |
| 2376 EXPECT_LE(1U, ep1_ch1()->ports().size()); | 2380 EXPECT_LE(1U, ep1_ch1()->ports().size()); |
| 2377 // Endpoint 1 enabled continual gathering; the port will be removed | 2381 // Endpoint 1 enabled continual gathering; the port will be removed |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2399 } | 2403 } |
| 2400 | 2404 |
| 2401 // Tests that continual gathering will create new connections when a new | 2405 // Tests that continual gathering will create new connections when a new |
| 2402 // interface is added. | 2406 // interface is added. |
| 2403 TEST_F(P2PTransportChannelMultihomedTest, | 2407 TEST_F(P2PTransportChannelMultihomedTest, |
| 2404 TestContinualGatheringOnNewInterface) { | 2408 TestContinualGatheringOnNewInterface) { |
| 2405 auto& wifi = kAlternateAddrs; | 2409 auto& wifi = kAlternateAddrs; |
| 2406 auto& cellular = kPublicAddrs; | 2410 auto& cellular = kPublicAddrs; |
| 2407 AddAddress(0, wifi[0], "test_wifi0", rtc::ADAPTER_TYPE_WIFI); | 2411 AddAddress(0, wifi[0], "test_wifi0", rtc::ADAPTER_TYPE_WIFI); |
| 2408 AddAddress(1, cellular[1], "test_cell1", rtc::ADAPTER_TYPE_CELLULAR); | 2412 AddAddress(1, cellular[1], "test_cell1", rtc::ADAPTER_TYPE_CELLULAR); |
| 2409 CreateChannels(1); | |
| 2410 // Set continual gathering policy. | 2413 // Set continual gathering policy. |
| 2411 ep1_ch1()->SetIceConfig(CreateIceConfig(1000, GATHER_CONTINUALLY)); | 2414 IceConfig continual_gathering_config = |
| 2412 ep2_ch1()->SetIceConfig(CreateIceConfig(1000, GATHER_CONTINUALLY)); | 2415 CreateIceConfig(1000, GATHER_CONTINUALLY); |
| 2416 CreateChannels(1, continual_gathering_config, continual_gathering_config); |
| 2413 SetAllocatorFlags(0, kOnlyLocalPorts); | 2417 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2414 SetAllocatorFlags(1, kOnlyLocalPorts); | 2418 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2415 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2419 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2416 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 2420 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 2417 kDefaultTimeout, kDefaultTimeout); | 2421 kDefaultTimeout, kDefaultTimeout); |
| 2418 | 2422 |
| 2419 // Add a new wifi interface on end point 2. We should expect a new connection | 2423 // Add a new wifi interface on end point 2. We should expect a new connection |
| 2420 // to be created and the new one will be the best connection. | 2424 // to be created and the new one will be the best connection. |
| 2421 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); | 2425 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); |
| 2422 const cricket::Connection* conn; | 2426 const cricket::Connection* conn; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2449 // Tests that we can switch links via continual gathering. | 2453 // Tests that we can switch links via continual gathering. |
| 2450 TEST_F(P2PTransportChannelMultihomedTest, | 2454 TEST_F(P2PTransportChannelMultihomedTest, |
| 2451 TestSwitchLinksViaContinualGathering) { | 2455 TestSwitchLinksViaContinualGathering) { |
| 2452 rtc::ScopedFakeClock clock; | 2456 rtc::ScopedFakeClock clock; |
| 2453 AddAddress(0, kPublicAddrs[0]); | 2457 AddAddress(0, kPublicAddrs[0]); |
| 2454 AddAddress(1, kPublicAddrs[1]); | 2458 AddAddress(1, kPublicAddrs[1]); |
| 2455 // Use only local ports for simplicity. | 2459 // Use only local ports for simplicity. |
| 2456 SetAllocatorFlags(0, kOnlyLocalPorts); | 2460 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2457 SetAllocatorFlags(1, kOnlyLocalPorts); | 2461 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2458 | 2462 |
| 2463 // Set continual gathering policy. |
| 2464 IceConfig continual_gathering_config = |
| 2465 CreateIceConfig(1000, GATHER_CONTINUALLY); |
| 2459 // Create channels and let them go writable, as usual. | 2466 // Create channels and let them go writable, as usual. |
| 2460 CreateChannels(1); | 2467 CreateChannels(1, continual_gathering_config, continual_gathering_config); |
| 2461 // Set continual gathering policy. | |
| 2462 ep1_ch1()->SetIceConfig(CreateIceConfig(1000, GATHER_CONTINUALLY)); | |
| 2463 ep2_ch1()->SetIceConfig(CreateIceConfig(1000, GATHER_CONTINUALLY)); | |
| 2464 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2468 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2465 ep2_ch1()->receiving() && | 2469 ep2_ch1()->receiving() && |
| 2466 ep2_ch1()->writable(), | 2470 ep2_ch1()->writable(), |
| 2467 3000, clock); | 2471 3000, clock); |
| 2468 EXPECT_TRUE( | 2472 EXPECT_TRUE( |
| 2469 ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection() && | 2473 ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection() && |
| 2470 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 2474 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 2471 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 2475 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
| 2472 | 2476 |
| 2473 // Add the new address first and then remove the other one. | 2477 // Add the new address first and then remove the other one. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2507 auto& wifi = kAlternateAddrs; | 2511 auto& wifi = kAlternateAddrs; |
| 2508 auto& cellular = kPublicAddrs; | 2512 auto& cellular = kPublicAddrs; |
| 2509 AddAddress(0, wifi[0], "test_wifi0", rtc::ADAPTER_TYPE_WIFI); | 2513 AddAddress(0, wifi[0], "test_wifi0", rtc::ADAPTER_TYPE_WIFI); |
| 2510 AddAddress(0, cellular[0], "test_cell0", rtc::ADAPTER_TYPE_CELLULAR); | 2514 AddAddress(0, cellular[0], "test_cell0", rtc::ADAPTER_TYPE_CELLULAR); |
| 2511 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); | 2515 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); |
| 2512 AddAddress(1, cellular[1], "test_cell1", rtc::ADAPTER_TYPE_CELLULAR); | 2516 AddAddress(1, cellular[1], "test_cell1", rtc::ADAPTER_TYPE_CELLULAR); |
| 2513 // Use only local ports for simplicity. | 2517 // Use only local ports for simplicity. |
| 2514 SetAllocatorFlags(0, kOnlyLocalPorts); | 2518 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2515 SetAllocatorFlags(1, kOnlyLocalPorts); | 2519 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2516 | 2520 |
| 2517 // Create channels and let them go writable, as usual. | |
| 2518 CreateChannels(1); | |
| 2519 // Set continual gathering policy. | 2521 // Set continual gathering policy. |
| 2520 IceConfig config = CreateIceConfig(1000, GATHER_CONTINUALLY_AND_RECOVER); | 2522 IceConfig config = CreateIceConfig(1000, GATHER_CONTINUALLY_AND_RECOVER); |
| 2521 ep1_ch1()->SetIceConfig(config); | 2523 // Create channels and let them go writable, as usual. |
| 2522 ep2_ch1()->SetIceConfig(config); | 2524 CreateChannels(1, config, config); |
| 2523 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2525 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2524 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 2526 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 2525 3000, clock); | 2527 3000, clock); |
| 2526 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 2528 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 2527 ep2_ch1()->selected_connection() && | 2529 ep2_ch1()->selected_connection() && |
| 2528 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && | 2530 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && |
| 2529 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1])); | 2531 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1])); |
| 2530 | 2532 |
| 2531 // First destroy all backup connection. | 2533 // First destroy all backup connection. |
| 2532 DestroyAllButBestConnection(ep1_ch1()); | 2534 DestroyAllButBestConnection(ep1_ch1()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2551 auto& cellular = kPublicAddrs; | 2553 auto& cellular = kPublicAddrs; |
| 2552 AddAddress(0, wifi[0], "test_wifi0", rtc::ADAPTER_TYPE_WIFI); | 2554 AddAddress(0, wifi[0], "test_wifi0", rtc::ADAPTER_TYPE_WIFI); |
| 2553 AddAddress(0, cellular[0], "test_cell0", rtc::ADAPTER_TYPE_CELLULAR); | 2555 AddAddress(0, cellular[0], "test_cell0", rtc::ADAPTER_TYPE_CELLULAR); |
| 2554 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); | 2556 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); |
| 2555 AddAddress(1, cellular[1], "test_cell1", rtc::ADAPTER_TYPE_CELLULAR); | 2557 AddAddress(1, cellular[1], "test_cell1", rtc::ADAPTER_TYPE_CELLULAR); |
| 2556 // Use only local ports for simplicity. | 2558 // Use only local ports for simplicity. |
| 2557 SetAllocatorFlags(0, kOnlyLocalPorts); | 2559 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2558 SetAllocatorFlags(1, kOnlyLocalPorts); | 2560 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2559 | 2561 |
| 2560 // Create channels and let them go writable, as usual. | 2562 // Create channels and let them go writable, as usual. |
| 2561 CreateChannels(1); | |
| 2562 IceConfig config = CreateIceConfig(1000, GATHER_CONTINUALLY); | 2563 IceConfig config = CreateIceConfig(1000, GATHER_CONTINUALLY); |
| 2563 config.regather_on_failed_networks_interval = rtc::Optional<int>(2000); | 2564 config.regather_on_failed_networks_interval = rtc::Optional<int>(2000); |
| 2564 ep1_ch1()->SetIceConfig(config); | 2565 CreateChannels(1, config, config); |
| 2565 ep2_ch1()->SetIceConfig(config); | |
| 2566 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2566 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2567 ep2_ch1()->receiving() && | 2567 ep2_ch1()->receiving() && |
| 2568 ep2_ch1()->writable(), | 2568 ep2_ch1()->writable(), |
| 2569 3000, clock); | 2569 3000, clock); |
| 2570 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 2570 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 2571 ep2_ch1()->selected_connection() && | 2571 ep2_ch1()->selected_connection() && |
| 2572 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && | 2572 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && |
| 2573 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1])); | 2573 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1])); |
| 2574 | 2574 |
| 2575 // Destroy all backup connections. | 2575 // Destroy all backup connections. |
| (...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4031 | 4031 |
| 4032 // TCP Relay/Relay is the next. | 4032 // TCP Relay/Relay is the next. |
| 4033 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, | 4033 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, |
| 4034 TCP_PROTOCOL_NAME); | 4034 TCP_PROTOCOL_NAME); |
| 4035 | 4035 |
| 4036 // Finally, Local/Relay will be pinged. | 4036 // Finally, Local/Relay will be pinged. |
| 4037 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); | 4037 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); |
| 4038 } | 4038 } |
| 4039 | 4039 |
| 4040 } // namespace cricket { | 4040 } // namespace cricket { |
| OLD | NEW |