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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 } | 381 } |
| 382 void AddAddress(int endpoint, | 382 void AddAddress(int endpoint, |
| 383 const SocketAddress& addr, | 383 const SocketAddress& addr, |
| 384 const std::string& ifname, | 384 const std::string& ifname, |
| 385 rtc::AdapterType adapter_type) { | 385 rtc::AdapterType adapter_type) { |
| 386 GetEndpoint(endpoint)->network_manager_.AddInterface(addr, ifname, | 386 GetEndpoint(endpoint)->network_manager_.AddInterface(addr, ifname, |
| 387 adapter_type); | 387 adapter_type); |
| 388 } | 388 } |
| 389 void RemoveAddress(int endpoint, const SocketAddress& addr) { | 389 void RemoveAddress(int endpoint, const SocketAddress& addr) { |
| 390 GetEndpoint(endpoint)->network_manager_.RemoveInterface(addr); | 390 GetEndpoint(endpoint)->network_manager_.RemoveInterface(addr); |
| 391 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, addr); | |
| 391 } | 392 } |
| 392 void SetProxy(int endpoint, rtc::ProxyType type) { | 393 void SetProxy(int endpoint, rtc::ProxyType type) { |
| 393 rtc::ProxyInfo info; | 394 rtc::ProxyInfo info; |
| 394 info.type = type; | 395 info.type = type; |
| 395 info.address = (type == rtc::PROXY_HTTPS) ? | 396 info.address = (type == rtc::PROXY_HTTPS) ? |
| 396 kHttpsProxyAddrs[endpoint] : kSocksProxyAddrs[endpoint]; | 397 kHttpsProxyAddrs[endpoint] : kSocksProxyAddrs[endpoint]; |
| 397 GetAllocator(endpoint)->set_proxy("unittest/1.0", info); | 398 GetAllocator(endpoint)->set_proxy("unittest/1.0", info); |
| 398 } | 399 } |
| 399 void SetAllocatorFlags(int endpoint, int flags) { | 400 void SetAllocatorFlags(int endpoint, int flags) { |
| 400 GetAllocator(endpoint)->set_flags(flags); | 401 GetAllocator(endpoint)->set_flags(flags); |
| (...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1577 TEST_F(P2PTransportChannelSameNatTest, TestConesBehindSameCone) { | 1578 TEST_F(P2PTransportChannelSameNatTest, TestConesBehindSameCone) { |
| 1578 ConfigureEndpoints(NAT_FULL_CONE, NAT_FULL_CONE, NAT_FULL_CONE); | 1579 ConfigureEndpoints(NAT_FULL_CONE, NAT_FULL_CONE, NAT_FULL_CONE); |
| 1579 Test(P2PTransportChannelTestBase::Result( | 1580 Test(P2PTransportChannelTestBase::Result( |
| 1580 "prflx", "udp", "stun", "udp", "stun", "udp", "prflx", "udp", 1000)); | 1581 "prflx", "udp", "stun", "udp", "stun", "udp", "prflx", "udp", 1000)); |
| 1581 } | 1582 } |
| 1582 | 1583 |
| 1583 // Test what happens when we have multiple available pathways. | 1584 // Test what happens when we have multiple available pathways. |
| 1584 // In the future we will try different RTTs and configs for the different | 1585 // In the future we will try different RTTs and configs for the different |
| 1585 // interfaces, so that we can simulate a user with Ethernet and VPN networks. | 1586 // interfaces, so that we can simulate a user with Ethernet and VPN networks. |
| 1586 class P2PTransportChannelMultihomedTest : public P2PTransportChannelTestBase { | 1587 class P2PTransportChannelMultihomedTest : public P2PTransportChannelTestBase { |
| 1588 public: | |
| 1589 const cricket::Connection* GetConnectionWithRemoteAddress( | |
| 1590 cricket::P2PTransportChannel* channel, | |
| 1591 const SocketAddress& address) { | |
| 1592 for (cricket::Connection* conn : channel->connections()) { | |
| 1593 if (conn->remote_candidate().address().EqualIPs(address)) { | |
| 1594 return conn; | |
| 1595 } | |
| 1596 } | |
| 1597 return nullptr; | |
| 1598 } | |
| 1599 | |
| 1600 const cricket::Connection* GetConnectionWithLocalAddress( | |
| 1601 cricket::P2PTransportChannel* channel, | |
| 1602 const SocketAddress& address) { | |
| 1603 for (cricket::Connection* conn : channel->connections()) { | |
| 1604 if (conn->local_candidate().address().EqualIPs(address)) { | |
| 1605 return conn; | |
| 1606 } | |
| 1607 } | |
| 1608 return nullptr; | |
| 1609 } | |
| 1610 | |
| 1611 void DestroyAllButBestConnection(cricket::P2PTransportChannel* channel) { | |
| 1612 const cricket::Connection* best_connection = channel->best_connection(); | |
| 1613 for (cricket::Connection* conn : channel->connections()) { | |
| 1614 if (conn != best_connection) { | |
| 1615 conn->Destroy(); | |
| 1616 } | |
| 1617 } | |
| 1618 } | |
| 1587 }; | 1619 }; |
| 1588 | 1620 |
| 1589 // Test that we can establish connectivity when both peers are multihomed. | 1621 // Test that we can establish connectivity when both peers are multihomed. |
| 1590 TEST_F(P2PTransportChannelMultihomedTest, DISABLED_TestBasic) { | 1622 TEST_F(P2PTransportChannelMultihomedTest, DISABLED_TestBasic) { |
| 1591 AddAddress(0, kPublicAddrs[0]); | 1623 AddAddress(0, kPublicAddrs[0]); |
| 1592 AddAddress(0, kAlternateAddrs[0]); | 1624 AddAddress(0, kAlternateAddrs[0]); |
| 1593 AddAddress(1, kPublicAddrs[1]); | 1625 AddAddress(1, kPublicAddrs[1]); |
| 1594 AddAddress(1, kAlternateAddrs[1]); | 1626 AddAddress(1, kAlternateAddrs[1]); |
| 1595 Test(kLocalUdpToLocalUdp); | 1627 Test(kLocalUdpToLocalUdp); |
| 1596 } | 1628 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1723 1000, 1000); | 1755 1000, 1000); |
| 1724 // Need to wait to make sure the connections on both networks are writable. | 1756 // Need to wait to make sure the connections on both networks are writable. |
| 1725 EXPECT_TRUE_WAIT(ep1_ch1()->best_connection() && | 1757 EXPECT_TRUE_WAIT(ep1_ch1()->best_connection() && |
| 1726 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && | 1758 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && |
| 1727 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1]), | 1759 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1]), |
| 1728 1000); | 1760 1000); |
| 1729 EXPECT_TRUE_WAIT(ep2_ch1()->best_connection() && | 1761 EXPECT_TRUE_WAIT(ep2_ch1()->best_connection() && |
| 1730 LocalCandidate(ep2_ch1())->address().EqualIPs(wifi[1]) && | 1762 LocalCandidate(ep2_ch1())->address().EqualIPs(wifi[1]) && |
| 1731 RemoteCandidate(ep2_ch1())->address().EqualIPs(wifi[0]), | 1763 RemoteCandidate(ep2_ch1())->address().EqualIPs(wifi[0]), |
| 1732 1000); | 1764 1000); |
| 1765 DestroyChannels(); | |
|
Taylor Brandstetter
2016/06/21 23:36:12
Can you explain why this is needed? Shouldn't the
| |
| 1733 } | 1766 } |
| 1734 | 1767 |
| 1735 // Tests that a Wifi-Cellular connection has higher precedence than | 1768 // Tests that a Wifi-Cellular connection has higher precedence than |
| 1736 // a Cellular-Cellular connection. | 1769 // a Cellular-Cellular connection. |
| 1737 TEST_F(P2PTransportChannelMultihomedTest, TestPreferWifiOverCellularNetwork) { | 1770 TEST_F(P2PTransportChannelMultihomedTest, TestPreferWifiOverCellularNetwork) { |
| 1738 // The interface names are chosen so that |cellular| would have higher | 1771 // The interface names are chosen so that |cellular| would have higher |
| 1739 // candidate priority if it is not for the network type. | 1772 // candidate priority if it is not for the network type. |
| 1740 auto& wifi = kAlternateAddrs; | 1773 auto& wifi = kAlternateAddrs; |
| 1741 auto& cellular = kPublicAddrs; | 1774 auto& cellular = kPublicAddrs; |
| 1742 AddAddress(0, cellular[0], "test1", rtc::ADAPTER_TYPE_CELLULAR); | 1775 AddAddress(0, cellular[0], "test1", rtc::ADAPTER_TYPE_CELLULAR); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1753 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1786 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1754 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1787 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 1755 1000, 1000); | 1788 1000, 1000); |
| 1756 // Need to wait to make sure the connections on both networks are writable. | 1789 // Need to wait to make sure the connections on both networks are writable. |
| 1757 EXPECT_TRUE_WAIT(ep1_ch1()->best_connection() && | 1790 EXPECT_TRUE_WAIT(ep1_ch1()->best_connection() && |
| 1758 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1]), | 1791 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1]), |
| 1759 1000); | 1792 1000); |
| 1760 EXPECT_TRUE_WAIT(ep2_ch1()->best_connection() && | 1793 EXPECT_TRUE_WAIT(ep2_ch1()->best_connection() && |
| 1761 LocalCandidate(ep2_ch1())->address().EqualIPs(wifi[1]), | 1794 LocalCandidate(ep2_ch1())->address().EqualIPs(wifi[1]), |
| 1762 1000); | 1795 1000); |
| 1796 DestroyChannels(); | |
| 1763 } | 1797 } |
| 1764 | 1798 |
| 1765 // Test that the backup connection is pinged at a rate no faster than | 1799 // Test that the backup connection is pinged at a rate no faster than |
| 1766 // what was configured. | 1800 // what was configured. |
| 1767 TEST_F(P2PTransportChannelMultihomedTest, TestPingBackupConnectionRate) { | 1801 TEST_F(P2PTransportChannelMultihomedTest, TestPingBackupConnectionRate) { |
| 1768 AddAddress(0, kPublicAddrs[0]); | 1802 AddAddress(0, kPublicAddrs[0]); |
| 1769 // Adding alternate address will make sure |kPublicAddrs| has the higher | 1803 // Adding alternate address will make sure |kPublicAddrs| has the higher |
| 1770 // priority than others. This is due to FakeNetwork::AddInterface method. | 1804 // priority than others. This is due to FakeNetwork::AddInterface method. |
| 1771 AddAddress(1, kAlternateAddrs[1]); | 1805 AddAddress(1, kAlternateAddrs[1]); |
| 1772 AddAddress(1, kPublicAddrs[1]); | 1806 AddAddress(1, kPublicAddrs[1]); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1790 ASSERT_EQ(2U, connections.size()); | 1824 ASSERT_EQ(2U, connections.size()); |
| 1791 cricket::Connection* backup_conn = connections[1]; | 1825 cricket::Connection* backup_conn = connections[1]; |
| 1792 EXPECT_TRUE_WAIT(backup_conn->writable(), 3000); | 1826 EXPECT_TRUE_WAIT(backup_conn->writable(), 3000); |
| 1793 int64_t last_ping_response_ms = backup_conn->last_ping_response_received(); | 1827 int64_t last_ping_response_ms = backup_conn->last_ping_response_received(); |
| 1794 EXPECT_TRUE_WAIT( | 1828 EXPECT_TRUE_WAIT( |
| 1795 last_ping_response_ms < backup_conn->last_ping_response_received(), 5000); | 1829 last_ping_response_ms < backup_conn->last_ping_response_received(), 5000); |
| 1796 int time_elapsed = | 1830 int time_elapsed = |
| 1797 backup_conn->last_ping_response_received() - last_ping_response_ms; | 1831 backup_conn->last_ping_response_received() - last_ping_response_ms; |
| 1798 LOG(LS_INFO) << "Time elapsed: " << time_elapsed; | 1832 LOG(LS_INFO) << "Time elapsed: " << time_elapsed; |
| 1799 EXPECT_GE(time_elapsed, backup_ping_interval); | 1833 EXPECT_GE(time_elapsed, backup_ping_interval); |
| 1834 | |
| 1835 DestroyChannels(); | |
| 1800 } | 1836 } |
| 1801 | 1837 |
| 1802 TEST_F(P2PTransportChannelMultihomedTest, TestGetState) { | 1838 TEST_F(P2PTransportChannelMultihomedTest, TestGetState) { |
| 1803 AddAddress(0, kAlternateAddrs[0]); | 1839 AddAddress(0, kAlternateAddrs[0]); |
| 1804 AddAddress(0, kPublicAddrs[0]); | 1840 AddAddress(0, kPublicAddrs[0]); |
| 1805 AddAddress(1, kPublicAddrs[1]); | 1841 AddAddress(1, kPublicAddrs[1]); |
| 1806 // Create channels and let them go writable, as usual. | 1842 // Create channels and let them go writable, as usual. |
| 1807 CreateChannels(1); | 1843 CreateChannels(1); |
| 1808 | 1844 |
| 1809 // Both transport channels will reach STATE_COMPLETED quickly. | 1845 // Both transport channels will reach STATE_COMPLETED quickly. |
| 1810 EXPECT_EQ_WAIT(cricket::TransportChannelState::STATE_COMPLETED, | 1846 EXPECT_EQ_WAIT(cricket::TransportChannelState::STATE_COMPLETED, |
| 1811 ep1_ch1()->GetState(), 1000); | 1847 ep1_ch1()->GetState(), 1000); |
| 1812 EXPECT_EQ_WAIT(cricket::TransportChannelState::STATE_COMPLETED, | 1848 EXPECT_EQ_WAIT(cricket::TransportChannelState::STATE_COMPLETED, |
| 1813 ep2_ch1()->GetState(), 1000); | 1849 ep2_ch1()->GetState(), 1000); |
| 1850 | |
| 1851 DestroyChannels(); | |
| 1814 } | 1852 } |
| 1815 | 1853 |
| 1816 // Tests that when a network interface becomes inactive, if and only if | 1854 // Tests that when a network interface becomes inactive, if and only if |
| 1817 // Continual Gathering is enabled, the ports associated with that network | 1855 // Continual Gathering is enabled, the ports associated with that network |
| 1818 // will be removed from the port list of the channel, and the respective | 1856 // will be removed from the port list of the channel, and the respective |
| 1819 // remote candidates on the other participant will be removed eventually. | 1857 // remote candidates on the other participant will be removed eventually. |
| 1820 TEST_F(P2PTransportChannelMultihomedTest, TestNetworkBecomesInactive) { | 1858 TEST_F(P2PTransportChannelMultihomedTest, TestNetworkBecomesInactive) { |
| 1821 AddAddress(0, kPublicAddrs[0]); | 1859 AddAddress(0, kPublicAddrs[0]); |
| 1822 AddAddress(1, kPublicAddrs[1]); | 1860 AddAddress(1, kPublicAddrs[1]); |
| 1823 // Create channels and let them go writable, as usual. | 1861 // Create channels and let them go writable, as usual. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1842 size_t num_ports = ep2_ch1()->ports().size(); | 1880 size_t num_ports = ep2_ch1()->ports().size(); |
| 1843 EXPECT_LE(1U, num_ports); | 1881 EXPECT_LE(1U, num_ports); |
| 1844 size_t num_remote_candidates = ep1_ch1()->remote_candidates().size(); | 1882 size_t num_remote_candidates = ep1_ch1()->remote_candidates().size(); |
| 1845 // Endpoint 2 did not enable continual gathering; the port will not be removed | 1883 // Endpoint 2 did not enable continual gathering; the port will not be removed |
| 1846 // when the interface is removed and neither the remote candidates on the | 1884 // when the interface is removed and neither the remote candidates on the |
| 1847 // other participant. | 1885 // other participant. |
| 1848 RemoveAddress(1, kPublicAddrs[1]); | 1886 RemoveAddress(1, kPublicAddrs[1]); |
| 1849 rtc::Thread::Current()->ProcessMessages(500); | 1887 rtc::Thread::Current()->ProcessMessages(500); |
| 1850 EXPECT_EQ(num_ports, ep2_ch1()->ports().size()); | 1888 EXPECT_EQ(num_ports, ep2_ch1()->ports().size()); |
| 1851 EXPECT_EQ(num_remote_candidates, ep1_ch1()->remote_candidates().size()); | 1889 EXPECT_EQ(num_remote_candidates, ep1_ch1()->remote_candidates().size()); |
| 1890 | |
| 1891 DestroyChannels(); | |
| 1852 } | 1892 } |
| 1853 | 1893 |
| 1854 /* | 1894 // Tests that continual gathering will create new connections when a new |
| 1895 // interface is added. | |
| 1896 TEST_F(P2PTransportChannelMultihomedTest, | |
| 1897 TestContinualGatheringOnNewInterface) { | |
| 1898 auto& wifi = kAlternateAddrs; | |
| 1899 auto& cellular = kPublicAddrs; | |
| 1900 AddAddress(0, wifi[0], "test_wifi0", rtc::ADAPTER_TYPE_WIFI); | |
| 1901 AddAddress(1, cellular[1], "test_cell1", rtc::ADAPTER_TYPE_CELLULAR); | |
| 1902 CreateChannels(1); | |
| 1903 // Enable continual gathering. | |
| 1904 ep1_ch1()->SetIceConfig(CreateIceConfig(1000, true)); | |
| 1905 ep2_ch1()->SetIceConfig(CreateIceConfig(1000, true)); | |
|
Taylor Brandstetter
2016/06/21 23:36:12
Would be nice to have a "CreateContinualGatheringC
| |
| 1906 SetAllocatorFlags(0, kOnlyLocalPorts); | |
| 1907 SetAllocatorFlags(1, kOnlyLocalPorts); | |
| 1908 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | |
| 1909 ep2_ch1()->receiving() && ep2_ch1()->writable(), | |
| 1910 kDefaultTimeout, kDefaultTimeout); | |
| 1855 | 1911 |
| 1856 TODO(pthatcher): Once have a way to handle network interfaces changes | 1912 // Add a new wifi interface on end point 2. We should expect a new connection |
| 1857 without signalling an ICE restart, put a test like this back. In the | 1913 // to be created and the new one will be the best connection. |
| 1858 mean time, this test only worked for GICE. With ICE, it's currently | 1914 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); |
| 1859 not possible without an ICE restart. | 1915 const cricket::Connection* conn; |
| 1916 EXPECT_TRUE_WAIT((conn = ep1_ch1()->best_connection()) != nullptr && | |
| 1917 conn->remote_candidate().address().EqualIPs(wifi[1]), | |
| 1918 kDefaultTimeout); | |
| 1919 EXPECT_TRUE_WAIT((conn = ep2_ch1()->best_connection()) != nullptr && | |
| 1920 conn->local_candidate().address().EqualIPs(wifi[1]), | |
| 1921 kDefaultTimeout); | |
| 1860 | 1922 |
| 1861 // Test that we can switch links in a coordinated fashion. | 1923 // Add a new cellular interface on end point 1, we should expect a new |
| 1862 TEST_F(P2PTransportChannelMultihomedTest, TestDrain) { | 1924 // backup connection created using this new interface. |
| 1925 AddAddress(0, cellular[0], "test_cellular0", rtc::ADAPTER_TYPE_CELLULAR); | |
| 1926 EXPECT_TRUE_WAIT( | |
| 1927 ep1_ch1()->GetState() == cricket::STATE_COMPLETED && | |
| 1928 (conn = GetConnectionWithLocalAddress(ep1_ch1(), cellular[0])) && | |
| 1929 conn != ep1_ch1()->best_connection() && conn->writable(), | |
| 1930 kDefaultTimeout); | |
| 1931 EXPECT_TRUE_WAIT( | |
| 1932 ep2_ch1()->GetState() == cricket::STATE_COMPLETED && | |
| 1933 (conn = GetConnectionWithRemoteAddress(ep2_ch1(), cellular[0])) && | |
| 1934 conn != ep2_ch1()->best_connection() && conn->receiving(), | |
| 1935 kDefaultTimeout); | |
| 1936 | |
| 1937 DestroyChannels(); | |
| 1938 } | |
| 1939 | |
| 1940 // Tests that we can switch links via continual gathering. | |
| 1941 TEST_F(P2PTransportChannelMultihomedTest, TestContinualGatheringSwitchLinks) { | |
| 1863 AddAddress(0, kPublicAddrs[0]); | 1942 AddAddress(0, kPublicAddrs[0]); |
| 1864 AddAddress(1, kPublicAddrs[1]); | 1943 AddAddress(1, kPublicAddrs[1]); |
| 1865 // Use only local ports for simplicity. | 1944 // Use only local ports for simplicity. |
| 1866 SetAllocatorFlags(0, kOnlyLocalPorts); | 1945 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 1867 SetAllocatorFlags(1, kOnlyLocalPorts); | 1946 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 1868 | 1947 |
| 1869 // Create channels and let them go writable, as usual. | 1948 // Create channels and let them go writable, as usual. |
| 1870 CreateChannels(1); | 1949 CreateChannels(1); |
| 1871 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1950 // Enable continual gathering. |
| 1872 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1951 ep1_ch1()->SetIceConfig(CreateIceConfig(1000, true)); |
| 1873 1000); | 1952 ep2_ch1()->SetIceConfig(CreateIceConfig(1000, true)); |
| 1953 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | |
| 1954 ep2_ch1()->receiving() && ep2_ch1()->writable(), | |
| 1955 kDefaultTimeout, kDefaultTimeout); | |
| 1874 EXPECT_TRUE( | 1956 EXPECT_TRUE( |
| 1875 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1957 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
| 1876 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1958 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 1877 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1959 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
| 1878 | 1960 |
| 1879 | 1961 // Add the new address first and then remove the other one. |
| 1880 // Remove the public interface, add the alternate interface, and allocate | |
| 1881 // a new generation of candidates for the new interface (via | |
| 1882 // MaybeStartGathering()). | |
| 1883 LOG(LS_INFO) << "Draining..."; | 1962 LOG(LS_INFO) << "Draining..."; |
| 1884 AddAddress(1, kAlternateAddrs[1]); | 1963 AddAddress(1, kAlternateAddrs[1]); |
| 1885 RemoveAddress(1, kPublicAddrs[1]); | 1964 RemoveAddress(1, kPublicAddrs[1]); |
| 1886 ep2_ch1()->MaybeStartGathering(); | 1965 // We should switch to use the alternate address after an exchange of pings. |
| 1887 | |
| 1888 // We should switch over to use the alternate address after | |
| 1889 // an exchange of pings. | |
| 1890 EXPECT_TRUE_WAIT( | 1966 EXPECT_TRUE_WAIT( |
| 1891 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1967 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
| 1892 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1968 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 1893 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1]), | 1969 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1]), |
| 1894 3000); | 1970 3000); |
| 1895 | 1971 |
| 1972 // Remove one address first and then add another address. | |
| 1973 LOG(LS_INFO) << "Draining again..."; | |
| 1974 RemoveAddress(1, kAlternateAddrs[1]); | |
| 1975 AddAddress(1, kAlternateAddrs[0]); | |
| 1976 EXPECT_TRUE_WAIT( | |
| 1977 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | |
| 1978 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | |
| 1979 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[0]), | |
| 1980 3000); | |
| 1981 | |
| 1896 DestroyChannels(); | 1982 DestroyChannels(); |
| 1897 } | 1983 } |
| 1898 | 1984 |
| 1899 */ | 1985 // Tests that if the backup connections are lost and then the interface with the |
| 1986 // selected connection is gone, continual gathering will restore the | |
| 1987 // connectivity. | |
| 1988 TEST_F(P2PTransportChannelMultihomedTest, | |
| 1989 TestBackupConnectionLostThenContinualGathering) { | |
| 1990 auto& wifi = kAlternateAddrs; | |
| 1991 auto& cellular = kPublicAddrs; | |
| 1992 AddAddress(0, wifi[0], "test_wifi0", rtc::ADAPTER_TYPE_WIFI); | |
| 1993 AddAddress(0, cellular[0], "test_cell0", rtc::ADAPTER_TYPE_CELLULAR); | |
| 1994 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); | |
| 1995 AddAddress(1, cellular[1], "test_cell1", rtc::ADAPTER_TYPE_CELLULAR); | |
| 1996 // Use only local ports for simplicity. | |
| 1997 SetAllocatorFlags(0, kOnlyLocalPorts); | |
| 1998 SetAllocatorFlags(1, kOnlyLocalPorts); | |
| 1999 | |
| 2000 // Create channels and let them go writable, as usual. | |
| 2001 CreateChannels(1); | |
| 2002 // Enable continual gathering. | |
| 2003 ep1_ch1()->SetIceConfig(CreateIceConfig(1000, true)); | |
| 2004 ep2_ch1()->SetIceConfig(CreateIceConfig(1000, true)); | |
| 2005 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | |
| 2006 ep2_ch1()->receiving() && ep2_ch1()->writable(), | |
| 2007 kDefaultTimeout, kDefaultTimeout); | |
| 2008 EXPECT_TRUE(ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | |
| 2009 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && | |
| 2010 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1])); | |
| 2011 | |
| 2012 // First destroy all backup connection. | |
| 2013 DestroyAllButBestConnection(ep1_ch1()); | |
| 2014 // Then the interface of the best connection goes away. | |
| 2015 RemoveAddress(0, wifi[0]); | |
| 2016 EXPECT_TRUE_WAIT( | |
| 2017 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | |
| 2018 LocalCandidate(ep1_ch1())->address().EqualIPs(cellular[0]) && | |
| 2019 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1]), | |
| 2020 kDefaultTimeout); | |
| 2021 | |
| 2022 DestroyChannels(); | |
| 2023 } | |
| 2024 | |
| 2025 // Tests that the backup connection will be restored after it is destroyed. | |
| 2026 TEST_F(P2PTransportChannelMultihomedTest, TestRestoreBackupConnection) { | |
| 2027 auto& wifi = kAlternateAddrs; | |
| 2028 auto& cellular = kPublicAddrs; | |
| 2029 AddAddress(0, wifi[0], "test_wifi0", rtc::ADAPTER_TYPE_WIFI); | |
| 2030 AddAddress(0, cellular[0], "test_cell0", rtc::ADAPTER_TYPE_CELLULAR); | |
| 2031 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); | |
| 2032 AddAddress(1, cellular[1], "test_cell1", rtc::ADAPTER_TYPE_CELLULAR); | |
| 2033 // Use only local ports for simplicity. | |
| 2034 SetAllocatorFlags(0, kOnlyLocalPorts); | |
| 2035 SetAllocatorFlags(1, kOnlyLocalPorts); | |
| 2036 | |
| 2037 // Create channels and let them go writable, as usual. | |
| 2038 CreateChannels(1); | |
| 2039 ep1_ch1()->SetIceConfig(CreateIceConfig(1000, true)); | |
| 2040 ep2_ch1()->SetIceConfig(CreateIceConfig(1000, true)); | |
| 2041 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | |
| 2042 ep2_ch1()->receiving() && ep2_ch1()->writable(), | |
| 2043 kDefaultTimeout, kDefaultTimeout); | |
| 2044 EXPECT_TRUE(ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | |
| 2045 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && | |
| 2046 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1])); | |
| 2047 | |
| 2048 // Destroy all backup connections. | |
| 2049 ep1_ch1()->set_check_restore_backup_connection_interval(2000); | |
| 2050 DestroyAllButBestConnection(ep1_ch1()); | |
| 2051 // Ensure the backup connection is removed first. | |
| 2052 EXPECT_TRUE_WAIT( | |
| 2053 GetConnectionWithLocalAddress(ep1_ch1(), cellular[0]) == nullptr, | |
| 2054 kDefaultTimeout); | |
| 2055 const cricket::Connection* conn; | |
| 2056 EXPECT_TRUE_WAIT( | |
| 2057 (conn = GetConnectionWithLocalAddress(ep1_ch1(), cellular[0])) && | |
| 2058 conn != ep1_ch1()->best_connection() && conn->writable(), | |
| 2059 5000); | |
|
Taylor Brandstetter
2016/06/21 23:36:12
Why 5000 specifically?
| |
| 2060 | |
| 2061 DestroyChannels(); | |
| 2062 } | |
| 1900 | 2063 |
| 1901 // A collection of tests which tests a single P2PTransportChannel by sending | 2064 // A collection of tests which tests a single P2PTransportChannel by sending |
| 1902 // pings. | 2065 // pings. |
| 1903 class P2PTransportChannelPingTest : public testing::Test, | 2066 class P2PTransportChannelPingTest : public testing::Test, |
| 1904 public sigslot::has_slots<> { | 2067 public sigslot::has_slots<> { |
| 1905 public: | 2068 public: |
| 1906 P2PTransportChannelPingTest() | 2069 P2PTransportChannelPingTest() |
| 1907 : pss_(new rtc::PhysicalSocketServer), | 2070 : pss_(new rtc::PhysicalSocketServer), |
| 1908 vss_(new rtc::VirtualSocketServer(pss_.get())), | 2071 vss_(new rtc::VirtualSocketServer(pss_.get())), |
| 1909 ss_scope_(vss_.get()) {} | 2072 ss_scope_(vss_.get()) {} |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2916 | 3079 |
| 2917 // TCP Relay/Relay is the next. | 3080 // TCP Relay/Relay is the next. |
| 2918 VerifyNextPingableConnection(cricket::RELAY_PORT_TYPE, | 3081 VerifyNextPingableConnection(cricket::RELAY_PORT_TYPE, |
| 2919 cricket::RELAY_PORT_TYPE, | 3082 cricket::RELAY_PORT_TYPE, |
| 2920 cricket::TCP_PROTOCOL_NAME); | 3083 cricket::TCP_PROTOCOL_NAME); |
| 2921 | 3084 |
| 2922 // Finally, Local/Relay will be pinged. | 3085 // Finally, Local/Relay will be pinged. |
| 2923 VerifyNextPingableConnection(cricket::LOCAL_PORT_TYPE, | 3086 VerifyNextPingableConnection(cricket::LOCAL_PORT_TYPE, |
| 2924 cricket::RELAY_PORT_TYPE); | 3087 cricket::RELAY_PORT_TYPE); |
| 2925 } | 3088 } |
| OLD | NEW |