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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 static const SocketAddress kRelaySslTcpExtAddr("99.99.99.3", 5005); | 85 static const SocketAddress kRelaySslTcpExtAddr("99.99.99.3", 5005); |
86 // The addresses for the public turn server. | 86 // The addresses for the public turn server. |
87 static const SocketAddress kTurnUdpIntAddr("99.99.99.4", | 87 static const SocketAddress kTurnUdpIntAddr("99.99.99.4", |
88 cricket::STUN_SERVER_PORT); | 88 cricket::STUN_SERVER_PORT); |
89 static const SocketAddress kTurnTcpIntAddr("99.99.99.4", | 89 static const SocketAddress kTurnTcpIntAddr("99.99.99.4", |
90 cricket::STUN_SERVER_PORT + 1); | 90 cricket::STUN_SERVER_PORT + 1); |
91 static const SocketAddress kTurnUdpExtAddr("99.99.99.5", 0); | 91 static const SocketAddress kTurnUdpExtAddr("99.99.99.5", 0); |
92 static const cricket::RelayCredentials kRelayCredentials("test", "test"); | 92 static const cricket::RelayCredentials kRelayCredentials("test", "test"); |
93 | 93 |
94 // Based on ICE_UFRAG_LENGTH | 94 // Based on ICE_UFRAG_LENGTH |
95 static const char* kIceUfrag[4] = {"UF00", "UF01", | 95 const char* kIceUfrag[4] = {"UF00", "UF01", "UF02", "UF03"}; |
96 "UF02", "UF03"}; | |
97 // Based on ICE_PWD_LENGTH | 96 // Based on ICE_PWD_LENGTH |
98 static const char* kIcePwd[4] = {"TESTICEPWD00000000000000", | 97 const char* kIcePwd[4] = { |
99 "TESTICEPWD00000000000001", | 98 "TESTICEPWD00000000000000", "TESTICEPWD00000000000001", |
100 "TESTICEPWD00000000000002", | 99 "TESTICEPWD00000000000002", "TESTICEPWD00000000000003"}; |
101 "TESTICEPWD00000000000003"}; | 100 const cricket::IceParameters kIceParams[4] = { |
| 101 {kIceUfrag[0], kIcePwd[0], false}, |
| 102 {kIceUfrag[1], kIcePwd[1], false}, |
| 103 {kIceUfrag[2], kIcePwd[2], false}, |
| 104 {kIceUfrag[3], kIcePwd[3], false}}; |
102 | 105 |
103 static const uint64_t kLowTiebreaker = 11111; | 106 const uint64_t kLowTiebreaker = 11111; |
104 static const uint64_t kHighTiebreaker = 22222; | 107 const uint64_t kHighTiebreaker = 22222; |
105 | 108 |
106 enum { MSG_ADD_CANDIDATES, MSG_REMOVE_CANDIDATES }; | 109 enum { MSG_ADD_CANDIDATES, MSG_REMOVE_CANDIDATES }; |
107 | 110 |
108 cricket::IceConfig CreateIceConfig( | 111 cricket::IceConfig CreateIceConfig( |
109 int receiving_timeout, | 112 int receiving_timeout, |
110 cricket::ContinualGatheringPolicy continual_gathering_policy, | 113 cricket::ContinualGatheringPolicy continual_gathering_policy, |
111 int backup_ping_interval = -1) { | 114 int backup_ping_interval = -1) { |
112 cricket::IceConfig config; | 115 cricket::IceConfig config; |
113 config.receiving_timeout = receiving_timeout; | 116 config.receiving_timeout = receiving_timeout; |
114 config.continual_gathering_policy = continual_gathering_policy; | 117 config.continual_gathering_policy = continual_gathering_policy; |
115 config.backup_connection_ping_interval = backup_ping_interval; | 118 config.backup_connection_ping_interval = backup_ping_interval; |
116 return config; | 119 return config; |
117 } | 120 } |
118 | 121 |
119 cricket::Candidate CreateUdpCandidate(const std::string& type, | 122 cricket::Candidate CreateUdpCandidate(const std::string& type, |
120 const std::string& ip, | 123 const std::string& ip, |
121 int port, | 124 int port, |
122 int priority, | 125 int priority, |
123 const std::string& ufrag = "") { | 126 const std::string& ufrag = "") { |
124 cricket::Candidate c; | 127 cricket::Candidate c; |
125 c.set_address(rtc::SocketAddress(ip, port)); | 128 c.set_address(rtc::SocketAddress(ip, port)); |
126 c.set_component(cricket::ICE_CANDIDATE_COMPONENT_DEFAULT); | 129 c.set_component(cricket::ICE_CANDIDATE_COMPONENT_DEFAULT); |
127 c.set_protocol(cricket::UDP_PROTOCOL_NAME); | 130 c.set_protocol(cricket::UDP_PROTOCOL_NAME); |
128 c.set_priority(priority); | 131 c.set_priority(priority); |
129 c.set_username(ufrag); | 132 c.set_username(ufrag); |
130 c.set_type(type); | 133 c.set_type(type); |
131 return c; | 134 return c; |
132 } | 135 } |
133 | 136 |
134 } // namespace { | 137 } // namespace |
135 | 138 |
136 namespace cricket { | 139 namespace cricket { |
137 | 140 |
138 // This test simulates 2 P2P endpoints that want to establish connectivity | 141 // This test simulates 2 P2P endpoints that want to establish connectivity |
139 // with each other over various network topologies and conditions, which can be | 142 // with each other over various network topologies and conditions, which can be |
140 // specified in each individial test. | 143 // specified in each individial test. |
141 // A virtual network (via VirtualSocketServer) along with virtual firewalls and | 144 // A virtual network (via VirtualSocketServer) along with virtual firewalls and |
142 // NATs (via Firewall/NATSocketServer) are used to simulate the various network | 145 // NATs (via Firewall/NATSocketServer) are used to simulate the various network |
143 // conditions. We can configure the IP addresses of the endpoints, | 146 // conditions. We can configure the IP addresses of the endpoints, |
144 // block various types of connectivity, or add arbitrary levels of NAT. | 147 // block various types of connectivity, or add arbitrary levels of NAT. |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 bool ready_to_send_ = false; | 301 bool ready_to_send_ = false; |
299 }; | 302 }; |
300 | 303 |
301 ChannelData* GetChannelData(TransportChannel* channel) { | 304 ChannelData* GetChannelData(TransportChannel* channel) { |
302 if (ep1_.HasChannel(channel)) | 305 if (ep1_.HasChannel(channel)) |
303 return ep1_.GetChannelData(channel); | 306 return ep1_.GetChannelData(channel); |
304 else | 307 else |
305 return ep2_.GetChannelData(channel); | 308 return ep2_.GetChannelData(channel); |
306 } | 309 } |
307 | 310 |
308 void CreateChannels(int num) { | 311 IceParameters IceParamsWithRenomination(const IceParameters& ice, |
309 std::string ice_ufrag_ep1_cd1_ch = kIceUfrag[0]; | 312 bool renomination) { |
310 std::string ice_pwd_ep1_cd1_ch = kIcePwd[0]; | 313 IceParameters new_ice = ice; |
311 std::string ice_ufrag_ep2_cd1_ch = kIceUfrag[1]; | 314 new_ice.renomination = renomination; |
312 std::string ice_pwd_ep2_cd1_ch = kIcePwd[1]; | 315 return new_ice; |
313 ep1_.cd1_.ch_.reset(CreateChannel( | 316 } |
314 0, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep1_cd1_ch, | 317 |
315 ice_pwd_ep1_cd1_ch, ice_ufrag_ep2_cd1_ch, ice_pwd_ep2_cd1_ch)); | 318 void CreateChannels(int num) { CreateChannelsWithRenomination(num, false); } |
316 ep2_.cd1_.ch_.reset(CreateChannel( | 319 |
317 1, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep2_cd1_ch, | 320 void CreateChannelsWithRenomination(int num, bool renomination) { |
318 ice_pwd_ep2_cd1_ch, ice_ufrag_ep1_cd1_ch, ice_pwd_ep1_cd1_ch)); | 321 IceParameters ice_ep1_cd1_ch = |
| 322 IceParamsWithRenomination(kIceParams[0], renomination); |
| 323 IceParameters ice_ep2_cd1_ch = |
| 324 IceParamsWithRenomination(kIceParams[1], renomination); |
| 325 ep1_.cd1_.ch_.reset(CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, |
| 326 ice_ep1_cd1_ch, ice_ep2_cd1_ch)); |
| 327 ep2_.cd1_.ch_.reset(CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, |
| 328 ice_ep2_cd1_ch, ice_ep1_cd1_ch)); |
319 ep1_.cd1_.ch_->MaybeStartGathering(); | 329 ep1_.cd1_.ch_->MaybeStartGathering(); |
320 ep2_.cd1_.ch_->MaybeStartGathering(); | 330 ep2_.cd1_.ch_->MaybeStartGathering(); |
321 if (num == 2) { | 331 if (num == 2) { |
322 std::string ice_ufrag_ep1_cd2_ch = kIceUfrag[2]; | 332 IceParameters ice_ep1_cd2_ch = |
323 std::string ice_pwd_ep1_cd2_ch = kIcePwd[2]; | 333 IceParamsWithRenomination(kIceParams[2], renomination); |
324 std::string ice_ufrag_ep2_cd2_ch = kIceUfrag[3]; | 334 IceParameters ice_ep2_cd2_ch = |
325 std::string ice_pwd_ep2_cd2_ch = kIcePwd[3]; | 335 IceParamsWithRenomination(kIceParams[3], renomination); |
326 ep1_.cd2_.ch_.reset(CreateChannel( | 336 ep1_.cd2_.ch_.reset(CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, |
327 0, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep1_cd2_ch, | 337 ice_ep1_cd2_ch, ice_ep2_cd2_ch)); |
328 ice_pwd_ep1_cd2_ch, ice_ufrag_ep2_cd2_ch, ice_pwd_ep2_cd2_ch)); | 338 ep2_.cd2_.ch_.reset(CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, |
329 ep2_.cd2_.ch_.reset(CreateChannel( | 339 ice_ep2_cd2_ch, ice_ep1_cd2_ch)); |
330 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)); | |
332 ep1_.cd2_.ch_->MaybeStartGathering(); | 340 ep1_.cd2_.ch_->MaybeStartGathering(); |
333 ep2_.cd2_.ch_->MaybeStartGathering(); | 341 ep2_.cd2_.ch_->MaybeStartGathering(); |
334 } | 342 } |
335 } | 343 } |
336 P2PTransportChannel* CreateChannel(int endpoint, | 344 P2PTransportChannel* CreateChannel(int endpoint, |
337 int component, | 345 int component, |
338 const std::string& local_ice_ufrag, | 346 const IceParameters& local_ice, |
339 const std::string& local_ice_pwd, | 347 const IceParameters& remote_ice) { |
340 const std::string& remote_ice_ufrag, | |
341 const std::string& remote_ice_pwd) { | |
342 P2PTransportChannel* channel = new P2PTransportChannel( | 348 P2PTransportChannel* channel = new P2PTransportChannel( |
343 "test content name", component, GetAllocator(endpoint)); | 349 "test content name", component, GetAllocator(endpoint)); |
344 channel->SignalReadyToSend.connect( | 350 channel->SignalReadyToSend.connect( |
345 this, &P2PTransportChannelTestBase::OnReadyToSend); | 351 this, &P2PTransportChannelTestBase::OnReadyToSend); |
346 channel->SignalCandidateGathered.connect( | 352 channel->SignalCandidateGathered.connect( |
347 this, &P2PTransportChannelTestBase::OnCandidateGathered); | 353 this, &P2PTransportChannelTestBase::OnCandidateGathered); |
348 channel->SignalCandidatesRemoved.connect( | 354 channel->SignalCandidatesRemoved.connect( |
349 this, &P2PTransportChannelTestBase::OnCandidatesRemoved); | 355 this, &P2PTransportChannelTestBase::OnCandidatesRemoved); |
350 channel->SignalReadPacket.connect( | 356 channel->SignalReadPacket.connect( |
351 this, &P2PTransportChannelTestBase::OnReadPacket); | 357 this, &P2PTransportChannelTestBase::OnReadPacket); |
352 channel->SignalRoleConflict.connect( | 358 channel->SignalRoleConflict.connect( |
353 this, &P2PTransportChannelTestBase::OnRoleConflict); | 359 this, &P2PTransportChannelTestBase::OnRoleConflict); |
354 channel->SignalSelectedCandidatePairChanged.connect( | 360 channel->SignalSelectedCandidatePairChanged.connect( |
355 this, &P2PTransportChannelTestBase::OnSelectedCandidatePairChanged); | 361 this, &P2PTransportChannelTestBase::OnSelectedCandidatePairChanged); |
356 channel->SetIceCredentials(local_ice_ufrag, local_ice_pwd); | 362 channel->SetIceParameters(local_ice); |
357 if (remote_ice_credential_source_ == FROM_SETICECREDENTIALS) { | 363 if (remote_ice_parameter_source_ == FROM_SETICEPARAMETERS) { |
358 channel->SetRemoteIceCredentials(remote_ice_ufrag, remote_ice_pwd); | 364 channel->SetRemoteIceParameters(remote_ice); |
359 } | 365 } |
360 channel->SetIceRole(GetEndpoint(endpoint)->ice_role()); | 366 channel->SetIceRole(GetEndpoint(endpoint)->ice_role()); |
361 channel->SetIceTiebreaker(GetEndpoint(endpoint)->GetIceTiebreaker()); | 367 channel->SetIceTiebreaker(GetEndpoint(endpoint)->GetIceTiebreaker()); |
362 return channel; | 368 return channel; |
363 } | 369 } |
364 void DestroyChannels() { | 370 void DestroyChannels() { |
365 ep1_.cd1_.ch_.reset(); | 371 ep1_.cd1_.ch_.reset(); |
366 ep2_.cd1_.ch_.reset(); | 372 ep2_.cd1_.ch_.reset(); |
367 ep1_.cd2_.ch_.reset(); | 373 ep1_.cd2_.ch_.reset(); |
368 ep2_.cd2_.ch_.reset(); | 374 ep2_.cd2_.ch_.reset(); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 // local_channel2 <==> remote_channel2 | 585 // local_channel2 <==> remote_channel2 |
580 EXPECT_EQ_WAIT(len, SendData(ep1_ch2(), data, len), 1000); | 586 EXPECT_EQ_WAIT(len, SendData(ep1_ch2(), data, len), 1000); |
581 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep2_ch2(), data, len), 1000); | 587 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep2_ch2(), data, len), 1000); |
582 EXPECT_EQ_WAIT(len, SendData(ep2_ch2(), data, len), 1000); | 588 EXPECT_EQ_WAIT(len, SendData(ep2_ch2(), data, len), 1000); |
583 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep1_ch2(), data, len), 1000); | 589 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep1_ch2(), data, len), 1000); |
584 } | 590 } |
585 } | 591 } |
586 } | 592 } |
587 | 593 |
588 // This test waits for the transport to become receiving and writable on both | 594 // This test waits for the transport to become receiving and writable on both |
589 // end points. Once they are, the end points set new local ice credentials and | 595 // end points. Once they are, the end points set new local ice parameters and |
590 // restart the ice gathering. Finally it waits for the transport to select a | 596 // restart the ice gathering. Finally it waits for the transport to select a |
591 // new connection using the newly generated ice candidates. | 597 // new connection using the newly generated ice candidates. |
592 // Before calling this function the end points must be configured. | 598 // Before calling this function the end points must be configured. |
593 void TestHandleIceUfragPasswordChanged() { | 599 void TestHandleIceUfragPasswordChanged() { |
594 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 600 ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); |
595 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); | 601 ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); |
596 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 602 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
597 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 603 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
598 1000, 1000); | 604 1000, 1000); |
599 | 605 |
600 const Candidate* old_local_candidate1 = LocalCandidate(ep1_ch1()); | 606 const Candidate* old_local_candidate1 = LocalCandidate(ep1_ch1()); |
601 const Candidate* old_local_candidate2 = LocalCandidate(ep2_ch1()); | 607 const Candidate* old_local_candidate2 = LocalCandidate(ep2_ch1()); |
602 const Candidate* old_remote_candidate1 = RemoteCandidate(ep1_ch1()); | 608 const Candidate* old_remote_candidate1 = RemoteCandidate(ep1_ch1()); |
603 const Candidate* old_remote_candidate2 = RemoteCandidate(ep2_ch1()); | 609 const Candidate* old_remote_candidate2 = RemoteCandidate(ep2_ch1()); |
604 | 610 |
605 ep1_ch1()->SetIceCredentials(kIceUfrag[2], kIcePwd[2]); | 611 ep1_ch1()->SetIceParameters(kIceParams[2]); |
606 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 612 ep1_ch1()->SetRemoteIceParameters(kIceParams[3]); |
607 ep1_ch1()->MaybeStartGathering(); | 613 ep1_ch1()->MaybeStartGathering(); |
608 ep2_ch1()->SetIceCredentials(kIceUfrag[3], kIcePwd[3]); | 614 ep2_ch1()->SetIceParameters(kIceParams[3]); |
609 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]); | 615 |
| 616 ep2_ch1()->SetRemoteIceParameters(kIceParams[2]); |
610 ep2_ch1()->MaybeStartGathering(); | 617 ep2_ch1()->MaybeStartGathering(); |
611 | 618 |
612 EXPECT_TRUE_WAIT_MARGIN(LocalCandidate(ep1_ch1())->generation() != | 619 EXPECT_TRUE_WAIT_MARGIN(LocalCandidate(ep1_ch1())->generation() != |
613 old_local_candidate1->generation(), | 620 old_local_candidate1->generation(), |
614 1000, 1000); | 621 1000, 1000); |
615 EXPECT_TRUE_WAIT_MARGIN(LocalCandidate(ep2_ch1())->generation() != | 622 EXPECT_TRUE_WAIT_MARGIN(LocalCandidate(ep2_ch1())->generation() != |
616 old_local_candidate2->generation(), | 623 old_local_candidate2->generation(), |
617 1000, 1000); | 624 1000, 1000); |
618 EXPECT_TRUE_WAIT_MARGIN(RemoteCandidate(ep1_ch1())->generation() != | 625 EXPECT_TRUE_WAIT_MARGIN(RemoteCandidate(ep1_ch1())->generation() != |
619 old_remote_candidate1->generation(), | 626 old_remote_candidate1->generation(), |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 void OnMessage(rtc::Message* msg) { | 733 void OnMessage(rtc::Message* msg) { |
727 switch (msg->message_id) { | 734 switch (msg->message_id) { |
728 case MSG_ADD_CANDIDATES: { | 735 case MSG_ADD_CANDIDATES: { |
729 std::unique_ptr<CandidatesData> data( | 736 std::unique_ptr<CandidatesData> data( |
730 static_cast<CandidatesData*>(msg->pdata)); | 737 static_cast<CandidatesData*>(msg->pdata)); |
731 P2PTransportChannel* rch = GetRemoteChannel(data->channel); | 738 P2PTransportChannel* rch = GetRemoteChannel(data->channel); |
732 if (!rch) { | 739 if (!rch) { |
733 return; | 740 return; |
734 } | 741 } |
735 for (auto& c : data->candidates) { | 742 for (auto& c : data->candidates) { |
736 if (remote_ice_credential_source_ != FROM_CANDIDATE) { | 743 if (remote_ice_parameter_source_ != FROM_CANDIDATE) { |
737 c.set_username(""); | 744 c.set_username(""); |
738 c.set_password(""); | 745 c.set_password(""); |
739 } | 746 } |
740 LOG(LS_INFO) << "Candidate(" << data->channel->component() << "->" | 747 LOG(LS_INFO) << "Candidate(" << data->channel->component() << "->" |
741 << rch->component() << "): " << c.ToString(); | 748 << rch->component() << "): " << c.ToString(); |
742 rch->AddRemoteCandidate(c); | 749 rch->AddRemoteCandidate(c); |
743 } | 750 } |
744 break; | 751 break; |
745 } | 752 } |
746 case MSG_REMOVE_CANDIDATES: { | 753 case MSG_REMOVE_CANDIDATES: { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 return ep1_ch1(); | 818 return ep1_ch1(); |
812 else if (ch == ep2_ch2()) | 819 else if (ch == ep2_ch2()) |
813 return ep1_ch2(); | 820 return ep1_ch2(); |
814 else | 821 else |
815 return NULL; | 822 return NULL; |
816 } | 823 } |
817 std::list<std::string>& GetPacketList(TransportChannel* ch) { | 824 std::list<std::string>& GetPacketList(TransportChannel* ch) { |
818 return GetChannelData(ch)->ch_packets_; | 825 return GetChannelData(ch)->ch_packets_; |
819 } | 826 } |
820 | 827 |
821 enum RemoteIceCredentialSource { FROM_CANDIDATE, FROM_SETICECREDENTIALS }; | 828 enum RemoteIceParameterSource { FROM_CANDIDATE, FROM_SETICEPARAMETERS }; |
822 | 829 |
823 // How does the test pass ICE credentials to the P2PTransportChannel? | 830 // How does the test pass ICE parameters to the P2PTransportChannel? |
824 // On the candidate itself, or through SetIceCredentials? | 831 // On the candidate itself, or through SetRemoteIceParameters? |
825 // Goes through the candidate itself by default. | 832 // Goes through the candidate itself by default. |
826 void set_remote_ice_credential_source(RemoteIceCredentialSource source) { | 833 void set_remote_ice_parameter_source(RemoteIceParameterSource source) { |
827 remote_ice_credential_source_ = source; | 834 remote_ice_parameter_source_ = source; |
828 } | 835 } |
829 | 836 |
830 void set_force_relay(bool relay) { | 837 void set_force_relay(bool relay) { |
831 force_relay_ = relay; | 838 force_relay_ = relay; |
832 } | 839 } |
833 | 840 |
834 void ConnectSignalNominated(Connection* conn) { | 841 void ConnectSignalNominated(Connection* conn) { |
835 conn->SignalNominated.connect(this, | 842 conn->SignalNominated.connect(this, |
836 &P2PTransportChannelTestBase::OnNominated); | 843 &P2PTransportChannelTestBase::OnNominated); |
837 } | 844 } |
838 | 845 |
839 void OnNominated(Connection* conn) { nominated_ = true; } | 846 void OnNominated(Connection* conn) { nominated_ = true; } |
840 bool nominated() { return nominated_; } | 847 bool nominated() { return nominated_; } |
841 | 848 |
842 private: | 849 private: |
843 rtc::Thread* main_; | 850 rtc::Thread* main_; |
844 std::unique_ptr<rtc::PhysicalSocketServer> pss_; | 851 std::unique_ptr<rtc::PhysicalSocketServer> pss_; |
845 std::unique_ptr<rtc::VirtualSocketServer> vss_; | 852 std::unique_ptr<rtc::VirtualSocketServer> vss_; |
846 std::unique_ptr<rtc::NATSocketServer> nss_; | 853 std::unique_ptr<rtc::NATSocketServer> nss_; |
847 std::unique_ptr<rtc::FirewallSocketServer> ss_; | 854 std::unique_ptr<rtc::FirewallSocketServer> ss_; |
848 rtc::SocketServerScope ss_scope_; | 855 rtc::SocketServerScope ss_scope_; |
849 std::unique_ptr<TestStunServer> stun_server_; | 856 std::unique_ptr<TestStunServer> stun_server_; |
850 TestTurnServer turn_server_; | 857 TestTurnServer turn_server_; |
851 TestRelayServer relay_server_; | 858 TestRelayServer relay_server_; |
852 rtc::SocksProxyServer socks_server1_; | 859 rtc::SocksProxyServer socks_server1_; |
853 rtc::SocksProxyServer socks_server2_; | 860 rtc::SocksProxyServer socks_server2_; |
854 Endpoint ep1_; | 861 Endpoint ep1_; |
855 Endpoint ep2_; | 862 Endpoint ep2_; |
856 RemoteIceCredentialSource remote_ice_credential_source_ = FROM_CANDIDATE; | 863 RemoteIceParameterSource remote_ice_parameter_source_ = FROM_CANDIDATE; |
857 bool force_relay_; | 864 bool force_relay_; |
858 int selected_candidate_pair_switches_ = 0; | 865 int selected_candidate_pair_switches_ = 0; |
859 | 866 |
860 bool nominated_ = false; | 867 bool nominated_ = false; |
861 }; | 868 }; |
862 | 869 |
863 // The tests have only a few outcomes, which we predefine. | 870 // The tests have only a few outcomes, which we predefine. |
864 const P2PTransportChannelTestBase::Result | 871 const P2PTransportChannelTestBase::Result |
865 P2PTransportChannelTestBase::kLocalUdpToLocalUdp("local", | 872 P2PTransportChannelTestBase::kLocalUdpToLocalUdp("local", |
866 "udp", | 873 "udp", |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 GetEndpoint(1)->allocator_->AddTurnServer(turn_server); | 979 GetEndpoint(1)->allocator_->AddTurnServer(turn_server); |
973 | 980 |
974 int delay = kMinimumStepDelay; | 981 int delay = kMinimumStepDelay; |
975 ConfigureEndpoint(0, config1); | 982 ConfigureEndpoint(0, config1); |
976 SetAllocatorFlags(0, allocator_flags1); | 983 SetAllocatorFlags(0, allocator_flags1); |
977 SetAllocationStepDelay(0, delay); | 984 SetAllocationStepDelay(0, delay); |
978 ConfigureEndpoint(1, config2); | 985 ConfigureEndpoint(1, config2); |
979 SetAllocatorFlags(1, allocator_flags2); | 986 SetAllocatorFlags(1, allocator_flags2); |
980 SetAllocationStepDelay(1, delay); | 987 SetAllocationStepDelay(1, delay); |
981 | 988 |
982 set_remote_ice_credential_source(FROM_SETICECREDENTIALS); | 989 set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
983 } | 990 } |
984 void ConfigureEndpoint(int endpoint, Config config) { | 991 void ConfigureEndpoint(int endpoint, Config config) { |
985 switch (config) { | 992 switch (config) { |
986 case OPEN: | 993 case OPEN: |
987 AddAddress(endpoint, kPublicAddrs[endpoint]); | 994 AddAddress(endpoint, kPublicAddrs[endpoint]); |
988 break; | 995 break; |
989 case NAT_FULL_CONE: | 996 case NAT_FULL_CONE: |
990 case NAT_ADDR_RESTRICTED: | 997 case NAT_ADDR_RESTRICTED: |
991 case NAT_PORT_RESTRICTED: | 998 case NAT_PORT_RESTRICTED: |
992 case NAT_SYMMETRIC: | 999 case NAT_SYMMETRIC: |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 EXPECT_EQ(10 * 36U, best_conn_info->recv_total_bytes); | 1190 EXPECT_EQ(10 * 36U, best_conn_info->recv_total_bytes); |
1184 EXPECT_GT(best_conn_info->rtt, 0U); | 1191 EXPECT_GT(best_conn_info->rtt, 0U); |
1185 DestroyChannels(); | 1192 DestroyChannels(); |
1186 } | 1193 } |
1187 | 1194 |
1188 // Test that we properly create a connection on a STUN ping from unknown address | 1195 // Test that we properly create a connection on a STUN ping from unknown address |
1189 // when the signaling is slow. | 1196 // when the signaling is slow. |
1190 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignaling) { | 1197 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignaling) { |
1191 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1198 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
1192 kDefaultPortAllocatorFlags); | 1199 kDefaultPortAllocatorFlags); |
1193 // Emulate no remote credentials coming in. | 1200 // Emulate no remote parameters coming in. |
1194 set_remote_ice_credential_source(FROM_CANDIDATE); | 1201 set_remote_ice_parameter_source(FROM_CANDIDATE); |
1195 CreateChannels(1); | 1202 CreateChannels(1); |
1196 // Only have remote credentials come in for ep2, not ep1. | 1203 // Only have remote parameters come in for ep2, not ep1. |
1197 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); | 1204 ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); |
1198 | 1205 |
1199 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive | 1206 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive |
1200 // candidate. | 1207 // candidate. |
1201 PauseCandidates(1); | 1208 PauseCandidates(1); |
1202 | 1209 |
1203 // Wait until the callee becomes writable to make sure that a ping request is | 1210 // Wait until the callee becomes writable to make sure that a ping request is |
1204 // received by the caller before his remote ICE credentials are set. | 1211 // received by the caller before his remote ICE credentials are set. |
1205 ASSERT_TRUE_WAIT(ep2_ch1()->selected_connection() != nullptr, 3000); | 1212 ASSERT_TRUE_WAIT(ep2_ch1()->selected_connection() != nullptr, 3000); |
1206 // Add two sets of remote ICE credentials, so that the ones used by the | 1213 // Add two sets of remote ICE credentials, so that the ones used by the |
1207 // candidate will be generation 1 instead of 0. | 1214 // candidate will be generation 1 instead of 0. |
1208 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 1215 ep1_ch1()->SetRemoteIceParameters(kIceParams[3]); |
1209 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 1216 ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); |
1210 // The caller should have the selected connection connected to the peer | 1217 // The caller should have the selected connection connected to the peer |
1211 // reflexive candidate. | 1218 // reflexive candidate. |
1212 const Connection* selected_connection = nullptr; | 1219 const Connection* selected_connection = nullptr; |
1213 ASSERT_TRUE_WAIT( | 1220 ASSERT_TRUE_WAIT( |
1214 (selected_connection = ep1_ch1()->selected_connection()) != nullptr, | 1221 (selected_connection = ep1_ch1()->selected_connection()) != nullptr, |
1215 2000); | 1222 2000); |
1216 EXPECT_EQ("prflx", selected_connection->remote_candidate().type()); | 1223 EXPECT_EQ("prflx", selected_connection->remote_candidate().type()); |
1217 EXPECT_EQ(kIceUfrag[1], selected_connection->remote_candidate().username()); | 1224 EXPECT_EQ(kIceUfrag[1], selected_connection->remote_candidate().username()); |
1218 EXPECT_EQ(kIcePwd[1], selected_connection->remote_candidate().password()); | 1225 EXPECT_EQ(kIcePwd[1], selected_connection->remote_candidate().password()); |
1219 EXPECT_EQ(1u, selected_connection->remote_candidate().generation()); | 1226 EXPECT_EQ(1u, selected_connection->remote_candidate().generation()); |
1220 | 1227 |
1221 ResumeCandidates(1); | 1228 ResumeCandidates(1); |
1222 // Verify ep1's selected connection is updated to use the 'local' candidate. | 1229 // Verify ep1's selected connection is updated to use the 'local' candidate. |
1223 EXPECT_EQ_WAIT("local", | 1230 EXPECT_EQ_WAIT("local", |
1224 ep1_ch1()->selected_connection()->remote_candidate().type(), | 1231 ep1_ch1()->selected_connection()->remote_candidate().type(), |
1225 2000); | 1232 2000); |
1226 EXPECT_EQ(selected_connection, ep1_ch1()->selected_connection()); | 1233 EXPECT_EQ(selected_connection, ep1_ch1()->selected_connection()); |
1227 DestroyChannels(); | 1234 DestroyChannels(); |
1228 } | 1235 } |
1229 | 1236 |
1230 // Test that we properly create a connection on a STUN ping from unknown address | 1237 // Test that we properly create a connection on a STUN ping from unknown address |
1231 // when the signaling is slow and the end points are behind NAT. | 1238 // when the signaling is slow and the end points are behind NAT. |
1232 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) { | 1239 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) { |
1233 ConfigureEndpoints(OPEN, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, | 1240 ConfigureEndpoints(OPEN, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, |
1234 kDefaultPortAllocatorFlags); | 1241 kDefaultPortAllocatorFlags); |
1235 // Emulate no remote credentials coming in. | 1242 // Emulate no remote parameters coming in. |
1236 set_remote_ice_credential_source(FROM_CANDIDATE); | 1243 set_remote_ice_parameter_source(FROM_CANDIDATE); |
1237 CreateChannels(1); | 1244 CreateChannels(1); |
1238 // Only have remote credentials come in for ep2, not ep1. | 1245 // Only have remote parameters come in for ep2, not ep1. |
1239 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); | 1246 ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); |
1240 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive | 1247 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive |
1241 // candidate. | 1248 // candidate. |
1242 PauseCandidates(1); | 1249 PauseCandidates(1); |
1243 | 1250 |
1244 // Wait until the callee becomes writable to make sure that a ping request is | 1251 // Wait until the callee becomes writable to make sure that a ping request is |
1245 // received by the caller before his remote ICE credentials are set. | 1252 // received by the caller before his remote ICE credentials are set. |
1246 ASSERT_TRUE_WAIT(ep2_ch1()->selected_connection() != nullptr, 3000); | 1253 ASSERT_TRUE_WAIT(ep2_ch1()->selected_connection() != nullptr, 3000); |
1247 // Add two sets of remote ICE credentials, so that the ones used by the | 1254 // Add two sets of remote ICE credentials, so that the ones used by the |
1248 // candidate will be generation 1 instead of 0. | 1255 // candidate will be generation 1 instead of 0. |
1249 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 1256 ep1_ch1()->SetRemoteIceParameters(kIceParams[3]); |
1250 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 1257 ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); |
1251 | 1258 |
1252 // The caller's selected connection should be connected to the peer reflexive | 1259 // The caller's selected connection should be connected to the peer reflexive |
1253 // candidate. | 1260 // candidate. |
1254 const Connection* selected_connection = nullptr; | 1261 const Connection* selected_connection = nullptr; |
1255 ASSERT_TRUE_WAIT( | 1262 ASSERT_TRUE_WAIT( |
1256 (selected_connection = ep1_ch1()->selected_connection()) != nullptr, | 1263 (selected_connection = ep1_ch1()->selected_connection()) != nullptr, |
1257 2000); | 1264 2000); |
1258 EXPECT_EQ("prflx", selected_connection->remote_candidate().type()); | 1265 EXPECT_EQ("prflx", selected_connection->remote_candidate().type()); |
1259 EXPECT_EQ(kIceUfrag[1], selected_connection->remote_candidate().username()); | 1266 EXPECT_EQ(kIceUfrag[1], selected_connection->remote_candidate().username()); |
1260 EXPECT_EQ(kIcePwd[1], selected_connection->remote_candidate().password()); | 1267 EXPECT_EQ(kIcePwd[1], selected_connection->remote_candidate().password()); |
(...skipping 18 matching lines...) Expand all Loading... |
1279 // generations. This resulted in the old-generation prflx candidate being | 1286 // generations. This resulted in the old-generation prflx candidate being |
1280 // prioritized above new-generation candidate pairs. | 1287 // prioritized above new-generation candidate pairs. |
1281 TEST_F(P2PTransportChannelTest, | 1288 TEST_F(P2PTransportChannelTest, |
1282 PeerReflexiveCandidateBeforeSignalingWithIceRestart) { | 1289 PeerReflexiveCandidateBeforeSignalingWithIceRestart) { |
1283 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1290 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
1284 kDefaultPortAllocatorFlags); | 1291 kDefaultPortAllocatorFlags); |
1285 // Only gather relay candidates, so that when the prflx candidate arrives | 1292 // Only gather relay candidates, so that when the prflx candidate arrives |
1286 // it's prioritized above the current candidate pair. | 1293 // it's prioritized above the current candidate pair. |
1287 GetEndpoint(0)->allocator_->set_candidate_filter(CF_RELAY); | 1294 GetEndpoint(0)->allocator_->set_candidate_filter(CF_RELAY); |
1288 GetEndpoint(1)->allocator_->set_candidate_filter(CF_RELAY); | 1295 GetEndpoint(1)->allocator_->set_candidate_filter(CF_RELAY); |
1289 // Setting this allows us to control when SetRemoteIceCredentials is called. | 1296 // Setting this allows us to control when SetRemoteIceParameters is called. |
1290 set_remote_ice_credential_source(FROM_CANDIDATE); | 1297 set_remote_ice_parameter_source(FROM_CANDIDATE); |
1291 CreateChannels(1); | 1298 CreateChannels(1); |
1292 // Wait for the initial connection to be made. | 1299 // Wait for the initial connection to be made. |
1293 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 1300 ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); |
1294 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); | 1301 ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); |
1295 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1302 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1296 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1303 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1297 kDefaultTimeout); | 1304 kDefaultTimeout); |
1298 | 1305 |
1299 // Simulate an ICE restart on ep2, but don't signal the candidate or new | 1306 // Simulate an ICE restart on ep2, but don't signal the candidate or new |
1300 // ICE credentials until after a prflx connection has been made. | 1307 // ICE parameters until after a prflx connection has been made. |
1301 PauseCandidates(1); | 1308 PauseCandidates(1); |
1302 ep2_ch1()->SetIceCredentials(kIceUfrag[3], kIcePwd[3]); | 1309 ep2_ch1()->SetIceParameters(kIceParams[3]); |
1303 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 1310 |
| 1311 ep1_ch1()->SetRemoteIceParameters(kIceParams[3]); |
1304 ep2_ch1()->MaybeStartGathering(); | 1312 ep2_ch1()->MaybeStartGathering(); |
1305 | 1313 |
1306 // The caller should have the selected connection connected to the peer | 1314 // The caller should have the selected connection connected to the peer |
1307 // reflexive candidate. | 1315 // reflexive candidate. |
1308 EXPECT_EQ_WAIT("prflx", | 1316 EXPECT_EQ_WAIT("prflx", |
1309 ep1_ch1()->selected_connection()->remote_candidate().type(), | 1317 ep1_ch1()->selected_connection()->remote_candidate().type(), |
1310 kDefaultTimeout); | 1318 kDefaultTimeout); |
1311 const Connection* prflx_selected_connection = | 1319 const Connection* prflx_selected_connection = |
1312 ep1_ch1()->selected_connection(); | 1320 ep1_ch1()->selected_connection(); |
1313 | 1321 |
1314 // Now simulate the ICE restart on ep1. | 1322 // Now simulate the ICE restart on ep1. |
1315 ep1_ch1()->SetIceCredentials(kIceUfrag[2], kIcePwd[2]); | 1323 ep1_ch1()->SetIceParameters(kIceParams[2]); |
1316 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]); | 1324 |
| 1325 ep2_ch1()->SetRemoteIceParameters(kIceParams[2]); |
1317 ep1_ch1()->MaybeStartGathering(); | 1326 ep1_ch1()->MaybeStartGathering(); |
1318 | 1327 |
1319 // Finally send the candidates from ep2's ICE restart and verify that ep1 uses | 1328 // Finally send the candidates from ep2's ICE restart and verify that ep1 uses |
1320 // their information to update the peer reflexive candidate. | 1329 // their information to update the peer reflexive candidate. |
1321 ResumeCandidates(1); | 1330 ResumeCandidates(1); |
1322 | 1331 |
1323 EXPECT_EQ_WAIT("relay", | 1332 EXPECT_EQ_WAIT("relay", |
1324 ep1_ch1()->selected_connection()->remote_candidate().type(), | 1333 ep1_ch1()->selected_connection()->remote_candidate().type(), |
1325 kDefaultTimeout); | 1334 kDefaultTimeout); |
1326 EXPECT_EQ(prflx_selected_connection, ep1_ch1()->selected_connection()); | 1335 EXPECT_EQ(prflx_selected_connection, ep1_ch1()->selected_connection()); |
1327 DestroyChannels(); | 1336 DestroyChannels(); |
1328 } | 1337 } |
1329 | 1338 |
1330 // Test that if remote candidates don't have ufrag and pwd, we still work. | 1339 // Test that if remote candidates don't have ufrag and pwd, we still work. |
1331 TEST_F(P2PTransportChannelTest, RemoteCandidatesWithoutUfragPwd) { | 1340 TEST_F(P2PTransportChannelTest, RemoteCandidatesWithoutUfragPwd) { |
1332 set_remote_ice_credential_source(FROM_SETICECREDENTIALS); | 1341 set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
1333 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1342 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
1334 kDefaultPortAllocatorFlags); | 1343 kDefaultPortAllocatorFlags); |
1335 CreateChannels(1); | 1344 CreateChannels(1); |
1336 const Connection* selected_connection = NULL; | 1345 const Connection* selected_connection = NULL; |
1337 // Wait until the callee's connections are created. | 1346 // Wait until the callee's connections are created. |
1338 WAIT((selected_connection = ep2_ch1()->selected_connection()) != NULL, 1000); | 1347 WAIT((selected_connection = ep2_ch1()->selected_connection()) != NULL, 1000); |
1339 // Wait to see if they get culled; they shouldn't. | 1348 // Wait to see if they get culled; they shouldn't. |
1340 WAIT(ep2_ch1()->selected_connection() != selected_connection, 1000); | 1349 WAIT(ep2_ch1()->selected_connection() != selected_connection, 1000); |
1341 EXPECT_TRUE(ep2_ch1()->selected_connection() == selected_connection); | 1350 EXPECT_TRUE(ep2_ch1()->selected_connection() == selected_connection); |
1342 DestroyChannels(); | 1351 DestroyChannels(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 int kOnlyLocalTcpPorts = PORTALLOCATOR_DISABLE_UDP | | 1400 int kOnlyLocalTcpPorts = PORTALLOCATOR_DISABLE_UDP | |
1392 PORTALLOCATOR_DISABLE_STUN | | 1401 PORTALLOCATOR_DISABLE_STUN | |
1393 PORTALLOCATOR_DISABLE_RELAY; | 1402 PORTALLOCATOR_DISABLE_RELAY; |
1394 // Disable all protocols except TCP. | 1403 // Disable all protocols except TCP. |
1395 SetAllocatorFlags(0, kOnlyLocalTcpPorts); | 1404 SetAllocatorFlags(0, kOnlyLocalTcpPorts); |
1396 SetAllocatorFlags(1, kOnlyLocalTcpPorts); | 1405 SetAllocatorFlags(1, kOnlyLocalTcpPorts); |
1397 | 1406 |
1398 SetAllowTcpListen(0, true); // actpass. | 1407 SetAllowTcpListen(0, true); // actpass. |
1399 SetAllowTcpListen(1, false); // active. | 1408 SetAllowTcpListen(1, false); // active. |
1400 | 1409 |
1401 // We want SetRemoteIceCredentials to be called as it normally would. | 1410 // We want SetRemoteIceParameters to be called as it normally would. |
1402 // Otherwise we won't know what credentials to use for the expected | 1411 // Otherwise we won't know what parameters to use for the expected |
1403 // prflx TCP candidates. | 1412 // prflx TCP candidates. |
1404 set_remote_ice_credential_source(FROM_SETICECREDENTIALS); | 1413 set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
1405 | 1414 |
1406 // Pause candidate so we could verify the candidate properties. | 1415 // Pause candidate so we could verify the candidate properties. |
1407 PauseCandidates(0); | 1416 PauseCandidates(0); |
1408 PauseCandidates(1); | 1417 PauseCandidates(1); |
1409 CreateChannels(1); | 1418 CreateChannels(1); |
1410 | 1419 |
1411 // Verify tcp candidates. | 1420 // Verify tcp candidates. |
1412 VerifySavedTcpCandidates(0, TCPTYPE_PASSIVE_STR); | 1421 VerifySavedTcpCandidates(0, TCPTYPE_PASSIVE_STR); |
1413 VerifySavedTcpCandidates(1, TCPTYPE_ACTIVE_STR); | 1422 VerifySavedTcpCandidates(1, TCPTYPE_ACTIVE_STR); |
1414 | 1423 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1680 } | 1689 } |
1681 | 1690 |
1682 // Test that when the "presume_writable_when_fully_relayed" flag is set to | 1691 // Test that when the "presume_writable_when_fully_relayed" flag is set to |
1683 // true and there's a TURN-TURN candidate pair, it's presumed to be writable | 1692 // true and there's a TURN-TURN candidate pair, it's presumed to be writable |
1684 // as soon as it's created. | 1693 // as soon as it's created. |
1685 TEST_F(P2PTransportChannelTest, TurnToTurnPresumedWritable) { | 1694 TEST_F(P2PTransportChannelTest, TurnToTurnPresumedWritable) { |
1686 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1695 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
1687 kDefaultPortAllocatorFlags); | 1696 kDefaultPortAllocatorFlags); |
1688 // Only configure one channel so we can control when the remote candidate | 1697 // Only configure one channel so we can control when the remote candidate |
1689 // is added. | 1698 // is added. |
1690 GetEndpoint(0)->cd1_.ch_.reset( | 1699 GetEndpoint(0)->cd1_.ch_.reset(CreateChannel( |
1691 CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[0], | 1700 0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[0], kIceParams[1])); |
1692 kIcePwd[0], kIceUfrag[1], kIcePwd[1])); | |
1693 IceConfig config; | 1701 IceConfig config; |
1694 config.presume_writable_when_fully_relayed = true; | 1702 config.presume_writable_when_fully_relayed = true; |
1695 ep1_ch1()->SetIceConfig(config); | 1703 ep1_ch1()->SetIceConfig(config); |
1696 ep1_ch1()->MaybeStartGathering(); | 1704 ep1_ch1()->MaybeStartGathering(); |
1697 EXPECT_EQ_WAIT(IceGatheringState::kIceGatheringComplete, | 1705 EXPECT_EQ_WAIT(IceGatheringState::kIceGatheringComplete, |
1698 ep1_ch1()->gathering_state(), kDefaultTimeout); | 1706 ep1_ch1()->gathering_state(), kDefaultTimeout); |
1699 // Add two remote candidates; a host candidate (with higher priority) | 1707 // Add two remote candidates; a host candidate (with higher priority) |
1700 // and TURN candidate. | 1708 // and TURN candidate. |
1701 ep1_ch1()->AddRemoteCandidate( | 1709 ep1_ch1()->AddRemoteCandidate( |
1702 CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); | 1710 CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); |
(...skipping 25 matching lines...) Expand all Loading... |
1728 virtual_socket_server()->UpdateDelayDistribution(); | 1736 virtual_socket_server()->UpdateDelayDistribution(); |
1729 | 1737 |
1730 ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, | 1738 ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, |
1731 kDefaultPortAllocatorFlags); | 1739 kDefaultPortAllocatorFlags); |
1732 // We want the remote TURN candidate to show up as prflx. To do this we need | 1740 // We want the remote TURN candidate to show up as prflx. To do this we need |
1733 // to configure the server to accept packets from an address we haven't | 1741 // to configure the server to accept packets from an address we haven't |
1734 // explicitly installed permission for. | 1742 // explicitly installed permission for. |
1735 test_turn_server()->set_enable_permission_checks(false); | 1743 test_turn_server()->set_enable_permission_checks(false); |
1736 IceConfig config; | 1744 IceConfig config; |
1737 config.presume_writable_when_fully_relayed = true; | 1745 config.presume_writable_when_fully_relayed = true; |
1738 GetEndpoint(0)->cd1_.ch_.reset( | 1746 GetEndpoint(0)->cd1_.ch_.reset(CreateChannel( |
1739 CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[0], | 1747 0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[0], kIceParams[1])); |
1740 kIcePwd[0], kIceUfrag[1], kIcePwd[1])); | 1748 GetEndpoint(1)->cd1_.ch_.reset(CreateChannel( |
1741 GetEndpoint(1)->cd1_.ch_.reset( | 1749 1, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[1], kIceParams[0])); |
1742 CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[1], | |
1743 kIcePwd[1], kIceUfrag[0], kIcePwd[0])); | |
1744 ep1_ch1()->SetIceConfig(config); | 1750 ep1_ch1()->SetIceConfig(config); |
1745 ep2_ch1()->SetIceConfig(config); | 1751 ep2_ch1()->SetIceConfig(config); |
1746 // Don't signal candidates from channel 2, so that channel 1 sees the TURN | 1752 // Don't signal candidates from channel 2, so that channel 1 sees the TURN |
1747 // candidate as peer reflexive. | 1753 // candidate as peer reflexive. |
1748 PauseCandidates(1); | 1754 PauseCandidates(1); |
1749 ep1_ch1()->MaybeStartGathering(); | 1755 ep1_ch1()->MaybeStartGathering(); |
1750 ep2_ch1()->MaybeStartGathering(); | 1756 ep2_ch1()->MaybeStartGathering(); |
1751 | 1757 |
1752 // Wait for the TURN<->prflx connection. | 1758 // Wait for the TURN<->prflx connection. |
1753 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable(), | 1759 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable(), |
(...skipping 15 matching lines...) Expand all Loading... |
1769 | 1775 |
1770 // Test that a presumed-writable TURN<->TURN connection is preferred above an | 1776 // Test that a presumed-writable TURN<->TURN connection is preferred above an |
1771 // unreliable connection (one that has failed to be pinged for some time). | 1777 // unreliable connection (one that has failed to be pinged for some time). |
1772 TEST_F(P2PTransportChannelTest, PresumedWritablePreferredOverUnreliable) { | 1778 TEST_F(P2PTransportChannelTest, PresumedWritablePreferredOverUnreliable) { |
1773 rtc::ScopedFakeClock fake_clock; | 1779 rtc::ScopedFakeClock fake_clock; |
1774 | 1780 |
1775 ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, | 1781 ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, |
1776 kDefaultPortAllocatorFlags); | 1782 kDefaultPortAllocatorFlags); |
1777 IceConfig config; | 1783 IceConfig config; |
1778 config.presume_writable_when_fully_relayed = true; | 1784 config.presume_writable_when_fully_relayed = true; |
1779 GetEndpoint(0)->cd1_.ch_.reset( | 1785 GetEndpoint(0)->cd1_.ch_.reset(CreateChannel( |
1780 CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[0], | 1786 0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[0], kIceParams[1])); |
1781 kIcePwd[0], kIceUfrag[1], kIcePwd[1])); | 1787 GetEndpoint(1)->cd1_.ch_.reset(CreateChannel( |
1782 GetEndpoint(1)->cd1_.ch_.reset( | 1788 1, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[1], kIceParams[0])); |
1783 CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[1], | |
1784 kIcePwd[1], kIceUfrag[0], kIcePwd[0])); | |
1785 ep1_ch1()->SetIceConfig(config); | 1789 ep1_ch1()->SetIceConfig(config); |
1786 ep2_ch1()->SetIceConfig(config); | 1790 ep2_ch1()->SetIceConfig(config); |
1787 ep1_ch1()->MaybeStartGathering(); | 1791 ep1_ch1()->MaybeStartGathering(); |
1788 ep2_ch1()->MaybeStartGathering(); | 1792 ep2_ch1()->MaybeStartGathering(); |
1789 // Wait for initial connection as usual. | 1793 // Wait for initial connection as usual. |
1790 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1794 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1791 ep1_ch1()->selected_connection()->writable() && | 1795 ep1_ch1()->selected_connection()->writable() && |
1792 ep2_ch1()->receiving() && | 1796 ep2_ch1()->receiving() && |
1793 ep2_ch1()->writable() && | 1797 ep2_ch1()->writable() && |
1794 ep2_ch1()->selected_connection()->writable(), | 1798 ep2_ch1()->selected_connection()->writable(), |
(...skipping 22 matching lines...) Expand all Loading... |
1817 // address of the outermost NAT. | 1821 // address of the outermost NAT. |
1818 class P2PTransportChannelSameNatTest : public P2PTransportChannelTestBase { | 1822 class P2PTransportChannelSameNatTest : public P2PTransportChannelTestBase { |
1819 protected: | 1823 protected: |
1820 void ConfigureEndpoints(Config nat_type, Config config1, Config config2) { | 1824 void ConfigureEndpoints(Config nat_type, Config config1, Config config2) { |
1821 ASSERT(nat_type >= NAT_FULL_CONE && nat_type <= NAT_SYMMETRIC); | 1825 ASSERT(nat_type >= NAT_FULL_CONE && nat_type <= NAT_SYMMETRIC); |
1822 rtc::NATSocketServer::Translator* outer_nat = | 1826 rtc::NATSocketServer::Translator* outer_nat = |
1823 nat()->AddTranslator(kPublicAddrs[0], kNatAddrs[0], | 1827 nat()->AddTranslator(kPublicAddrs[0], kNatAddrs[0], |
1824 static_cast<rtc::NATType>(nat_type - NAT_FULL_CONE)); | 1828 static_cast<rtc::NATType>(nat_type - NAT_FULL_CONE)); |
1825 ConfigureEndpoint(outer_nat, 0, config1); | 1829 ConfigureEndpoint(outer_nat, 0, config1); |
1826 ConfigureEndpoint(outer_nat, 1, config2); | 1830 ConfigureEndpoint(outer_nat, 1, config2); |
1827 set_remote_ice_credential_source(FROM_SETICECREDENTIALS); | 1831 set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
1828 } | 1832 } |
1829 void ConfigureEndpoint(rtc::NATSocketServer::Translator* nat, | 1833 void ConfigureEndpoint(rtc::NATSocketServer::Translator* nat, |
1830 int endpoint, Config config) { | 1834 int endpoint, Config config) { |
1831 ASSERT(config <= NAT_SYMMETRIC); | 1835 ASSERT(config <= NAT_SYMMETRIC); |
1832 if (config == OPEN) { | 1836 if (config == OPEN) { |
1833 AddAddress(endpoint, kPrivateAddrs[endpoint]); | 1837 AddAddress(endpoint, kPrivateAddrs[endpoint]); |
1834 nat->AddClient(kPrivateAddrs[endpoint]); | 1838 nat->AddClient(kPrivateAddrs[endpoint]); |
1835 } else { | 1839 } else { |
1836 AddAddress(endpoint, kCascadedPrivateAddrs[endpoint]); | 1840 AddAddress(endpoint, kCascadedPrivateAddrs[endpoint]); |
1837 nat->AddTranslator(kPrivateAddrs[endpoint], kCascadedNatAddrs[endpoint], | 1841 nat->AddTranslator(kPrivateAddrs[endpoint], kCascadedNatAddrs[endpoint], |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2013 // Adding alternate address will make sure |kPublicAddrs| has the higher | 2017 // Adding alternate address will make sure |kPublicAddrs| has the higher |
2014 // priority than others. This is due to FakeNetwork::AddInterface method. | 2018 // priority than others. This is due to FakeNetwork::AddInterface method. |
2015 AddAddress(0, kAlternateAddrs[0]); | 2019 AddAddress(0, kAlternateAddrs[0]); |
2016 AddAddress(0, kPublicAddrs[0]); | 2020 AddAddress(0, kPublicAddrs[0]); |
2017 AddAddress(1, kPublicAddrs[1]); | 2021 AddAddress(1, kPublicAddrs[1]); |
2018 | 2022 |
2019 // Use only local ports for simplicity. | 2023 // Use only local ports for simplicity. |
2020 SetAllocatorFlags(0, kOnlyLocalPorts); | 2024 SetAllocatorFlags(0, kOnlyLocalPorts); |
2021 SetAllocatorFlags(1, kOnlyLocalPorts); | 2025 SetAllocatorFlags(1, kOnlyLocalPorts); |
2022 | 2026 |
2023 // Create channels and let them go writable, as usual. | 2027 // We want it to set the remote ICE parameters when creating channels. |
2024 CreateChannels(1); | 2028 set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
2025 ep1_ch1()->set_remote_supports_renomination(true); | 2029 // Create channels with renomination enabled. |
| 2030 CreateChannelsWithRenomination(1, true); |
2026 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2031 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
2027 ep2_ch1()->receiving() && | 2032 ep2_ch1()->receiving() && |
2028 ep2_ch1()->writable(), | 2033 ep2_ch1()->writable(), |
2029 3000, clock); | 2034 3000, clock); |
2030 EXPECT_TRUE_SIMULATED_WAIT( | 2035 EXPECT_TRUE_SIMULATED_WAIT( |
2031 ep2_ch1()->selected_connection()->remote_nomination() > 0 && | 2036 ep2_ch1()->selected_connection()->remote_nomination() > 0 && |
2032 ep1_ch1()->selected_connection()->acked_nomination() > 0, | 2037 ep1_ch1()->selected_connection()->acked_nomination() > 0, |
2033 kDefaultTimeout, clock); | 2038 kDefaultTimeout, clock); |
2034 const Connection* selected_connection1 = ep1_ch1()->selected_connection(); | 2039 const Connection* selected_connection1 = ep1_ch1()->selected_connection(); |
2035 Connection* selected_connection2 = | 2040 Connection* selected_connection2 = |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2594 public sigslot::has_slots<> { | 2599 public sigslot::has_slots<> { |
2595 public: | 2600 public: |
2596 P2PTransportChannelPingTest() | 2601 P2PTransportChannelPingTest() |
2597 : pss_(new rtc::PhysicalSocketServer), | 2602 : pss_(new rtc::PhysicalSocketServer), |
2598 vss_(new rtc::VirtualSocketServer(pss_.get())), | 2603 vss_(new rtc::VirtualSocketServer(pss_.get())), |
2599 ss_scope_(vss_.get()) {} | 2604 ss_scope_(vss_.get()) {} |
2600 | 2605 |
2601 protected: | 2606 protected: |
2602 void PrepareChannel(P2PTransportChannel* ch) { | 2607 void PrepareChannel(P2PTransportChannel* ch) { |
2603 ch->SetIceRole(ICEROLE_CONTROLLING); | 2608 ch->SetIceRole(ICEROLE_CONTROLLING); |
2604 ch->SetIceCredentials(kIceUfrag[0], kIcePwd[0]); | 2609 ch->SetIceParameters(kIceParams[0]); |
2605 ch->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 2610 ch->SetRemoteIceParameters(kIceParams[1]); |
2606 ch->SignalSelectedCandidatePairChanged.connect( | 2611 ch->SignalSelectedCandidatePairChanged.connect( |
2607 this, &P2PTransportChannelPingTest::OnSelectedCandidatePairChanged); | 2612 this, &P2PTransportChannelPingTest::OnSelectedCandidatePairChanged); |
2608 ch->SignalReadyToSend.connect(this, | 2613 ch->SignalReadyToSend.connect(this, |
2609 &P2PTransportChannelPingTest::OnReadyToSend); | 2614 &P2PTransportChannelPingTest::OnReadyToSend); |
2610 ch->SignalStateChanged.connect( | 2615 ch->SignalStateChanged.connect( |
2611 this, &P2PTransportChannelPingTest::OnChannelStateChanged); | 2616 this, &P2PTransportChannelPingTest::OnChannelStateChanged); |
2612 } | 2617 } |
2613 | 2618 |
2614 Connection* WaitForConnectionTo(P2PTransportChannel* ch, | 2619 Connection* WaitForConnectionTo(P2PTransportChannel* ch, |
2615 const std::string& ip, | 2620 const std::string& ip, |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2874 start = clock.TimeNanos(); | 2879 start = clock.TimeNanos(); |
2875 ping_sent_before = conn->num_pings_sent(); | 2880 ping_sent_before = conn->num_pings_sent(); |
2876 SIMULATED_WAIT(conn->num_pings_sent() == ping_sent_before + 1, 3000, clock); | 2881 SIMULATED_WAIT(conn->num_pings_sent() == ping_sent_before + 1, 3000, clock); |
2877 ping_interval_ms = (clock.TimeNanos() - start) / rtc::kNumNanosecsPerMillisec; | 2882 ping_interval_ms = (clock.TimeNanos() - start) / rtc::kNumNanosecsPerMillisec; |
2878 EXPECT_GE(ping_interval_ms, STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL); | 2883 EXPECT_GE(ping_interval_ms, STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL); |
2879 EXPECT_LE(ping_interval_ms, | 2884 EXPECT_LE(ping_interval_ms, |
2880 STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL + SCHEDULING_RANGE); | 2885 STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL + SCHEDULING_RANGE); |
2881 } | 2886 } |
2882 | 2887 |
2883 // Test that we start pinging as soon as we have a connection and remote ICE | 2888 // Test that we start pinging as soon as we have a connection and remote ICE |
2884 // credentials. | 2889 // parameters. |
2885 TEST_F(P2PTransportChannelPingTest, PingingStartedAsSoonAsPossible) { | 2890 TEST_F(P2PTransportChannelPingTest, PingingStartedAsSoonAsPossible) { |
2886 rtc::ScopedFakeClock clock; | 2891 rtc::ScopedFakeClock clock; |
2887 | 2892 |
2888 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 2893 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
2889 P2PTransportChannel ch("TestChannel", 1, &pa); | 2894 P2PTransportChannel ch("TestChannel", 1, &pa); |
2890 ch.SetIceRole(ICEROLE_CONTROLLING); | 2895 ch.SetIceRole(ICEROLE_CONTROLLING); |
2891 ch.SetIceCredentials(kIceUfrag[0], kIcePwd[0]); | 2896 ch.SetIceParameters(kIceParams[0]); |
2892 ch.MaybeStartGathering(); | 2897 ch.MaybeStartGathering(); |
2893 EXPECT_EQ_WAIT(IceGatheringState::kIceGatheringComplete, ch.gathering_state(), | 2898 EXPECT_EQ_WAIT(IceGatheringState::kIceGatheringComplete, ch.gathering_state(), |
2894 kDefaultTimeout); | 2899 kDefaultTimeout); |
2895 | 2900 |
2896 // Simulate a binding request being received, creating a peer reflexive | 2901 // Simulate a binding request being received, creating a peer reflexive |
2897 // candidate pair while we still don't have remote ICE credentials. | 2902 // candidate pair while we still don't have remote ICE parameters. |
2898 IceMessage request; | 2903 IceMessage request; |
2899 request.SetType(STUN_BINDING_REQUEST); | 2904 request.SetType(STUN_BINDING_REQUEST); |
2900 request.AddAttribute( | 2905 request.AddAttribute( |
2901 new StunByteStringAttribute(STUN_ATTR_USERNAME, kIceUfrag[1])); | 2906 new StunByteStringAttribute(STUN_ATTR_USERNAME, kIceUfrag[1])); |
2902 uint32_t prflx_priority = ICE_TYPE_PREFERENCE_PRFLX << 24; | 2907 uint32_t prflx_priority = ICE_TYPE_PREFERENCE_PRFLX << 24; |
2903 request.AddAttribute( | 2908 request.AddAttribute( |
2904 new StunUInt32Attribute(STUN_ATTR_PRIORITY, prflx_priority)); | 2909 new StunUInt32Attribute(STUN_ATTR_PRIORITY, prflx_priority)); |
2905 Port* port = GetPort(&ch); | 2910 Port* port = GetPort(&ch); |
2906 ASSERT_NE(nullptr, port); | 2911 ASSERT_NE(nullptr, port); |
2907 port->SignalUnknownAddress(port, rtc::SocketAddress("1.1.1.1", 1), PROTO_UDP, | 2912 port->SignalUnknownAddress(port, rtc::SocketAddress("1.1.1.1", 1), PROTO_UDP, |
2908 &request, kIceUfrag[1], false); | 2913 &request, kIceUfrag[1], false); |
2909 Connection* conn = GetConnectionTo(&ch, "1.1.1.1", 1); | 2914 Connection* conn = GetConnectionTo(&ch, "1.1.1.1", 1); |
2910 ASSERT_NE(nullptr, conn); | 2915 ASSERT_NE(nullptr, conn); |
2911 | 2916 |
2912 // Simulate waiting for a second (and change) and verify that no pings were | 2917 // Simulate waiting for a second (and change) and verify that no pings were |
2913 // sent, since we don't yet have remote ICE credentials. | 2918 // sent, since we don't yet have remote ICE parameters. |
2914 SIMULATED_WAIT(conn->num_pings_sent() > 0, 1025, clock); | 2919 SIMULATED_WAIT(conn->num_pings_sent() > 0, 1025, clock); |
2915 EXPECT_EQ(0, conn->num_pings_sent()); | 2920 EXPECT_EQ(0, conn->num_pings_sent()); |
2916 | 2921 |
2917 // Set remote ICE credentials. Now we should be able to ping. Ensure that | 2922 // Set remote ICE parameters. Now we should be able to ping. Ensure that |
2918 // the first ping is sent as soon as possible, within one simulated clock | 2923 // the first ping is sent as soon as possible, within one simulated clock |
2919 // tick. | 2924 // tick. |
2920 ch.SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 2925 ch.SetRemoteIceParameters(kIceParams[1]); |
2921 EXPECT_TRUE_SIMULATED_WAIT(conn->num_pings_sent() > 0, 1, clock); | 2926 EXPECT_TRUE_SIMULATED_WAIT(conn->num_pings_sent() > 0, 1, clock); |
2922 } | 2927 } |
2923 | 2928 |
2924 TEST_F(P2PTransportChannelPingTest, TestNoTriggeredChecksWhenWritable) { | 2929 TEST_F(P2PTransportChannelPingTest, TestNoTriggeredChecksWhenWritable) { |
2925 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 2930 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
2926 P2PTransportChannel ch("trigger checks", 1, &pa); | 2931 P2PTransportChannel ch("trigger checks", 1, &pa); |
2927 PrepareChannel(&ch); | 2932 PrepareChannel(&ch); |
2928 ch.MaybeStartGathering(); | 2933 ch.MaybeStartGathering(); |
2929 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); | 2934 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); |
2930 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 2)); | 2935 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 2)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2974 // Pruning the connection reduces the set of active connections and changes | 2979 // Pruning the connection reduces the set of active connections and changes |
2975 // the channel state. | 2980 // the channel state. |
2976 conn1->Prune(); | 2981 conn1->Prune(); |
2977 EXPECT_EQ_WAIT(STATE_FAILED, channel_state(), kDefaultTimeout); | 2982 EXPECT_EQ_WAIT(STATE_FAILED, channel_state(), kDefaultTimeout); |
2978 } | 2983 } |
2979 | 2984 |
2980 // Test adding remote candidates with different ufrags. If a remote candidate | 2985 // Test adding remote candidates with different ufrags. If a remote candidate |
2981 // is added with an old ufrag, it will be discarded. If it is added with a | 2986 // is added with an old ufrag, it will be discarded. If it is added with a |
2982 // ufrag that was not seen before, it will be used to create connections | 2987 // ufrag that was not seen before, it will be used to create connections |
2983 // although the ICE pwd in the remote candidate will be set when the ICE | 2988 // although the ICE pwd in the remote candidate will be set when the ICE |
2984 // credentials arrive. If a remote candidate is added with the current ICE | 2989 // parameters arrive. If a remote candidate is added with the current ICE |
2985 // ufrag, its pwd and generation will be set properly. | 2990 // ufrag, its pwd and generation will be set properly. |
2986 TEST_F(P2PTransportChannelPingTest, TestAddRemoteCandidateWithVariousUfrags) { | 2991 TEST_F(P2PTransportChannelPingTest, TestAddRemoteCandidateWithVariousUfrags) { |
2987 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 2992 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
2988 P2PTransportChannel ch("add candidate", 1, &pa); | 2993 P2PTransportChannel ch("add candidate", 1, &pa); |
2989 PrepareChannel(&ch); | 2994 PrepareChannel(&ch); |
2990 ch.MaybeStartGathering(); | 2995 ch.MaybeStartGathering(); |
2991 // Add a candidate with a future ufrag. | 2996 // Add a candidate with a future ufrag. |
2992 ch.AddRemoteCandidate( | 2997 ch.AddRemoteCandidate( |
2993 CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1, kIceUfrag[2])); | 2998 CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1, kIceUfrag[2])); |
2994 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 2999 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
2995 ASSERT_TRUE(conn1 != nullptr); | 3000 ASSERT_TRUE(conn1 != nullptr); |
2996 const Candidate& candidate = conn1->remote_candidate(); | 3001 const Candidate& candidate = conn1->remote_candidate(); |
2997 EXPECT_EQ(kIceUfrag[2], candidate.username()); | 3002 EXPECT_EQ(kIceUfrag[2], candidate.username()); |
2998 EXPECT_TRUE(candidate.password().empty()); | 3003 EXPECT_TRUE(candidate.password().empty()); |
2999 EXPECT_TRUE(FindNextPingableConnectionAndPingIt(&ch) == nullptr); | 3004 EXPECT_TRUE(FindNextPingableConnectionAndPingIt(&ch) == nullptr); |
3000 | 3005 |
3001 // Set the remote credentials with the "future" ufrag. | 3006 // Set the remote ICE parameters with the "future" ufrag. |
3002 // This should set the ICE pwd in the remote candidate of |conn1|, making | 3007 // This should set the ICE pwd in the remote candidate of |conn1|, making |
3003 // it pingable. | 3008 // it pingable. |
3004 ch.SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]); | 3009 ch.SetRemoteIceParameters(kIceParams[2]); |
3005 EXPECT_EQ(kIceUfrag[2], candidate.username()); | 3010 EXPECT_EQ(kIceUfrag[2], candidate.username()); |
3006 EXPECT_EQ(kIcePwd[2], candidate.password()); | 3011 EXPECT_EQ(kIcePwd[2], candidate.password()); |
3007 EXPECT_EQ(conn1, FindNextPingableConnectionAndPingIt(&ch)); | 3012 EXPECT_EQ(conn1, FindNextPingableConnectionAndPingIt(&ch)); |
3008 | 3013 |
3009 // Add a candidate with an old ufrag. No connection will be created. | 3014 // Add a candidate with an old ufrag. No connection will be created. |
3010 ch.AddRemoteCandidate( | 3015 ch.AddRemoteCandidate( |
3011 CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 2, kIceUfrag[1])); | 3016 CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 2, kIceUfrag[1])); |
3012 rtc::Thread::Current()->ProcessMessages(500); | 3017 rtc::Thread::Current()->ProcessMessages(500); |
3013 EXPECT_TRUE(GetConnectionTo(&ch, "2.2.2.2", 2) == nullptr); | 3018 EXPECT_TRUE(GetConnectionTo(&ch, "2.2.2.2", 2) == nullptr); |
3014 | 3019 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3254 ASSERT_TRUE(conn4 != nullptr); | 3259 ASSERT_TRUE(conn4 != nullptr); |
3255 EXPECT_TRUE(port->sent_binding_response()); | 3260 EXPECT_TRUE(port->sent_binding_response()); |
3256 // conn4 is not the selected connection yet because it is not writable. | 3261 // conn4 is not the selected connection yet because it is not writable. |
3257 EXPECT_EQ(conn2, ch.selected_connection()); | 3262 EXPECT_EQ(conn2, ch.selected_connection()); |
3258 conn4->ReceivedPingResponse(LOW_RTT, "id"); // Become writable. | 3263 conn4->ReceivedPingResponse(LOW_RTT, "id"); // Become writable. |
3259 EXPECT_EQ_WAIT(conn4, ch.selected_connection(), kDefaultTimeout); | 3264 EXPECT_EQ_WAIT(conn4, ch.selected_connection(), kDefaultTimeout); |
3260 | 3265 |
3261 // Test that the request from an unknown address contains a ufrag from an old | 3266 // Test that the request from an unknown address contains a ufrag from an old |
3262 // generation. | 3267 // generation. |
3263 port->set_sent_binding_response(false); | 3268 port->set_sent_binding_response(false); |
3264 ch.SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]); | 3269 ch.SetRemoteIceParameters(kIceParams[2]); |
3265 ch.SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 3270 ch.SetRemoteIceParameters(kIceParams[3]); |
3266 port->SignalUnknownAddress(port, rtc::SocketAddress("5.5.5.5", 5), PROTO_UDP, | 3271 port->SignalUnknownAddress(port, rtc::SocketAddress("5.5.5.5", 5), PROTO_UDP, |
3267 &request, kIceUfrag[2], false); | 3272 &request, kIceUfrag[2], false); |
3268 Connection* conn5 = WaitForConnectionTo(&ch, "5.5.5.5", 5); | 3273 Connection* conn5 = WaitForConnectionTo(&ch, "5.5.5.5", 5); |
3269 ASSERT_TRUE(conn5 != nullptr); | 3274 ASSERT_TRUE(conn5 != nullptr); |
3270 EXPECT_TRUE(port->sent_binding_response()); | 3275 EXPECT_TRUE(port->sent_binding_response()); |
3271 EXPECT_EQ(kIcePwd[2], conn5->remote_candidate().password()); | 3276 EXPECT_EQ(kIcePwd[2], conn5->remote_candidate().password()); |
3272 } | 3277 } |
3273 | 3278 |
3274 // The controlled side will select a connection as the "selected connection" | 3279 // The controlled side will select a connection as the "selected connection" |
3275 // based on media received until the controlling side nominates a connection, | 3280 // based on media received until the controlling side nominates a connection, |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3725 ch.MaybeStartGathering(); | 3730 ch.MaybeStartGathering(); |
3726 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); | 3731 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); |
3727 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 3732 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
3728 ASSERT_TRUE(conn1 != nullptr); | 3733 ASSERT_TRUE(conn1 != nullptr); |
3729 conn1->ReceivedPingResponse(LOW_RTT, "id"); // Becomes writable and receiving | 3734 conn1->ReceivedPingResponse(LOW_RTT, "id"); // Becomes writable and receiving |
3730 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); | 3735 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); |
3731 | 3736 |
3732 // Start a new session. Even though conn1, which belongs to an older | 3737 // Start a new session. Even though conn1, which belongs to an older |
3733 // session, becomes unwritable and writable again, it should not stop the | 3738 // session, becomes unwritable and writable again, it should not stop the |
3734 // current session. | 3739 // current session. |
3735 ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]); | 3740 ch.SetIceParameters(kIceParams[1]); |
3736 ch.MaybeStartGathering(); | 3741 ch.MaybeStartGathering(); |
3737 conn1->Prune(); | 3742 conn1->Prune(); |
3738 conn1->ReceivedPingResponse(LOW_RTT, "id"); | 3743 conn1->ReceivedPingResponse(LOW_RTT, "id"); |
3739 EXPECT_TRUE(ch.allocator_session()->IsGettingPorts()); | 3744 EXPECT_TRUE(ch.allocator_session()->IsGettingPorts()); |
3740 | 3745 |
3741 // But if a new connection created from the new session becomes writable, | 3746 // But if a new connection created from the new session becomes writable, |
3742 // it will stop the current session. | 3747 // it will stop the current session. |
3743 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 100)); | 3748 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 100)); |
3744 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 3749 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
3745 ASSERT_TRUE(conn2 != nullptr); | 3750 ASSERT_TRUE(conn2 != nullptr); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3781 // Starts with ICEROLE_CONTROLLING. | 3786 // Starts with ICEROLE_CONTROLLING. |
3782 PrepareChannel(&ch); | 3787 PrepareChannel(&ch); |
3783 ch.MaybeStartGathering(); | 3788 ch.MaybeStartGathering(); |
3784 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); | 3789 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); |
3785 | 3790 |
3786 Connection* conn = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 3791 Connection* conn = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
3787 ASSERT_TRUE(conn != nullptr); | 3792 ASSERT_TRUE(conn != nullptr); |
3788 | 3793 |
3789 // Do an ICE restart, change the role, and expect the old port to have its | 3794 // Do an ICE restart, change the role, and expect the old port to have its |
3790 // role updated. | 3795 // role updated. |
3791 ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]); | 3796 ch.SetIceParameters(kIceParams[1]); |
3792 ch.MaybeStartGathering(); | 3797 ch.MaybeStartGathering(); |
3793 ch.SetIceRole(ICEROLE_CONTROLLED); | 3798 ch.SetIceRole(ICEROLE_CONTROLLED); |
3794 EXPECT_EQ(ICEROLE_CONTROLLED, conn->port()->GetIceRole()); | 3799 EXPECT_EQ(ICEROLE_CONTROLLED, conn->port()->GetIceRole()); |
3795 } | 3800 } |
3796 | 3801 |
3797 // Test that after some amount of time without receiving data, the connection | 3802 // Test that after some amount of time without receiving data, the connection |
3798 // will be destroyed. The port will only be destroyed after it is marked as | 3803 // will be destroyed. The port will only be destroyed after it is marked as |
3799 // "pruned." | 3804 // "pruned." |
3800 TEST_F(P2PTransportChannelPingTest, TestPortDestroyedAfterTimeoutAndPruned) { | 3805 TEST_F(P2PTransportChannelPingTest, TestPortDestroyedAfterTimeoutAndPruned) { |
3801 rtc::ScopedFakeClock fake_clock; | 3806 rtc::ScopedFakeClock fake_clock; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4031 | 4036 |
4032 // TCP Relay/Relay is the next. | 4037 // TCP Relay/Relay is the next. |
4033 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, | 4038 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, |
4034 TCP_PROTOCOL_NAME); | 4039 TCP_PROTOCOL_NAME); |
4035 | 4040 |
4036 // Finally, Local/Relay will be pinged. | 4041 // Finally, Local/Relay will be pinged. |
4037 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); | 4042 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); |
4038 } | 4043 } |
4039 | 4044 |
4040 } // namespace cricket { | 4045 } // namespace cricket { |
OLD | NEW |