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; |
35 using cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET; | 36 using cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET; |
36 using cricket::ServerAddresses; | 37 using cricket::ServerAddresses; |
37 using rtc::SocketAddress; | 38 using rtc::SocketAddress; |
38 | 39 |
39 static const int kDefaultTimeout = 1000; | 40 static const int kDefaultTimeout = 1000; |
40 static const int kOnlyLocalPorts = cricket::PORTALLOCATOR_DISABLE_STUN | | 41 static const int kOnlyLocalPorts = cricket::PORTALLOCATOR_DISABLE_STUN | |
41 cricket::PORTALLOCATOR_DISABLE_RELAY | | 42 cricket::PORTALLOCATOR_DISABLE_RELAY | |
42 cricket::PORTALLOCATOR_DISABLE_TCP; | 43 cricket::PORTALLOCATOR_DISABLE_TCP; |
43 // Addresses on the public internet. | 44 // Addresses on the public internet. |
44 static const SocketAddress kPublicAddrs[2] = | 45 static const SocketAddress kPublicAddrs[2] = |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 170 |
170 struct Result { | 171 struct Result { |
171 Result(const std::string& lt, const std::string& lp, | 172 Result(const std::string& lt, const std::string& lp, |
172 const std::string& rt, const std::string& rp, | 173 const std::string& rt, const std::string& rp, |
173 const std::string& lt2, const std::string& lp2, | 174 const std::string& lt2, const std::string& lp2, |
174 const std::string& rt2, const std::string& rp2, int wait) | 175 const std::string& rt2, const std::string& rp2, int wait) |
175 : local_type(lt), local_proto(lp), remote_type(rt), remote_proto(rp), | 176 : local_type(lt), local_proto(lp), remote_type(rt), remote_proto(rp), |
176 local_type2(lt2), local_proto2(lp2), remote_type2(rt2), | 177 local_type2(lt2), local_proto2(lp2), remote_type2(rt2), |
177 remote_proto2(rp2), connect_wait(wait) { | 178 remote_proto2(rp2), connect_wait(wait) { |
178 } | 179 } |
179 | |
180 std::string local_type; | 180 std::string local_type; |
181 std::string local_proto; | 181 std::string local_proto; |
182 std::string remote_type; | 182 std::string remote_type; |
183 std::string remote_proto; | 183 std::string remote_proto; |
184 std::string local_type2; | 184 std::string local_type2; |
185 std::string local_proto2; | 185 std::string local_proto2; |
186 std::string remote_type2; | 186 std::string remote_type2; |
187 std::string remote_proto2; | 187 std::string remote_proto2; |
188 int connect_wait; | 188 int connect_wait; |
189 }; | 189 }; |
(...skipping 20 matching lines...) Expand all Loading... |
210 } | 210 } |
211 cricket::TransportChannel* channel; | 211 cricket::TransportChannel* channel; |
212 cricket::Candidate candidate; | 212 cricket::Candidate candidate; |
213 }; | 213 }; |
214 | 214 |
215 struct Endpoint { | 215 struct Endpoint { |
216 Endpoint() | 216 Endpoint() |
217 : role_(cricket::ICEROLE_UNKNOWN), | 217 : role_(cricket::ICEROLE_UNKNOWN), |
218 tiebreaker_(0), | 218 tiebreaker_(0), |
219 role_conflict_(false), | 219 role_conflict_(false), |
220 save_candidates_(false) {} | 220 save_candidates_(false), |
| 221 protocol_type_(cricket::ICEPROTO_GOOGLE) {} |
221 bool HasChannel(cricket::TransportChannel* ch) { | 222 bool HasChannel(cricket::TransportChannel* ch) { |
222 return (ch == cd1_.ch_.get() || ch == cd2_.ch_.get()); | 223 return (ch == cd1_.ch_.get() || ch == cd2_.ch_.get()); |
223 } | 224 } |
224 ChannelData* GetChannelData(cricket::TransportChannel* ch) { | 225 ChannelData* GetChannelData(cricket::TransportChannel* ch) { |
225 if (!HasChannel(ch)) return NULL; | 226 if (!HasChannel(ch)) return NULL; |
226 if (cd1_.ch_.get() == ch) | 227 if (cd1_.ch_.get() == ch) |
227 return &cd1_; | 228 return &cd1_; |
228 else | 229 else |
229 return &cd2_; | 230 return &cd2_; |
230 } | 231 } |
231 | 232 |
232 void SetIceRole(cricket::IceRole role) { role_ = role; } | 233 void SetIceRole(cricket::IceRole role) { role_ = role; } |
233 cricket::IceRole ice_role() { return role_; } | 234 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_; } |
234 void SetIceTiebreaker(uint64 tiebreaker) { tiebreaker_ = tiebreaker; } | 239 void SetIceTiebreaker(uint64 tiebreaker) { tiebreaker_ = tiebreaker; } |
235 uint64 GetIceTiebreaker() { return tiebreaker_; } | 240 uint64 GetIceTiebreaker() { return tiebreaker_; } |
236 void OnRoleConflict(bool role_conflict) { role_conflict_ = role_conflict; } | 241 void OnRoleConflict(bool role_conflict) { role_conflict_ = role_conflict; } |
237 bool role_conflict() { return role_conflict_; } | 242 bool role_conflict() { return role_conflict_; } |
238 void SetAllocationStepDelay(uint32 delay) { | 243 void SetAllocationStepDelay(uint32 delay) { |
239 allocator_->set_step_delay(delay); | 244 allocator_->set_step_delay(delay); |
240 } | 245 } |
241 void SetAllowTcpListen(bool allow_tcp_listen) { | 246 void SetAllowTcpListen(bool allow_tcp_listen) { |
242 allocator_->set_allow_tcp_listen(allow_tcp_listen); | 247 allocator_->set_allow_tcp_listen(allow_tcp_listen); |
243 } | 248 } |
244 | 249 |
245 rtc::FakeNetworkManager network_manager_; | 250 rtc::FakeNetworkManager network_manager_; |
246 rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; | 251 rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; |
247 ChannelData cd1_; | 252 ChannelData cd1_; |
248 ChannelData cd2_; | 253 ChannelData cd2_; |
249 cricket::IceRole role_; | 254 cricket::IceRole role_; |
250 uint64 tiebreaker_; | 255 uint64 tiebreaker_; |
251 bool role_conflict_; | 256 bool role_conflict_; |
252 bool save_candidates_; | 257 bool save_candidates_; |
| 258 cricket::IceProtocolType protocol_type_; |
253 std::vector<CandidateData*> saved_candidates_; | 259 std::vector<CandidateData*> saved_candidates_; |
254 }; | 260 }; |
255 | 261 |
256 ChannelData* GetChannelData(cricket::TransportChannel* channel) { | 262 ChannelData* GetChannelData(cricket::TransportChannel* channel) { |
257 if (ep1_.HasChannel(channel)) | 263 if (ep1_.HasChannel(channel)) |
258 return ep1_.GetChannelData(channel); | 264 return ep1_.GetChannelData(channel); |
259 else | 265 else |
260 return ep2_.GetChannelData(channel); | 266 return ep2_.GetChannelData(channel); |
261 } | 267 } |
262 | 268 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 cricket::P2PTransportChannel* channel = new cricket::P2PTransportChannel( | 304 cricket::P2PTransportChannel* channel = new cricket::P2PTransportChannel( |
299 "test content name", component, NULL, GetAllocator(endpoint)); | 305 "test content name", component, NULL, GetAllocator(endpoint)); |
300 channel->SignalRequestSignaling.connect( | 306 channel->SignalRequestSignaling.connect( |
301 this, &P2PTransportChannelTestBase::OnChannelRequestSignaling); | 307 this, &P2PTransportChannelTestBase::OnChannelRequestSignaling); |
302 channel->SignalCandidateReady.connect(this, | 308 channel->SignalCandidateReady.connect(this, |
303 &P2PTransportChannelTestBase::OnCandidate); | 309 &P2PTransportChannelTestBase::OnCandidate); |
304 channel->SignalReadPacket.connect( | 310 channel->SignalReadPacket.connect( |
305 this, &P2PTransportChannelTestBase::OnReadPacket); | 311 this, &P2PTransportChannelTestBase::OnReadPacket); |
306 channel->SignalRoleConflict.connect( | 312 channel->SignalRoleConflict.connect( |
307 this, &P2PTransportChannelTestBase::OnRoleConflict); | 313 this, &P2PTransportChannelTestBase::OnRoleConflict); |
| 314 channel->SetIceProtocolType(GetEndpoint(endpoint)->protocol_type()); |
308 channel->SetIceCredentials(local_ice_ufrag, local_ice_pwd); | 315 channel->SetIceCredentials(local_ice_ufrag, local_ice_pwd); |
309 if (clear_remote_candidates_ufrag_pwd_) { | 316 if (clear_remote_candidates_ufrag_pwd_) { |
310 // This only needs to be set if we're clearing them from the | 317 // This only needs to be set if we're clearing them from the |
311 // candidates. Some unit tests rely on this not being set. | 318 // candidates. Some unit tests rely on this not being set. |
312 channel->SetRemoteIceCredentials(remote_ice_ufrag, remote_ice_pwd); | 319 channel->SetRemoteIceCredentials(remote_ice_ufrag, remote_ice_pwd); |
313 } | 320 } |
314 channel->SetIceRole(GetEndpoint(endpoint)->ice_role()); | 321 channel->SetIceRole(GetEndpoint(endpoint)->ice_role()); |
315 channel->SetIceTiebreaker(GetEndpoint(endpoint)->GetIceTiebreaker()); | 322 channel->SetIceTiebreaker(GetEndpoint(endpoint)->GetIceTiebreaker()); |
316 channel->Connect(); | 323 channel->Connect(); |
317 return channel; | 324 return channel; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 void SetProxy(int endpoint, rtc::ProxyType type) { | 372 void SetProxy(int endpoint, rtc::ProxyType type) { |
366 rtc::ProxyInfo info; | 373 rtc::ProxyInfo info; |
367 info.type = type; | 374 info.type = type; |
368 info.address = (type == rtc::PROXY_HTTPS) ? | 375 info.address = (type == rtc::PROXY_HTTPS) ? |
369 kHttpsProxyAddrs[endpoint] : kSocksProxyAddrs[endpoint]; | 376 kHttpsProxyAddrs[endpoint] : kSocksProxyAddrs[endpoint]; |
370 GetAllocator(endpoint)->set_proxy("unittest/1.0", info); | 377 GetAllocator(endpoint)->set_proxy("unittest/1.0", info); |
371 } | 378 } |
372 void SetAllocatorFlags(int endpoint, int flags) { | 379 void SetAllocatorFlags(int endpoint, int flags) { |
373 GetAllocator(endpoint)->set_flags(flags); | 380 GetAllocator(endpoint)->set_flags(flags); |
374 } | 381 } |
| 382 void SetIceProtocol(int endpoint, cricket::IceProtocolType type) { |
| 383 GetEndpoint(endpoint)->SetIceProtocolType(type); |
| 384 } |
375 void SetIceRole(int endpoint, cricket::IceRole role) { | 385 void SetIceRole(int endpoint, cricket::IceRole role) { |
376 GetEndpoint(endpoint)->SetIceRole(role); | 386 GetEndpoint(endpoint)->SetIceRole(role); |
377 } | 387 } |
378 void SetIceTiebreaker(int endpoint, uint64 tiebreaker) { | 388 void SetIceTiebreaker(int endpoint, uint64 tiebreaker) { |
379 GetEndpoint(endpoint)->SetIceTiebreaker(tiebreaker); | 389 GetEndpoint(endpoint)->SetIceTiebreaker(tiebreaker); |
380 } | 390 } |
381 bool GetRoleConflict(int endpoint) { | 391 bool GetRoleConflict(int endpoint) { |
382 return GetEndpoint(endpoint)->role_conflict(); | 392 return GetEndpoint(endpoint)->role_conflict(); |
383 } | 393 } |
384 void SetAllocationStepDelay(int endpoint, uint32 delay) { | 394 void SetAllocationStepDelay(int endpoint, uint32 delay) { |
385 return GetEndpoint(endpoint)->SetAllocationStepDelay(delay); | 395 return GetEndpoint(endpoint)->SetAllocationStepDelay(delay); |
386 } | 396 } |
387 void SetAllowTcpListen(int endpoint, bool allow_tcp_listen) { | 397 void SetAllowTcpListen(int endpoint, bool allow_tcp_listen) { |
388 return GetEndpoint(endpoint)->SetAllowTcpListen(allow_tcp_listen); | 398 return GetEndpoint(endpoint)->SetAllowTcpListen(allow_tcp_listen); |
389 } | 399 } |
390 | 400 |
391 bool IsLocalToPrflxOrTheReverse(const Result& expected) { | |
392 return ((expected.local_type == "local" && | |
393 expected.remote_type == "prflx") || | |
394 (expected.local_type == "prflx" && | |
395 expected.remote_type == "local")); | |
396 } | |
397 | |
398 // Return true if the approprite parts of the expected Result, based | |
399 // on the local and remote candidate of ep1_ch1, match. This can be | |
400 // used in an EXPECT_TRUE_WAIT. | |
401 bool CheckCandidate1(const Result& expected) { | |
402 const std::string& local_type = LocalCandidate(ep1_ch1())->type(); | |
403 const std::string& local_proto = LocalCandidate(ep1_ch1())->protocol(); | |
404 const std::string& remote_type = RemoteCandidate(ep1_ch1())->type(); | |
405 const std::string& remote_proto = RemoteCandidate(ep1_ch1())->protocol(); | |
406 return ((local_proto == expected.local_proto && | |
407 remote_proto == expected.remote_proto) && | |
408 ((local_type == expected.local_type && | |
409 remote_type == expected.remote_type) || | |
410 // Sometimes we expect local -> prflx or prflx -> local | |
411 // and instead get prflx -> local or local -> prflx, and | |
412 // that's OK. | |
413 (IsLocalToPrflxOrTheReverse(expected) && | |
414 local_type == expected.remote_type && | |
415 remote_type == expected.local_type))); | |
416 } | |
417 | |
418 // EXPECT_EQ on the approprite parts of the expected Result, based | |
419 // on the local and remote candidate of ep1_ch1. This is like | |
420 // CheckCandidate1, except that it will provide more detail about | |
421 // what didn't match. | |
422 void ExpectCandidate1(const Result& expected) { | |
423 if (CheckCandidate1(expected)) { | |
424 return; | |
425 } | |
426 | |
427 const std::string& local_type = LocalCandidate(ep1_ch1())->type(); | |
428 const std::string& local_proto = LocalCandidate(ep1_ch1())->protocol(); | |
429 const std::string& remote_type = RemoteCandidate(ep1_ch1())->type(); | |
430 const std::string& remote_proto = RemoteCandidate(ep1_ch1())->protocol(); | |
431 EXPECT_EQ(expected.local_type, local_type); | |
432 EXPECT_EQ(expected.remote_type, remote_type); | |
433 EXPECT_EQ(expected.local_proto, local_proto); | |
434 EXPECT_EQ(expected.remote_proto, remote_proto); | |
435 } | |
436 | |
437 // Return true if the approprite parts of the expected Result, based | |
438 // on the local and remote candidate of ep2_ch1, match. This can be | |
439 // used in an EXPECT_TRUE_WAIT. | |
440 bool CheckCandidate2(const Result& expected) { | |
441 const std::string& local_type = LocalCandidate(ep2_ch1())->type(); | |
442 // const std::string& remote_type = RemoteCandidate(ep2_ch1())->type(); | |
443 const std::string& local_proto = LocalCandidate(ep2_ch1())->protocol(); | |
444 const std::string& remote_proto = RemoteCandidate(ep2_ch1())->protocol(); | |
445 // Removed remote_type comparision aginst best connection remote | |
446 // candidate. This is done to handle remote type discrepancy from | |
447 // local to stun based on the test type. | |
448 // For example in case of Open -> NAT, ep2 channels will have LULU | |
449 // and in other cases like NAT -> NAT it will be LUSU. To avoid these | |
450 // mismatches and we are doing comparision in different way. | |
451 // i.e. when don't match its remote type is either local or stun. | |
452 // TODO(ronghuawu): Refine the test criteria. | |
453 // https://code.google.com/p/webrtc/issues/detail?id=1953 | |
454 return ((local_proto == expected.local_proto2 && | |
455 remote_proto == expected.remote_proto2) && | |
456 (local_type == expected.local_type2 || | |
457 // Sometimes we expect local -> prflx or prflx -> local | |
458 // and instead get prflx -> local or local -> prflx, and | |
459 // that's OK. | |
460 (IsLocalToPrflxOrTheReverse(expected) && | |
461 local_type == expected.remote_type2))); | |
462 } | |
463 | |
464 // EXPECT_EQ on the approprite parts of the expected Result, based | |
465 // on the local and remote candidate of ep2_ch1. This is like | |
466 // CheckCandidate2, except that it will provide more detail about | |
467 // what didn't match. | |
468 void ExpectCandidate2(const Result& expected) { | |
469 if (CheckCandidate2(expected)) { | |
470 return; | |
471 } | |
472 | |
473 const std::string& local_type = LocalCandidate(ep2_ch1())->type(); | |
474 const std::string& local_proto = LocalCandidate(ep2_ch1())->protocol(); | |
475 const std::string& remote_type = RemoteCandidate(ep2_ch1())->type(); | |
476 EXPECT_EQ(expected.local_proto2, local_proto); | |
477 EXPECT_EQ(expected.remote_proto2, remote_type); | |
478 EXPECT_EQ(expected.local_type2, local_type); | |
479 if (remote_type != expected.remote_type2) { | |
480 EXPECT_TRUE(expected.remote_type2 == cricket::LOCAL_PORT_TYPE || | |
481 expected.remote_type2 == cricket::STUN_PORT_TYPE); | |
482 EXPECT_TRUE(remote_type == cricket::LOCAL_PORT_TYPE || | |
483 remote_type == cricket::STUN_PORT_TYPE || | |
484 remote_type == cricket::PRFLX_PORT_TYPE); | |
485 } | |
486 } | |
487 | |
488 void Test(const Result& expected) { | 401 void Test(const Result& expected) { |
489 int32 connect_start = rtc::Time(), connect_time; | 402 int32 connect_start = rtc::Time(), connect_time; |
490 | 403 |
491 // Create the channels and wait for them to connect. | 404 // Create the channels and wait for them to connect. |
492 CreateChannels(1); | 405 CreateChannels(1); |
493 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && | 406 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && |
494 ep2_ch1() != NULL && | 407 ep2_ch1() != NULL && |
495 ep1_ch1()->readable() && | 408 ep1_ch1()->readable() && |
496 ep1_ch1()->writable() && | 409 ep1_ch1()->writable() && |
497 ep2_ch1()->readable() && | 410 ep2_ch1()->readable() && |
498 ep2_ch1()->writable(), | 411 ep2_ch1()->writable(), |
499 expected.connect_wait, | 412 expected.connect_wait, |
500 1000); | 413 1000); |
501 connect_time = rtc::TimeSince(connect_start); | 414 connect_time = rtc::TimeSince(connect_start); |
502 if (connect_time < expected.connect_wait) { | 415 if (connect_time < expected.connect_wait) { |
503 LOG(LS_INFO) << "Connect time: " << connect_time << " ms"; | 416 LOG(LS_INFO) << "Connect time: " << connect_time << " ms"; |
504 } else { | 417 } else { |
505 LOG(LS_INFO) << "Connect time: " << "TIMEOUT (" | 418 LOG(LS_INFO) << "Connect time: " << "TIMEOUT (" |
506 << expected.connect_wait << " ms)"; | 419 << expected.connect_wait << " ms)"; |
507 } | 420 } |
508 | 421 |
509 // Allow a few turns of the crank for the best connections to emerge. | 422 // Allow a few turns of the crank for the best connections to emerge. |
510 // This may take up to 2 seconds. | 423 // This may take up to 2 seconds. |
511 if (ep1_ch1()->best_connection() && | 424 if (ep1_ch1()->best_connection() && |
512 ep2_ch1()->best_connection()) { | 425 ep2_ch1()->best_connection()) { |
513 int32 converge_start = rtc::Time(), converge_time; | 426 int32 converge_start = rtc::Time(), converge_time; |
514 int converge_wait = 2000; | 427 int converge_wait = 2000; |
515 EXPECT_TRUE_WAIT_MARGIN(CheckCandidate1(expected), | 428 EXPECT_TRUE_WAIT_MARGIN( |
516 converge_wait, converge_wait); | 429 LocalCandidate(ep1_ch1())->type() == expected.local_type && |
| 430 LocalCandidate(ep1_ch1())->protocol() == expected.local_proto && |
| 431 RemoteCandidate(ep1_ch1())->type() == expected.remote_type && |
| 432 RemoteCandidate(ep1_ch1())->protocol() == expected.remote_proto, |
| 433 converge_wait, |
| 434 converge_wait); |
| 435 |
517 // Also do EXPECT_EQ on each part so that failures are more verbose. | 436 // Also do EXPECT_EQ on each part so that failures are more verbose. |
518 ExpectCandidate1(expected); | 437 EXPECT_EQ(expected.local_type, LocalCandidate(ep1_ch1())->type()); |
| 438 EXPECT_EQ(expected.local_proto, LocalCandidate(ep1_ch1())->protocol()); |
| 439 EXPECT_EQ(expected.remote_type, RemoteCandidate(ep1_ch1())->type()); |
| 440 EXPECT_EQ(expected.remote_proto, RemoteCandidate(ep1_ch1())->protocol()); |
519 | 441 |
520 // Verifying remote channel best connection information. This is done | 442 // Verifying remote channel best connection information. This is done |
521 // only for the RFC 5245 as controlled agent will use USE-CANDIDATE | 443 // only for the RFC 5245 as controlled agent will use USE-CANDIDATE |
522 // from controlling (ep1) agent. We can easily predict from EP1 result | 444 // from controlling (ep1) agent. We can easily predict from EP1 result |
523 // matrix. | 445 // 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); |
524 | 453 |
525 // Checking for best connection candidates information at remote. | 454 // For verbose |
526 EXPECT_TRUE_WAIT(CheckCandidate2(expected), kDefaultTimeout); | 455 EXPECT_EQ(expected.local_type2, LocalCandidate(ep2_ch1())->type()); |
527 // For verbose | 456 EXPECT_EQ(expected.local_proto2, LocalCandidate(ep2_ch1())->protocol()); |
528 ExpectCandidate2(expected); | 457 EXPECT_EQ(expected.remote_proto2, |
| 458 RemoteCandidate(ep2_ch1())->protocol()); |
| 459 // Removed remote_type comparision aginst best connection remote |
| 460 // candidate. This is done to handle remote type discrepancy from |
| 461 // local to stun based on the test type. |
| 462 // For example in case of Open -> NAT, ep2 channels will have LULU |
| 463 // and in other cases like NAT -> NAT it will be LUSU. To avoid these |
| 464 // mismatches and we are doing comparision in different way. |
| 465 // i.e. when don't match its remote type is either local or stun. |
| 466 // TODO(ronghuawu): Refine the test criteria. |
| 467 // https://code.google.com/p/webrtc/issues/detail?id=1953 |
| 468 if (expected.remote_type2 != RemoteCandidate(ep2_ch1())->type()) { |
| 469 EXPECT_TRUE(expected.remote_type2 == cricket::LOCAL_PORT_TYPE || |
| 470 expected.remote_type2 == cricket::STUN_PORT_TYPE); |
| 471 EXPECT_TRUE( |
| 472 RemoteCandidate(ep2_ch1())->type() == cricket::LOCAL_PORT_TYPE || |
| 473 RemoteCandidate(ep2_ch1())->type() == cricket::STUN_PORT_TYPE || |
| 474 RemoteCandidate(ep2_ch1())->type() == cricket::PRFLX_PORT_TYPE); |
| 475 } |
| 476 } |
529 | 477 |
530 converge_time = rtc::TimeSince(converge_start); | 478 converge_time = rtc::TimeSince(converge_start); |
531 if (converge_time < converge_wait) { | 479 if (converge_time < converge_wait) { |
532 LOG(LS_INFO) << "Converge time: " << converge_time << " ms"; | 480 LOG(LS_INFO) << "Converge time: " << converge_time << " ms"; |
533 } else { | 481 } else { |
534 LOG(LS_INFO) << "Converge time: " << "TIMEOUT (" | 482 LOG(LS_INFO) << "Converge time: " << "TIMEOUT (" |
535 << converge_wait << " ms)"; | 483 << converge_wait << " ms)"; |
536 } | 484 } |
537 } | 485 } |
538 // Try sending some data to other end. | 486 // Try sending some data to other end. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 old_remote_candidate1->generation(), | 543 old_remote_candidate1->generation(), |
596 1000, 1000); | 544 1000, 1000); |
597 EXPECT_TRUE_WAIT_MARGIN(RemoteCandidate(ep2_ch1())->generation() != | 545 EXPECT_TRUE_WAIT_MARGIN(RemoteCandidate(ep2_ch1())->generation() != |
598 old_remote_candidate2->generation(), | 546 old_remote_candidate2->generation(), |
599 1000, 1000); | 547 1000, 1000); |
600 EXPECT_EQ(1u, RemoteCandidate(ep2_ch1())->generation()); | 548 EXPECT_EQ(1u, RemoteCandidate(ep2_ch1())->generation()); |
601 EXPECT_EQ(1u, RemoteCandidate(ep1_ch1())->generation()); | 549 EXPECT_EQ(1u, RemoteCandidate(ep1_ch1())->generation()); |
602 } | 550 } |
603 | 551 |
604 void TestSignalRoleConflict() { | 552 void TestSignalRoleConflict() { |
| 553 SetIceProtocol(0, cricket::ICEPROTO_RFC5245); |
605 SetIceTiebreaker(0, kTiebreaker1); // Default EP1 is in controlling state. | 554 SetIceTiebreaker(0, kTiebreaker1); // Default EP1 is in controlling state. |
606 | 555 |
| 556 SetIceProtocol(1, cricket::ICEPROTO_RFC5245); |
607 SetIceRole(1, cricket::ICEROLE_CONTROLLING); | 557 SetIceRole(1, cricket::ICEROLE_CONTROLLING); |
608 SetIceTiebreaker(1, kTiebreaker2); | 558 SetIceTiebreaker(1, kTiebreaker2); |
609 | 559 |
610 // Creating channels with both channels role set to CONTROLLING. | 560 // Creating channels with both channels role set to CONTROLLING. |
611 CreateChannels(1); | 561 CreateChannels(1); |
612 // Since both the channels initiated with controlling state and channel2 | 562 // Since both the channels initiated with controlling state and channel2 |
613 // has higher tiebreaker value, channel1 should receive SignalRoleConflict. | 563 // has higher tiebreaker value, channel1 should receive SignalRoleConflict. |
614 EXPECT_TRUE_WAIT(GetRoleConflict(0), 1000); | 564 EXPECT_TRUE_WAIT(GetRoleConflict(0), 1000); |
615 EXPECT_FALSE(GetRoleConflict(1)); | 565 EXPECT_FALSE(GetRoleConflict(1)); |
616 | 566 |
617 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && | 567 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && |
618 ep1_ch1()->writable() && | 568 ep1_ch1()->writable() && |
619 ep2_ch1()->readable() && | 569 ep2_ch1()->readable() && |
620 ep2_ch1()->writable(), | 570 ep2_ch1()->writable(), |
621 1000); | 571 1000); |
622 | 572 |
623 EXPECT_TRUE(ep1_ch1()->best_connection() && | 573 EXPECT_TRUE(ep1_ch1()->best_connection() && |
624 ep2_ch1()->best_connection()); | 574 ep2_ch1()->best_connection()); |
625 | 575 |
626 TestSendRecv(1); | 576 TestSendRecv(1); |
627 } | 577 } |
628 | 578 |
| 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 |
629 void OnChannelRequestSignaling(cricket::TransportChannelImpl* channel) { | 619 void OnChannelRequestSignaling(cricket::TransportChannelImpl* channel) { |
630 channel->OnSignalingReady(); | 620 channel->OnSignalingReady(); |
631 } | 621 } |
632 // We pass the candidates directly to the other side. | 622 // We pass the candidates directly to the other side. |
633 void OnCandidate(cricket::TransportChannelImpl* ch, | 623 void OnCandidate(cricket::TransportChannelImpl* ch, |
634 const cricket::Candidate& c) { | 624 const cricket::Candidate& c) { |
635 if (force_relay_ && c.type() != cricket::RELAY_PORT_TYPE) | 625 if (force_relay_ && c.type() != cricket::RELAY_PORT_TYPE) |
636 return; | 626 return; |
637 | 627 |
638 if (GetEndpoint(ch)->save_candidates_) { | 628 if (GetEndpoint(ch)->save_candidates_) { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 | 788 |
799 // Test the matrix of all the connectivity types we expect to see in the wild. | 789 // Test the matrix of all the connectivity types we expect to see in the wild. |
800 // Just test every combination of the configs in the Config enum. | 790 // Just test every combination of the configs in the Config enum. |
801 class P2PTransportChannelTest : public P2PTransportChannelTestBase { | 791 class P2PTransportChannelTest : public P2PTransportChannelTestBase { |
802 protected: | 792 protected: |
803 static const Result* kMatrix[NUM_CONFIGS][NUM_CONFIGS]; | 793 static const Result* kMatrix[NUM_CONFIGS][NUM_CONFIGS]; |
804 static const Result* kMatrixSharedUfrag[NUM_CONFIGS][NUM_CONFIGS]; | 794 static const Result* kMatrixSharedUfrag[NUM_CONFIGS][NUM_CONFIGS]; |
805 static const Result* kMatrixSharedSocketAsGice[NUM_CONFIGS][NUM_CONFIGS]; | 795 static const Result* kMatrixSharedSocketAsGice[NUM_CONFIGS][NUM_CONFIGS]; |
806 static const Result* kMatrixSharedSocketAsIce[NUM_CONFIGS][NUM_CONFIGS]; | 796 static const Result* kMatrixSharedSocketAsIce[NUM_CONFIGS][NUM_CONFIGS]; |
807 void ConfigureEndpoints(Config config1, Config config2, | 797 void ConfigureEndpoints(Config config1, Config config2, |
808 int allocator_flags1, int allocator_flags2) { | 798 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. |
809 ServerAddresses stun_servers; | 804 ServerAddresses stun_servers; |
810 stun_servers.insert(kStunAddr); | 805 stun_servers.insert(kStunAddr); |
811 GetEndpoint(0)->allocator_.reset( | 806 GetEndpoint(0)->allocator_.reset( |
812 new cricket::BasicPortAllocator(&(GetEndpoint(0)->network_manager_), | 807 new cricket::BasicPortAllocator(&(GetEndpoint(0)->network_manager_), |
813 stun_servers, | 808 stun_servers, |
814 rtc::SocketAddress(), rtc::SocketAddress(), | 809 rtc::SocketAddress(), rtc::SocketAddress(), |
815 rtc::SocketAddress())); | 810 rtc::SocketAddress())); |
816 GetEndpoint(1)->allocator_.reset( | 811 GetEndpoint(1)->allocator_.reset( |
817 new cricket::BasicPortAllocator(&(GetEndpoint(1)->network_manager_), | 812 new cricket::BasicPortAllocator(&(GetEndpoint(1)->network_manager_), |
818 stun_servers, | 813 stun_servers, |
819 rtc::SocketAddress(), rtc::SocketAddress(), | 814 rtc::SocketAddress(), rtc::SocketAddress(), |
820 rtc::SocketAddress())); | 815 rtc::SocketAddress())); |
821 | 816 |
822 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); | 817 cricket::RelayServerConfig relay_server(cricket::RELAY_GTURN); |
823 relay_server.credentials = kRelayCredentials; | 818 if (type == cricket::ICEPROTO_RFC5245) { |
824 relay_server.ports.push_back(cricket::ProtocolAddress( | 819 relay_server.type = cricket::RELAY_TURN; |
825 kTurnUdpIntAddr, cricket::PROTO_UDP, false)); | 820 relay_server.credentials = kRelayCredentials; |
| 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 } |
826 GetEndpoint(0)->allocator_->AddRelay(relay_server); | 831 GetEndpoint(0)->allocator_->AddRelay(relay_server); |
827 GetEndpoint(1)->allocator_->AddRelay(relay_server); | 832 GetEndpoint(1)->allocator_->AddRelay(relay_server); |
828 | 833 |
829 int delay = kMinimumStepDelay; | |
830 ConfigureEndpoint(0, config1); | 834 ConfigureEndpoint(0, config1); |
| 835 SetIceProtocol(0, type); |
831 SetAllocatorFlags(0, allocator_flags1); | 836 SetAllocatorFlags(0, allocator_flags1); |
832 SetAllocationStepDelay(0, delay); | 837 SetAllocationStepDelay(0, delay1); |
833 ConfigureEndpoint(1, config2); | 838 ConfigureEndpoint(1, config2); |
| 839 SetIceProtocol(1, type); |
834 SetAllocatorFlags(1, allocator_flags2); | 840 SetAllocatorFlags(1, allocator_flags2); |
835 SetAllocationStepDelay(1, delay); | 841 SetAllocationStepDelay(1, delay2); |
836 | 842 |
837 set_clear_remote_candidates_ufrag_pwd(true); | 843 if (type == cricket::ICEPROTO_RFC5245) { |
| 844 set_clear_remote_candidates_ufrag_pwd(true); |
| 845 } |
838 } | 846 } |
839 void ConfigureEndpoint(int endpoint, Config config) { | 847 void ConfigureEndpoint(int endpoint, Config config) { |
840 switch (config) { | 848 switch (config) { |
841 case OPEN: | 849 case OPEN: |
842 AddAddress(endpoint, kPublicAddrs[endpoint]); | 850 AddAddress(endpoint, kPublicAddrs[endpoint]); |
843 break; | 851 break; |
844 case NAT_FULL_CONE: | 852 case NAT_FULL_CONE: |
845 case NAT_ADDR_RESTRICTED: | 853 case NAT_ADDR_RESTRICTED: |
846 case NAT_PORT_RESTRICTED: | 854 case NAT_PORT_RESTRICTED: |
847 case NAT_SYMMETRIC: | 855 case NAT_SYMMETRIC: |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 /*SC*/ {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL, LTRT}, | 1027 /*SC*/ {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL, LTRT}, |
1020 /*!U*/ {PTLT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTPT, LSRS, NULL, LTRT}, | 1028 /*!U*/ {PTLT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTPT, LSRS, NULL, LTRT}, |
1021 /*!T*/ {LTRT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTRT, LSRS, NULL, LTRT}, | 1029 /*!T*/ {LTRT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTRT, LSRS, NULL, LTRT}, |
1022 /*HT*/ {LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, NULL, LSRS}, | 1030 /*HT*/ {LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, NULL, LSRS}, |
1023 /*PR*/ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, | 1031 /*PR*/ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, |
1024 /*PR*/ {LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LSRS, NULL, LTRT}, | 1032 /*PR*/ {LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LSRS, NULL, LTRT}, |
1025 }; | 1033 }; |
1026 | 1034 |
1027 // The actual tests that exercise all the various configurations. | 1035 // The actual tests that exercise all the various configurations. |
1028 // Test names are of the form P2PTransportChannelTest_TestOPENToNAT_FULL_CONE | 1036 // 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. |
1029 #define P2P_TEST_DECLARATION(x, y, z) \ | 1044 #define P2P_TEST_DECLARATION(x, y, z) \ |
1030 TEST_F(P2PTransportChannelTest, z##Test##x##To##y) { \ | 1045 TEST_F(P2PTransportChannelTest, z##Test##x##To##y##AsGiceNoneSharedUfrag) { \ |
1031 ConfigureEndpoints(x, y, \ | 1046 ConfigureEndpoints(x, y, kDefaultPortAllocatorFlags, \ |
| 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 | \ |
1032 PORTALLOCATOR_ENABLE_SHARED_SOCKET, \ | 1099 PORTALLOCATOR_ENABLE_SHARED_SOCKET, \ |
1033 PORTALLOCATOR_ENABLE_SHARED_SOCKET); \ | 1100 PORTALLOCATOR_ENABLE_SHARED_UFRAG | \ |
| 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); \ |
1034 if (kMatrixSharedSocketAsIce[x][y] != NULL) \ | 1116 if (kMatrixSharedSocketAsIce[x][y] != NULL) \ |
1035 Test(*kMatrixSharedSocketAsIce[x][y]); \ | 1117 Test(*kMatrixSharedSocketAsIce[x][y]); \ |
1036 else \ | 1118 else \ |
1037 LOG(LS_WARNING) << "Not yet implemented"; \ | 1119 LOG(LS_WARNING) << "Not yet implemented"; \ |
1038 } | 1120 } |
1039 | 1121 |
1040 #define P2P_TEST(x, y) \ | 1122 #define P2P_TEST(x, y) \ |
1041 P2P_TEST_DECLARATION(x, y,) | 1123 P2P_TEST_DECLARATION(x, y,) |
1042 | 1124 |
1043 #define FLAKY_P2P_TEST(x, y) \ | 1125 #define FLAKY_P2P_TEST(x, y) \ |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 P2P_TEST_SET(NAT_DOUBLE_CONE) | 1163 P2P_TEST_SET(NAT_DOUBLE_CONE) |
1082 P2P_TEST_SET(NAT_SYMMETRIC_THEN_CONE) | 1164 P2P_TEST_SET(NAT_SYMMETRIC_THEN_CONE) |
1083 P2P_TEST_SET(BLOCK_UDP) | 1165 P2P_TEST_SET(BLOCK_UDP) |
1084 P2P_TEST_SET(BLOCK_UDP_AND_INCOMING_TCP) | 1166 P2P_TEST_SET(BLOCK_UDP_AND_INCOMING_TCP) |
1085 P2P_TEST_SET(BLOCK_ALL_BUT_OUTGOING_HTTP) | 1167 P2P_TEST_SET(BLOCK_ALL_BUT_OUTGOING_HTTP) |
1086 P2P_TEST_SET(PROXY_HTTPS) | 1168 P2P_TEST_SET(PROXY_HTTPS) |
1087 P2P_TEST_SET(PROXY_SOCKS) | 1169 P2P_TEST_SET(PROXY_SOCKS) |
1088 | 1170 |
1089 // Test that we restart candidate allocation when local ufrag&pwd changed. | 1171 // Test that we restart candidate allocation when local ufrag&pwd changed. |
1090 // Standard Ice protocol is used. | 1172 // Standard Ice protocol is used. |
1091 TEST_F(P2PTransportChannelTest, HandleUfragPwdChange) { | 1173 TEST_F(P2PTransportChannelTest, HandleUfragPwdChangeAsIce) { |
1092 ConfigureEndpoints(OPEN, OPEN, | 1174 ConfigureEndpoints(OPEN, OPEN, |
1093 kDefaultPortAllocatorFlags, | 1175 PORTALLOCATOR_ENABLE_SHARED_UFRAG, |
1094 kDefaultPortAllocatorFlags); | 1176 PORTALLOCATOR_ENABLE_SHARED_UFRAG, |
| 1177 kMinimumStepDelay, kMinimumStepDelay, |
| 1178 cricket::ICEPROTO_RFC5245); |
1095 CreateChannels(1); | 1179 CreateChannels(1); |
1096 TestHandleIceUfragPasswordChanged(); | 1180 TestHandleIceUfragPasswordChanged(); |
1097 DestroyChannels(); | 1181 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(); |
1098 } | 1195 } |
1099 | 1196 |
1100 // Test the operation of GetStats. | 1197 // Test the operation of GetStats. |
1101 TEST_F(P2PTransportChannelTest, GetStats) { | 1198 TEST_F(P2PTransportChannelTest, GetStats) { |
1102 ConfigureEndpoints(OPEN, OPEN, | 1199 ConfigureEndpoints(OPEN, OPEN, |
1103 kDefaultPortAllocatorFlags, | 1200 kDefaultPortAllocatorFlags, |
1104 kDefaultPortAllocatorFlags); | 1201 kDefaultPortAllocatorFlags, |
| 1202 kDefaultStepDelay, kDefaultStepDelay, |
| 1203 cricket::ICEPROTO_GOOGLE); |
1105 CreateChannels(1); | 1204 CreateChannels(1); |
1106 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->readable() && ep1_ch1()->writable() && | 1205 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->readable() && ep1_ch1()->writable() && |
1107 ep2_ch1()->readable() && ep2_ch1()->writable(), | 1206 ep2_ch1()->readable() && ep2_ch1()->writable(), |
1108 1000, 1000); | 1207 1000, 1000); |
1109 TestSendRecv(1); | 1208 TestSendRecv(1); |
1110 cricket::ConnectionInfos infos; | 1209 cricket::ConnectionInfos infos; |
1111 ASSERT_TRUE(ep1_ch1()->GetStats(&infos)); | 1210 ASSERT_TRUE(ep1_ch1()->GetStats(&infos)); |
1112 ASSERT_EQ(1U, infos.size()); | 1211 ASSERT_EQ(1U, infos.size()); |
1113 EXPECT_TRUE(infos[0].new_connection); | 1212 EXPECT_TRUE(infos[0].new_connection); |
1114 EXPECT_TRUE(infos[0].best_connection); | 1213 EXPECT_TRUE(infos[0].best_connection); |
1115 EXPECT_TRUE(infos[0].readable); | 1214 EXPECT_TRUE(infos[0].readable); |
1116 EXPECT_TRUE(infos[0].writable); | 1215 EXPECT_TRUE(infos[0].writable); |
1117 EXPECT_FALSE(infos[0].timeout); | 1216 EXPECT_FALSE(infos[0].timeout); |
1118 EXPECT_EQ(10U, infos[0].sent_total_packets); | 1217 EXPECT_EQ(10U, infos[0].sent_total_packets); |
1119 EXPECT_EQ(0U, infos[0].sent_discarded_packets); | 1218 EXPECT_EQ(0U, infos[0].sent_discarded_packets); |
1120 EXPECT_EQ(10 * 36U, infos[0].sent_total_bytes); | 1219 EXPECT_EQ(10 * 36U, infos[0].sent_total_bytes); |
1121 EXPECT_EQ(10 * 36U, infos[0].recv_total_bytes); | 1220 EXPECT_EQ(10 * 36U, infos[0].recv_total_bytes); |
1122 EXPECT_GT(infos[0].rtt, 0U); | 1221 EXPECT_GT(infos[0].rtt, 0U); |
1123 DestroyChannels(); | 1222 DestroyChannels(); |
1124 } | 1223 } |
1125 | 1224 |
1126 // Test that we properly create a connection on a STUN ping from unknown address | 1225 // Test that we properly create a connection on a STUN ping from unknown address |
1127 // when the signaling is slow. | 1226 // when the signaling is slow. |
1128 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignaling) { | 1227 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignaling) { |
1129 ConfigureEndpoints(OPEN, OPEN, | 1228 ConfigureEndpoints(OPEN, OPEN, |
1130 kDefaultPortAllocatorFlags, | 1229 PORTALLOCATOR_ENABLE_SHARED_UFRAG, |
1131 kDefaultPortAllocatorFlags); | 1230 PORTALLOCATOR_ENABLE_SHARED_UFRAG, |
| 1231 kDefaultStepDelay, kDefaultStepDelay, |
| 1232 cricket::ICEPROTO_RFC5245); |
1132 // Emulate no remote credentials coming in. | 1233 // Emulate no remote credentials coming in. |
1133 set_clear_remote_candidates_ufrag_pwd(false); | 1234 set_clear_remote_candidates_ufrag_pwd(false); |
1134 CreateChannels(1); | 1235 CreateChannels(1); |
1135 // Only have remote credentials come in for ep2, not ep1. | 1236 // Only have remote credentials come in for ep2, not ep1. |
1136 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 1237 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); |
1137 | 1238 |
1138 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive | 1239 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive |
1139 // candidate. | 1240 // candidate. |
1140 PauseCandidates(1); | 1241 PauseCandidates(1); |
1141 | 1242 |
(...skipping 23 matching lines...) Expand all Loading... |
1165 ep1_ch1()->best_connection()->remote_candidate().type(), | 1266 ep1_ch1()->best_connection()->remote_candidate().type(), |
1166 2000); | 1267 2000); |
1167 EXPECT_EQ(best_connection, ep1_ch1()->best_connection()); | 1268 EXPECT_EQ(best_connection, ep1_ch1()->best_connection()); |
1168 DestroyChannels(); | 1269 DestroyChannels(); |
1169 } | 1270 } |
1170 | 1271 |
1171 // Test that we properly create a connection on a STUN ping from unknown address | 1272 // Test that we properly create a connection on a STUN ping from unknown address |
1172 // when the signaling is slow and the end points are behind NAT. | 1273 // when the signaling is slow and the end points are behind NAT. |
1173 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) { | 1274 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) { |
1174 ConfigureEndpoints(OPEN, NAT_SYMMETRIC, | 1275 ConfigureEndpoints(OPEN, NAT_SYMMETRIC, |
1175 kDefaultPortAllocatorFlags, | 1276 PORTALLOCATOR_ENABLE_SHARED_UFRAG, |
1176 kDefaultPortAllocatorFlags); | 1277 PORTALLOCATOR_ENABLE_SHARED_UFRAG, |
| 1278 kDefaultStepDelay, kDefaultStepDelay, |
| 1279 cricket::ICEPROTO_RFC5245); |
1177 // Emulate no remote credentials coming in. | 1280 // Emulate no remote credentials coming in. |
1178 set_clear_remote_candidates_ufrag_pwd(false); | 1281 set_clear_remote_candidates_ufrag_pwd(false); |
1179 CreateChannels(1); | 1282 CreateChannels(1); |
1180 // Only have remote credentials come in for ep2, not ep1. | 1283 // Only have remote credentials come in for ep2, not ep1. |
1181 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); | 1284 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); |
1182 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive | 1285 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive |
1183 // candidate. | 1286 // candidate. |
1184 PauseCandidates(1); | 1287 PauseCandidates(1); |
1185 | 1288 |
1186 // The caller should have the best connection connected to the peer reflexive | 1289 // The caller should have the best connection connected to the peer reflexive |
(...skipping 21 matching lines...) Expand all Loading... |
1208 WAIT(ep1_ch1()->writable(), 2000); | 1311 WAIT(ep1_ch1()->writable(), 2000); |
1209 EXPECT_EQ(ep2_ch1()->best_connection(), best_connection); | 1312 EXPECT_EQ(ep2_ch1()->best_connection(), best_connection); |
1210 EXPECT_EQ("prflx", ep1_ch1()->best_connection()->remote_candidate().type()); | 1313 EXPECT_EQ("prflx", ep1_ch1()->best_connection()->remote_candidate().type()); |
1211 DestroyChannels(); | 1314 DestroyChannels(); |
1212 } | 1315 } |
1213 | 1316 |
1214 // Test that if remote candidates don't have ufrag and pwd, we still work. | 1317 // Test that if remote candidates don't have ufrag and pwd, we still work. |
1215 TEST_F(P2PTransportChannelTest, RemoteCandidatesWithoutUfragPwd) { | 1318 TEST_F(P2PTransportChannelTest, RemoteCandidatesWithoutUfragPwd) { |
1216 set_clear_remote_candidates_ufrag_pwd(true); | 1319 set_clear_remote_candidates_ufrag_pwd(true); |
1217 ConfigureEndpoints(OPEN, OPEN, | 1320 ConfigureEndpoints(OPEN, OPEN, |
1218 kDefaultPortAllocatorFlags, | 1321 PORTALLOCATOR_ENABLE_SHARED_UFRAG, |
1219 kDefaultPortAllocatorFlags); | 1322 PORTALLOCATOR_ENABLE_SHARED_UFRAG, |
| 1323 kMinimumStepDelay, kMinimumStepDelay, |
| 1324 cricket::ICEPROTO_GOOGLE); |
1220 CreateChannels(1); | 1325 CreateChannels(1); |
1221 const cricket::Connection* best_connection = NULL; | 1326 const cricket::Connection* best_connection = NULL; |
1222 // Wait until the callee's connections are created. | 1327 // Wait until the callee's connections are created. |
1223 WAIT((best_connection = ep2_ch1()->best_connection()) != NULL, 1000); | 1328 WAIT((best_connection = ep2_ch1()->best_connection()) != NULL, 1000); |
1224 // Wait to see if they get culled; they shouldn't. | 1329 // Wait to see if they get culled; they shouldn't. |
1225 WAIT(ep2_ch1()->best_connection() != best_connection, 1000); | 1330 WAIT(ep2_ch1()->best_connection() != best_connection, 1000); |
1226 EXPECT_TRUE(ep2_ch1()->best_connection() == best_connection); | 1331 EXPECT_TRUE(ep2_ch1()->best_connection() == best_connection); |
1227 DestroyChannels(); | 1332 DestroyChannels(); |
1228 } | 1333 } |
1229 | 1334 |
1230 // Test that a host behind NAT cannot be reached when incoming_only | 1335 // Test that a host behind NAT cannot be reached when incoming_only |
1231 // is set to true. | 1336 // is set to true. |
1232 TEST_F(P2PTransportChannelTest, IncomingOnlyBlocked) { | 1337 TEST_F(P2PTransportChannelTest, IncomingOnlyBlocked) { |
1233 ConfigureEndpoints(NAT_FULL_CONE, OPEN, | 1338 ConfigureEndpoints(NAT_FULL_CONE, OPEN, |
1234 kDefaultPortAllocatorFlags, | 1339 kDefaultPortAllocatorFlags, |
1235 kDefaultPortAllocatorFlags); | 1340 kDefaultPortAllocatorFlags, |
| 1341 kDefaultStepDelay, kDefaultStepDelay, |
| 1342 cricket::ICEPROTO_GOOGLE); |
1236 | 1343 |
1237 SetAllocatorFlags(0, kOnlyLocalPorts); | 1344 SetAllocatorFlags(0, kOnlyLocalPorts); |
1238 CreateChannels(1); | 1345 CreateChannels(1); |
1239 ep1_ch1()->set_incoming_only(true); | 1346 ep1_ch1()->set_incoming_only(true); |
1240 | 1347 |
1241 // Pump for 1 second and verify that the channels are not connected. | 1348 // Pump for 1 second and verify that the channels are not connected. |
1242 rtc::Thread::Current()->ProcessMessages(1000); | 1349 rtc::Thread::Current()->ProcessMessages(1000); |
1243 | 1350 |
1244 EXPECT_FALSE(ep1_ch1()->readable()); | 1351 EXPECT_FALSE(ep1_ch1()->readable()); |
1245 EXPECT_FALSE(ep1_ch1()->writable()); | 1352 EXPECT_FALSE(ep1_ch1()->writable()); |
1246 EXPECT_FALSE(ep2_ch1()->readable()); | 1353 EXPECT_FALSE(ep2_ch1()->readable()); |
1247 EXPECT_FALSE(ep2_ch1()->writable()); | 1354 EXPECT_FALSE(ep2_ch1()->writable()); |
1248 | 1355 |
1249 DestroyChannels(); | 1356 DestroyChannels(); |
1250 } | 1357 } |
1251 | 1358 |
1252 // Test that a peer behind NAT can connect to a peer that has | 1359 // Test that a peer behind NAT can connect to a peer that has |
1253 // incoming_only flag set. | 1360 // incoming_only flag set. |
1254 TEST_F(P2PTransportChannelTest, IncomingOnlyOpen) { | 1361 TEST_F(P2PTransportChannelTest, IncomingOnlyOpen) { |
1255 ConfigureEndpoints(OPEN, NAT_FULL_CONE, | 1362 ConfigureEndpoints(OPEN, NAT_FULL_CONE, |
1256 kDefaultPortAllocatorFlags, | 1363 kDefaultPortAllocatorFlags, |
1257 kDefaultPortAllocatorFlags); | 1364 kDefaultPortAllocatorFlags, |
| 1365 kDefaultStepDelay, kDefaultStepDelay, |
| 1366 cricket::ICEPROTO_GOOGLE); |
1258 | 1367 |
1259 SetAllocatorFlags(0, kOnlyLocalPorts); | 1368 SetAllocatorFlags(0, kOnlyLocalPorts); |
1260 CreateChannels(1); | 1369 CreateChannels(1); |
1261 ep1_ch1()->set_incoming_only(true); | 1370 ep1_ch1()->set_incoming_only(true); |
1262 | 1371 |
1263 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && | 1372 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && |
1264 ep1_ch1()->readable() && ep1_ch1()->writable() && | 1373 ep1_ch1()->readable() && ep1_ch1()->writable() && |
1265 ep2_ch1()->readable() && ep2_ch1()->writable(), | 1374 ep2_ch1()->readable() && ep2_ch1()->writable(), |
1266 1000, 1000); | 1375 1000, 1000); |
1267 | 1376 |
1268 DestroyChannels(); | 1377 DestroyChannels(); |
1269 } | 1378 } |
1270 | 1379 |
1271 TEST_F(P2PTransportChannelTest, TestTcpConnectionsFromActiveToPassive) { | 1380 TEST_F(P2PTransportChannelTest, TestTcpConnectionsFromActiveToPassive) { |
1272 AddAddress(0, kPublicAddrs[0]); | 1381 AddAddress(0, kPublicAddrs[0]); |
1273 AddAddress(1, kPublicAddrs[1]); | 1382 AddAddress(1, kPublicAddrs[1]); |
1274 | 1383 |
1275 SetAllocationStepDelay(0, kMinimumStepDelay); | 1384 SetAllocationStepDelay(0, kMinimumStepDelay); |
1276 SetAllocationStepDelay(1, kMinimumStepDelay); | 1385 SetAllocationStepDelay(1, kMinimumStepDelay); |
1277 | 1386 |
1278 int kOnlyLocalTcpPorts = cricket::PORTALLOCATOR_DISABLE_UDP | | 1387 int kOnlyLocalTcpPorts = cricket::PORTALLOCATOR_DISABLE_UDP | |
1279 cricket::PORTALLOCATOR_DISABLE_STUN | | 1388 cricket::PORTALLOCATOR_DISABLE_STUN | |
1280 cricket::PORTALLOCATOR_DISABLE_RELAY; | 1389 cricket::PORTALLOCATOR_DISABLE_RELAY | |
| 1390 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG; |
1281 // Disable all protocols except TCP. | 1391 // Disable all protocols except TCP. |
1282 SetAllocatorFlags(0, kOnlyLocalTcpPorts); | 1392 SetAllocatorFlags(0, kOnlyLocalTcpPorts); |
1283 SetAllocatorFlags(1, kOnlyLocalTcpPorts); | 1393 SetAllocatorFlags(1, kOnlyLocalTcpPorts); |
1284 | 1394 |
1285 SetAllowTcpListen(0, true); // actpass. | 1395 SetAllowTcpListen(0, true); // actpass. |
1286 SetAllowTcpListen(1, false); // active. | 1396 SetAllowTcpListen(1, false); // active. |
1287 | 1397 |
1288 CreateChannels(1); | 1398 CreateChannels(1); |
1289 | 1399 |
1290 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && ep1_ch1()->writable() && | 1400 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && ep1_ch1()->writable() && |
(...skipping 20 matching lines...) Expand all Loading... |
1311 TestSignalRoleConflict(); | 1421 TestSignalRoleConflict(); |
1312 } | 1422 } |
1313 | 1423 |
1314 // Tests that the ice configs (protocol, tiebreaker and role) can be passed | 1424 // Tests that the ice configs (protocol, tiebreaker and role) can be passed |
1315 // down to ports. | 1425 // down to ports. |
1316 TEST_F(P2PTransportChannelTest, TestIceConfigWillPassDownToPort) { | 1426 TEST_F(P2PTransportChannelTest, TestIceConfigWillPassDownToPort) { |
1317 AddAddress(0, kPublicAddrs[0]); | 1427 AddAddress(0, kPublicAddrs[0]); |
1318 AddAddress(1, kPublicAddrs[1]); | 1428 AddAddress(1, kPublicAddrs[1]); |
1319 | 1429 |
1320 SetIceRole(0, cricket::ICEROLE_CONTROLLING); | 1430 SetIceRole(0, cricket::ICEROLE_CONTROLLING); |
| 1431 SetIceProtocol(0, cricket::ICEPROTO_GOOGLE); |
1321 SetIceTiebreaker(0, kTiebreaker1); | 1432 SetIceTiebreaker(0, kTiebreaker1); |
1322 SetIceRole(1, cricket::ICEROLE_CONTROLLING); | 1433 SetIceRole(1, cricket::ICEROLE_CONTROLLING); |
| 1434 SetIceProtocol(1, cricket::ICEPROTO_RFC5245); |
1323 SetIceTiebreaker(1, kTiebreaker2); | 1435 SetIceTiebreaker(1, kTiebreaker2); |
1324 | 1436 |
1325 CreateChannels(1); | 1437 CreateChannels(1); |
1326 | 1438 |
1327 EXPECT_EQ_WAIT(2u, ep1_ch1()->ports().size(), 1000); | 1439 EXPECT_EQ_WAIT(2u, ep1_ch1()->ports().size(), 1000); |
1328 | 1440 |
1329 const std::vector<cricket::PortInterface *> ports_before = ep1_ch1()->ports(); | 1441 const std::vector<cricket::PortInterface *> ports_before = ep1_ch1()->ports(); |
1330 for (size_t i = 0; i < ports_before.size(); ++i) { | 1442 for (size_t i = 0; i < ports_before.size(); ++i) { |
1331 EXPECT_EQ(cricket::ICEROLE_CONTROLLING, ports_before[i]->GetIceRole()); | 1443 EXPECT_EQ(cricket::ICEROLE_CONTROLLING, ports_before[i]->GetIceRole()); |
| 1444 EXPECT_EQ(cricket::ICEPROTO_GOOGLE, ports_before[i]->IceProtocol()); |
1332 EXPECT_EQ(kTiebreaker1, ports_before[i]->IceTiebreaker()); | 1445 EXPECT_EQ(kTiebreaker1, ports_before[i]->IceTiebreaker()); |
1333 } | 1446 } |
1334 | 1447 |
1335 ep1_ch1()->SetIceRole(cricket::ICEROLE_CONTROLLED); | 1448 ep1_ch1()->SetIceRole(cricket::ICEROLE_CONTROLLED); |
| 1449 ep1_ch1()->SetIceProtocolType(cricket::ICEPROTO_RFC5245); |
1336 ep1_ch1()->SetIceTiebreaker(kTiebreaker2); | 1450 ep1_ch1()->SetIceTiebreaker(kTiebreaker2); |
1337 | 1451 |
1338 const std::vector<cricket::PortInterface *> ports_after = ep1_ch1()->ports(); | 1452 const std::vector<cricket::PortInterface *> ports_after = ep1_ch1()->ports(); |
1339 for (size_t i = 0; i < ports_after.size(); ++i) { | 1453 for (size_t i = 0; i < ports_after.size(); ++i) { |
1340 EXPECT_EQ(cricket::ICEROLE_CONTROLLED, ports_before[i]->GetIceRole()); | 1454 EXPECT_EQ(cricket::ICEROLE_CONTROLLED, ports_before[i]->GetIceRole()); |
| 1455 EXPECT_EQ(cricket::ICEPROTO_RFC5245, ports_before[i]->IceProtocol()); |
1341 // SetIceTiebreaker after Connect() has been called will fail. So expect the | 1456 // SetIceTiebreaker after Connect() has been called will fail. So expect the |
1342 // original value. | 1457 // original value. |
1343 EXPECT_EQ(kTiebreaker1, ports_before[i]->IceTiebreaker()); | 1458 EXPECT_EQ(kTiebreaker1, ports_before[i]->IceTiebreaker()); |
1344 } | 1459 } |
1345 | 1460 |
1346 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && | 1461 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && |
1347 ep1_ch1()->writable() && | 1462 ep1_ch1()->writable() && |
1348 ep2_ch1()->readable() && | 1463 ep2_ch1()->readable() && |
1349 ep2_ch1()->writable(), | 1464 ep2_ch1()->writable(), |
1350 1000); | 1465 1000); |
1351 | 1466 |
1352 EXPECT_TRUE(ep1_ch1()->best_connection() && | 1467 EXPECT_TRUE(ep1_ch1()->best_connection() && |
1353 ep2_ch1()->best_connection()); | 1468 ep2_ch1()->best_connection()); |
1354 | 1469 |
1355 TestSendRecv(1); | 1470 TestSendRecv(1); |
1356 DestroyChannels(); | 1471 DestroyChannels(); |
1357 } | 1472 } |
1358 | 1473 |
| 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 |
1359 // Verify that we can set DSCP value and retrieve properly from P2PTC. | 1486 // Verify that we can set DSCP value and retrieve properly from P2PTC. |
1360 TEST_F(P2PTransportChannelTest, TestDefaultDscpValue) { | 1487 TEST_F(P2PTransportChannelTest, TestDefaultDscpValue) { |
1361 AddAddress(0, kPublicAddrs[0]); | 1488 AddAddress(0, kPublicAddrs[0]); |
1362 AddAddress(1, kPublicAddrs[1]); | 1489 AddAddress(1, kPublicAddrs[1]); |
1363 | 1490 |
1364 CreateChannels(1); | 1491 CreateChannels(1); |
1365 EXPECT_EQ(rtc::DSCP_NO_CHANGE, | 1492 EXPECT_EQ(rtc::DSCP_NO_CHANGE, |
1366 GetEndpoint(0)->cd1_.ch_->DefaultDscpValue()); | 1493 GetEndpoint(0)->cd1_.ch_->DefaultDscpValue()); |
1367 EXPECT_EQ(rtc::DSCP_NO_CHANGE, | 1494 EXPECT_EQ(rtc::DSCP_NO_CHANGE, |
1368 GetEndpoint(1)->cd1_.ch_->DefaultDscpValue()); | 1495 GetEndpoint(1)->cd1_.ch_->DefaultDscpValue()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 RemoteCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[1])); | 1536 RemoteCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[1])); |
1410 | 1537 |
1411 TestSendRecv(1); | 1538 TestSendRecv(1); |
1412 DestroyChannels(); | 1539 DestroyChannels(); |
1413 } | 1540 } |
1414 | 1541 |
1415 // Testing forceful TURN connections. | 1542 // Testing forceful TURN connections. |
1416 TEST_F(P2PTransportChannelTest, TestForceTurn) { | 1543 TEST_F(P2PTransportChannelTest, TestForceTurn) { |
1417 ConfigureEndpoints(NAT_PORT_RESTRICTED, NAT_SYMMETRIC, | 1544 ConfigureEndpoints(NAT_PORT_RESTRICTED, NAT_SYMMETRIC, |
1418 kDefaultPortAllocatorFlags | | 1545 kDefaultPortAllocatorFlags | |
1419 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET, | 1546 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 1547 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG, |
1420 kDefaultPortAllocatorFlags | | 1548 kDefaultPortAllocatorFlags | |
1421 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1549 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 1550 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG, |
| 1551 kDefaultStepDelay, kDefaultStepDelay, |
| 1552 cricket::ICEPROTO_RFC5245); |
1422 set_force_relay(true); | 1553 set_force_relay(true); |
1423 | 1554 |
1424 SetAllocationStepDelay(0, kMinimumStepDelay); | 1555 SetAllocationStepDelay(0, kMinimumStepDelay); |
1425 SetAllocationStepDelay(1, kMinimumStepDelay); | 1556 SetAllocationStepDelay(1, kMinimumStepDelay); |
1426 | 1557 |
1427 CreateChannels(1); | 1558 CreateChannels(1); |
1428 | 1559 |
1429 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && | 1560 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && |
1430 ep1_ch1()->writable() && | 1561 ep1_ch1()->writable() && |
1431 ep2_ch1()->readable() && | 1562 ep2_ch1()->readable() && |
1432 ep2_ch1()->writable(), | 1563 ep2_ch1()->writable(), |
1433 2000); | 1564 1000); |
1434 | 1565 |
1435 EXPECT_TRUE(ep1_ch1()->best_connection() && | 1566 EXPECT_TRUE(ep1_ch1()->best_connection() && |
1436 ep2_ch1()->best_connection()); | 1567 ep2_ch1()->best_connection()); |
1437 | 1568 |
1438 EXPECT_EQ("relay", RemoteCandidate(ep1_ch1())->type()); | 1569 EXPECT_EQ("relay", RemoteCandidate(ep1_ch1())->type()); |
1439 EXPECT_EQ("relay", LocalCandidate(ep1_ch1())->type()); | 1570 EXPECT_EQ("relay", LocalCandidate(ep1_ch1())->type()); |
1440 EXPECT_EQ("relay", RemoteCandidate(ep2_ch1())->type()); | 1571 EXPECT_EQ("relay", RemoteCandidate(ep2_ch1())->type()); |
1441 EXPECT_EQ("relay", LocalCandidate(ep2_ch1())->type()); | 1572 EXPECT_EQ("relay", LocalCandidate(ep2_ch1())->type()); |
1442 | 1573 |
1443 TestSendRecv(1); | 1574 TestSendRecv(1); |
(...skipping 23 matching lines...) Expand all Loading... |
1467 AddAddress(endpoint, kCascadedPrivateAddrs[endpoint]); | 1598 AddAddress(endpoint, kCascadedPrivateAddrs[endpoint]); |
1468 nat->AddTranslator(kPrivateAddrs[endpoint], kCascadedNatAddrs[endpoint], | 1599 nat->AddTranslator(kPrivateAddrs[endpoint], kCascadedNatAddrs[endpoint], |
1469 static_cast<rtc::NATType>(config - NAT_FULL_CONE))->AddClient( | 1600 static_cast<rtc::NATType>(config - NAT_FULL_CONE))->AddClient( |
1470 kCascadedPrivateAddrs[endpoint]); | 1601 kCascadedPrivateAddrs[endpoint]); |
1471 } | 1602 } |
1472 } | 1603 } |
1473 }; | 1604 }; |
1474 | 1605 |
1475 TEST_F(P2PTransportChannelSameNatTest, TestConesBehindSameCone) { | 1606 TEST_F(P2PTransportChannelSameNatTest, TestConesBehindSameCone) { |
1476 ConfigureEndpoints(NAT_FULL_CONE, NAT_FULL_CONE, NAT_FULL_CONE); | 1607 ConfigureEndpoints(NAT_FULL_CONE, NAT_FULL_CONE, NAT_FULL_CONE); |
1477 Test(P2PTransportChannelTestBase::Result( | 1608 Test(kLocalUdpToStunUdp); |
1478 "prflx", "udp", "stun", "udp", | |
1479 "stun", "udp", "prflx", "udp", 1000)); | |
1480 } | 1609 } |
1481 | 1610 |
1482 // Test what happens when we have multiple available pathways. | 1611 // Test what happens when we have multiple available pathways. |
1483 // In the future we will try different RTTs and configs for the different | 1612 // In the future we will try different RTTs and configs for the different |
1484 // interfaces, so that we can simulate a user with Ethernet and VPN networks. | 1613 // interfaces, so that we can simulate a user with Ethernet and VPN networks. |
1485 class P2PTransportChannelMultihomedTest : public P2PTransportChannelTestBase { | 1614 class P2PTransportChannelMultihomedTest : public P2PTransportChannelTestBase { |
1486 }; | 1615 }; |
1487 | 1616 |
1488 // Test that we can establish connectivity when both peers are multihomed. | 1617 // Test that we can establish connectivity when both peers are multihomed. |
1489 TEST_F(P2PTransportChannelMultihomedTest, DISABLED_TestBasic) { | 1618 TEST_F(P2PTransportChannelMultihomedTest, DISABLED_TestBasic) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 // when we lose writability. | 1657 // when we lose writability. |
1529 EXPECT_TRUE_WAIT( | 1658 EXPECT_TRUE_WAIT( |
1530 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1659 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
1531 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1660 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
1532 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1]), | 1661 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1]), |
1533 3000); | 1662 3000); |
1534 | 1663 |
1535 DestroyChannels(); | 1664 DestroyChannels(); |
1536 } | 1665 } |
1537 | 1666 |
1538 /* | |
1539 | |
1540 TODO(pthatcher): Once have a way to handle network interfaces changes | |
1541 without signalling an ICE restart, put a test like this back. In the | |
1542 mean time, this test only worked for GICE. With ICE, it's currently | |
1543 not possible without an ICE restart. | |
1544 | |
1545 // Test that we can switch links in a coordinated fashion. | 1667 // Test that we can switch links in a coordinated fashion. |
1546 TEST_F(P2PTransportChannelMultihomedTest, TestDrain) { | 1668 TEST_F(P2PTransportChannelMultihomedTest, TestDrain) { |
1547 AddAddress(0, kPublicAddrs[0]); | 1669 AddAddress(0, kPublicAddrs[0]); |
1548 AddAddress(1, kPublicAddrs[1]); | 1670 AddAddress(1, kPublicAddrs[1]); |
1549 // Use only local ports for simplicity. | 1671 // Use only local ports for simplicity. |
1550 SetAllocatorFlags(0, kOnlyLocalPorts); | 1672 SetAllocatorFlags(0, kOnlyLocalPorts); |
1551 SetAllocatorFlags(1, kOnlyLocalPorts); | 1673 SetAllocatorFlags(1, kOnlyLocalPorts); |
1552 | 1674 |
1553 // Create channels and let them go writable, as usual. | 1675 // Create channels and let them go writable, as usual. |
1554 CreateChannels(1); | 1676 CreateChannels(1); |
1555 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && ep1_ch1()->writable() && | 1677 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && ep1_ch1()->writable() && |
1556 ep2_ch1()->readable() && ep2_ch1()->writable(), | 1678 ep2_ch1()->readable() && ep2_ch1()->writable(), |
1557 1000); | 1679 1000); |
1558 EXPECT_TRUE( | 1680 EXPECT_TRUE( |
1559 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1681 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
1560 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1682 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
1561 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1683 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
1562 | 1684 |
1563 | |
1564 // Remove the public interface, add the alternate interface, and allocate | 1685 // Remove the public interface, add the alternate interface, and allocate |
1565 // a new generation of candidates for the new interface (via Connect()). | 1686 // a new generation of candidates for the new interface (via Connect()). |
1566 LOG(LS_INFO) << "Draining..."; | 1687 LOG(LS_INFO) << "Draining..."; |
1567 AddAddress(1, kAlternateAddrs[1]); | 1688 AddAddress(1, kAlternateAddrs[1]); |
1568 RemoveAddress(1, kPublicAddrs[1]); | 1689 RemoveAddress(1, kPublicAddrs[1]); |
1569 ep2_ch1()->Connect(); | 1690 ep2_ch1()->Connect(); |
1570 | 1691 |
1571 // We should switch over to use the alternate address after | 1692 // We should switch over to use the alternate address after |
1572 // an exchange of pings. | 1693 // an exchange of pings. |
1573 EXPECT_TRUE_WAIT( | 1694 EXPECT_TRUE_WAIT( |
1574 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1695 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
1575 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1696 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
1576 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1]), | 1697 RemoteCandidate(ep1_ch1())->address().EqualIPs(kAlternateAddrs[1]), |
1577 3000); | 1698 3000); |
1578 | 1699 |
1579 DestroyChannels(); | 1700 DestroyChannels(); |
1580 } | 1701 } |
1581 | 1702 |
1582 */ | |
1583 | |
1584 // A collection of tests which tests a single P2PTransportChannel by sending | 1703 // A collection of tests which tests a single P2PTransportChannel by sending |
1585 // pings. | 1704 // pings. |
1586 class P2PTransportChannelPingTest : public testing::Test, | 1705 class P2PTransportChannelPingTest : public testing::Test, |
1587 public sigslot::has_slots<> { | 1706 public sigslot::has_slots<> { |
1588 public: | 1707 public: |
1589 P2PTransportChannelPingTest() | 1708 P2PTransportChannelPingTest() |
1590 : pss_(new rtc::PhysicalSocketServer), | 1709 : pss_(new rtc::PhysicalSocketServer), |
1591 vss_(new rtc::VirtualSocketServer(pss_.get())), | 1710 vss_(new rtc::VirtualSocketServer(pss_.get())), |
1592 ss_scope_(vss_.get()) {} | 1711 ss_scope_(vss_.get()) {} |
1593 | 1712 |
1594 protected: | 1713 protected: |
1595 void PrepareChannel(cricket::P2PTransportChannel* ch) { | 1714 void PrepareChannel(cricket::P2PTransportChannel* ch) { |
1596 ch->SignalRequestSignaling.connect( | 1715 ch->SignalRequestSignaling.connect( |
1597 this, &P2PTransportChannelPingTest::OnChannelRequestSignaling); | 1716 this, &P2PTransportChannelPingTest::OnChannelRequestSignaling); |
| 1717 ch->SetIceProtocolType(cricket::ICEPROTO_RFC5245); |
1598 ch->SetIceRole(cricket::ICEROLE_CONTROLLING); | 1718 ch->SetIceRole(cricket::ICEROLE_CONTROLLING); |
1599 ch->SetIceCredentials(kIceUfrag[0], kIcePwd[0]); | 1719 ch->SetIceCredentials(kIceUfrag[0], kIcePwd[0]); |
1600 ch->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 1720 ch->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); |
1601 } | 1721 } |
1602 | 1722 |
1603 void OnChannelRequestSignaling(cricket::TransportChannelImpl* channel) { | 1723 void OnChannelRequestSignaling(cricket::TransportChannelImpl* channel) { |
1604 channel->OnSignalingReady(); | 1724 channel->OnSignalingReady(); |
1605 } | 1725 } |
1606 | 1726 |
1607 cricket::Candidate CreateCandidate(const std::string& ip, | 1727 cricket::Candidate CreateCandidate(const std::string& ip, |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1935 conn3->ReceivedPingResponse(); // Become writable. | 2055 conn3->ReceivedPingResponse(); // Become writable. |
1936 EXPECT_EQ(conn3, ch.best_connection()); | 2056 EXPECT_EQ(conn3, ch.best_connection()); |
1937 | 2057 |
1938 // Now another data packet will not switch the best connection because the | 2058 // Now another data packet will not switch the best connection because the |
1939 // best connection was nominated by the controlling side. | 2059 // best connection was nominated by the controlling side. |
1940 conn2->ReceivedPing(); | 2060 conn2->ReceivedPing(); |
1941 conn2->ReceivedPingResponse(); | 2061 conn2->ReceivedPingResponse(); |
1942 conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); | 2062 conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); |
1943 EXPECT_EQ(conn3, ch.best_connection()); | 2063 EXPECT_EQ(conn3, ch.best_connection()); |
1944 } | 2064 } |
OLD | NEW |