| 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 14 matching lines...) Expand all Loading... |
| 25 #include "webrtc/base/physicalsocketserver.h" | 25 #include "webrtc/base/physicalsocketserver.h" |
| 26 #include "webrtc/base/proxyserver.h" | 26 #include "webrtc/base/proxyserver.h" |
| 27 #include "webrtc/base/socketaddress.h" | 27 #include "webrtc/base/socketaddress.h" |
| 28 #include "webrtc/base/ssladapter.h" | 28 #include "webrtc/base/ssladapter.h" |
| 29 #include "webrtc/base/thread.h" | 29 #include "webrtc/base/thread.h" |
| 30 #include "webrtc/base/virtualsocketserver.h" | 30 #include "webrtc/base/virtualsocketserver.h" |
| 31 | 31 |
| 32 using cricket::kDefaultPortAllocatorFlags; | 32 using cricket::kDefaultPortAllocatorFlags; |
| 33 using cricket::kMinimumStepDelay; | 33 using cricket::kMinimumStepDelay; |
| 34 using cricket::kDefaultStepDelay; | 34 using cricket::kDefaultStepDelay; |
| 35 using cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG; | |
| 36 using cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET; | 35 using cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET; |
| 37 using cricket::ServerAddresses; | 36 using cricket::ServerAddresses; |
| 38 using rtc::SocketAddress; | 37 using rtc::SocketAddress; |
| 39 | 38 |
| 40 static const int kDefaultTimeout = 1000; | 39 static const int kDefaultTimeout = 1000; |
| 41 static const int kOnlyLocalPorts = cricket::PORTALLOCATOR_DISABLE_STUN | | 40 static const int kOnlyLocalPorts = cricket::PORTALLOCATOR_DISABLE_STUN | |
| 42 cricket::PORTALLOCATOR_DISABLE_RELAY | | 41 cricket::PORTALLOCATOR_DISABLE_RELAY | |
| 43 cricket::PORTALLOCATOR_DISABLE_TCP; | 42 cricket::PORTALLOCATOR_DISABLE_TCP; |
| 44 // Addresses on the public internet. | 43 // Addresses on the public internet. |
| 45 static const SocketAddress kPublicAddrs[2] = | 44 static const SocketAddress kPublicAddrs[2] = |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 209 } |
| 211 cricket::TransportChannel* channel; | 210 cricket::TransportChannel* channel; |
| 212 cricket::Candidate candidate; | 211 cricket::Candidate candidate; |
| 213 }; | 212 }; |
| 214 | 213 |
| 215 struct Endpoint { | 214 struct Endpoint { |
| 216 Endpoint() | 215 Endpoint() |
| 217 : role_(cricket::ICEROLE_UNKNOWN), | 216 : role_(cricket::ICEROLE_UNKNOWN), |
| 218 tiebreaker_(0), | 217 tiebreaker_(0), |
| 219 role_conflict_(false), | 218 role_conflict_(false), |
| 220 save_candidates_(false), | 219 save_candidates_(false) {} |
| 221 protocol_type_(cricket::ICEPROTO_GOOGLE) {} | |
| 222 bool HasChannel(cricket::TransportChannel* ch) { | 220 bool HasChannel(cricket::TransportChannel* ch) { |
| 223 return (ch == cd1_.ch_.get() || ch == cd2_.ch_.get()); | 221 return (ch == cd1_.ch_.get() || ch == cd2_.ch_.get()); |
| 224 } | 222 } |
| 225 ChannelData* GetChannelData(cricket::TransportChannel* ch) { | 223 ChannelData* GetChannelData(cricket::TransportChannel* ch) { |
| 226 if (!HasChannel(ch)) return NULL; | 224 if (!HasChannel(ch)) return NULL; |
| 227 if (cd1_.ch_.get() == ch) | 225 if (cd1_.ch_.get() == ch) |
| 228 return &cd1_; | 226 return &cd1_; |
| 229 else | 227 else |
| 230 return &cd2_; | 228 return &cd2_; |
| 231 } | 229 } |
| 232 | 230 |
| 233 void SetIceRole(cricket::IceRole role) { role_ = role; } | 231 void SetIceRole(cricket::IceRole role) { role_ = role; } |
| 234 cricket::IceRole ice_role() { return role_; } | 232 cricket::IceRole ice_role() { return role_; } |
| 235 void SetIceProtocolType(cricket::IceProtocolType type) { | |
| 236 protocol_type_ = type; | |
| 237 } | |
| 238 cricket::IceProtocolType protocol_type() { return protocol_type_; } | |
| 239 void SetIceTiebreaker(uint64 tiebreaker) { tiebreaker_ = tiebreaker; } | 233 void SetIceTiebreaker(uint64 tiebreaker) { tiebreaker_ = tiebreaker; } |
| 240 uint64 GetIceTiebreaker() { return tiebreaker_; } | 234 uint64 GetIceTiebreaker() { return tiebreaker_; } |
| 241 void OnRoleConflict(bool role_conflict) { role_conflict_ = role_conflict; } | 235 void OnRoleConflict(bool role_conflict) { role_conflict_ = role_conflict; } |
| 242 bool role_conflict() { return role_conflict_; } | 236 bool role_conflict() { return role_conflict_; } |
| 243 void SetAllocationStepDelay(uint32 delay) { | 237 void SetAllocationStepDelay(uint32 delay) { |
| 244 allocator_->set_step_delay(delay); | 238 allocator_->set_step_delay(delay); |
| 245 } | 239 } |
| 246 void SetAllowTcpListen(bool allow_tcp_listen) { | 240 void SetAllowTcpListen(bool allow_tcp_listen) { |
| 247 allocator_->set_allow_tcp_listen(allow_tcp_listen); | 241 allocator_->set_allow_tcp_listen(allow_tcp_listen); |
| 248 } | 242 } |
| 249 | 243 |
| 250 rtc::FakeNetworkManager network_manager_; | 244 rtc::FakeNetworkManager network_manager_; |
| 251 rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; | 245 rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; |
| 252 ChannelData cd1_; | 246 ChannelData cd1_; |
| 253 ChannelData cd2_; | 247 ChannelData cd2_; |
| 254 cricket::IceRole role_; | 248 cricket::IceRole role_; |
| 255 uint64 tiebreaker_; | 249 uint64 tiebreaker_; |
| 256 bool role_conflict_; | 250 bool role_conflict_; |
| 257 bool save_candidates_; | 251 bool save_candidates_; |
| 258 cricket::IceProtocolType protocol_type_; | |
| 259 std::vector<CandidateData*> saved_candidates_; | 252 std::vector<CandidateData*> saved_candidates_; |
| 260 }; | 253 }; |
| 261 | 254 |
| 262 ChannelData* GetChannelData(cricket::TransportChannel* channel) { | 255 ChannelData* GetChannelData(cricket::TransportChannel* channel) { |
| 263 if (ep1_.HasChannel(channel)) | 256 if (ep1_.HasChannel(channel)) |
| 264 return ep1_.GetChannelData(channel); | 257 return ep1_.GetChannelData(channel); |
| 265 else | 258 else |
| 266 return ep2_.GetChannelData(channel); | 259 return ep2_.GetChannelData(channel); |
| 267 } | 260 } |
| 268 | 261 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 cricket::P2PTransportChannel* channel = new cricket::P2PTransportChannel( | 297 cricket::P2PTransportChannel* channel = new cricket::P2PTransportChannel( |
| 305 "test content name", component, NULL, GetAllocator(endpoint)); | 298 "test content name", component, NULL, GetAllocator(endpoint)); |
| 306 channel->SignalRequestSignaling.connect( | 299 channel->SignalRequestSignaling.connect( |
| 307 this, &P2PTransportChannelTestBase::OnChannelRequestSignaling); | 300 this, &P2PTransportChannelTestBase::OnChannelRequestSignaling); |
| 308 channel->SignalCandidateReady.connect(this, | 301 channel->SignalCandidateReady.connect(this, |
| 309 &P2PTransportChannelTestBase::OnCandidate); | 302 &P2PTransportChannelTestBase::OnCandidate); |
| 310 channel->SignalReadPacket.connect( | 303 channel->SignalReadPacket.connect( |
| 311 this, &P2PTransportChannelTestBase::OnReadPacket); | 304 this, &P2PTransportChannelTestBase::OnReadPacket); |
| 312 channel->SignalRoleConflict.connect( | 305 channel->SignalRoleConflict.connect( |
| 313 this, &P2PTransportChannelTestBase::OnRoleConflict); | 306 this, &P2PTransportChannelTestBase::OnRoleConflict); |
| 314 channel->SetIceProtocolType(GetEndpoint(endpoint)->protocol_type()); | |
| 315 channel->SetIceCredentials(local_ice_ufrag, local_ice_pwd); | 307 channel->SetIceCredentials(local_ice_ufrag, local_ice_pwd); |
| 316 if (clear_remote_candidates_ufrag_pwd_) { | 308 if (clear_remote_candidates_ufrag_pwd_) { |
| 317 // This only needs to be set if we're clearing them from the | 309 // This only needs to be set if we're clearing them from the |
| 318 // candidates. Some unit tests rely on this not being set. | 310 // candidates. Some unit tests rely on this not being set. |
| 319 channel->SetRemoteIceCredentials(remote_ice_ufrag, remote_ice_pwd); | 311 channel->SetRemoteIceCredentials(remote_ice_ufrag, remote_ice_pwd); |
| 320 } | 312 } |
| 321 channel->SetIceRole(GetEndpoint(endpoint)->ice_role()); | 313 channel->SetIceRole(GetEndpoint(endpoint)->ice_role()); |
| 322 channel->SetIceTiebreaker(GetEndpoint(endpoint)->GetIceTiebreaker()); | 314 channel->SetIceTiebreaker(GetEndpoint(endpoint)->GetIceTiebreaker()); |
| 323 channel->Connect(); | 315 channel->Connect(); |
| 324 return channel; | 316 return channel; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 void SetProxy(int endpoint, rtc::ProxyType type) { | 364 void SetProxy(int endpoint, rtc::ProxyType type) { |
| 373 rtc::ProxyInfo info; | 365 rtc::ProxyInfo info; |
| 374 info.type = type; | 366 info.type = type; |
| 375 info.address = (type == rtc::PROXY_HTTPS) ? | 367 info.address = (type == rtc::PROXY_HTTPS) ? |
| 376 kHttpsProxyAddrs[endpoint] : kSocksProxyAddrs[endpoint]; | 368 kHttpsProxyAddrs[endpoint] : kSocksProxyAddrs[endpoint]; |
| 377 GetAllocator(endpoint)->set_proxy("unittest/1.0", info); | 369 GetAllocator(endpoint)->set_proxy("unittest/1.0", info); |
| 378 } | 370 } |
| 379 void SetAllocatorFlags(int endpoint, int flags) { | 371 void SetAllocatorFlags(int endpoint, int flags) { |
| 380 GetAllocator(endpoint)->set_flags(flags); | 372 GetAllocator(endpoint)->set_flags(flags); |
| 381 } | 373 } |
| 382 void SetIceProtocol(int endpoint, cricket::IceProtocolType type) { | |
| 383 GetEndpoint(endpoint)->SetIceProtocolType(type); | |
| 384 } | |
| 385 void SetIceRole(int endpoint, cricket::IceRole role) { | 374 void SetIceRole(int endpoint, cricket::IceRole role) { |
| 386 GetEndpoint(endpoint)->SetIceRole(role); | 375 GetEndpoint(endpoint)->SetIceRole(role); |
| 387 } | 376 } |
| 388 void SetIceTiebreaker(int endpoint, uint64 tiebreaker) { | 377 void SetIceTiebreaker(int endpoint, uint64 tiebreaker) { |
| 389 GetEndpoint(endpoint)->SetIceTiebreaker(tiebreaker); | 378 GetEndpoint(endpoint)->SetIceTiebreaker(tiebreaker); |
| 390 } | 379 } |
| 391 bool GetRoleConflict(int endpoint) { | 380 bool GetRoleConflict(int endpoint) { |
| 392 return GetEndpoint(endpoint)->role_conflict(); | 381 return GetEndpoint(endpoint)->role_conflict(); |
| 393 } | 382 } |
| 394 void SetAllocationStepDelay(int endpoint, uint32 delay) { | 383 void SetAllocationStepDelay(int endpoint, uint32 delay) { |
| 395 return GetEndpoint(endpoint)->SetAllocationStepDelay(delay); | 384 return GetEndpoint(endpoint)->SetAllocationStepDelay(delay); |
| 396 } | 385 } |
| 397 void SetAllowTcpListen(int endpoint, bool allow_tcp_listen) { | 386 void SetAllowTcpListen(int endpoint, bool allow_tcp_listen) { |
| 398 return GetEndpoint(endpoint)->SetAllowTcpListen(allow_tcp_listen); | 387 return GetEndpoint(endpoint)->SetAllowTcpListen(allow_tcp_listen); |
| 399 } | 388 } |
| 400 | 389 |
| 390 bool CandidateTypesEqual(const std::string& type1, |
| 391 const std::string& type2) { |
| 392 // "prflx" is just as good as "local". |
| 393 return (type1 == type2) || (type1 == "local" && type2 == "prflx") |
| 394 || (type2 == "local" && type1 == "prflx"); |
| 395 } |
| 396 |
| 397 bool LocalCandidateTypeEquals( |
| 398 cricket::P2PTransportChannel* ch, const std::string& type) { |
| 399 return CandidateTypesEqual(LocalCandidate(ch)->type(), type); |
| 400 } |
| 401 |
| 402 bool RemoteCandidateTypeEquals( |
| 403 cricket::P2PTransportChannel* ch, const std::string& type) { |
| 404 return CandidateTypesEqual(RemoteCandidate(ch)->type(), type); |
| 405 } |
| 406 |
| 401 void Test(const Result& expected) { | 407 void Test(const Result& expected) { |
| 402 int32 connect_start = rtc::Time(), connect_time; | 408 int32 connect_start = rtc::Time(), connect_time; |
| 403 | 409 |
| 404 // Create the channels and wait for them to connect. | 410 // Create the channels and wait for them to connect. |
| 405 CreateChannels(1); | 411 CreateChannels(1); |
| 406 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && | 412 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && |
| 407 ep2_ch1() != NULL && | 413 ep2_ch1() != NULL && |
| 408 ep1_ch1()->readable() && | 414 ep1_ch1()->readable() && |
| 409 ep1_ch1()->writable() && | 415 ep1_ch1()->writable() && |
| 410 ep2_ch1()->readable() && | 416 ep2_ch1()->readable() && |
| 411 ep2_ch1()->writable(), | 417 ep2_ch1()->writable(), |
| 412 expected.connect_wait, | 418 expected.connect_wait, |
| 413 1000); | 419 1000); |
| 414 connect_time = rtc::TimeSince(connect_start); | 420 connect_time = rtc::TimeSince(connect_start); |
| 415 if (connect_time < expected.connect_wait) { | 421 if (connect_time < expected.connect_wait) { |
| 416 LOG(LS_INFO) << "Connect time: " << connect_time << " ms"; | 422 LOG(LS_INFO) << "Connect time: " << connect_time << " ms"; |
| 417 } else { | 423 } else { |
| 418 LOG(LS_INFO) << "Connect time: " << "TIMEOUT (" | 424 LOG(LS_INFO) << "Connect time: " << "TIMEOUT (" |
| 419 << expected.connect_wait << " ms)"; | 425 << expected.connect_wait << " ms)"; |
| 420 } | 426 } |
| 421 | 427 |
| 422 // Allow a few turns of the crank for the best connections to emerge. | 428 // Allow a few turns of the crank for the best connections to emerge. |
| 423 // This may take up to 2 seconds. | 429 // This may take up to 2 seconds. |
| 424 if (ep1_ch1()->best_connection() && | 430 if (ep1_ch1()->best_connection() && |
| 425 ep2_ch1()->best_connection()) { | 431 ep2_ch1()->best_connection()) { |
| 426 int32 converge_start = rtc::Time(), converge_time; | 432 int32 converge_start = rtc::Time(), converge_time; |
| 427 int converge_wait = 2000; | 433 int converge_wait = 2000; |
| 428 EXPECT_TRUE_WAIT_MARGIN( | 434 EXPECT_TRUE_WAIT_MARGIN( |
| 429 LocalCandidate(ep1_ch1())->type() == expected.local_type && | 435 LocalCandidateTypeEquals(ep1_ch1(), expected.local_type) && |
| 430 LocalCandidate(ep1_ch1())->protocol() == expected.local_proto && | 436 LocalCandidate(ep1_ch1())->protocol() == expected.local_proto && |
| 431 RemoteCandidate(ep1_ch1())->type() == expected.remote_type && | 437 RemoteCandidateTypeEquals(ep1_ch1(), expected.remote_type) && |
| 432 RemoteCandidate(ep1_ch1())->protocol() == expected.remote_proto, | 438 RemoteCandidate(ep1_ch1())->protocol() == expected.remote_proto, |
| 433 converge_wait, | 439 converge_wait, |
| 434 converge_wait); | 440 converge_wait); |
| 435 | 441 |
| 436 // Also do EXPECT_EQ on each part so that failures are more verbose. | 442 // Also do EXPECT_EQ on each part so that failures are more verbose. |
| 437 EXPECT_EQ(expected.local_type, LocalCandidate(ep1_ch1())->type()); | 443 EXPECT_TRUE(LocalCandidateTypeEquals(ep1_ch1(), expected.local_type)); |
| 438 EXPECT_EQ(expected.local_proto, LocalCandidate(ep1_ch1())->protocol()); | 444 EXPECT_EQ(expected.local_proto, LocalCandidate(ep1_ch1())->protocol()); |
| 439 EXPECT_EQ(expected.remote_type, RemoteCandidate(ep1_ch1())->type()); | 445 EXPECT_TRUE(RemoteCandidateTypeEquals(ep1_ch1(), expected.remote_type)); |
| 440 EXPECT_EQ(expected.remote_proto, RemoteCandidate(ep1_ch1())->protocol()); | 446 EXPECT_EQ(expected.remote_proto, RemoteCandidate(ep1_ch1())->protocol()); |
| 441 | 447 |
| 442 // Verifying remote channel best connection information. This is done | 448 // Verifying remote channel best connection information. This is done |
| 443 // only for the RFC 5245 as controlled agent will use USE-CANDIDATE | 449 // only for the RFC 5245 as controlled agent will use USE-CANDIDATE |
| 444 // from controlling (ep1) agent. We can easily predict from EP1 result | 450 // from controlling (ep1) agent. We can easily predict from EP1 result |
| 445 // matrix. | 451 // matrix. |
| 446 if (ep2_.protocol_type_ == cricket::ICEPROTO_RFC5245) { | |
| 447 // Checking for best connection candidates information at remote. | |
| 448 EXPECT_TRUE_WAIT( | |
| 449 LocalCandidate(ep2_ch1())->type() == expected.local_type2 && | |
| 450 LocalCandidate(ep2_ch1())->protocol() == expected.local_proto2 && | |
| 451 RemoteCandidate(ep2_ch1())->protocol() == expected.remote_proto2, | |
| 452 kDefaultTimeout); | |
| 453 | 452 |
| 454 // For verbose | 453 // Checking for best connection candidates information at remote. |
| 455 EXPECT_EQ(expected.local_type2, LocalCandidate(ep2_ch1())->type()); | 454 EXPECT_TRUE_WAIT( |
| 456 EXPECT_EQ(expected.local_proto2, LocalCandidate(ep2_ch1())->protocol()); | 455 LocalCandidateTypeEquals(ep2_ch1(), expected.local_type2) && |
| 457 EXPECT_EQ(expected.remote_proto2, | 456 LocalCandidate(ep2_ch1())->protocol() == expected.local_proto2 && |
| 458 RemoteCandidate(ep2_ch1())->protocol()); | 457 RemoteCandidate(ep2_ch1())->protocol() == expected.remote_proto2, |
| 459 // Removed remote_type comparision aginst best connection remote | 458 kDefaultTimeout); |
| 460 // candidate. This is done to handle remote type discrepancy from | 459 |
| 461 // local to stun based on the test type. | 460 // For verbose |
| 462 // For example in case of Open -> NAT, ep2 channels will have LULU | 461 EXPECT_TRUE(LocalCandidateTypeEquals(ep2_ch1(), expected.local_type2)); |
| 463 // and in other cases like NAT -> NAT it will be LUSU. To avoid these | 462 EXPECT_EQ(expected.local_proto2, LocalCandidate(ep2_ch1())->protocol()); |
| 464 // mismatches and we are doing comparision in different way. | 463 EXPECT_EQ(expected.remote_proto2, |
| 465 // i.e. when don't match its remote type is either local or stun. | 464 RemoteCandidate(ep2_ch1())->protocol()); |
| 466 // TODO(ronghuawu): Refine the test criteria. | 465 // Removed remote_type comparision aginst best connection remote |
| 467 // https://code.google.com/p/webrtc/issues/detail?id=1953 | 466 // candidate. This is done to handle remote type discrepancy from |
| 468 if (expected.remote_type2 != RemoteCandidate(ep2_ch1())->type()) { | 467 // local to stun based on the test type. |
| 469 EXPECT_TRUE(expected.remote_type2 == cricket::LOCAL_PORT_TYPE || | 468 // For example in case of Open -> NAT, ep2 channels will have LULU |
| 470 expected.remote_type2 == cricket::STUN_PORT_TYPE); | 469 // and in other cases like NAT -> NAT it will be LUSU. To avoid these |
| 471 EXPECT_TRUE( | 470 // mismatches and we are doing comparision in different way. |
| 472 RemoteCandidate(ep2_ch1())->type() == cricket::LOCAL_PORT_TYPE || | 471 // i.e. when don't match its remote type is either local or stun. |
| 473 RemoteCandidate(ep2_ch1())->type() == cricket::STUN_PORT_TYPE || | 472 // TODO(ronghuawu): Refine the test criteria. |
| 474 RemoteCandidate(ep2_ch1())->type() == cricket::PRFLX_PORT_TYPE); | 473 // https://code.google.com/p/webrtc/issues/detail?id=1953 |
| 475 } | 474 if (!RemoteCandidateTypeEquals(ep2_ch1(), expected.remote_type2)) { |
| 475 EXPECT_TRUE(expected.remote_type2 == cricket::LOCAL_PORT_TYPE || |
| 476 expected.remote_type2 == cricket::STUN_PORT_TYPE); |
| 477 EXPECT_TRUE( |
| 478 RemoteCandidate(ep2_ch1())->type() == cricket::LOCAL_PORT_TYPE || |
| 479 RemoteCandidate(ep2_ch1())->type() == cricket::STUN_PORT_TYPE || |
| 480 RemoteCandidate(ep2_ch1())->type() == cricket::PRFLX_PORT_TYPE); |
| 476 } | 481 } |
| 477 | 482 |
| 478 converge_time = rtc::TimeSince(converge_start); | 483 converge_time = rtc::TimeSince(converge_start); |
| 479 if (converge_time < converge_wait) { | 484 if (converge_time < converge_wait) { |
| 480 LOG(LS_INFO) << "Converge time: " << converge_time << " ms"; | 485 LOG(LS_INFO) << "Converge time: " << converge_time << " ms"; |
| 481 } else { | 486 } else { |
| 482 LOG(LS_INFO) << "Converge time: " << "TIMEOUT (" | 487 LOG(LS_INFO) << "Converge time: " << "TIMEOUT (" |
| 483 << converge_wait << " ms)"; | 488 << converge_wait << " ms)"; |
| 484 } | 489 } |
| 485 } | 490 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 old_remote_candidate1->generation(), | 548 old_remote_candidate1->generation(), |
| 544 1000, 1000); | 549 1000, 1000); |
| 545 EXPECT_TRUE_WAIT_MARGIN(RemoteCandidate(ep2_ch1())->generation() != | 550 EXPECT_TRUE_WAIT_MARGIN(RemoteCandidate(ep2_ch1())->generation() != |
| 546 old_remote_candidate2->generation(), | 551 old_remote_candidate2->generation(), |
| 547 1000, 1000); | 552 1000, 1000); |
| 548 EXPECT_EQ(1u, RemoteCandidate(ep2_ch1())->generation()); | 553 EXPECT_EQ(1u, RemoteCandidate(ep2_ch1())->generation()); |
| 549 EXPECT_EQ(1u, RemoteCandidate(ep1_ch1())->generation()); | 554 EXPECT_EQ(1u, RemoteCandidate(ep1_ch1())->generation()); |
| 550 } | 555 } |
| 551 | 556 |
| 552 void TestSignalRoleConflict() { | 557 void TestSignalRoleConflict() { |
| 553 SetIceProtocol(0, cricket::ICEPROTO_RFC5245); | |
| 554 SetIceTiebreaker(0, kTiebreaker1); // Default EP1 is in controlling state. | 558 SetIceTiebreaker(0, kTiebreaker1); // Default EP1 is in controlling state. |
| 555 | 559 |
| 556 SetIceProtocol(1, cricket::ICEPROTO_RFC5245); | |
| 557 SetIceRole(1, cricket::ICEROLE_CONTROLLING); | 560 SetIceRole(1, cricket::ICEROLE_CONTROLLING); |
| 558 SetIceTiebreaker(1, kTiebreaker2); | 561 SetIceTiebreaker(1, kTiebreaker2); |
| 559 | 562 |
| 560 // Creating channels with both channels role set to CONTROLLING. | 563 // Creating channels with both channels role set to CONTROLLING. |
| 561 CreateChannels(1); | 564 CreateChannels(1); |
| 562 // Since both the channels initiated with controlling state and channel2 | 565 // Since both the channels initiated with controlling state and channel2 |
| 563 // has higher tiebreaker value, channel1 should receive SignalRoleConflict. | 566 // has higher tiebreaker value, channel1 should receive SignalRoleConflict. |
| 564 EXPECT_TRUE_WAIT(GetRoleConflict(0), 1000); | 567 EXPECT_TRUE_WAIT(GetRoleConflict(0), 1000); |
| 565 EXPECT_FALSE(GetRoleConflict(1)); | 568 EXPECT_FALSE(GetRoleConflict(1)); |
| 566 | 569 |
| 567 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && | 570 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && |
| 568 ep1_ch1()->writable() && | 571 ep1_ch1()->writable() && |
| 569 ep2_ch1()->readable() && | 572 ep2_ch1()->readable() && |
| 570 ep2_ch1()->writable(), | 573 ep2_ch1()->writable(), |
| 571 1000); | 574 1000); |
| 572 | 575 |
| 573 EXPECT_TRUE(ep1_ch1()->best_connection() && | 576 EXPECT_TRUE(ep1_ch1()->best_connection() && |
| 574 ep2_ch1()->best_connection()); | 577 ep2_ch1()->best_connection()); |
| 575 | 578 |
| 576 TestSendRecv(1); | 579 TestSendRecv(1); |
| 577 } | 580 } |
| 578 | 581 |
| 579 void TestHybridConnectivity(cricket::IceProtocolType proto) { | |
| 580 AddAddress(0, kPublicAddrs[0]); | |
| 581 AddAddress(1, kPublicAddrs[1]); | |
| 582 | |
| 583 SetAllocationStepDelay(0, kMinimumStepDelay); | |
| 584 SetAllocationStepDelay(1, kMinimumStepDelay); | |
| 585 | |
| 586 SetIceRole(0, cricket::ICEROLE_CONTROLLING); | |
| 587 SetIceProtocol(0, cricket::ICEPROTO_HYBRID); | |
| 588 SetIceTiebreaker(0, kTiebreaker1); | |
| 589 SetIceRole(1, cricket::ICEROLE_CONTROLLED); | |
| 590 SetIceProtocol(1, proto); | |
| 591 SetIceTiebreaker(1, kTiebreaker2); | |
| 592 | |
| 593 CreateChannels(1); | |
| 594 // When channel is in hybrid and it's controlling agent, channel will | |
| 595 // receive ping request from the remote. Hence connection is readable. | |
| 596 // Since channel is in hybrid, it will not send any pings, so no writable | |
| 597 // connection. Since channel2 is in controlled state, it will not have | |
| 598 // any connections which are readable or writable, as it didn't received | |
| 599 // pings (or none) with USE-CANDIDATE attribute. | |
| 600 EXPECT_TRUE_WAIT(ep1_ch1()->readable(), 1000); | |
| 601 | |
| 602 // Set real protocol type. | |
| 603 ep1_ch1()->SetIceProtocolType(proto); | |
| 604 | |
| 605 // Channel should able to send ping requests and connections become writable | |
| 606 // in both directions. | |
| 607 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && ep1_ch1()->writable() && | |
| 608 ep2_ch1()->readable() && ep2_ch1()->writable(), | |
| 609 1000); | |
| 610 EXPECT_TRUE( | |
| 611 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | |
| 612 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | |
| 613 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | |
| 614 | |
| 615 TestSendRecv(1); | |
| 616 DestroyChannels(); | |
| 617 } | |
| 618 | |
| 619 void OnChannelRequestSignaling(cricket::TransportChannelImpl* channel) { | 582 void OnChannelRequestSignaling(cricket::TransportChannelImpl* channel) { |
| 620 channel->OnSignalingReady(); | 583 channel->OnSignalingReady(); |
| 621 } | 584 } |
| 622 // We pass the candidates directly to the other side. | 585 // We pass the candidates directly to the other side. |
| 623 void OnCandidate(cricket::TransportChannelImpl* ch, | 586 void OnCandidate(cricket::TransportChannelImpl* ch, |
| 624 const cricket::Candidate& c) { | 587 const cricket::Candidate& c) { |
| 625 if (force_relay_ && c.type() != cricket::RELAY_PORT_TYPE) | 588 if (force_relay_ && c.type() != cricket::RELAY_PORT_TYPE) |
| 626 return; | 589 return; |
| 627 | 590 |
| 628 if (GetEndpoint(ch)->save_candidates_) { | 591 if (GetEndpoint(ch)->save_candidates_) { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 | 751 |
| 789 // Test the matrix of all the connectivity types we expect to see in the wild. | 752 // Test the matrix of all the connectivity types we expect to see in the wild. |
| 790 // Just test every combination of the configs in the Config enum. | 753 // Just test every combination of the configs in the Config enum. |
| 791 class P2PTransportChannelTest : public P2PTransportChannelTestBase { | 754 class P2PTransportChannelTest : public P2PTransportChannelTestBase { |
| 792 protected: | 755 protected: |
| 793 static const Result* kMatrix[NUM_CONFIGS][NUM_CONFIGS]; | 756 static const Result* kMatrix[NUM_CONFIGS][NUM_CONFIGS]; |
| 794 static const Result* kMatrixSharedUfrag[NUM_CONFIGS][NUM_CONFIGS]; | 757 static const Result* kMatrixSharedUfrag[NUM_CONFIGS][NUM_CONFIGS]; |
| 795 static const Result* kMatrixSharedSocketAsGice[NUM_CONFIGS][NUM_CONFIGS]; | 758 static const Result* kMatrixSharedSocketAsGice[NUM_CONFIGS][NUM_CONFIGS]; |
| 796 static const Result* kMatrixSharedSocketAsIce[NUM_CONFIGS][NUM_CONFIGS]; | 759 static const Result* kMatrixSharedSocketAsIce[NUM_CONFIGS][NUM_CONFIGS]; |
| 797 void ConfigureEndpoints(Config config1, Config config2, | 760 void ConfigureEndpoints(Config config1, Config config2, |
| 798 int allocator_flags1, int allocator_flags2, | 761 int allocator_flags1, int allocator_flags2) { |
| 799 int delay1, int delay2, | |
| 800 cricket::IceProtocolType type) { | |
| 801 // Ideally we want to use TURN server for both GICE and ICE, but in case | |
| 802 // of GICE, TURN server usage is not producing results reliabally. | |
| 803 // TODO(mallinath): Remove Relay and use TURN server for all tests. | |
| 804 ServerAddresses stun_servers; | 762 ServerAddresses stun_servers; |
| 805 stun_servers.insert(kStunAddr); | 763 stun_servers.insert(kStunAddr); |
| 806 GetEndpoint(0)->allocator_.reset( | 764 GetEndpoint(0)->allocator_.reset( |
| 807 new cricket::BasicPortAllocator(&(GetEndpoint(0)->network_manager_), | 765 new cricket::BasicPortAllocator(&(GetEndpoint(0)->network_manager_), |
| 808 stun_servers, | 766 stun_servers, |
| 809 rtc::SocketAddress(), rtc::SocketAddress(), | 767 rtc::SocketAddress(), rtc::SocketAddress(), |
| 810 rtc::SocketAddress())); | 768 rtc::SocketAddress())); |
| 811 GetEndpoint(1)->allocator_.reset( | 769 GetEndpoint(1)->allocator_.reset( |
| 812 new cricket::BasicPortAllocator(&(GetEndpoint(1)->network_manager_), | 770 new cricket::BasicPortAllocator(&(GetEndpoint(1)->network_manager_), |
| 813 stun_servers, | 771 stun_servers, |
| 814 rtc::SocketAddress(), rtc::SocketAddress(), | 772 rtc::SocketAddress(), rtc::SocketAddress(), |
| 815 rtc::SocketAddress())); | 773 rtc::SocketAddress())); |
| 816 | 774 |
| 817 cricket::RelayServerConfig relay_server(cricket::RELAY_GTURN); | 775 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); |
| 818 if (type == cricket::ICEPROTO_RFC5245) { | 776 relay_server.credentials = kRelayCredentials; |
| 819 relay_server.type = cricket::RELAY_TURN; | 777 relay_server.ports.push_back(cricket::ProtocolAddress( |
| 820 relay_server.credentials = kRelayCredentials; | 778 kTurnUdpIntAddr, cricket::PROTO_UDP, false)); |
| 821 relay_server.ports.push_back(cricket::ProtocolAddress( | |
| 822 kTurnUdpIntAddr, cricket::PROTO_UDP, false)); | |
| 823 } else { | |
| 824 relay_server.ports.push_back(cricket::ProtocolAddress( | |
| 825 kRelayUdpIntAddr, cricket::PROTO_UDP, false)); | |
| 826 relay_server.ports.push_back(cricket::ProtocolAddress( | |
| 827 kRelayTcpIntAddr, cricket::PROTO_TCP, false)); | |
| 828 relay_server.ports.push_back(cricket::ProtocolAddress( | |
| 829 kRelaySslTcpIntAddr, cricket::PROTO_SSLTCP, false)); | |
| 830 } | |
| 831 GetEndpoint(0)->allocator_->AddRelay(relay_server); | 779 GetEndpoint(0)->allocator_->AddRelay(relay_server); |
| 832 GetEndpoint(1)->allocator_->AddRelay(relay_server); | 780 GetEndpoint(1)->allocator_->AddRelay(relay_server); |
| 833 | 781 |
| 834 ConfigureEndpoint(0, config1); | 782 ConfigureEndpoint(0, config1); |
| 835 SetIceProtocol(0, type); | |
| 836 SetAllocatorFlags(0, allocator_flags1); | 783 SetAllocatorFlags(0, allocator_flags1); |
| 837 SetAllocationStepDelay(0, delay1); | 784 SetAllocationStepDelay(0, kMinimumStepDelay); |
| 838 ConfigureEndpoint(1, config2); | 785 ConfigureEndpoint(1, config2); |
| 839 SetIceProtocol(1, type); | |
| 840 SetAllocatorFlags(1, allocator_flags2); | 786 SetAllocatorFlags(1, allocator_flags2); |
| 841 SetAllocationStepDelay(1, delay2); | 787 SetAllocationStepDelay(1, kMinimumStepDelay); |
| 842 | 788 |
| 843 if (type == cricket::ICEPROTO_RFC5245) { | 789 set_clear_remote_candidates_ufrag_pwd(true); |
| 844 set_clear_remote_candidates_ufrag_pwd(true); | |
| 845 } | |
| 846 } | 790 } |
| 847 void ConfigureEndpoint(int endpoint, Config config) { | 791 void ConfigureEndpoint(int endpoint, Config config) { |
| 848 switch (config) { | 792 switch (config) { |
| 849 case OPEN: | 793 case OPEN: |
| 850 AddAddress(endpoint, kPublicAddrs[endpoint]); | 794 AddAddress(endpoint, kPublicAddrs[endpoint]); |
| 851 break; | 795 break; |
| 852 case NAT_FULL_CONE: | 796 case NAT_FULL_CONE: |
| 853 case NAT_ADDR_RESTRICTED: | 797 case NAT_ADDR_RESTRICTED: |
| 854 case NAT_PORT_RESTRICTED: | 798 case NAT_PORT_RESTRICTED: |
| 855 case NAT_SYMMETRIC: | 799 case NAT_SYMMETRIC: |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 /*SC*/ {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL, LTRT}, | 971 /*SC*/ {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL, LTRT}, |
| 1028 /*!U*/ {PTLT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTPT, LSRS, NULL, LTRT}, | 972 /*!U*/ {PTLT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTPT, LSRS, NULL, LTRT}, |
| 1029 /*!T*/ {LTRT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTRT, LSRS, NULL, LTRT}, | 973 /*!T*/ {LTRT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTRT, LSRS, NULL, LTRT}, |
| 1030 /*HT*/ {LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, NULL, LSRS}, | 974 /*HT*/ {LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, NULL, LSRS}, |
| 1031 /*PR*/ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, | 975 /*PR*/ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, |
| 1032 /*PR*/ {LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LSRS, NULL, LTRT}, | 976 /*PR*/ {LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LSRS, NULL, LTRT}, |
| 1033 }; | 977 }; |
| 1034 | 978 |
| 1035 // The actual tests that exercise all the various configurations. | 979 // The actual tests that exercise all the various configurations. |
| 1036 // Test names are of the form P2PTransportChannelTest_TestOPENToNAT_FULL_CONE | 980 // Test names are of the form P2PTransportChannelTest_TestOPENToNAT_FULL_CONE |
| 1037 // Same test case is run in both GICE and ICE mode. | |
| 1038 // kDefaultStepDelay - is used for all Gice cases. | |
| 1039 // kMinimumStepDelay - is used when both end points have | |
| 1040 // PORTALLOCATOR_ENABLE_SHARED_UFRAG flag enabled. | |
| 1041 // Technically we should be able to use kMinimumStepDelay irrespective of | |
| 1042 // protocol type. But which might need modifications to current result matrices | |
| 1043 // for tests in this file. | |
| 1044 #define P2P_TEST_DECLARATION(x, y, z) \ | 981 #define P2P_TEST_DECLARATION(x, y, z) \ |
| 1045 TEST_F(P2PTransportChannelTest, z##Test##x##To##y##AsGiceNoneSharedUfrag) { \ | 982 TEST_F(P2PTransportChannelTest, z##Test##x##To##y) { \ |
| 1046 ConfigureEndpoints(x, y, kDefaultPortAllocatorFlags, \ | 983 ConfigureEndpoints(x, y, \ |
| 1047 kDefaultPortAllocatorFlags, \ | |
| 1048 kDefaultStepDelay, kDefaultStepDelay, \ | |
| 1049 cricket::ICEPROTO_GOOGLE); \ | |
| 1050 if (kMatrix[x][y] != NULL) \ | |
| 1051 Test(*kMatrix[x][y]); \ | |
| 1052 else \ | |
| 1053 LOG(LS_WARNING) << "Not yet implemented"; \ | |
| 1054 } \ | |
| 1055 TEST_F(P2PTransportChannelTest, z##Test##x##To##y##AsGiceP0SharedUfrag) { \ | |
| 1056 ConfigureEndpoints(x, y, PORTALLOCATOR_ENABLE_SHARED_UFRAG, \ | |
| 1057 kDefaultPortAllocatorFlags, \ | |
| 1058 kDefaultStepDelay, kDefaultStepDelay, \ | |
| 1059 cricket::ICEPROTO_GOOGLE); \ | |
| 1060 if (kMatrix[x][y] != NULL) \ | |
| 1061 Test(*kMatrix[x][y]); \ | |
| 1062 else \ | |
| 1063 LOG(LS_WARNING) << "Not yet implemented"; \ | |
| 1064 } \ | |
| 1065 TEST_F(P2PTransportChannelTest, z##Test##x##To##y##AsGiceP1SharedUfrag) { \ | |
| 1066 ConfigureEndpoints(x, y, kDefaultPortAllocatorFlags, \ | |
| 1067 PORTALLOCATOR_ENABLE_SHARED_UFRAG, \ | |
| 1068 kDefaultStepDelay, kDefaultStepDelay, \ | |
| 1069 cricket::ICEPROTO_GOOGLE); \ | |
| 1070 if (kMatrixSharedUfrag[x][y] != NULL) \ | |
| 1071 Test(*kMatrixSharedUfrag[x][y]); \ | |
| 1072 else \ | |
| 1073 LOG(LS_WARNING) << "Not yet implemented"; \ | |
| 1074 } \ | |
| 1075 TEST_F(P2PTransportChannelTest, z##Test##x##To##y##AsGiceBothSharedUfrag) { \ | |
| 1076 ConfigureEndpoints(x, y, PORTALLOCATOR_ENABLE_SHARED_UFRAG, \ | |
| 1077 PORTALLOCATOR_ENABLE_SHARED_UFRAG, \ | |
| 1078 kDefaultStepDelay, kDefaultStepDelay, \ | |
| 1079 cricket::ICEPROTO_GOOGLE); \ | |
| 1080 if (kMatrixSharedUfrag[x][y] != NULL) \ | |
| 1081 Test(*kMatrixSharedUfrag[x][y]); \ | |
| 1082 else \ | |
| 1083 LOG(LS_WARNING) << "Not yet implemented"; \ | |
| 1084 } \ | |
| 1085 TEST_F(P2PTransportChannelTest, \ | |
| 1086 z##Test##x##To##y##AsGiceBothSharedUfragWithMinimumStepDelay) { \ | |
| 1087 ConfigureEndpoints(x, y, PORTALLOCATOR_ENABLE_SHARED_UFRAG, \ | |
| 1088 PORTALLOCATOR_ENABLE_SHARED_UFRAG, \ | |
| 1089 kMinimumStepDelay, kMinimumStepDelay, \ | |
| 1090 cricket::ICEPROTO_GOOGLE); \ | |
| 1091 if (kMatrixSharedUfrag[x][y] != NULL) \ | |
| 1092 Test(*kMatrixSharedUfrag[x][y]); \ | |
| 1093 else \ | |
| 1094 LOG(LS_WARNING) << "Not yet implemented"; \ | |
| 1095 } \ | |
| 1096 TEST_F(P2PTransportChannelTest, \ | |
| 1097 z##Test##x##To##y##AsGiceBothSharedUfragSocket) { \ | |
| 1098 ConfigureEndpoints(x, y, PORTALLOCATOR_ENABLE_SHARED_UFRAG | \ | |
| 1099 PORTALLOCATOR_ENABLE_SHARED_SOCKET, \ | 984 PORTALLOCATOR_ENABLE_SHARED_SOCKET, \ |
| 1100 PORTALLOCATOR_ENABLE_SHARED_UFRAG | \ | 985 PORTALLOCATOR_ENABLE_SHARED_SOCKET); \ |
| 1101 PORTALLOCATOR_ENABLE_SHARED_SOCKET, \ | |
| 1102 kMinimumStepDelay, kMinimumStepDelay, \ | |
| 1103 cricket::ICEPROTO_GOOGLE); \ | |
| 1104 if (kMatrixSharedSocketAsGice[x][y] != NULL) \ | |
| 1105 Test(*kMatrixSharedSocketAsGice[x][y]); \ | |
| 1106 else \ | |
| 1107 LOG(LS_WARNING) << "Not yet implemented"; \ | |
| 1108 } \ | |
| 1109 TEST_F(P2PTransportChannelTest, z##Test##x##To##y##AsIce) { \ | |
| 1110 ConfigureEndpoints(x, y, PORTALLOCATOR_ENABLE_SHARED_UFRAG | \ | |
| 1111 PORTALLOCATOR_ENABLE_SHARED_SOCKET, \ | |
| 1112 PORTALLOCATOR_ENABLE_SHARED_UFRAG | \ | |
| 1113 PORTALLOCATOR_ENABLE_SHARED_SOCKET, \ | |
| 1114 kMinimumStepDelay, kMinimumStepDelay, \ | |
| 1115 cricket::ICEPROTO_RFC5245); \ | |
| 1116 if (kMatrixSharedSocketAsIce[x][y] != NULL) \ | 986 if (kMatrixSharedSocketAsIce[x][y] != NULL) \ |
| 1117 Test(*kMatrixSharedSocketAsIce[x][y]); \ | 987 Test(*kMatrixSharedSocketAsIce[x][y]); \ |
| 1118 else \ | 988 else \ |
| 1119 LOG(LS_WARNING) << "Not yet implemented"; \ | 989 LOG(LS_WARNING) << "Not yet implemented"; \ |
| 1120 } | 990 } |
| 1121 | 991 |
| 1122 #define P2P_TEST(x, y) \ | 992 #define P2P_TEST(x, y) \ |
| 1123 P2P_TEST_DECLARATION(x, y,) | 993 P2P_TEST_DECLARATION(x, y,) |
| 1124 | 994 |
| 1125 #define FLAKY_P2P_TEST(x, y) \ | 995 #define FLAKY_P2P_TEST(x, y) \ |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 P2P_TEST_SET(NAT_DOUBLE_CONE) | 1033 P2P_TEST_SET(NAT_DOUBLE_CONE) |
| 1164 P2P_TEST_SET(NAT_SYMMETRIC_THEN_CONE) | 1034 P2P_TEST_SET(NAT_SYMMETRIC_THEN_CONE) |
| 1165 P2P_TEST_SET(BLOCK_UDP) | 1035 P2P_TEST_SET(BLOCK_UDP) |
| 1166 P2P_TEST_SET(BLOCK_UDP_AND_INCOMING_TCP) | 1036 P2P_TEST_SET(BLOCK_UDP_AND_INCOMING_TCP) |
| 1167 P2P_TEST_SET(BLOCK_ALL_BUT_OUTGOING_HTTP) | 1037 P2P_TEST_SET(BLOCK_ALL_BUT_OUTGOING_HTTP) |
| 1168 P2P_TEST_SET(PROXY_HTTPS) | 1038 P2P_TEST_SET(PROXY_HTTPS) |
| 1169 P2P_TEST_SET(PROXY_SOCKS) | 1039 P2P_TEST_SET(PROXY_SOCKS) |
| 1170 | 1040 |
| 1171 // Test that we restart candidate allocation when local ufrag&pwd changed. | 1041 // Test that we restart candidate allocation when local ufrag&pwd changed. |
| 1172 // Standard Ice protocol is used. | 1042 // Standard Ice protocol is used. |
| 1173 TEST_F(P2PTransportChannelTest, HandleUfragPwdChangeAsIce) { | 1043 TEST_F(P2PTransportChannelTest, HandleUfragPwdChange) { |
| 1174 ConfigureEndpoints(OPEN, OPEN, | 1044 ConfigureEndpoints(OPEN, OPEN, |
| 1175 PORTALLOCATOR_ENABLE_SHARED_UFRAG, | 1045 kDefaultPortAllocatorFlags, |
| 1176 PORTALLOCATOR_ENABLE_SHARED_UFRAG, | 1046 kDefaultPortAllocatorFlags); |
| 1177 kMinimumStepDelay, kMinimumStepDelay, | |
| 1178 cricket::ICEPROTO_RFC5245); | |
| 1179 CreateChannels(1); | 1047 CreateChannels(1); |
| 1180 TestHandleIceUfragPasswordChanged(); | 1048 TestHandleIceUfragPasswordChanged(); |
| 1181 DestroyChannels(); | 1049 DestroyChannels(); |
| 1182 } | |
| 1183 | |
| 1184 // Test that we restart candidate allocation when local ufrag&pwd changed. | |
| 1185 // Google Ice protocol is used. | |
| 1186 TEST_F(P2PTransportChannelTest, HandleUfragPwdChangeAsGice) { | |
| 1187 ConfigureEndpoints(OPEN, OPEN, | |
| 1188 PORTALLOCATOR_ENABLE_SHARED_UFRAG, | |
| 1189 PORTALLOCATOR_ENABLE_SHARED_UFRAG, | |
| 1190 kDefaultStepDelay, kDefaultStepDelay, | |
| 1191 cricket::ICEPROTO_GOOGLE); | |
| 1192 CreateChannels(1); | |
| 1193 TestHandleIceUfragPasswordChanged(); | |
| 1194 DestroyChannels(); | |
| 1195 } | 1050 } |
| 1196 | 1051 |
| 1197 // Test the operation of GetStats. | 1052 // Test the operation of GetStats. |
| 1198 TEST_F(P2PTransportChannelTest, GetStats) { | 1053 TEST_F(P2PTransportChannelTest, GetStats) { |
| 1199 ConfigureEndpoints(OPEN, OPEN, | 1054 ConfigureEndpoints(OPEN, OPEN, |
| 1200 kDefaultPortAllocatorFlags, | 1055 kDefaultPortAllocatorFlags, |
| 1201 kDefaultPortAllocatorFlags, | 1056 kDefaultPortAllocatorFlags); |
| 1202 kDefaultStepDelay, kDefaultStepDelay, | |
| 1203 cricket::ICEPROTO_GOOGLE); | |
| 1204 CreateChannels(1); | 1057 CreateChannels(1); |
| 1205 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->readable() && ep1_ch1()->writable() && | 1058 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->readable() && ep1_ch1()->writable() && |
| 1206 ep2_ch1()->readable() && ep2_ch1()->writable(), | 1059 ep2_ch1()->readable() && ep2_ch1()->writable(), |
| 1207 1000, 1000); | 1060 1000, 1000); |
| 1208 TestSendRecv(1); | 1061 TestSendRecv(1); |
| 1209 cricket::ConnectionInfos infos; | 1062 cricket::ConnectionInfos infos; |
| 1210 ASSERT_TRUE(ep1_ch1()->GetStats(&infos)); | 1063 ASSERT_TRUE(ep1_ch1()->GetStats(&infos)); |
| 1211 ASSERT_EQ(1U, infos.size()); | 1064 ASSERT_EQ(1U, infos.size()); |
| 1212 EXPECT_TRUE(infos[0].new_connection); | 1065 EXPECT_TRUE(infos[0].new_connection); |
| 1213 EXPECT_TRUE(infos[0].best_connection); | 1066 EXPECT_TRUE(infos[0].best_connection); |
| 1214 EXPECT_TRUE(infos[0].readable); | 1067 EXPECT_TRUE(infos[0].readable); |
| 1215 EXPECT_TRUE(infos[0].writable); | 1068 EXPECT_TRUE(infos[0].writable); |
| 1216 EXPECT_FALSE(infos[0].timeout); | 1069 EXPECT_FALSE(infos[0].timeout); |
| 1217 EXPECT_EQ(10U, infos[0].sent_total_packets); | 1070 EXPECT_EQ(10U, infos[0].sent_total_packets); |
| 1218 EXPECT_EQ(0U, infos[0].sent_discarded_packets); | 1071 EXPECT_EQ(0U, infos[0].sent_discarded_packets); |
| 1219 EXPECT_EQ(10 * 36U, infos[0].sent_total_bytes); | 1072 EXPECT_EQ(10 * 36U, infos[0].sent_total_bytes); |
| 1220 EXPECT_EQ(10 * 36U, infos[0].recv_total_bytes); | 1073 EXPECT_EQ(10 * 36U, infos[0].recv_total_bytes); |
| 1221 EXPECT_GT(infos[0].rtt, 0U); | 1074 EXPECT_GT(infos[0].rtt, 0U); |
| 1222 DestroyChannels(); | 1075 DestroyChannels(); |
| 1223 } | 1076 } |
| 1224 | 1077 |
| 1225 // Test that we properly create a connection on a STUN ping from unknown address | 1078 // Test that we properly create a connection on a STUN ping from unknown address |
| 1226 // when the signaling is slow. | 1079 // when the signaling is slow. |
| 1227 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignaling) { | 1080 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignaling) { |
| 1228 ConfigureEndpoints(OPEN, OPEN, | 1081 ConfigureEndpoints(OPEN, OPEN, |
| 1229 PORTALLOCATOR_ENABLE_SHARED_UFRAG, | 1082 kDefaultPortAllocatorFlags, |
| 1230 PORTALLOCATOR_ENABLE_SHARED_UFRAG, | 1083 kDefaultPortAllocatorFlags); |
| 1231 kDefaultStepDelay, kDefaultStepDelay, | |
| 1232 cricket::ICEPROTO_RFC5245); | |
| 1233 // Emulate no remote credentials coming in. | 1084 // Emulate no remote credentials coming in. |
| 1234 set_clear_remote_candidates_ufrag_pwd(false); | 1085 set_clear_remote_candidates_ufrag_pwd(false); |
| 1235 CreateChannels(1); | 1086 CreateChannels(1); |
| 1236 // Only have remote credentials come in for ep2, not ep1. | 1087 // Only have remote credentials come in for ep2, not ep1. |
| 1237 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 1088 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); |
| 1238 | 1089 |
| 1239 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive | 1090 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive |
| 1240 // candidate. | 1091 // candidate. |
| 1241 PauseCandidates(1); | 1092 PauseCandidates(1); |
| 1242 | 1093 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1266 ep1_ch1()->best_connection()->remote_candidate().type(), | 1117 ep1_ch1()->best_connection()->remote_candidate().type(), |
| 1267 2000); | 1118 2000); |
| 1268 EXPECT_EQ(best_connection, ep1_ch1()->best_connection()); | 1119 EXPECT_EQ(best_connection, ep1_ch1()->best_connection()); |
| 1269 DestroyChannels(); | 1120 DestroyChannels(); |
| 1270 } | 1121 } |
| 1271 | 1122 |
| 1272 // Test that we properly create a connection on a STUN ping from unknown address | 1123 // Test that we properly create a connection on a STUN ping from unknown address |
| 1273 // when the signaling is slow and the end points are behind NAT. | 1124 // when the signaling is slow and the end points are behind NAT. |
| 1274 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) { | 1125 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) { |
| 1275 ConfigureEndpoints(OPEN, NAT_SYMMETRIC, | 1126 ConfigureEndpoints(OPEN, NAT_SYMMETRIC, |
| 1276 PORTALLOCATOR_ENABLE_SHARED_UFRAG, | 1127 kDefaultPortAllocatorFlags, |
| 1277 PORTALLOCATOR_ENABLE_SHARED_UFRAG, | 1128 kDefaultPortAllocatorFlags); |
| 1278 kDefaultStepDelay, kDefaultStepDelay, | |
| 1279 cricket::ICEPROTO_RFC5245); | |
| 1280 // Emulate no remote credentials coming in. | 1129 // Emulate no remote credentials coming in. |
| 1281 set_clear_remote_candidates_ufrag_pwd(false); | 1130 set_clear_remote_candidates_ufrag_pwd(false); |
| 1282 CreateChannels(1); | 1131 CreateChannels(1); |
| 1283 // Only have remote credentials come in for ep2, not ep1. | 1132 // Only have remote credentials come in for ep2, not ep1. |
| 1284 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 1133 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); |
| 1285 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive | 1134 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive |
| 1286 // candidate. | 1135 // candidate. |
| 1287 PauseCandidates(1); | 1136 PauseCandidates(1); |
| 1288 | 1137 |
| 1289 // The caller should have the best connection connected to the peer reflexive | 1138 // The caller should have the best connection connected to the peer reflexive |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1311 WAIT(ep1_ch1()->writable(), 2000); | 1160 WAIT(ep1_ch1()->writable(), 2000); |
| 1312 EXPECT_EQ(ep2_ch1()->best_connection(), best_connection); | 1161 EXPECT_EQ(ep2_ch1()->best_connection(), best_connection); |
| 1313 EXPECT_EQ("prflx", ep1_ch1()->best_connection()->remote_candidate().type()); | 1162 EXPECT_EQ("prflx", ep1_ch1()->best_connection()->remote_candidate().type()); |
| 1314 DestroyChannels(); | 1163 DestroyChannels(); |
| 1315 } | 1164 } |
| 1316 | 1165 |
| 1317 // Test that if remote candidates don't have ufrag and pwd, we still work. | 1166 // Test that if remote candidates don't have ufrag and pwd, we still work. |
| 1318 TEST_F(P2PTransportChannelTest, RemoteCandidatesWithoutUfragPwd) { | 1167 TEST_F(P2PTransportChannelTest, RemoteCandidatesWithoutUfragPwd) { |
| 1319 set_clear_remote_candidates_ufrag_pwd(true); | 1168 set_clear_remote_candidates_ufrag_pwd(true); |
| 1320 ConfigureEndpoints(OPEN, OPEN, | 1169 ConfigureEndpoints(OPEN, OPEN, |
| 1321 PORTALLOCATOR_ENABLE_SHARED_UFRAG, | 1170 kDefaultPortAllocatorFlags, |
| 1322 PORTALLOCATOR_ENABLE_SHARED_UFRAG, | 1171 kDefaultPortAllocatorFlags); |
| 1323 kMinimumStepDelay, kMinimumStepDelay, | |
| 1324 cricket::ICEPROTO_GOOGLE); | |
| 1325 CreateChannels(1); | 1172 CreateChannels(1); |
| 1326 const cricket::Connection* best_connection = NULL; | 1173 const cricket::Connection* best_connection = NULL; |
| 1327 // Wait until the callee's connections are created. | 1174 // Wait until the callee's connections are created. |
| 1328 WAIT((best_connection = ep2_ch1()->best_connection()) != NULL, 1000); | 1175 WAIT((best_connection = ep2_ch1()->best_connection()) != NULL, 1000); |
| 1329 // Wait to see if they get culled; they shouldn't. | 1176 // Wait to see if they get culled; they shouldn't. |
| 1330 WAIT(ep2_ch1()->best_connection() != best_connection, 1000); | 1177 WAIT(ep2_ch1()->best_connection() != best_connection, 1000); |
| 1331 EXPECT_TRUE(ep2_ch1()->best_connection() == best_connection); | 1178 EXPECT_TRUE(ep2_ch1()->best_connection() == best_connection); |
| 1332 DestroyChannels(); | 1179 DestroyChannels(); |
| 1333 } | 1180 } |
| 1334 | 1181 |
| 1335 // Test that a host behind NAT cannot be reached when incoming_only | 1182 // Test that a host behind NAT cannot be reached when incoming_only |
| 1336 // is set to true. | 1183 // is set to true. |
| 1337 TEST_F(P2PTransportChannelTest, IncomingOnlyBlocked) { | 1184 TEST_F(P2PTransportChannelTest, IncomingOnlyBlocked) { |
| 1338 ConfigureEndpoints(NAT_FULL_CONE, OPEN, | 1185 ConfigureEndpoints(NAT_FULL_CONE, OPEN, |
| 1339 kDefaultPortAllocatorFlags, | 1186 kDefaultPortAllocatorFlags, |
| 1340 kDefaultPortAllocatorFlags, | 1187 kDefaultPortAllocatorFlags); |
| 1341 kDefaultStepDelay, kDefaultStepDelay, | |
| 1342 cricket::ICEPROTO_GOOGLE); | |
| 1343 | 1188 |
| 1344 SetAllocatorFlags(0, kOnlyLocalPorts); | 1189 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 1345 CreateChannels(1); | 1190 CreateChannels(1); |
| 1346 ep1_ch1()->set_incoming_only(true); | 1191 ep1_ch1()->set_incoming_only(true); |
| 1347 | 1192 |
| 1348 // Pump for 1 second and verify that the channels are not connected. | 1193 // Pump for 1 second and verify that the channels are not connected. |
| 1349 rtc::Thread::Current()->ProcessMessages(1000); | 1194 rtc::Thread::Current()->ProcessMessages(1000); |
| 1350 | 1195 |
| 1351 EXPECT_FALSE(ep1_ch1()->readable()); | 1196 EXPECT_FALSE(ep1_ch1()->readable()); |
| 1352 EXPECT_FALSE(ep1_ch1()->writable()); | 1197 EXPECT_FALSE(ep1_ch1()->writable()); |
| 1353 EXPECT_FALSE(ep2_ch1()->readable()); | 1198 EXPECT_FALSE(ep2_ch1()->readable()); |
| 1354 EXPECT_FALSE(ep2_ch1()->writable()); | 1199 EXPECT_FALSE(ep2_ch1()->writable()); |
| 1355 | 1200 |
| 1356 DestroyChannels(); | 1201 DestroyChannels(); |
| 1357 } | 1202 } |
| 1358 | 1203 |
| 1359 // Test that a peer behind NAT can connect to a peer that has | 1204 // Test that a peer behind NAT can connect to a peer that has |
| 1360 // incoming_only flag set. | 1205 // incoming_only flag set. |
| 1361 TEST_F(P2PTransportChannelTest, IncomingOnlyOpen) { | 1206 TEST_F(P2PTransportChannelTest, IncomingOnlyOpen) { |
| 1362 ConfigureEndpoints(OPEN, NAT_FULL_CONE, | 1207 ConfigureEndpoints(OPEN, NAT_FULL_CONE, |
| 1363 kDefaultPortAllocatorFlags, | 1208 kDefaultPortAllocatorFlags, |
| 1364 kDefaultPortAllocatorFlags, | 1209 kDefaultPortAllocatorFlags); |
| 1365 kDefaultStepDelay, kDefaultStepDelay, | |
| 1366 cricket::ICEPROTO_GOOGLE); | |
| 1367 | 1210 |
| 1368 SetAllocatorFlags(0, kOnlyLocalPorts); | 1211 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 1369 CreateChannels(1); | 1212 CreateChannels(1); |
| 1370 ep1_ch1()->set_incoming_only(true); | 1213 ep1_ch1()->set_incoming_only(true); |
| 1371 | 1214 |
| 1372 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && | 1215 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && |
| 1373 ep1_ch1()->readable() && ep1_ch1()->writable() && | 1216 ep1_ch1()->readable() && ep1_ch1()->writable() && |
| 1374 ep2_ch1()->readable() && ep2_ch1()->writable(), | 1217 ep2_ch1()->readable() && ep2_ch1()->writable(), |
| 1375 1000, 1000); | 1218 1000, 1000); |
| 1376 | 1219 |
| 1377 DestroyChannels(); | 1220 DestroyChannels(); |
| 1378 } | 1221 } |
| 1379 | 1222 |
| 1380 TEST_F(P2PTransportChannelTest, TestTcpConnectionsFromActiveToPassive) { | 1223 TEST_F(P2PTransportChannelTest, TestTcpConnectionsFromActiveToPassive) { |
| 1381 AddAddress(0, kPublicAddrs[0]); | 1224 AddAddress(0, kPublicAddrs[0]); |
| 1382 AddAddress(1, kPublicAddrs[1]); | 1225 AddAddress(1, kPublicAddrs[1]); |
| 1383 | 1226 |
| 1384 SetAllocationStepDelay(0, kMinimumStepDelay); | 1227 SetAllocationStepDelay(0, kMinimumStepDelay); |
| 1385 SetAllocationStepDelay(1, kMinimumStepDelay); | 1228 SetAllocationStepDelay(1, kMinimumStepDelay); |
| 1386 | 1229 |
| 1387 int kOnlyLocalTcpPorts = cricket::PORTALLOCATOR_DISABLE_UDP | | 1230 int kOnlyLocalTcpPorts = cricket::PORTALLOCATOR_DISABLE_UDP | |
| 1388 cricket::PORTALLOCATOR_DISABLE_STUN | | 1231 cricket::PORTALLOCATOR_DISABLE_STUN | |
| 1389 cricket::PORTALLOCATOR_DISABLE_RELAY | | 1232 cricket::PORTALLOCATOR_DISABLE_RELAY; |
| 1390 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG; | |
| 1391 // Disable all protocols except TCP. | 1233 // Disable all protocols except TCP. |
| 1392 SetAllocatorFlags(0, kOnlyLocalTcpPorts); | 1234 SetAllocatorFlags(0, kOnlyLocalTcpPorts); |
| 1393 SetAllocatorFlags(1, kOnlyLocalTcpPorts); | 1235 SetAllocatorFlags(1, kOnlyLocalTcpPorts); |
| 1394 | 1236 |
| 1395 SetAllowTcpListen(0, true); // actpass. | 1237 SetAllowTcpListen(0, true); // actpass. |
| 1396 SetAllowTcpListen(1, false); // active. | 1238 SetAllowTcpListen(1, false); // active. |
| 1397 | 1239 |
| 1398 CreateChannels(1); | 1240 CreateChannels(1); |
| 1399 | 1241 |
| 1400 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && ep1_ch1()->writable() && | 1242 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && ep1_ch1()->writable() && |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1421 TestSignalRoleConflict(); | 1263 TestSignalRoleConflict(); |
| 1422 } | 1264 } |
| 1423 | 1265 |
| 1424 // Tests that the ice configs (protocol, tiebreaker and role) can be passed | 1266 // Tests that the ice configs (protocol, tiebreaker and role) can be passed |
| 1425 // down to ports. | 1267 // down to ports. |
| 1426 TEST_F(P2PTransportChannelTest, TestIceConfigWillPassDownToPort) { | 1268 TEST_F(P2PTransportChannelTest, TestIceConfigWillPassDownToPort) { |
| 1427 AddAddress(0, kPublicAddrs[0]); | 1269 AddAddress(0, kPublicAddrs[0]); |
| 1428 AddAddress(1, kPublicAddrs[1]); | 1270 AddAddress(1, kPublicAddrs[1]); |
| 1429 | 1271 |
| 1430 SetIceRole(0, cricket::ICEROLE_CONTROLLING); | 1272 SetIceRole(0, cricket::ICEROLE_CONTROLLING); |
| 1431 SetIceProtocol(0, cricket::ICEPROTO_GOOGLE); | |
| 1432 SetIceTiebreaker(0, kTiebreaker1); | 1273 SetIceTiebreaker(0, kTiebreaker1); |
| 1433 SetIceRole(1, cricket::ICEROLE_CONTROLLING); | 1274 SetIceRole(1, cricket::ICEROLE_CONTROLLING); |
| 1434 SetIceProtocol(1, cricket::ICEPROTO_RFC5245); | |
| 1435 SetIceTiebreaker(1, kTiebreaker2); | 1275 SetIceTiebreaker(1, kTiebreaker2); |
| 1436 | 1276 |
| 1437 CreateChannels(1); | 1277 CreateChannels(1); |
| 1438 | 1278 |
| 1439 EXPECT_EQ_WAIT(2u, ep1_ch1()->ports().size(), 1000); | 1279 EXPECT_EQ_WAIT(2u, ep1_ch1()->ports().size(), 1000); |
| 1440 | 1280 |
| 1441 const std::vector<cricket::PortInterface *> ports_before = ep1_ch1()->ports(); | 1281 const std::vector<cricket::PortInterface *> ports_before = ep1_ch1()->ports(); |
| 1442 for (size_t i = 0; i < ports_before.size(); ++i) { | 1282 for (size_t i = 0; i < ports_before.size(); ++i) { |
| 1443 EXPECT_EQ(cricket::ICEROLE_CONTROLLING, ports_before[i]->GetIceRole()); | 1283 EXPECT_EQ(cricket::ICEROLE_CONTROLLING, ports_before[i]->GetIceRole()); |
| 1444 EXPECT_EQ(cricket::ICEPROTO_GOOGLE, ports_before[i]->IceProtocol()); | |
| 1445 EXPECT_EQ(kTiebreaker1, ports_before[i]->IceTiebreaker()); | 1284 EXPECT_EQ(kTiebreaker1, ports_before[i]->IceTiebreaker()); |
| 1446 } | 1285 } |
| 1447 | 1286 |
| 1448 ep1_ch1()->SetIceRole(cricket::ICEROLE_CONTROLLED); | 1287 ep1_ch1()->SetIceRole(cricket::ICEROLE_CONTROLLED); |
| 1449 ep1_ch1()->SetIceProtocolType(cricket::ICEPROTO_RFC5245); | |
| 1450 ep1_ch1()->SetIceTiebreaker(kTiebreaker2); | 1288 ep1_ch1()->SetIceTiebreaker(kTiebreaker2); |
| 1451 | 1289 |
| 1452 const std::vector<cricket::PortInterface *> ports_after = ep1_ch1()->ports(); | 1290 const std::vector<cricket::PortInterface *> ports_after = ep1_ch1()->ports(); |
| 1453 for (size_t i = 0; i < ports_after.size(); ++i) { | 1291 for (size_t i = 0; i < ports_after.size(); ++i) { |
| 1454 EXPECT_EQ(cricket::ICEROLE_CONTROLLED, ports_before[i]->GetIceRole()); | 1292 EXPECT_EQ(cricket::ICEROLE_CONTROLLED, ports_before[i]->GetIceRole()); |
| 1455 EXPECT_EQ(cricket::ICEPROTO_RFC5245, ports_before[i]->IceProtocol()); | |
| 1456 // SetIceTiebreaker after Connect() has been called will fail. So expect the | 1293 // SetIceTiebreaker after Connect() has been called will fail. So expect the |
| 1457 // original value. | 1294 // original value. |
| 1458 EXPECT_EQ(kTiebreaker1, ports_before[i]->IceTiebreaker()); | 1295 EXPECT_EQ(kTiebreaker1, ports_before[i]->IceTiebreaker()); |
| 1459 } | 1296 } |
| 1460 | 1297 |
| 1461 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && | 1298 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && |
| 1462 ep1_ch1()->writable() && | 1299 ep1_ch1()->writable() && |
| 1463 ep2_ch1()->readable() && | 1300 ep2_ch1()->readable() && |
| 1464 ep2_ch1()->writable(), | 1301 ep2_ch1()->writable(), |
| 1465 1000); | 1302 1000); |
| 1466 | 1303 |
| 1467 EXPECT_TRUE(ep1_ch1()->best_connection() && | 1304 EXPECT_TRUE(ep1_ch1()->best_connection() && |
| 1468 ep2_ch1()->best_connection()); | 1305 ep2_ch1()->best_connection()); |
| 1469 | 1306 |
| 1470 TestSendRecv(1); | 1307 TestSendRecv(1); |
| 1471 DestroyChannels(); | 1308 DestroyChannels(); |
| 1472 } | 1309 } |
| 1473 | 1310 |
| 1474 // This test verifies channel can handle ice messages when channel is in | |
| 1475 // hybrid mode. | |
| 1476 TEST_F(P2PTransportChannelTest, TestConnectivityBetweenHybridandIce) { | |
| 1477 TestHybridConnectivity(cricket::ICEPROTO_RFC5245); | |
| 1478 } | |
| 1479 | |
| 1480 // This test verifies channel can handle Gice messages when channel is in | |
| 1481 // hybrid mode. | |
| 1482 TEST_F(P2PTransportChannelTest, TestConnectivityBetweenHybridandGice) { | |
| 1483 TestHybridConnectivity(cricket::ICEPROTO_GOOGLE); | |
| 1484 } | |
| 1485 | |
| 1486 // Verify that we can set DSCP value and retrieve properly from P2PTC. | 1311 // Verify that we can set DSCP value and retrieve properly from P2PTC. |
| 1487 TEST_F(P2PTransportChannelTest, TestDefaultDscpValue) { | 1312 TEST_F(P2PTransportChannelTest, TestDefaultDscpValue) { |
| 1488 AddAddress(0, kPublicAddrs[0]); | 1313 AddAddress(0, kPublicAddrs[0]); |
| 1489 AddAddress(1, kPublicAddrs[1]); | 1314 AddAddress(1, kPublicAddrs[1]); |
| 1490 | 1315 |
| 1491 CreateChannels(1); | 1316 CreateChannels(1); |
| 1492 EXPECT_EQ(rtc::DSCP_NO_CHANGE, | 1317 EXPECT_EQ(rtc::DSCP_NO_CHANGE, |
| 1493 GetEndpoint(0)->cd1_.ch_->DefaultDscpValue()); | 1318 GetEndpoint(0)->cd1_.ch_->DefaultDscpValue()); |
| 1494 EXPECT_EQ(rtc::DSCP_NO_CHANGE, | 1319 EXPECT_EQ(rtc::DSCP_NO_CHANGE, |
| 1495 GetEndpoint(1)->cd1_.ch_->DefaultDscpValue()); | 1320 GetEndpoint(1)->cd1_.ch_->DefaultDscpValue()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 RemoteCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[1])); | 1361 RemoteCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[1])); |
| 1537 | 1362 |
| 1538 TestSendRecv(1); | 1363 TestSendRecv(1); |
| 1539 DestroyChannels(); | 1364 DestroyChannels(); |
| 1540 } | 1365 } |
| 1541 | 1366 |
| 1542 // Testing forceful TURN connections. | 1367 // Testing forceful TURN connections. |
| 1543 TEST_F(P2PTransportChannelTest, TestForceTurn) { | 1368 TEST_F(P2PTransportChannelTest, TestForceTurn) { |
| 1544 ConfigureEndpoints(NAT_PORT_RESTRICTED, NAT_SYMMETRIC, | 1369 ConfigureEndpoints(NAT_PORT_RESTRICTED, NAT_SYMMETRIC, |
| 1545 kDefaultPortAllocatorFlags | | 1370 kDefaultPortAllocatorFlags | |
| 1546 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 1371 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET, |
| 1547 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG, | |
| 1548 kDefaultPortAllocatorFlags | | 1372 kDefaultPortAllocatorFlags | |
| 1549 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 1373 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1550 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG, | |
| 1551 kDefaultStepDelay, kDefaultStepDelay, | |
| 1552 cricket::ICEPROTO_RFC5245); | |
| 1553 set_force_relay(true); | 1374 set_force_relay(true); |
| 1554 | 1375 |
| 1555 SetAllocationStepDelay(0, kMinimumStepDelay); | 1376 SetAllocationStepDelay(0, kMinimumStepDelay); |
| 1556 SetAllocationStepDelay(1, kMinimumStepDelay); | 1377 SetAllocationStepDelay(1, kMinimumStepDelay); |
| 1557 | 1378 |
| 1558 CreateChannels(1); | 1379 CreateChannels(1); |
| 1559 | 1380 |
| 1560 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && | 1381 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && |
| 1561 ep1_ch1()->writable() && | 1382 ep1_ch1()->writable() && |
| 1562 ep2_ch1()->readable() && | 1383 ep2_ch1()->readable() && |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 AddAddress(endpoint, kCascadedPrivateAddrs[endpoint]); | 1419 AddAddress(endpoint, kCascadedPrivateAddrs[endpoint]); |
| 1599 nat->AddTranslator(kPrivateAddrs[endpoint], kCascadedNatAddrs[endpoint], | 1420 nat->AddTranslator(kPrivateAddrs[endpoint], kCascadedNatAddrs[endpoint], |
| 1600 static_cast<rtc::NATType>(config - NAT_FULL_CONE))->AddClient( | 1421 static_cast<rtc::NATType>(config - NAT_FULL_CONE))->AddClient( |
| 1601 kCascadedPrivateAddrs[endpoint]); | 1422 kCascadedPrivateAddrs[endpoint]); |
| 1602 } | 1423 } |
| 1603 } | 1424 } |
| 1604 }; | 1425 }; |
| 1605 | 1426 |
| 1606 TEST_F(P2PTransportChannelSameNatTest, TestConesBehindSameCone) { | 1427 TEST_F(P2PTransportChannelSameNatTest, TestConesBehindSameCone) { |
| 1607 ConfigureEndpoints(NAT_FULL_CONE, NAT_FULL_CONE, NAT_FULL_CONE); | 1428 ConfigureEndpoints(NAT_FULL_CONE, NAT_FULL_CONE, NAT_FULL_CONE); |
| 1608 Test(kLocalUdpToStunUdp); | 1429 Test(P2PTransportChannelTestBase::Result( |
| 1430 "local", "udp", "stun", "udp", |
| 1431 "stun", "udp", "local", "udp", 1000)); |
| 1609 } | 1432 } |
| 1610 | 1433 |
| 1611 // Test what happens when we have multiple available pathways. | 1434 // Test what happens when we have multiple available pathways. |
| 1612 // In the future we will try different RTTs and configs for the different | 1435 // In the future we will try different RTTs and configs for the different |
| 1613 // interfaces, so that we can simulate a user with Ethernet and VPN networks. | 1436 // interfaces, so that we can simulate a user with Ethernet and VPN networks. |
| 1614 class P2PTransportChannelMultihomedTest : public P2PTransportChannelTestBase { | 1437 class P2PTransportChannelMultihomedTest : public P2PTransportChannelTestBase { |
| 1615 }; | 1438 }; |
| 1616 | 1439 |
| 1617 // Test that we can establish connectivity when both peers are multihomed. | 1440 // Test that we can establish connectivity when both peers are multihomed. |
| 1618 TEST_F(P2PTransportChannelMultihomedTest, DISABLED_TestBasic) { | 1441 TEST_F(P2PTransportChannelMultihomedTest, DISABLED_TestBasic) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 // when we lose writability. | 1480 // when we lose writability. |
| 1658 EXPECT_TRUE_WAIT( | 1481 EXPECT_TRUE_WAIT( |
| 1659 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1482 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
| 1660 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1483 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 1661 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1]), | 1484 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1]), |
| 1662 3000); | 1485 3000); |
| 1663 | 1486 |
| 1664 DestroyChannels(); | 1487 DestroyChannels(); |
| 1665 } | 1488 } |
| 1666 | 1489 |
| 1490 /* |
| 1491 |
| 1492 TODO(pthatcher): Once have a way to handle network interfaces changes |
| 1493 without signalling an ICE restart, put a test like this back. In the |
| 1494 mean time, this test only worked for GICE. With ICE, it's currently |
| 1495 not possible without an ICE restart. |
| 1496 |
| 1667 // Test that we can switch links in a coordinated fashion. | 1497 // Test that we can switch links in a coordinated fashion. |
| 1668 TEST_F(P2PTransportChannelMultihomedTest, TestDrain) { | 1498 TEST_F(P2PTransportChannelMultihomedTest, TestDrain) { |
| 1669 AddAddress(0, kPublicAddrs[0]); | 1499 AddAddress(0, kPublicAddrs[0]); |
| 1670 AddAddress(1, kPublicAddrs[1]); | 1500 AddAddress(1, kPublicAddrs[1]); |
| 1671 // Use only local ports for simplicity. | 1501 // Use only local ports for simplicity. |
| 1672 SetAllocatorFlags(0, kOnlyLocalPorts); | 1502 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 1673 SetAllocatorFlags(1, kOnlyLocalPorts); | 1503 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 1674 | 1504 |
| 1675 // Create channels and let them go writable, as usual. | 1505 // Create channels and let them go writable, as usual. |
| 1676 CreateChannels(1); | 1506 CreateChannels(1); |
| 1677 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && ep1_ch1()->writable() && | 1507 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && ep1_ch1()->writable() && |
| 1678 ep2_ch1()->readable() && ep2_ch1()->writable(), | 1508 ep2_ch1()->readable() && ep2_ch1()->writable(), |
| 1679 1000); | 1509 1000); |
| 1680 EXPECT_TRUE( | 1510 EXPECT_TRUE( |
| 1681 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1511 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
| 1682 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1512 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 1683 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1513 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
| 1684 | 1514 |
| 1515 |
| 1685 // Remove the public interface, add the alternate interface, and allocate | 1516 // Remove the public interface, add the alternate interface, and allocate |
| 1686 // a new generation of candidates for the new interface (via Connect()). | 1517 // a new generation of candidates for the new interface (via Connect()). |
| 1687 LOG(LS_INFO) << "Draining..."; | 1518 LOG(LS_INFO) << "Draining..."; |
| 1688 AddAddress(1, kAlternateAddrs[1]); | 1519 AddAddress(1, kAlternateAddrs[1]); |
| 1689 RemoveAddress(1, kPublicAddrs[1]); | 1520 RemoveAddress(1, kPublicAddrs[1]); |
| 1690 ep2_ch1()->Connect(); | 1521 ep2_ch1()->Connect(); |
| 1691 | 1522 |
| 1692 // We should switch over to use the alternate address after | 1523 // We should switch over to use the alternate address after |
| 1693 // an exchange of pings. | 1524 // an exchange of pings. |
| 1694 EXPECT_TRUE_WAIT( | 1525 EXPECT_TRUE_WAIT( |
| 1695 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1526 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
| 1696 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1527 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 1697 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1]), | 1528 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1]), |
| 1698 3000); | 1529 3000); |
| 1699 | 1530 |
| 1700 DestroyChannels(); | 1531 DestroyChannels(); |
| 1701 } | 1532 } |
| 1702 | 1533 |
| 1534 */ |
| 1535 |
| 1703 // A collection of tests which tests a single P2PTransportChannel by sending | 1536 // A collection of tests which tests a single P2PTransportChannel by sending |
| 1704 // pings. | 1537 // pings. |
| 1705 class P2PTransportChannelPingTest : public testing::Test, | 1538 class P2PTransportChannelPingTest : public testing::Test, |
| 1706 public sigslot::has_slots<> { | 1539 public sigslot::has_slots<> { |
| 1707 public: | 1540 public: |
| 1708 P2PTransportChannelPingTest() | 1541 P2PTransportChannelPingTest() |
| 1709 : pss_(new rtc::PhysicalSocketServer), | 1542 : pss_(new rtc::PhysicalSocketServer), |
| 1710 vss_(new rtc::VirtualSocketServer(pss_.get())), | 1543 vss_(new rtc::VirtualSocketServer(pss_.get())), |
| 1711 ss_scope_(vss_.get()) {} | 1544 ss_scope_(vss_.get()) {} |
| 1712 | 1545 |
| 1713 protected: | 1546 protected: |
| 1714 void PrepareChannel(cricket::P2PTransportChannel* ch) { | 1547 void PrepareChannel(cricket::P2PTransportChannel* ch) { |
| 1715 ch->SignalRequestSignaling.connect( | 1548 ch->SignalRequestSignaling.connect( |
| 1716 this, &P2PTransportChannelPingTest::OnChannelRequestSignaling); | 1549 this, &P2PTransportChannelPingTest::OnChannelRequestSignaling); |
| 1717 ch->SetIceProtocolType(cricket::ICEPROTO_RFC5245); | |
| 1718 ch->SetIceRole(cricket::ICEROLE_CONTROLLING); | 1550 ch->SetIceRole(cricket::ICEROLE_CONTROLLING); |
| 1719 ch->SetIceCredentials(kIceUfrag[0], kIcePwd[0]); | 1551 ch->SetIceCredentials(kIceUfrag[0], kIcePwd[0]); |
| 1720 ch->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 1552 ch->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); |
| 1721 } | 1553 } |
| 1722 | 1554 |
| 1723 void OnChannelRequestSignaling(cricket::TransportChannelImpl* channel) { | 1555 void OnChannelRequestSignaling(cricket::TransportChannelImpl* channel) { |
| 1724 channel->OnSignalingReady(); | 1556 channel->OnSignalingReady(); |
| 1725 } | 1557 } |
| 1726 | 1558 |
| 1727 cricket::Candidate CreateCandidate(const std::string& ip, | 1559 cricket::Candidate CreateCandidate(const std::string& ip, |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1877 ch.OnCandidate(CreateCandidate("1.1.1.1", 1, 1)); | 1709 ch.OnCandidate(CreateCandidate("1.1.1.1", 1, 1)); |
| 1878 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 1710 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
| 1879 ASSERT_TRUE(conn1 != nullptr); | 1711 ASSERT_TRUE(conn1 != nullptr); |
| 1880 | 1712 |
| 1881 conn1->ReceivedPing(); | 1713 conn1->ReceivedPing(); |
| 1882 conn1->OnReadPacket("ABC", 3, rtc::CreatePacketTime(0)); | 1714 conn1->OnReadPacket("ABC", 3, rtc::CreatePacketTime(0)); |
| 1883 EXPECT_TRUE_WAIT(ch.best_connection() != nullptr, 1000) | 1715 EXPECT_TRUE_WAIT(ch.best_connection() != nullptr, 1000) |
| 1884 EXPECT_TRUE_WAIT(ch.receiving(), 1000); | 1716 EXPECT_TRUE_WAIT(ch.receiving(), 1000); |
| 1885 EXPECT_TRUE_WAIT(!ch.receiving(), 1000); | 1717 EXPECT_TRUE_WAIT(!ch.receiving(), 1000); |
| 1886 } | 1718 } |
| OLD | NEW |