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, bool renomination = false) { |
Taylor Brandstetter
2016/08/17 22:02:00
nit: Similar to my last comment, I'd prefer to hav
honghaiz3
2016/08/19 18:42:01
I would argue for using a single method with a ren
Taylor Brandstetter
2016/08/20 00:52:13
I do agree there should be a renomination argument
honghaiz3
2016/08/22 18:46:44
Done.
| |
316 ep2_.cd1_.ch_.reset(CreateChannel( | 319 IceParameters ice_ep1_cd1_ch = |
317 1, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep2_cd1_ch, | 320 IceParamsWithRenomination(kIceParams[0], renomination); |
318 ice_pwd_ep2_cd1_ch, ice_ufrag_ep1_cd1_ch, ice_pwd_ep1_cd1_ch)); | 321 IceParameters ice_ep2_cd1_ch = |
322 IceParamsWithRenomination(kIceParams[1], renomination); | |
323 ep1_.cd1_.ch_.reset(CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, | |
324 ice_ep1_cd1_ch, ice_ep2_cd1_ch)); | |
325 ep2_.cd1_.ch_.reset(CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, | |
326 ice_ep2_cd1_ch, ice_ep1_cd1_ch)); | |
319 ep1_.cd1_.ch_->MaybeStartGathering(); | 327 ep1_.cd1_.ch_->MaybeStartGathering(); |
320 ep2_.cd1_.ch_->MaybeStartGathering(); | 328 ep2_.cd1_.ch_->MaybeStartGathering(); |
321 if (num == 2) { | 329 if (num == 2) { |
322 std::string ice_ufrag_ep1_cd2_ch = kIceUfrag[2]; | 330 IceParameters ice_ep1_cd2_ch = |
323 std::string ice_pwd_ep1_cd2_ch = kIcePwd[2]; | 331 IceParamsWithRenomination(kIceParams[2], renomination); |
324 std::string ice_ufrag_ep2_cd2_ch = kIceUfrag[3]; | 332 IceParameters ice_ep2_cd2_ch = |
325 std::string ice_pwd_ep2_cd2_ch = kIcePwd[3]; | 333 IceParamsWithRenomination(kIceParams[3], renomination); |
326 ep1_.cd2_.ch_.reset(CreateChannel( | 334 ep1_.cd2_.ch_.reset(CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, |
327 0, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep1_cd2_ch, | 335 ice_ep1_cd2_ch, ice_ep2_cd2_ch)); |
328 ice_pwd_ep1_cd2_ch, ice_ufrag_ep2_cd2_ch, ice_pwd_ep2_cd2_ch)); | 336 ep2_.cd2_.ch_.reset(CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, |
329 ep2_.cd2_.ch_.reset(CreateChannel( | 337 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(); | 338 ep1_.cd2_.ch_->MaybeStartGathering(); |
333 ep2_.cd2_.ch_->MaybeStartGathering(); | 339 ep2_.cd2_.ch_->MaybeStartGathering(); |
334 } | 340 } |
335 } | 341 } |
336 P2PTransportChannel* CreateChannel(int endpoint, | 342 P2PTransportChannel* CreateChannel(int endpoint, |
337 int component, | 343 int component, |
338 const std::string& local_ice_ufrag, | 344 const IceParameters& local_ice, |
339 const std::string& local_ice_pwd, | 345 const IceParameters& remote_ice) { |
340 const std::string& remote_ice_ufrag, | |
341 const std::string& remote_ice_pwd) { | |
342 P2PTransportChannel* channel = new P2PTransportChannel( | 346 P2PTransportChannel* channel = new P2PTransportChannel( |
343 "test content name", component, GetAllocator(endpoint)); | 347 "test content name", component, GetAllocator(endpoint)); |
344 channel->SignalReadyToSend.connect( | 348 channel->SignalReadyToSend.connect( |
345 this, &P2PTransportChannelTestBase::OnReadyToSend); | 349 this, &P2PTransportChannelTestBase::OnReadyToSend); |
346 channel->SignalCandidateGathered.connect( | 350 channel->SignalCandidateGathered.connect( |
347 this, &P2PTransportChannelTestBase::OnCandidateGathered); | 351 this, &P2PTransportChannelTestBase::OnCandidateGathered); |
348 channel->SignalCandidatesRemoved.connect( | 352 channel->SignalCandidatesRemoved.connect( |
349 this, &P2PTransportChannelTestBase::OnCandidatesRemoved); | 353 this, &P2PTransportChannelTestBase::OnCandidatesRemoved); |
350 channel->SignalReadPacket.connect( | 354 channel->SignalReadPacket.connect( |
351 this, &P2PTransportChannelTestBase::OnReadPacket); | 355 this, &P2PTransportChannelTestBase::OnReadPacket); |
352 channel->SignalRoleConflict.connect( | 356 channel->SignalRoleConflict.connect( |
353 this, &P2PTransportChannelTestBase::OnRoleConflict); | 357 this, &P2PTransportChannelTestBase::OnRoleConflict); |
354 channel->SignalSelectedCandidatePairChanged.connect( | 358 channel->SignalSelectedCandidatePairChanged.connect( |
355 this, &P2PTransportChannelTestBase::OnSelectedCandidatePairChanged); | 359 this, &P2PTransportChannelTestBase::OnSelectedCandidatePairChanged); |
356 channel->SetIceCredentials(local_ice_ufrag, local_ice_pwd); | 360 channel->SetIceParameters(local_ice); |
357 if (remote_ice_credential_source_ == FROM_SETICECREDENTIALS) { | 361 if (remote_ice_parameter_source_ == FROM_SETICEPARAMETERS) { |
358 channel->SetRemoteIceCredentials(remote_ice_ufrag, remote_ice_pwd); | 362 channel->SetRemoteIceParameters(remote_ice); |
359 } | 363 } |
360 channel->SetIceRole(GetEndpoint(endpoint)->ice_role()); | 364 channel->SetIceRole(GetEndpoint(endpoint)->ice_role()); |
361 channel->SetIceTiebreaker(GetEndpoint(endpoint)->GetIceTiebreaker()); | 365 channel->SetIceTiebreaker(GetEndpoint(endpoint)->GetIceTiebreaker()); |
362 return channel; | 366 return channel; |
363 } | 367 } |
364 void DestroyChannels() { | 368 void DestroyChannels() { |
365 ep1_.cd1_.ch_.reset(); | 369 ep1_.cd1_.ch_.reset(); |
366 ep2_.cd1_.ch_.reset(); | 370 ep2_.cd1_.ch_.reset(); |
367 ep1_.cd2_.ch_.reset(); | 371 ep1_.cd2_.ch_.reset(); |
368 ep2_.cd2_.ch_.reset(); | 372 ep2_.cd2_.ch_.reset(); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
579 // local_channel2 <==> remote_channel2 | 583 // local_channel2 <==> remote_channel2 |
580 EXPECT_EQ_WAIT(len, SendData(ep1_ch2(), data, len), 1000); | 584 EXPECT_EQ_WAIT(len, SendData(ep1_ch2(), data, len), 1000); |
581 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep2_ch2(), data, len), 1000); | 585 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep2_ch2(), data, len), 1000); |
582 EXPECT_EQ_WAIT(len, SendData(ep2_ch2(), data, len), 1000); | 586 EXPECT_EQ_WAIT(len, SendData(ep2_ch2(), data, len), 1000); |
583 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep1_ch2(), data, len), 1000); | 587 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep1_ch2(), data, len), 1000); |
584 } | 588 } |
585 } | 589 } |
586 } | 590 } |
587 | 591 |
588 // This test waits for the transport to become receiving and writable on both | 592 // 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 | 593 // 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 | 594 // restart the ice gathering. Finally it waits for the transport to select a |
591 // new connection using the newly generated ice candidates. | 595 // new connection using the newly generated ice candidates. |
592 // Before calling this function the end points must be configured. | 596 // Before calling this function the end points must be configured. |
593 void TestHandleIceUfragPasswordChanged() { | 597 void TestHandleIceUfragPasswordChanged() { |
594 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 598 ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); |
595 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); | 599 ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); |
596 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 600 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
597 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 601 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
598 1000, 1000); | 602 1000, 1000); |
599 | 603 |
600 const Candidate* old_local_candidate1 = LocalCandidate(ep1_ch1()); | 604 const Candidate* old_local_candidate1 = LocalCandidate(ep1_ch1()); |
601 const Candidate* old_local_candidate2 = LocalCandidate(ep2_ch1()); | 605 const Candidate* old_local_candidate2 = LocalCandidate(ep2_ch1()); |
602 const Candidate* old_remote_candidate1 = RemoteCandidate(ep1_ch1()); | 606 const Candidate* old_remote_candidate1 = RemoteCandidate(ep1_ch1()); |
603 const Candidate* old_remote_candidate2 = RemoteCandidate(ep2_ch1()); | 607 const Candidate* old_remote_candidate2 = RemoteCandidate(ep2_ch1()); |
604 | 608 |
605 ep1_ch1()->SetIceCredentials(kIceUfrag[2], kIcePwd[2]); | 609 ep1_ch1()->SetIceParameters(kIceParams[2]); |
606 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 610 ep1_ch1()->SetRemoteIceParameters(kIceParams[3]); |
607 ep1_ch1()->MaybeStartGathering(); | 611 ep1_ch1()->MaybeStartGathering(); |
608 ep2_ch1()->SetIceCredentials(kIceUfrag[3], kIcePwd[3]); | 612 ep2_ch1()->SetIceParameters(kIceParams[3]); |
609 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]); | 613 |
614 ep2_ch1()->SetRemoteIceParameters(kIceParams[2]); | |
610 ep2_ch1()->MaybeStartGathering(); | 615 ep2_ch1()->MaybeStartGathering(); |
611 | 616 |
612 EXPECT_TRUE_WAIT_MARGIN(LocalCandidate(ep1_ch1())->generation() != | 617 EXPECT_TRUE_WAIT_MARGIN(LocalCandidate(ep1_ch1())->generation() != |
613 old_local_candidate1->generation(), | 618 old_local_candidate1->generation(), |
614 1000, 1000); | 619 1000, 1000); |
615 EXPECT_TRUE_WAIT_MARGIN(LocalCandidate(ep2_ch1())->generation() != | 620 EXPECT_TRUE_WAIT_MARGIN(LocalCandidate(ep2_ch1())->generation() != |
616 old_local_candidate2->generation(), | 621 old_local_candidate2->generation(), |
617 1000, 1000); | 622 1000, 1000); |
618 EXPECT_TRUE_WAIT_MARGIN(RemoteCandidate(ep1_ch1())->generation() != | 623 EXPECT_TRUE_WAIT_MARGIN(RemoteCandidate(ep1_ch1())->generation() != |
619 old_remote_candidate1->generation(), | 624 old_remote_candidate1->generation(), |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
722 void OnMessage(rtc::Message* msg) { | 727 void OnMessage(rtc::Message* msg) { |
723 switch (msg->message_id) { | 728 switch (msg->message_id) { |
724 case MSG_ADD_CANDIDATES: { | 729 case MSG_ADD_CANDIDATES: { |
725 std::unique_ptr<CandidatesData> data( | 730 std::unique_ptr<CandidatesData> data( |
726 static_cast<CandidatesData*>(msg->pdata)); | 731 static_cast<CandidatesData*>(msg->pdata)); |
727 P2PTransportChannel* rch = GetRemoteChannel(data->channel); | 732 P2PTransportChannel* rch = GetRemoteChannel(data->channel); |
728 if (!rch) { | 733 if (!rch) { |
729 return; | 734 return; |
730 } | 735 } |
731 for (auto& c : data->candidates) { | 736 for (auto& c : data->candidates) { |
732 if (remote_ice_credential_source_ != FROM_CANDIDATE) { | 737 if (remote_ice_parameter_source_ != FROM_CANDIDATE) { |
733 c.set_username(""); | 738 c.set_username(""); |
734 c.set_password(""); | 739 c.set_password(""); |
735 } | 740 } |
736 LOG(LS_INFO) << "Candidate(" << data->channel->component() << "->" | 741 LOG(LS_INFO) << "Candidate(" << data->channel->component() << "->" |
737 << rch->component() << "): " << c.ToString(); | 742 << rch->component() << "): " << c.ToString(); |
738 rch->AddRemoteCandidate(c); | 743 rch->AddRemoteCandidate(c); |
739 } | 744 } |
740 break; | 745 break; |
741 } | 746 } |
742 case MSG_REMOVE_CANDIDATES: { | 747 case MSG_REMOVE_CANDIDATES: { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
807 return ep1_ch1(); | 812 return ep1_ch1(); |
808 else if (ch == ep2_ch2()) | 813 else if (ch == ep2_ch2()) |
809 return ep1_ch2(); | 814 return ep1_ch2(); |
810 else | 815 else |
811 return NULL; | 816 return NULL; |
812 } | 817 } |
813 std::list<std::string>& GetPacketList(TransportChannel* ch) { | 818 std::list<std::string>& GetPacketList(TransportChannel* ch) { |
814 return GetChannelData(ch)->ch_packets_; | 819 return GetChannelData(ch)->ch_packets_; |
815 } | 820 } |
816 | 821 |
817 enum RemoteIceCredentialSource { FROM_CANDIDATE, FROM_SETICECREDENTIALS }; | 822 enum RemoteIceParameterSource { FROM_CANDIDATE, FROM_SETICEPARAMETERS }; |
818 | 823 |
819 // How does the test pass ICE credentials to the P2PTransportChannel? | 824 // How does the test pass ICE parameters to the P2PTransportChannel? |
820 // On the candidate itself, or through SetIceCredentials? | 825 // On the candidate itself, or through SetRemoteIceParameters? |
821 // Goes through the candidate itself by default. | 826 // Goes through the candidate itself by default. |
822 void set_remote_ice_credential_source(RemoteIceCredentialSource source) { | 827 void set_remote_ice_parameter_source(RemoteIceParameterSource source) { |
823 remote_ice_credential_source_ = source; | 828 remote_ice_parameter_source_ = source; |
824 } | 829 } |
825 | 830 |
826 void set_force_relay(bool relay) { | 831 void set_force_relay(bool relay) { |
827 force_relay_ = relay; | 832 force_relay_ = relay; |
828 } | 833 } |
829 | 834 |
830 void ConnectSignalNominated(Connection* conn) { | 835 void ConnectSignalNominated(Connection* conn) { |
831 conn->SignalNominated.connect(this, | 836 conn->SignalNominated.connect(this, |
832 &P2PTransportChannelTestBase::OnNominated); | 837 &P2PTransportChannelTestBase::OnNominated); |
833 } | 838 } |
834 | 839 |
835 void OnNominated(Connection* conn) { nominated_ = true; } | 840 void OnNominated(Connection* conn) { nominated_ = true; } |
836 bool nominated() { return nominated_; } | 841 bool nominated() { return nominated_; } |
837 | 842 |
838 private: | 843 private: |
839 rtc::Thread* main_; | 844 rtc::Thread* main_; |
840 std::unique_ptr<rtc::PhysicalSocketServer> pss_; | 845 std::unique_ptr<rtc::PhysicalSocketServer> pss_; |
841 std::unique_ptr<rtc::VirtualSocketServer> vss_; | 846 std::unique_ptr<rtc::VirtualSocketServer> vss_; |
842 std::unique_ptr<rtc::NATSocketServer> nss_; | 847 std::unique_ptr<rtc::NATSocketServer> nss_; |
843 std::unique_ptr<rtc::FirewallSocketServer> ss_; | 848 std::unique_ptr<rtc::FirewallSocketServer> ss_; |
844 rtc::SocketServerScope ss_scope_; | 849 rtc::SocketServerScope ss_scope_; |
845 std::unique_ptr<TestStunServer> stun_server_; | 850 std::unique_ptr<TestStunServer> stun_server_; |
846 TestTurnServer turn_server_; | 851 TestTurnServer turn_server_; |
847 TestRelayServer relay_server_; | 852 TestRelayServer relay_server_; |
848 rtc::SocksProxyServer socks_server1_; | 853 rtc::SocksProxyServer socks_server1_; |
849 rtc::SocksProxyServer socks_server2_; | 854 rtc::SocksProxyServer socks_server2_; |
850 Endpoint ep1_; | 855 Endpoint ep1_; |
851 Endpoint ep2_; | 856 Endpoint ep2_; |
852 RemoteIceCredentialSource remote_ice_credential_source_ = FROM_CANDIDATE; | 857 RemoteIceParameterSource remote_ice_parameter_source_ = FROM_CANDIDATE; |
853 bool force_relay_; | 858 bool force_relay_; |
854 int selected_candidate_pair_switches_ = 0; | 859 int selected_candidate_pair_switches_ = 0; |
855 | 860 |
856 bool nominated_ = false; | 861 bool nominated_ = false; |
857 }; | 862 }; |
858 | 863 |
859 // The tests have only a few outcomes, which we predefine. | 864 // The tests have only a few outcomes, which we predefine. |
860 const P2PTransportChannelTestBase::Result | 865 const P2PTransportChannelTestBase::Result |
861 P2PTransportChannelTestBase::kLocalUdpToLocalUdp("local", | 866 P2PTransportChannelTestBase::kLocalUdpToLocalUdp("local", |
862 "udp", | 867 "udp", |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
968 GetEndpoint(1)->allocator_->AddTurnServer(turn_server); | 973 GetEndpoint(1)->allocator_->AddTurnServer(turn_server); |
969 | 974 |
970 int delay = kMinimumStepDelay; | 975 int delay = kMinimumStepDelay; |
971 ConfigureEndpoint(0, config1); | 976 ConfigureEndpoint(0, config1); |
972 SetAllocatorFlags(0, allocator_flags1); | 977 SetAllocatorFlags(0, allocator_flags1); |
973 SetAllocationStepDelay(0, delay); | 978 SetAllocationStepDelay(0, delay); |
974 ConfigureEndpoint(1, config2); | 979 ConfigureEndpoint(1, config2); |
975 SetAllocatorFlags(1, allocator_flags2); | 980 SetAllocatorFlags(1, allocator_flags2); |
976 SetAllocationStepDelay(1, delay); | 981 SetAllocationStepDelay(1, delay); |
977 | 982 |
978 set_remote_ice_credential_source(FROM_SETICECREDENTIALS); | 983 set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
979 } | 984 } |
980 void ConfigureEndpoint(int endpoint, Config config) { | 985 void ConfigureEndpoint(int endpoint, Config config) { |
981 switch (config) { | 986 switch (config) { |
982 case OPEN: | 987 case OPEN: |
983 AddAddress(endpoint, kPublicAddrs[endpoint]); | 988 AddAddress(endpoint, kPublicAddrs[endpoint]); |
984 break; | 989 break; |
985 case NAT_FULL_CONE: | 990 case NAT_FULL_CONE: |
986 case NAT_ADDR_RESTRICTED: | 991 case NAT_ADDR_RESTRICTED: |
987 case NAT_PORT_RESTRICTED: | 992 case NAT_PORT_RESTRICTED: |
988 case NAT_SYMMETRIC: | 993 case NAT_SYMMETRIC: |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1179 EXPECT_EQ(10 * 36U, best_conn_info->recv_total_bytes); | 1184 EXPECT_EQ(10 * 36U, best_conn_info->recv_total_bytes); |
1180 EXPECT_GT(best_conn_info->rtt, 0U); | 1185 EXPECT_GT(best_conn_info->rtt, 0U); |
1181 DestroyChannels(); | 1186 DestroyChannels(); |
1182 } | 1187 } |
1183 | 1188 |
1184 // Test that we properly create a connection on a STUN ping from unknown address | 1189 // Test that we properly create a connection on a STUN ping from unknown address |
1185 // when the signaling is slow. | 1190 // when the signaling is slow. |
1186 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignaling) { | 1191 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignaling) { |
1187 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1192 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
1188 kDefaultPortAllocatorFlags); | 1193 kDefaultPortAllocatorFlags); |
1189 // Emulate no remote credentials coming in. | 1194 // Emulate no remote parameters coming in. |
1190 set_remote_ice_credential_source(FROM_CANDIDATE); | 1195 set_remote_ice_parameter_source(FROM_CANDIDATE); |
1191 CreateChannels(1); | 1196 CreateChannels(1); |
1192 // Only have remote credentials come in for ep2, not ep1. | 1197 // Only have remote parameters come in for ep2, not ep1. |
1193 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); | 1198 ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); |
1194 | 1199 |
1195 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive | 1200 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive |
1196 // candidate. | 1201 // candidate. |
1197 PauseCandidates(1); | 1202 PauseCandidates(1); |
1198 | 1203 |
1199 // Wait until the callee becomes writable to make sure that a ping request is | 1204 // Wait until the callee becomes writable to make sure that a ping request is |
1200 // received by the caller before his remote ICE credentials are set. | 1205 // received by the caller before his remote ICE credentials are set. |
1201 ASSERT_TRUE_WAIT(ep2_ch1()->selected_connection() != nullptr, 3000); | 1206 ASSERT_TRUE_WAIT(ep2_ch1()->selected_connection() != nullptr, 3000); |
1202 // Add two sets of remote ICE credentials, so that the ones used by the | 1207 // Add two sets of remote ICE credentials, so that the ones used by the |
1203 // candidate will be generation 1 instead of 0. | 1208 // candidate will be generation 1 instead of 0. |
1204 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 1209 ep1_ch1()->SetRemoteIceParameters(kIceParams[3]); |
1205 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 1210 ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); |
1206 // The caller should have the selected connection connected to the peer | 1211 // The caller should have the selected connection connected to the peer |
1207 // reflexive candidate. | 1212 // reflexive candidate. |
1208 const Connection* selected_connection = nullptr; | 1213 const Connection* selected_connection = nullptr; |
1209 ASSERT_TRUE_WAIT( | 1214 ASSERT_TRUE_WAIT( |
1210 (selected_connection = ep1_ch1()->selected_connection()) != nullptr, | 1215 (selected_connection = ep1_ch1()->selected_connection()) != nullptr, |
1211 2000); | 1216 2000); |
1212 EXPECT_EQ("prflx", selected_connection->remote_candidate().type()); | 1217 EXPECT_EQ("prflx", selected_connection->remote_candidate().type()); |
1213 EXPECT_EQ(kIceUfrag[1], selected_connection->remote_candidate().username()); | 1218 EXPECT_EQ(kIceUfrag[1], selected_connection->remote_candidate().username()); |
1214 EXPECT_EQ(kIcePwd[1], selected_connection->remote_candidate().password()); | 1219 EXPECT_EQ(kIcePwd[1], selected_connection->remote_candidate().password()); |
1215 EXPECT_EQ(1u, selected_connection->remote_candidate().generation()); | 1220 EXPECT_EQ(1u, selected_connection->remote_candidate().generation()); |
1216 | 1221 |
1217 ResumeCandidates(1); | 1222 ResumeCandidates(1); |
1218 // Verify ep1's selected connection is updated to use the 'local' candidate. | 1223 // Verify ep1's selected connection is updated to use the 'local' candidate. |
1219 EXPECT_EQ_WAIT("local", | 1224 EXPECT_EQ_WAIT("local", |
1220 ep1_ch1()->selected_connection()->remote_candidate().type(), | 1225 ep1_ch1()->selected_connection()->remote_candidate().type(), |
1221 2000); | 1226 2000); |
1222 EXPECT_EQ(selected_connection, ep1_ch1()->selected_connection()); | 1227 EXPECT_EQ(selected_connection, ep1_ch1()->selected_connection()); |
1223 DestroyChannels(); | 1228 DestroyChannels(); |
1224 } | 1229 } |
1225 | 1230 |
1226 // Test that we properly create a connection on a STUN ping from unknown address | 1231 // Test that we properly create a connection on a STUN ping from unknown address |
1227 // when the signaling is slow and the end points are behind NAT. | 1232 // when the signaling is slow and the end points are behind NAT. |
1228 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) { | 1233 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) { |
1229 ConfigureEndpoints(OPEN, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, | 1234 ConfigureEndpoints(OPEN, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, |
1230 kDefaultPortAllocatorFlags); | 1235 kDefaultPortAllocatorFlags); |
1231 // Emulate no remote credentials coming in. | 1236 // Emulate no remote parameters coming in. |
1232 set_remote_ice_credential_source(FROM_CANDIDATE); | 1237 set_remote_ice_parameter_source(FROM_CANDIDATE); |
1233 CreateChannels(1); | 1238 CreateChannels(1); |
1234 // Only have remote credentials come in for ep2, not ep1. | 1239 // Only have remote parameters come in for ep2, not ep1. |
1235 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); | 1240 ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); |
1236 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive | 1241 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive |
1237 // candidate. | 1242 // candidate. |
1238 PauseCandidates(1); | 1243 PauseCandidates(1); |
1239 | 1244 |
1240 // Wait until the callee becomes writable to make sure that a ping request is | 1245 // Wait until the callee becomes writable to make sure that a ping request is |
1241 // received by the caller before his remote ICE credentials are set. | 1246 // received by the caller before his remote ICE credentials are set. |
1242 ASSERT_TRUE_WAIT(ep2_ch1()->selected_connection() != nullptr, 3000); | 1247 ASSERT_TRUE_WAIT(ep2_ch1()->selected_connection() != nullptr, 3000); |
1243 // Add two sets of remote ICE credentials, so that the ones used by the | 1248 // Add two sets of remote ICE credentials, so that the ones used by the |
1244 // candidate will be generation 1 instead of 0. | 1249 // candidate will be generation 1 instead of 0. |
1245 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 1250 ep1_ch1()->SetRemoteIceParameters(kIceParams[3]); |
1246 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 1251 ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); |
1247 | 1252 |
1248 // The caller's selected connection should be connected to the peer reflexive | 1253 // The caller's selected connection should be connected to the peer reflexive |
1249 // candidate. | 1254 // candidate. |
1250 const Connection* selected_connection = nullptr; | 1255 const Connection* selected_connection = nullptr; |
1251 ASSERT_TRUE_WAIT( | 1256 ASSERT_TRUE_WAIT( |
1252 (selected_connection = ep1_ch1()->selected_connection()) != nullptr, | 1257 (selected_connection = ep1_ch1()->selected_connection()) != nullptr, |
1253 2000); | 1258 2000); |
1254 EXPECT_EQ("prflx", selected_connection->remote_candidate().type()); | 1259 EXPECT_EQ("prflx", selected_connection->remote_candidate().type()); |
1255 EXPECT_EQ(kIceUfrag[1], selected_connection->remote_candidate().username()); | 1260 EXPECT_EQ(kIceUfrag[1], selected_connection->remote_candidate().username()); |
1256 EXPECT_EQ(kIcePwd[1], selected_connection->remote_candidate().password()); | 1261 EXPECT_EQ(kIcePwd[1], selected_connection->remote_candidate().password()); |
(...skipping 18 matching lines...) Expand all Loading... | |
1275 // generations. This resulted in the old-generation prflx candidate being | 1280 // generations. This resulted in the old-generation prflx candidate being |
1276 // prioritized above new-generation candidate pairs. | 1281 // prioritized above new-generation candidate pairs. |
1277 TEST_F(P2PTransportChannelTest, | 1282 TEST_F(P2PTransportChannelTest, |
1278 PeerReflexiveCandidateBeforeSignalingWithIceRestart) { | 1283 PeerReflexiveCandidateBeforeSignalingWithIceRestart) { |
1279 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1284 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
1280 kDefaultPortAllocatorFlags); | 1285 kDefaultPortAllocatorFlags); |
1281 // Only gather relay candidates, so that when the prflx candidate arrives | 1286 // Only gather relay candidates, so that when the prflx candidate arrives |
1282 // it's prioritized above the current candidate pair. | 1287 // it's prioritized above the current candidate pair. |
1283 GetEndpoint(0)->allocator_->set_candidate_filter(CF_RELAY); | 1288 GetEndpoint(0)->allocator_->set_candidate_filter(CF_RELAY); |
1284 GetEndpoint(1)->allocator_->set_candidate_filter(CF_RELAY); | 1289 GetEndpoint(1)->allocator_->set_candidate_filter(CF_RELAY); |
1285 // Setting this allows us to control when SetRemoteIceCredentials is called. | 1290 // Setting this allows us to control when SetRemoteIceParameters is called. |
1286 set_remote_ice_credential_source(FROM_CANDIDATE); | 1291 set_remote_ice_parameter_source(FROM_CANDIDATE); |
1287 CreateChannels(1); | 1292 CreateChannels(1); |
1288 // Wait for the initial connection to be made. | 1293 // Wait for the initial connection to be made. |
1289 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 1294 ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); |
1290 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); | 1295 ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); |
1291 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1296 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1292 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1297 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1293 kDefaultTimeout); | 1298 kDefaultTimeout); |
1294 | 1299 |
1295 // Simulate an ICE restart on ep2, but don't signal the candidate or new | 1300 // Simulate an ICE restart on ep2, but don't signal the candidate or new |
1296 // ICE credentials until after a prflx connection has been made. | 1301 // ICE parameters until after a prflx connection has been made. |
1297 PauseCandidates(1); | 1302 PauseCandidates(1); |
1298 ep2_ch1()->SetIceCredentials(kIceUfrag[3], kIcePwd[3]); | 1303 ep2_ch1()->SetIceParameters(kIceParams[3]); |
1299 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 1304 |
1305 ep1_ch1()->SetRemoteIceParameters(kIceParams[3]); | |
1300 ep2_ch1()->MaybeStartGathering(); | 1306 ep2_ch1()->MaybeStartGathering(); |
1301 | 1307 |
1302 // The caller should have the selected connection connected to the peer | 1308 // The caller should have the selected connection connected to the peer |
1303 // reflexive candidate. | 1309 // reflexive candidate. |
1304 EXPECT_EQ_WAIT("prflx", | 1310 EXPECT_EQ_WAIT("prflx", |
1305 ep1_ch1()->selected_connection()->remote_candidate().type(), | 1311 ep1_ch1()->selected_connection()->remote_candidate().type(), |
1306 kDefaultTimeout); | 1312 kDefaultTimeout); |
1307 const Connection* prflx_selected_connection = | 1313 const Connection* prflx_selected_connection = |
1308 ep1_ch1()->selected_connection(); | 1314 ep1_ch1()->selected_connection(); |
1309 | 1315 |
1310 // Now simulate the ICE restart on ep1. | 1316 // Now simulate the ICE restart on ep1. |
1311 ep1_ch1()->SetIceCredentials(kIceUfrag[2], kIcePwd[2]); | 1317 ep1_ch1()->SetIceParameters(kIceParams[2]); |
1312 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]); | 1318 |
1319 ep2_ch1()->SetRemoteIceParameters(kIceParams[2]); | |
1313 ep1_ch1()->MaybeStartGathering(); | 1320 ep1_ch1()->MaybeStartGathering(); |
1314 | 1321 |
1315 // Finally send the candidates from ep2's ICE restart and verify that ep1 uses | 1322 // Finally send the candidates from ep2's ICE restart and verify that ep1 uses |
1316 // their information to update the peer reflexive candidate. | 1323 // their information to update the peer reflexive candidate. |
1317 ResumeCandidates(1); | 1324 ResumeCandidates(1); |
1318 | 1325 |
1319 EXPECT_EQ_WAIT("relay", | 1326 EXPECT_EQ_WAIT("relay", |
1320 ep1_ch1()->selected_connection()->remote_candidate().type(), | 1327 ep1_ch1()->selected_connection()->remote_candidate().type(), |
1321 kDefaultTimeout); | 1328 kDefaultTimeout); |
1322 EXPECT_EQ(prflx_selected_connection, ep1_ch1()->selected_connection()); | 1329 EXPECT_EQ(prflx_selected_connection, ep1_ch1()->selected_connection()); |
1323 DestroyChannels(); | 1330 DestroyChannels(); |
1324 } | 1331 } |
1325 | 1332 |
1326 // Test that if remote candidates don't have ufrag and pwd, we still work. | 1333 // Test that if remote candidates don't have ufrag and pwd, we still work. |
1327 TEST_F(P2PTransportChannelTest, RemoteCandidatesWithoutUfragPwd) { | 1334 TEST_F(P2PTransportChannelTest, RemoteCandidatesWithoutUfragPwd) { |
1328 set_remote_ice_credential_source(FROM_SETICECREDENTIALS); | 1335 set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
1329 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1336 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
1330 kDefaultPortAllocatorFlags); | 1337 kDefaultPortAllocatorFlags); |
1331 CreateChannels(1); | 1338 CreateChannels(1); |
1332 const Connection* selected_connection = NULL; | 1339 const Connection* selected_connection = NULL; |
1333 // Wait until the callee's connections are created. | 1340 // Wait until the callee's connections are created. |
1334 WAIT((selected_connection = ep2_ch1()->selected_connection()) != NULL, 1000); | 1341 WAIT((selected_connection = ep2_ch1()->selected_connection()) != NULL, 1000); |
1335 // Wait to see if they get culled; they shouldn't. | 1342 // Wait to see if they get culled; they shouldn't. |
1336 WAIT(ep2_ch1()->selected_connection() != selected_connection, 1000); | 1343 WAIT(ep2_ch1()->selected_connection() != selected_connection, 1000); |
1337 EXPECT_TRUE(ep2_ch1()->selected_connection() == selected_connection); | 1344 EXPECT_TRUE(ep2_ch1()->selected_connection() == selected_connection); |
1338 DestroyChannels(); | 1345 DestroyChannels(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1387 int kOnlyLocalTcpPorts = PORTALLOCATOR_DISABLE_UDP | | 1394 int kOnlyLocalTcpPorts = PORTALLOCATOR_DISABLE_UDP | |
1388 PORTALLOCATOR_DISABLE_STUN | | 1395 PORTALLOCATOR_DISABLE_STUN | |
1389 PORTALLOCATOR_DISABLE_RELAY; | 1396 PORTALLOCATOR_DISABLE_RELAY; |
1390 // Disable all protocols except TCP. | 1397 // Disable all protocols except TCP. |
1391 SetAllocatorFlags(0, kOnlyLocalTcpPorts); | 1398 SetAllocatorFlags(0, kOnlyLocalTcpPorts); |
1392 SetAllocatorFlags(1, kOnlyLocalTcpPorts); | 1399 SetAllocatorFlags(1, kOnlyLocalTcpPorts); |
1393 | 1400 |
1394 SetAllowTcpListen(0, true); // actpass. | 1401 SetAllowTcpListen(0, true); // actpass. |
1395 SetAllowTcpListen(1, false); // active. | 1402 SetAllowTcpListen(1, false); // active. |
1396 | 1403 |
1397 // We want SetRemoteIceCredentials to be called as it normally would. | 1404 // We want SetRemoteIceParameters to be called as it normally would. |
1398 // Otherwise we won't know what credentials to use for the expected | 1405 // Otherwise we won't know what parameters to use for the expected |
1399 // prflx TCP candidates. | 1406 // prflx TCP candidates. |
1400 set_remote_ice_credential_source(FROM_SETICECREDENTIALS); | 1407 set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
1401 | 1408 |
1402 // Pause candidate so we could verify the candidate properties. | 1409 // Pause candidate so we could verify the candidate properties. |
1403 PauseCandidates(0); | 1410 PauseCandidates(0); |
1404 PauseCandidates(1); | 1411 PauseCandidates(1); |
1405 CreateChannels(1); | 1412 CreateChannels(1); |
1406 | 1413 |
1407 // Verify tcp candidates. | 1414 // Verify tcp candidates. |
1408 VerifySavedTcpCandidates(0, TCPTYPE_PASSIVE_STR); | 1415 VerifySavedTcpCandidates(0, TCPTYPE_PASSIVE_STR); |
1409 VerifySavedTcpCandidates(1, TCPTYPE_ACTIVE_STR); | 1416 VerifySavedTcpCandidates(1, TCPTYPE_ACTIVE_STR); |
1410 | 1417 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1676 } | 1683 } |
1677 | 1684 |
1678 // Test that when the "presume_writable_when_fully_relayed" flag is set to | 1685 // Test that when the "presume_writable_when_fully_relayed" flag is set to |
1679 // true and there's a TURN-TURN candidate pair, it's presumed to be writable | 1686 // true and there's a TURN-TURN candidate pair, it's presumed to be writable |
1680 // as soon as it's created. | 1687 // as soon as it's created. |
1681 TEST_F(P2PTransportChannelTest, TurnToTurnPresumedWritable) { | 1688 TEST_F(P2PTransportChannelTest, TurnToTurnPresumedWritable) { |
1682 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1689 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
1683 kDefaultPortAllocatorFlags); | 1690 kDefaultPortAllocatorFlags); |
1684 // Only configure one channel so we can control when the remote candidate | 1691 // Only configure one channel so we can control when the remote candidate |
1685 // is added. | 1692 // is added. |
1686 GetEndpoint(0)->cd1_.ch_.reset( | 1693 GetEndpoint(0)->cd1_.ch_.reset(CreateChannel( |
1687 CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[0], | 1694 0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[0], kIceParams[1])); |
1688 kIcePwd[0], kIceUfrag[1], kIcePwd[1])); | |
1689 IceConfig config; | 1695 IceConfig config; |
1690 config.presume_writable_when_fully_relayed = true; | 1696 config.presume_writable_when_fully_relayed = true; |
1691 ep1_ch1()->SetIceConfig(config); | 1697 ep1_ch1()->SetIceConfig(config); |
1692 ep1_ch1()->MaybeStartGathering(); | 1698 ep1_ch1()->MaybeStartGathering(); |
1693 EXPECT_EQ_WAIT(IceGatheringState::kIceGatheringComplete, | 1699 EXPECT_EQ_WAIT(IceGatheringState::kIceGatheringComplete, |
1694 ep1_ch1()->gathering_state(), kDefaultTimeout); | 1700 ep1_ch1()->gathering_state(), kDefaultTimeout); |
1695 // Add two remote candidates; a host candidate (with higher priority) | 1701 // Add two remote candidates; a host candidate (with higher priority) |
1696 // and TURN candidate. | 1702 // and TURN candidate. |
1697 ep1_ch1()->AddRemoteCandidate( | 1703 ep1_ch1()->AddRemoteCandidate( |
1698 CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); | 1704 CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); |
(...skipping 25 matching lines...) Expand all Loading... | |
1724 virtual_socket_server()->UpdateDelayDistribution(); | 1730 virtual_socket_server()->UpdateDelayDistribution(); |
1725 | 1731 |
1726 ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, | 1732 ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, |
1727 kDefaultPortAllocatorFlags); | 1733 kDefaultPortAllocatorFlags); |
1728 // We want the remote TURN candidate to show up as prflx. To do this we need | 1734 // We want the remote TURN candidate to show up as prflx. To do this we need |
1729 // to configure the server to accept packets from an address we haven't | 1735 // to configure the server to accept packets from an address we haven't |
1730 // explicitly installed permission for. | 1736 // explicitly installed permission for. |
1731 test_turn_server()->set_enable_permission_checks(false); | 1737 test_turn_server()->set_enable_permission_checks(false); |
1732 IceConfig config; | 1738 IceConfig config; |
1733 config.presume_writable_when_fully_relayed = true; | 1739 config.presume_writable_when_fully_relayed = true; |
1734 GetEndpoint(0)->cd1_.ch_.reset( | 1740 GetEndpoint(0)->cd1_.ch_.reset(CreateChannel( |
1735 CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[0], | 1741 0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[0], kIceParams[1])); |
1736 kIcePwd[0], kIceUfrag[1], kIcePwd[1])); | 1742 GetEndpoint(1)->cd1_.ch_.reset(CreateChannel( |
1737 GetEndpoint(1)->cd1_.ch_.reset( | 1743 1, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[1], kIceParams[0])); |
1738 CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[1], | |
1739 kIcePwd[1], kIceUfrag[0], kIcePwd[0])); | |
1740 ep1_ch1()->SetIceConfig(config); | 1744 ep1_ch1()->SetIceConfig(config); |
1741 ep2_ch1()->SetIceConfig(config); | 1745 ep2_ch1()->SetIceConfig(config); |
1742 // Don't signal candidates from channel 2, so that channel 1 sees the TURN | 1746 // Don't signal candidates from channel 2, so that channel 1 sees the TURN |
1743 // candidate as peer reflexive. | 1747 // candidate as peer reflexive. |
1744 PauseCandidates(1); | 1748 PauseCandidates(1); |
1745 ep1_ch1()->MaybeStartGathering(); | 1749 ep1_ch1()->MaybeStartGathering(); |
1746 ep2_ch1()->MaybeStartGathering(); | 1750 ep2_ch1()->MaybeStartGathering(); |
1747 | 1751 |
1748 // Wait for the TURN<->prflx connection. | 1752 // Wait for the TURN<->prflx connection. |
1749 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable(), | 1753 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable(), |
(...skipping 15 matching lines...) Expand all Loading... | |
1765 | 1769 |
1766 // Test that a presumed-writable TURN<->TURN connection is preferred above an | 1770 // Test that a presumed-writable TURN<->TURN connection is preferred above an |
1767 // unreliable connection (one that has failed to be pinged for some time). | 1771 // unreliable connection (one that has failed to be pinged for some time). |
1768 TEST_F(P2PTransportChannelTest, PresumedWritablePreferredOverUnreliable) { | 1772 TEST_F(P2PTransportChannelTest, PresumedWritablePreferredOverUnreliable) { |
1769 rtc::ScopedFakeClock fake_clock; | 1773 rtc::ScopedFakeClock fake_clock; |
1770 | 1774 |
1771 ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, | 1775 ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, |
1772 kDefaultPortAllocatorFlags); | 1776 kDefaultPortAllocatorFlags); |
1773 IceConfig config; | 1777 IceConfig config; |
1774 config.presume_writable_when_fully_relayed = true; | 1778 config.presume_writable_when_fully_relayed = true; |
1775 GetEndpoint(0)->cd1_.ch_.reset( | 1779 GetEndpoint(0)->cd1_.ch_.reset(CreateChannel( |
1776 CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[0], | 1780 0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[0], kIceParams[1])); |
1777 kIcePwd[0], kIceUfrag[1], kIcePwd[1])); | 1781 GetEndpoint(1)->cd1_.ch_.reset(CreateChannel( |
1778 GetEndpoint(1)->cd1_.ch_.reset( | 1782 1, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[1], kIceParams[0])); |
1779 CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[1], | |
1780 kIcePwd[1], kIceUfrag[0], kIcePwd[0])); | |
1781 ep1_ch1()->SetIceConfig(config); | 1783 ep1_ch1()->SetIceConfig(config); |
1782 ep2_ch1()->SetIceConfig(config); | 1784 ep2_ch1()->SetIceConfig(config); |
1783 ep1_ch1()->MaybeStartGathering(); | 1785 ep1_ch1()->MaybeStartGathering(); |
1784 ep2_ch1()->MaybeStartGathering(); | 1786 ep2_ch1()->MaybeStartGathering(); |
1785 // Wait for initial connection as usual. | 1787 // Wait for initial connection as usual. |
1786 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1788 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1787 ep1_ch1()->selected_connection()->writable() && | 1789 ep1_ch1()->selected_connection()->writable() && |
1788 ep2_ch1()->receiving() && | 1790 ep2_ch1()->receiving() && |
1789 ep2_ch1()->writable() && | 1791 ep2_ch1()->writable() && |
1790 ep2_ch1()->selected_connection()->writable(), | 1792 ep2_ch1()->selected_connection()->writable(), |
(...skipping 22 matching lines...) Expand all Loading... | |
1813 // address of the outermost NAT. | 1815 // address of the outermost NAT. |
1814 class P2PTransportChannelSameNatTest : public P2PTransportChannelTestBase { | 1816 class P2PTransportChannelSameNatTest : public P2PTransportChannelTestBase { |
1815 protected: | 1817 protected: |
1816 void ConfigureEndpoints(Config nat_type, Config config1, Config config2) { | 1818 void ConfigureEndpoints(Config nat_type, Config config1, Config config2) { |
1817 ASSERT(nat_type >= NAT_FULL_CONE && nat_type <= NAT_SYMMETRIC); | 1819 ASSERT(nat_type >= NAT_FULL_CONE && nat_type <= NAT_SYMMETRIC); |
1818 rtc::NATSocketServer::Translator* outer_nat = | 1820 rtc::NATSocketServer::Translator* outer_nat = |
1819 nat()->AddTranslator(kPublicAddrs[0], kNatAddrs[0], | 1821 nat()->AddTranslator(kPublicAddrs[0], kNatAddrs[0], |
1820 static_cast<rtc::NATType>(nat_type - NAT_FULL_CONE)); | 1822 static_cast<rtc::NATType>(nat_type - NAT_FULL_CONE)); |
1821 ConfigureEndpoint(outer_nat, 0, config1); | 1823 ConfigureEndpoint(outer_nat, 0, config1); |
1822 ConfigureEndpoint(outer_nat, 1, config2); | 1824 ConfigureEndpoint(outer_nat, 1, config2); |
1823 set_remote_ice_credential_source(FROM_SETICECREDENTIALS); | 1825 set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
1824 } | 1826 } |
1825 void ConfigureEndpoint(rtc::NATSocketServer::Translator* nat, | 1827 void ConfigureEndpoint(rtc::NATSocketServer::Translator* nat, |
1826 int endpoint, Config config) { | 1828 int endpoint, Config config) { |
1827 ASSERT(config <= NAT_SYMMETRIC); | 1829 ASSERT(config <= NAT_SYMMETRIC); |
1828 if (config == OPEN) { | 1830 if (config == OPEN) { |
1829 AddAddress(endpoint, kPrivateAddrs[endpoint]); | 1831 AddAddress(endpoint, kPrivateAddrs[endpoint]); |
1830 nat->AddClient(kPrivateAddrs[endpoint]); | 1832 nat->AddClient(kPrivateAddrs[endpoint]); |
1831 } else { | 1833 } else { |
1832 AddAddress(endpoint, kCascadedPrivateAddrs[endpoint]); | 1834 AddAddress(endpoint, kCascadedPrivateAddrs[endpoint]); |
1833 nat->AddTranslator(kPrivateAddrs[endpoint], kCascadedNatAddrs[endpoint], | 1835 nat->AddTranslator(kPrivateAddrs[endpoint], kCascadedNatAddrs[endpoint], |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2009 // Adding alternate address will make sure |kPublicAddrs| has the higher | 2011 // Adding alternate address will make sure |kPublicAddrs| has the higher |
2010 // priority than others. This is due to FakeNetwork::AddInterface method. | 2012 // priority than others. This is due to FakeNetwork::AddInterface method. |
2011 AddAddress(0, kAlternateAddrs[0]); | 2013 AddAddress(0, kAlternateAddrs[0]); |
2012 AddAddress(0, kPublicAddrs[0]); | 2014 AddAddress(0, kPublicAddrs[0]); |
2013 AddAddress(1, kPublicAddrs[1]); | 2015 AddAddress(1, kPublicAddrs[1]); |
2014 | 2016 |
2015 // Use only local ports for simplicity. | 2017 // Use only local ports for simplicity. |
2016 SetAllocatorFlags(0, kOnlyLocalPorts); | 2018 SetAllocatorFlags(0, kOnlyLocalPorts); |
2017 SetAllocatorFlags(1, kOnlyLocalPorts); | 2019 SetAllocatorFlags(1, kOnlyLocalPorts); |
2018 | 2020 |
2019 // Create channels and let them go writable, as usual. | 2021 // We want it to set the remote ICE parameters when creating channels. |
2020 CreateChannels(1); | 2022 set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
2021 ep1_ch1()->set_remote_supports_renomination(true); | 2023 // Create channels with renomination enabled. |
2024 CreateChannels(1, true); | |
2022 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2025 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
2023 ep2_ch1()->receiving() && | 2026 ep2_ch1()->receiving() && |
2024 ep2_ch1()->writable(), | 2027 ep2_ch1()->writable(), |
2025 3000, clock); | 2028 3000, clock); |
2026 EXPECT_TRUE_SIMULATED_WAIT( | 2029 EXPECT_TRUE_SIMULATED_WAIT( |
2027 ep2_ch1()->selected_connection()->remote_nomination() > 0 && | 2030 ep2_ch1()->selected_connection()->remote_nomination() > 0 && |
2028 ep1_ch1()->selected_connection()->acked_nomination() > 0, | 2031 ep1_ch1()->selected_connection()->acked_nomination() > 0, |
2029 kDefaultTimeout, clock); | 2032 kDefaultTimeout, clock); |
2030 const Connection* selected_connection1 = ep1_ch1()->selected_connection(); | 2033 const Connection* selected_connection1 = ep1_ch1()->selected_connection(); |
2031 Connection* selected_connection2 = | 2034 Connection* selected_connection2 = |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2537 public sigslot::has_slots<> { | 2540 public sigslot::has_slots<> { |
2538 public: | 2541 public: |
2539 P2PTransportChannelPingTest() | 2542 P2PTransportChannelPingTest() |
2540 : pss_(new rtc::PhysicalSocketServer), | 2543 : pss_(new rtc::PhysicalSocketServer), |
2541 vss_(new rtc::VirtualSocketServer(pss_.get())), | 2544 vss_(new rtc::VirtualSocketServer(pss_.get())), |
2542 ss_scope_(vss_.get()) {} | 2545 ss_scope_(vss_.get()) {} |
2543 | 2546 |
2544 protected: | 2547 protected: |
2545 void PrepareChannel(P2PTransportChannel* ch) { | 2548 void PrepareChannel(P2PTransportChannel* ch) { |
2546 ch->SetIceRole(ICEROLE_CONTROLLING); | 2549 ch->SetIceRole(ICEROLE_CONTROLLING); |
2547 ch->SetIceCredentials(kIceUfrag[0], kIcePwd[0]); | 2550 ch->SetIceParameters(kIceParams[0]); |
2548 ch->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 2551 ch->SetRemoteIceParameters(kIceParams[1]); |
2549 ch->SignalSelectedCandidatePairChanged.connect( | 2552 ch->SignalSelectedCandidatePairChanged.connect( |
2550 this, &P2PTransportChannelPingTest::OnSelectedCandidatePairChanged); | 2553 this, &P2PTransportChannelPingTest::OnSelectedCandidatePairChanged); |
2551 ch->SignalReadyToSend.connect(this, | 2554 ch->SignalReadyToSend.connect(this, |
2552 &P2PTransportChannelPingTest::OnReadyToSend); | 2555 &P2PTransportChannelPingTest::OnReadyToSend); |
2553 ch->SignalStateChanged.connect( | 2556 ch->SignalStateChanged.connect( |
2554 this, &P2PTransportChannelPingTest::OnChannelStateChanged); | 2557 this, &P2PTransportChannelPingTest::OnChannelStateChanged); |
2555 } | 2558 } |
2556 | 2559 |
2557 Connection* WaitForConnectionTo(P2PTransportChannel* ch, | 2560 Connection* WaitForConnectionTo(P2PTransportChannel* ch, |
2558 const std::string& ip, | 2561 const std::string& ip, |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2817 start = clock.TimeNanos(); | 2820 start = clock.TimeNanos(); |
2818 ping_sent_before = conn->num_pings_sent(); | 2821 ping_sent_before = conn->num_pings_sent(); |
2819 SIMULATED_WAIT(conn->num_pings_sent() == ping_sent_before + 1, 3000, clock); | 2822 SIMULATED_WAIT(conn->num_pings_sent() == ping_sent_before + 1, 3000, clock); |
2820 ping_interval_ms = (clock.TimeNanos() - start) / rtc::kNumNanosecsPerMillisec; | 2823 ping_interval_ms = (clock.TimeNanos() - start) / rtc::kNumNanosecsPerMillisec; |
2821 EXPECT_GE(ping_interval_ms, STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL); | 2824 EXPECT_GE(ping_interval_ms, STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL); |
2822 EXPECT_LE(ping_interval_ms, | 2825 EXPECT_LE(ping_interval_ms, |
2823 STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL + SCHEDULING_RANGE); | 2826 STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL + SCHEDULING_RANGE); |
2824 } | 2827 } |
2825 | 2828 |
2826 // Test that we start pinging as soon as we have a connection and remote ICE | 2829 // Test that we start pinging as soon as we have a connection and remote ICE |
2827 // credentials. | 2830 // parameters. |
2828 TEST_F(P2PTransportChannelPingTest, PingingStartedAsSoonAsPossible) { | 2831 TEST_F(P2PTransportChannelPingTest, PingingStartedAsSoonAsPossible) { |
2829 rtc::ScopedFakeClock clock; | 2832 rtc::ScopedFakeClock clock; |
2830 | 2833 |
2831 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 2834 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
2832 P2PTransportChannel ch("TestChannel", 1, &pa); | 2835 P2PTransportChannel ch("TestChannel", 1, &pa); |
2833 ch.SetIceRole(ICEROLE_CONTROLLING); | 2836 ch.SetIceRole(ICEROLE_CONTROLLING); |
2834 ch.SetIceCredentials(kIceUfrag[0], kIcePwd[0]); | 2837 ch.SetIceParameters(kIceParams[0]); |
2835 ch.MaybeStartGathering(); | 2838 ch.MaybeStartGathering(); |
2836 EXPECT_EQ_WAIT(IceGatheringState::kIceGatheringComplete, ch.gathering_state(), | 2839 EXPECT_EQ_WAIT(IceGatheringState::kIceGatheringComplete, ch.gathering_state(), |
2837 kDefaultTimeout); | 2840 kDefaultTimeout); |
2838 | 2841 |
2839 // Simulate a binding request being received, creating a peer reflexive | 2842 // Simulate a binding request being received, creating a peer reflexive |
2840 // candidate pair while we still don't have remote ICE credentials. | 2843 // candidate pair while we still don't have remote ICE parameters. |
2841 IceMessage request; | 2844 IceMessage request; |
2842 request.SetType(STUN_BINDING_REQUEST); | 2845 request.SetType(STUN_BINDING_REQUEST); |
2843 request.AddAttribute( | 2846 request.AddAttribute( |
2844 new StunByteStringAttribute(STUN_ATTR_USERNAME, kIceUfrag[1])); | 2847 new StunByteStringAttribute(STUN_ATTR_USERNAME, kIceUfrag[1])); |
2845 uint32_t prflx_priority = ICE_TYPE_PREFERENCE_PRFLX << 24; | 2848 uint32_t prflx_priority = ICE_TYPE_PREFERENCE_PRFLX << 24; |
2846 request.AddAttribute( | 2849 request.AddAttribute( |
2847 new StunUInt32Attribute(STUN_ATTR_PRIORITY, prflx_priority)); | 2850 new StunUInt32Attribute(STUN_ATTR_PRIORITY, prflx_priority)); |
2848 Port* port = GetPort(&ch); | 2851 Port* port = GetPort(&ch); |
2849 ASSERT_NE(nullptr, port); | 2852 ASSERT_NE(nullptr, port); |
2850 port->SignalUnknownAddress(port, rtc::SocketAddress("1.1.1.1", 1), PROTO_UDP, | 2853 port->SignalUnknownAddress(port, rtc::SocketAddress("1.1.1.1", 1), PROTO_UDP, |
2851 &request, kIceUfrag[1], false); | 2854 &request, kIceUfrag[1], false); |
2852 Connection* conn = GetConnectionTo(&ch, "1.1.1.1", 1); | 2855 Connection* conn = GetConnectionTo(&ch, "1.1.1.1", 1); |
2853 ASSERT_NE(nullptr, conn); | 2856 ASSERT_NE(nullptr, conn); |
2854 | 2857 |
2855 // Simulate waiting for a second (and change) and verify that no pings were | 2858 // Simulate waiting for a second (and change) and verify that no pings were |
2856 // sent, since we don't yet have remote ICE credentials. | 2859 // sent, since we don't yet have remote ICE parameters. |
2857 SIMULATED_WAIT(conn->num_pings_sent() > 0, 1025, clock); | 2860 SIMULATED_WAIT(conn->num_pings_sent() > 0, 1025, clock); |
2858 EXPECT_EQ(0, conn->num_pings_sent()); | 2861 EXPECT_EQ(0, conn->num_pings_sent()); |
2859 | 2862 |
2860 // Set remote ICE credentials. Now we should be able to ping. Ensure that | 2863 // Set remote ICE parameters. Now we should be able to ping. Ensure that |
2861 // the first ping is sent as soon as possible, within one simulated clock | 2864 // the first ping is sent as soon as possible, within one simulated clock |
2862 // tick. | 2865 // tick. |
2863 ch.SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 2866 ch.SetRemoteIceParameters(kIceParams[1]); |
2864 EXPECT_TRUE_SIMULATED_WAIT(conn->num_pings_sent() > 0, 1, clock); | 2867 EXPECT_TRUE_SIMULATED_WAIT(conn->num_pings_sent() > 0, 1, clock); |
2865 } | 2868 } |
2866 | 2869 |
2867 TEST_F(P2PTransportChannelPingTest, TestNoTriggeredChecksWhenWritable) { | 2870 TEST_F(P2PTransportChannelPingTest, TestNoTriggeredChecksWhenWritable) { |
2868 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 2871 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
2869 P2PTransportChannel ch("trigger checks", 1, &pa); | 2872 P2PTransportChannel ch("trigger checks", 1, &pa); |
2870 PrepareChannel(&ch); | 2873 PrepareChannel(&ch); |
2871 ch.MaybeStartGathering(); | 2874 ch.MaybeStartGathering(); |
2872 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); | 2875 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); |
2873 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 2)); | 2876 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... | |
2917 // Pruning the connection reduces the set of active connections and changes | 2920 // Pruning the connection reduces the set of active connections and changes |
2918 // the channel state. | 2921 // the channel state. |
2919 conn1->Prune(); | 2922 conn1->Prune(); |
2920 EXPECT_EQ_WAIT(STATE_FAILED, channel_state(), kDefaultTimeout); | 2923 EXPECT_EQ_WAIT(STATE_FAILED, channel_state(), kDefaultTimeout); |
2921 } | 2924 } |
2922 | 2925 |
2923 // Test adding remote candidates with different ufrags. If a remote candidate | 2926 // Test adding remote candidates with different ufrags. If a remote candidate |
2924 // is added with an old ufrag, it will be discarded. If it is added with a | 2927 // is added with an old ufrag, it will be discarded. If it is added with a |
2925 // ufrag that was not seen before, it will be used to create connections | 2928 // ufrag that was not seen before, it will be used to create connections |
2926 // although the ICE pwd in the remote candidate will be set when the ICE | 2929 // although the ICE pwd in the remote candidate will be set when the ICE |
2927 // credentials arrive. If a remote candidate is added with the current ICE | 2930 // parameters arrive. If a remote candidate is added with the current ICE |
2928 // ufrag, its pwd and generation will be set properly. | 2931 // ufrag, its pwd and generation will be set properly. |
2929 TEST_F(P2PTransportChannelPingTest, TestAddRemoteCandidateWithVariousUfrags) { | 2932 TEST_F(P2PTransportChannelPingTest, TestAddRemoteCandidateWithVariousUfrags) { |
2930 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 2933 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
2931 P2PTransportChannel ch("add candidate", 1, &pa); | 2934 P2PTransportChannel ch("add candidate", 1, &pa); |
2932 PrepareChannel(&ch); | 2935 PrepareChannel(&ch); |
2933 ch.MaybeStartGathering(); | 2936 ch.MaybeStartGathering(); |
2934 // Add a candidate with a future ufrag. | 2937 // Add a candidate with a future ufrag. |
2935 ch.AddRemoteCandidate( | 2938 ch.AddRemoteCandidate( |
2936 CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1, kIceUfrag[2])); | 2939 CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1, kIceUfrag[2])); |
2937 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 2940 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
2938 ASSERT_TRUE(conn1 != nullptr); | 2941 ASSERT_TRUE(conn1 != nullptr); |
2939 const Candidate& candidate = conn1->remote_candidate(); | 2942 const Candidate& candidate = conn1->remote_candidate(); |
2940 EXPECT_EQ(kIceUfrag[2], candidate.username()); | 2943 EXPECT_EQ(kIceUfrag[2], candidate.username()); |
2941 EXPECT_TRUE(candidate.password().empty()); | 2944 EXPECT_TRUE(candidate.password().empty()); |
2942 EXPECT_TRUE(FindNextPingableConnectionAndPingIt(&ch) == nullptr); | 2945 EXPECT_TRUE(FindNextPingableConnectionAndPingIt(&ch) == nullptr); |
2943 | 2946 |
2944 // Set the remote credentials with the "future" ufrag. | 2947 // Set the remote ICE parameters with the "future" ufrag. |
2945 // This should set the ICE pwd in the remote candidate of |conn1|, making | 2948 // This should set the ICE pwd in the remote candidate of |conn1|, making |
2946 // it pingable. | 2949 // it pingable. |
2947 ch.SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]); | 2950 ch.SetRemoteIceParameters(kIceParams[2]); |
2948 EXPECT_EQ(kIceUfrag[2], candidate.username()); | 2951 EXPECT_EQ(kIceUfrag[2], candidate.username()); |
2949 EXPECT_EQ(kIcePwd[2], candidate.password()); | 2952 EXPECT_EQ(kIcePwd[2], candidate.password()); |
2950 EXPECT_EQ(conn1, FindNextPingableConnectionAndPingIt(&ch)); | 2953 EXPECT_EQ(conn1, FindNextPingableConnectionAndPingIt(&ch)); |
2951 | 2954 |
2952 // Add a candidate with an old ufrag. No connection will be created. | 2955 // Add a candidate with an old ufrag. No connection will be created. |
2953 ch.AddRemoteCandidate( | 2956 ch.AddRemoteCandidate( |
2954 CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 2, kIceUfrag[1])); | 2957 CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 2, kIceUfrag[1])); |
2955 rtc::Thread::Current()->ProcessMessages(500); | 2958 rtc::Thread::Current()->ProcessMessages(500); |
2956 EXPECT_TRUE(GetConnectionTo(&ch, "2.2.2.2", 2) == nullptr); | 2959 EXPECT_TRUE(GetConnectionTo(&ch, "2.2.2.2", 2) == nullptr); |
2957 | 2960 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3197 ASSERT_TRUE(conn4 != nullptr); | 3200 ASSERT_TRUE(conn4 != nullptr); |
3198 EXPECT_TRUE(port->sent_binding_response()); | 3201 EXPECT_TRUE(port->sent_binding_response()); |
3199 // conn4 is not the selected connection yet because it is not writable. | 3202 // conn4 is not the selected connection yet because it is not writable. |
3200 EXPECT_EQ(conn2, ch.selected_connection()); | 3203 EXPECT_EQ(conn2, ch.selected_connection()); |
3201 conn4->ReceivedPingResponse(LOW_RTT, "id"); // Become writable. | 3204 conn4->ReceivedPingResponse(LOW_RTT, "id"); // Become writable. |
3202 EXPECT_EQ_WAIT(conn4, ch.selected_connection(), kDefaultTimeout); | 3205 EXPECT_EQ_WAIT(conn4, ch.selected_connection(), kDefaultTimeout); |
3203 | 3206 |
3204 // Test that the request from an unknown address contains a ufrag from an old | 3207 // Test that the request from an unknown address contains a ufrag from an old |
3205 // generation. | 3208 // generation. |
3206 port->set_sent_binding_response(false); | 3209 port->set_sent_binding_response(false); |
3207 ch.SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]); | 3210 ch.SetRemoteIceParameters(kIceParams[2]); |
3208 ch.SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 3211 ch.SetRemoteIceParameters(kIceParams[3]); |
3209 port->SignalUnknownAddress(port, rtc::SocketAddress("5.5.5.5", 5), PROTO_UDP, | 3212 port->SignalUnknownAddress(port, rtc::SocketAddress("5.5.5.5", 5), PROTO_UDP, |
3210 &request, kIceUfrag[2], false); | 3213 &request, kIceUfrag[2], false); |
3211 Connection* conn5 = WaitForConnectionTo(&ch, "5.5.5.5", 5); | 3214 Connection* conn5 = WaitForConnectionTo(&ch, "5.5.5.5", 5); |
3212 ASSERT_TRUE(conn5 != nullptr); | 3215 ASSERT_TRUE(conn5 != nullptr); |
3213 EXPECT_TRUE(port->sent_binding_response()); | 3216 EXPECT_TRUE(port->sent_binding_response()); |
3214 EXPECT_EQ(kIcePwd[2], conn5->remote_candidate().password()); | 3217 EXPECT_EQ(kIcePwd[2], conn5->remote_candidate().password()); |
3215 } | 3218 } |
3216 | 3219 |
3217 // The controlled side will select a connection as the "selected connection" | 3220 // The controlled side will select a connection as the "selected connection" |
3218 // based on media received until the controlling side nominates a connection, | 3221 // based on media received until the controlling side nominates a connection, |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3668 ch.MaybeStartGathering(); | 3671 ch.MaybeStartGathering(); |
3669 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); | 3672 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); |
3670 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 3673 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
3671 ASSERT_TRUE(conn1 != nullptr); | 3674 ASSERT_TRUE(conn1 != nullptr); |
3672 conn1->ReceivedPingResponse(LOW_RTT, "id"); // Becomes writable and receiving | 3675 conn1->ReceivedPingResponse(LOW_RTT, "id"); // Becomes writable and receiving |
3673 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); | 3676 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); |
3674 | 3677 |
3675 // Start a new session. Even though conn1, which belongs to an older | 3678 // Start a new session. Even though conn1, which belongs to an older |
3676 // session, becomes unwritable and writable again, it should not stop the | 3679 // session, becomes unwritable and writable again, it should not stop the |
3677 // current session. | 3680 // current session. |
3678 ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]); | 3681 ch.SetIceParameters(kIceParams[1]); |
3679 ch.MaybeStartGathering(); | 3682 ch.MaybeStartGathering(); |
3680 conn1->Prune(); | 3683 conn1->Prune(); |
3681 conn1->ReceivedPingResponse(LOW_RTT, "id"); | 3684 conn1->ReceivedPingResponse(LOW_RTT, "id"); |
3682 EXPECT_TRUE(ch.allocator_session()->IsGettingPorts()); | 3685 EXPECT_TRUE(ch.allocator_session()->IsGettingPorts()); |
3683 | 3686 |
3684 // But if a new connection created from the new session becomes writable, | 3687 // But if a new connection created from the new session becomes writable, |
3685 // it will stop the current session. | 3688 // it will stop the current session. |
3686 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 100)); | 3689 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 100)); |
3687 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 3690 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
3688 ASSERT_TRUE(conn2 != nullptr); | 3691 ASSERT_TRUE(conn2 != nullptr); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3724 // Starts with ICEROLE_CONTROLLING. | 3727 // Starts with ICEROLE_CONTROLLING. |
3725 PrepareChannel(&ch); | 3728 PrepareChannel(&ch); |
3726 ch.MaybeStartGathering(); | 3729 ch.MaybeStartGathering(); |
3727 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); | 3730 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); |
3728 | 3731 |
3729 Connection* conn = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 3732 Connection* conn = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
3730 ASSERT_TRUE(conn != nullptr); | 3733 ASSERT_TRUE(conn != nullptr); |
3731 | 3734 |
3732 // Do an ICE restart, change the role, and expect the old port to have its | 3735 // Do an ICE restart, change the role, and expect the old port to have its |
3733 // role updated. | 3736 // role updated. |
3734 ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]); | 3737 ch.SetIceParameters(kIceParams[1]); |
3735 ch.MaybeStartGathering(); | 3738 ch.MaybeStartGathering(); |
3736 ch.SetIceRole(ICEROLE_CONTROLLED); | 3739 ch.SetIceRole(ICEROLE_CONTROLLED); |
3737 EXPECT_EQ(ICEROLE_CONTROLLED, conn->port()->GetIceRole()); | 3740 EXPECT_EQ(ICEROLE_CONTROLLED, conn->port()->GetIceRole()); |
3738 } | 3741 } |
3739 | 3742 |
3740 // Test that after some amount of time without receiving data, the connection | 3743 // Test that after some amount of time without receiving data, the connection |
3741 // will be destroyed. The port will only be destroyed after it is marked as | 3744 // will be destroyed. The port will only be destroyed after it is marked as |
3742 // "pruned." | 3745 // "pruned." |
3743 TEST_F(P2PTransportChannelPingTest, TestPortDestroyedAfterTimeoutAndPruned) { | 3746 TEST_F(P2PTransportChannelPingTest, TestPortDestroyedAfterTimeoutAndPruned) { |
3744 rtc::ScopedFakeClock fake_clock; | 3747 rtc::ScopedFakeClock fake_clock; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3974 | 3977 |
3975 // TCP Relay/Relay is the next. | 3978 // TCP Relay/Relay is the next. |
3976 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, | 3979 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, |
3977 TCP_PROTOCOL_NAME); | 3980 TCP_PROTOCOL_NAME); |
3978 | 3981 |
3979 // Finally, Local/Relay will be pinged. | 3982 // Finally, Local/Relay will be pinged. |
3980 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); | 3983 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); |
3981 } | 3984 } |
3982 | 3985 |
3983 } // namespace cricket { | 3986 } // namespace cricket { |
OLD | NEW |