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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 } | 485 } |
486 } | 486 } |
487 | 487 |
488 void Test(const Result& expected) { | 488 void Test(const Result& expected) { |
489 int32 connect_start = rtc::Time(), connect_time; | 489 int32 connect_start = rtc::Time(), connect_time; |
490 | 490 |
491 // Create the channels and wait for them to connect. | 491 // Create the channels and wait for them to connect. |
492 CreateChannels(1); | 492 CreateChannels(1); |
493 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && | 493 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && |
494 ep2_ch1() != NULL && | 494 ep2_ch1() != NULL && |
495 ep1_ch1()->readable() && | 495 ep1_ch1()->receiving() && |
496 ep1_ch1()->writable() && | 496 ep1_ch1()->writable() && |
497 ep2_ch1()->readable() && | 497 ep2_ch1()->receiving() && |
498 ep2_ch1()->writable(), | 498 ep2_ch1()->writable(), |
499 expected.connect_wait, | 499 expected.connect_wait, |
500 1000); | 500 1000); |
501 connect_time = rtc::TimeSince(connect_start); | 501 connect_time = rtc::TimeSince(connect_start); |
502 if (connect_time < expected.connect_wait) { | 502 if (connect_time < expected.connect_wait) { |
503 LOG(LS_INFO) << "Connect time: " << connect_time << " ms"; | 503 LOG(LS_INFO) << "Connect time: " << connect_time << " ms"; |
504 } else { | 504 } else { |
505 LOG(LS_INFO) << "Connect time: " << "TIMEOUT (" | 505 LOG(LS_INFO) << "Connect time: " << "TIMEOUT (" |
506 << expected.connect_wait << " ms)"; | 506 << expected.connect_wait << " ms)"; |
507 } | 507 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 if (channels == 2 && ep1_ch2() && ep2_ch2()) { | 554 if (channels == 2 && ep1_ch2() && ep2_ch2()) { |
555 // local_channel2 <==> remote_channel2 | 555 // local_channel2 <==> remote_channel2 |
556 EXPECT_EQ_WAIT(len, SendData(ep1_ch2(), data, len), 1000); | 556 EXPECT_EQ_WAIT(len, SendData(ep1_ch2(), data, len), 1000); |
557 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep2_ch2(), data, len), 1000); | 557 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep2_ch2(), data, len), 1000); |
558 EXPECT_EQ_WAIT(len, SendData(ep2_ch2(), data, len), 1000); | 558 EXPECT_EQ_WAIT(len, SendData(ep2_ch2(), data, len), 1000); |
559 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep1_ch2(), data, len), 1000); | 559 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep1_ch2(), data, len), 1000); |
560 } | 560 } |
561 } | 561 } |
562 } | 562 } |
563 | 563 |
564 // This test waits for the transport to become readable and writable on both | 564 // This test waits for the transport to become receiving and writable on both |
565 // end points. Once they are, the end points set new local ice credentials to | 565 // end points. Once they are, the end points set new local ice credentials to |
566 // restart the ice gathering. Finally it waits for the transport to select a | 566 // restart the ice gathering. Finally it waits for the transport to select a |
567 // new connection using the newly generated ice candidates. | 567 // new connection using the newly generated ice candidates. |
568 // Before calling this function the end points must be configured. | 568 // Before calling this function the end points must be configured. |
569 void TestHandleIceUfragPasswordChanged() { | 569 void TestHandleIceUfragPasswordChanged() { |
570 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); | 570 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); |
571 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); | 571 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); |
572 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->readable() && ep1_ch1()->writable() && | 572 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
573 ep2_ch1()->readable() && ep2_ch1()->writable(), | 573 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
574 1000, 1000); | 574 1000, 1000); |
575 | 575 |
576 const cricket::Candidate* old_local_candidate1 = LocalCandidate(ep1_ch1()); | 576 const cricket::Candidate* old_local_candidate1 = LocalCandidate(ep1_ch1()); |
577 const cricket::Candidate* old_local_candidate2 = LocalCandidate(ep2_ch1()); | 577 const cricket::Candidate* old_local_candidate2 = LocalCandidate(ep2_ch1()); |
578 const cricket::Candidate* old_remote_candidate1 = | 578 const cricket::Candidate* old_remote_candidate1 = |
579 RemoteCandidate(ep1_ch1()); | 579 RemoteCandidate(ep1_ch1()); |
580 const cricket::Candidate* old_remote_candidate2 = | 580 const cricket::Candidate* old_remote_candidate2 = |
581 RemoteCandidate(ep2_ch1()); | 581 RemoteCandidate(ep2_ch1()); |
582 | 582 |
583 ep1_ch1()->SetIceCredentials(kIceUfrag[2], kIcePwd[2]); | 583 ep1_ch1()->SetIceCredentials(kIceUfrag[2], kIcePwd[2]); |
(...skipping 23 matching lines...) Expand all Loading... |
607 SetIceRole(1, cricket::ICEROLE_CONTROLLING); | 607 SetIceRole(1, cricket::ICEROLE_CONTROLLING); |
608 SetIceTiebreaker(1, kTiebreaker2); | 608 SetIceTiebreaker(1, kTiebreaker2); |
609 | 609 |
610 // Creating channels with both channels role set to CONTROLLING. | 610 // Creating channels with both channels role set to CONTROLLING. |
611 CreateChannels(1); | 611 CreateChannels(1); |
612 // Since both the channels initiated with controlling state and channel2 | 612 // Since both the channels initiated with controlling state and channel2 |
613 // has higher tiebreaker value, channel1 should receive SignalRoleConflict. | 613 // has higher tiebreaker value, channel1 should receive SignalRoleConflict. |
614 EXPECT_TRUE_WAIT(GetRoleConflict(0), 1000); | 614 EXPECT_TRUE_WAIT(GetRoleConflict(0), 1000); |
615 EXPECT_FALSE(GetRoleConflict(1)); | 615 EXPECT_FALSE(GetRoleConflict(1)); |
616 | 616 |
617 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && | 617 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && |
618 ep1_ch1()->writable() && | 618 ep1_ch1()->writable() && |
619 ep2_ch1()->readable() && | 619 ep2_ch1()->receiving() && |
620 ep2_ch1()->writable(), | 620 ep2_ch1()->writable(), |
621 1000); | 621 1000); |
622 | 622 |
623 EXPECT_TRUE(ep1_ch1()->best_connection() && | 623 EXPECT_TRUE(ep1_ch1()->best_connection() && |
624 ep2_ch1()->best_connection()); | 624 ep2_ch1()->best_connection()); |
625 | 625 |
626 TestSendRecv(1); | 626 TestSendRecv(1); |
627 } | 627 } |
628 | 628 |
629 void OnChannelRequestSignaling(cricket::TransportChannelImpl* channel) { | 629 void OnChannelRequestSignaling(cricket::TransportChannelImpl* channel) { |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 TestHandleIceUfragPasswordChanged(); | 1096 TestHandleIceUfragPasswordChanged(); |
1097 DestroyChannels(); | 1097 DestroyChannels(); |
1098 } | 1098 } |
1099 | 1099 |
1100 // Test the operation of GetStats. | 1100 // Test the operation of GetStats. |
1101 TEST_F(P2PTransportChannelTest, GetStats) { | 1101 TEST_F(P2PTransportChannelTest, GetStats) { |
1102 ConfigureEndpoints(OPEN, OPEN, | 1102 ConfigureEndpoints(OPEN, OPEN, |
1103 kDefaultPortAllocatorFlags, | 1103 kDefaultPortAllocatorFlags, |
1104 kDefaultPortAllocatorFlags); | 1104 kDefaultPortAllocatorFlags); |
1105 CreateChannels(1); | 1105 CreateChannels(1); |
1106 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->readable() && ep1_ch1()->writable() && | 1106 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1107 ep2_ch1()->readable() && ep2_ch1()->writable(), | 1107 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1108 1000, 1000); | 1108 1000, 1000); |
1109 TestSendRecv(1); | 1109 TestSendRecv(1); |
1110 cricket::ConnectionInfos infos; | 1110 cricket::ConnectionInfos infos; |
1111 ASSERT_TRUE(ep1_ch1()->GetStats(&infos)); | 1111 ASSERT_TRUE(ep1_ch1()->GetStats(&infos)); |
1112 ASSERT_EQ(1U, infos.size()); | 1112 ASSERT_EQ(1U, infos.size()); |
1113 EXPECT_TRUE(infos[0].new_connection); | 1113 EXPECT_TRUE(infos[0].new_connection); |
1114 EXPECT_TRUE(infos[0].best_connection); | 1114 EXPECT_TRUE(infos[0].best_connection); |
1115 EXPECT_TRUE(infos[0].readable); | 1115 EXPECT_TRUE(infos[0].receiving); |
1116 EXPECT_TRUE(infos[0].writable); | 1116 EXPECT_TRUE(infos[0].writable); |
1117 EXPECT_FALSE(infos[0].timeout); | 1117 EXPECT_FALSE(infos[0].timeout); |
1118 EXPECT_EQ(10U, infos[0].sent_total_packets); | 1118 EXPECT_EQ(10U, infos[0].sent_total_packets); |
1119 EXPECT_EQ(0U, infos[0].sent_discarded_packets); | 1119 EXPECT_EQ(0U, infos[0].sent_discarded_packets); |
1120 EXPECT_EQ(10 * 36U, infos[0].sent_total_bytes); | 1120 EXPECT_EQ(10 * 36U, infos[0].sent_total_bytes); |
1121 EXPECT_EQ(10 * 36U, infos[0].recv_total_bytes); | 1121 EXPECT_EQ(10 * 36U, infos[0].recv_total_bytes); |
1122 EXPECT_GT(infos[0].rtt, 0U); | 1122 EXPECT_GT(infos[0].rtt, 0U); |
1123 DestroyChannels(); | 1123 DestroyChannels(); |
1124 } | 1124 } |
1125 | 1125 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 kDefaultPortAllocatorFlags, | 1234 kDefaultPortAllocatorFlags, |
1235 kDefaultPortAllocatorFlags); | 1235 kDefaultPortAllocatorFlags); |
1236 | 1236 |
1237 SetAllocatorFlags(0, kOnlyLocalPorts); | 1237 SetAllocatorFlags(0, kOnlyLocalPorts); |
1238 CreateChannels(1); | 1238 CreateChannels(1); |
1239 ep1_ch1()->set_incoming_only(true); | 1239 ep1_ch1()->set_incoming_only(true); |
1240 | 1240 |
1241 // Pump for 1 second and verify that the channels are not connected. | 1241 // Pump for 1 second and verify that the channels are not connected. |
1242 rtc::Thread::Current()->ProcessMessages(1000); | 1242 rtc::Thread::Current()->ProcessMessages(1000); |
1243 | 1243 |
1244 EXPECT_FALSE(ep1_ch1()->readable()); | 1244 EXPECT_FALSE(ep1_ch1()->receiving()); |
1245 EXPECT_FALSE(ep1_ch1()->writable()); | 1245 EXPECT_FALSE(ep1_ch1()->writable()); |
1246 EXPECT_FALSE(ep2_ch1()->readable()); | 1246 EXPECT_FALSE(ep2_ch1()->receiving()); |
1247 EXPECT_FALSE(ep2_ch1()->writable()); | 1247 EXPECT_FALSE(ep2_ch1()->writable()); |
1248 | 1248 |
1249 DestroyChannels(); | 1249 DestroyChannels(); |
1250 } | 1250 } |
1251 | 1251 |
1252 // Test that a peer behind NAT can connect to a peer that has | 1252 // Test that a peer behind NAT can connect to a peer that has |
1253 // incoming_only flag set. | 1253 // incoming_only flag set. |
1254 TEST_F(P2PTransportChannelTest, IncomingOnlyOpen) { | 1254 TEST_F(P2PTransportChannelTest, IncomingOnlyOpen) { |
1255 ConfigureEndpoints(OPEN, NAT_FULL_CONE, | 1255 ConfigureEndpoints(OPEN, NAT_FULL_CONE, |
1256 kDefaultPortAllocatorFlags, | 1256 kDefaultPortAllocatorFlags, |
1257 kDefaultPortAllocatorFlags); | 1257 kDefaultPortAllocatorFlags); |
1258 | 1258 |
1259 SetAllocatorFlags(0, kOnlyLocalPorts); | 1259 SetAllocatorFlags(0, kOnlyLocalPorts); |
1260 CreateChannels(1); | 1260 CreateChannels(1); |
1261 ep1_ch1()->set_incoming_only(true); | 1261 ep1_ch1()->set_incoming_only(true); |
1262 | 1262 |
1263 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && | 1263 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && |
1264 ep1_ch1()->readable() && ep1_ch1()->writable() && | 1264 ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1265 ep2_ch1()->readable() && ep2_ch1()->writable(), | 1265 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1266 1000, 1000); | 1266 1000, 1000); |
1267 | 1267 |
1268 DestroyChannels(); | 1268 DestroyChannels(); |
1269 } | 1269 } |
1270 | 1270 |
1271 TEST_F(P2PTransportChannelTest, TestTcpConnectionsFromActiveToPassive) { | 1271 TEST_F(P2PTransportChannelTest, TestTcpConnectionsFromActiveToPassive) { |
1272 AddAddress(0, kPublicAddrs[0]); | 1272 AddAddress(0, kPublicAddrs[0]); |
1273 AddAddress(1, kPublicAddrs[1]); | 1273 AddAddress(1, kPublicAddrs[1]); |
1274 | 1274 |
1275 SetAllocationStepDelay(0, kMinimumStepDelay); | 1275 SetAllocationStepDelay(0, kMinimumStepDelay); |
1276 SetAllocationStepDelay(1, kMinimumStepDelay); | 1276 SetAllocationStepDelay(1, kMinimumStepDelay); |
1277 | 1277 |
1278 int kOnlyLocalTcpPorts = cricket::PORTALLOCATOR_DISABLE_UDP | | 1278 int kOnlyLocalTcpPorts = cricket::PORTALLOCATOR_DISABLE_UDP | |
1279 cricket::PORTALLOCATOR_DISABLE_STUN | | 1279 cricket::PORTALLOCATOR_DISABLE_STUN | |
1280 cricket::PORTALLOCATOR_DISABLE_RELAY; | 1280 cricket::PORTALLOCATOR_DISABLE_RELAY; |
1281 // Disable all protocols except TCP. | 1281 // Disable all protocols except TCP. |
1282 SetAllocatorFlags(0, kOnlyLocalTcpPorts); | 1282 SetAllocatorFlags(0, kOnlyLocalTcpPorts); |
1283 SetAllocatorFlags(1, kOnlyLocalTcpPorts); | 1283 SetAllocatorFlags(1, kOnlyLocalTcpPorts); |
1284 | 1284 |
1285 SetAllowTcpListen(0, true); // actpass. | 1285 SetAllowTcpListen(0, true); // actpass. |
1286 SetAllowTcpListen(1, false); // active. | 1286 SetAllowTcpListen(1, false); // active. |
1287 | 1287 |
1288 CreateChannels(1); | 1288 CreateChannels(1); |
1289 | 1289 |
1290 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && ep1_ch1()->writable() && | 1290 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1291 ep2_ch1()->readable() && ep2_ch1()->writable(), | 1291 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1292 1000); | 1292 1000); |
1293 EXPECT_TRUE( | 1293 EXPECT_TRUE( |
1294 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1294 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
1295 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1295 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
1296 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1296 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
1297 | 1297 |
1298 std::string kTcpProtocol = "tcp"; | 1298 std::string kTcpProtocol = "tcp"; |
1299 EXPECT_EQ(kTcpProtocol, RemoteCandidate(ep1_ch1())->protocol()); | 1299 EXPECT_EQ(kTcpProtocol, RemoteCandidate(ep1_ch1())->protocol()); |
1300 EXPECT_EQ(kTcpProtocol, LocalCandidate(ep1_ch1())->protocol()); | 1300 EXPECT_EQ(kTcpProtocol, LocalCandidate(ep1_ch1())->protocol()); |
1301 EXPECT_EQ(kTcpProtocol, RemoteCandidate(ep2_ch1())->protocol()); | 1301 EXPECT_EQ(kTcpProtocol, RemoteCandidate(ep2_ch1())->protocol()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 ep1_ch1()->SetIceTiebreaker(kTiebreaker2); | 1336 ep1_ch1()->SetIceTiebreaker(kTiebreaker2); |
1337 | 1337 |
1338 const std::vector<cricket::PortInterface *> ports_after = ep1_ch1()->ports(); | 1338 const std::vector<cricket::PortInterface *> ports_after = ep1_ch1()->ports(); |
1339 for (size_t i = 0; i < ports_after.size(); ++i) { | 1339 for (size_t i = 0; i < ports_after.size(); ++i) { |
1340 EXPECT_EQ(cricket::ICEROLE_CONTROLLED, ports_before[i]->GetIceRole()); | 1340 EXPECT_EQ(cricket::ICEROLE_CONTROLLED, ports_before[i]->GetIceRole()); |
1341 // SetIceTiebreaker after Connect() has been called will fail. So expect the | 1341 // SetIceTiebreaker after Connect() has been called will fail. So expect the |
1342 // original value. | 1342 // original value. |
1343 EXPECT_EQ(kTiebreaker1, ports_before[i]->IceTiebreaker()); | 1343 EXPECT_EQ(kTiebreaker1, ports_before[i]->IceTiebreaker()); |
1344 } | 1344 } |
1345 | 1345 |
1346 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && | 1346 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && |
1347 ep1_ch1()->writable() && | 1347 ep1_ch1()->writable() && |
1348 ep2_ch1()->readable() && | 1348 ep2_ch1()->receiving() && |
1349 ep2_ch1()->writable(), | 1349 ep2_ch1()->writable(), |
1350 1000); | 1350 1000); |
1351 | 1351 |
1352 EXPECT_TRUE(ep1_ch1()->best_connection() && | 1352 EXPECT_TRUE(ep1_ch1()->best_connection() && |
1353 ep2_ch1()->best_connection()); | 1353 ep2_ch1()->best_connection()); |
1354 | 1354 |
1355 TestSendRecv(1); | 1355 TestSendRecv(1); |
1356 DestroyChannels(); | 1356 DestroyChannels(); |
1357 } | 1357 } |
1358 | 1358 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 | 1393 |
1394 SetAllocationStepDelay(0, kMinimumStepDelay); | 1394 SetAllocationStepDelay(0, kMinimumStepDelay); |
1395 SetAllocationStepDelay(1, kMinimumStepDelay); | 1395 SetAllocationStepDelay(1, kMinimumStepDelay); |
1396 | 1396 |
1397 // Enable IPv6 | 1397 // Enable IPv6 |
1398 SetAllocatorFlags(0, cricket::PORTALLOCATOR_ENABLE_IPV6); | 1398 SetAllocatorFlags(0, cricket::PORTALLOCATOR_ENABLE_IPV6); |
1399 SetAllocatorFlags(1, cricket::PORTALLOCATOR_ENABLE_IPV6); | 1399 SetAllocatorFlags(1, cricket::PORTALLOCATOR_ENABLE_IPV6); |
1400 | 1400 |
1401 CreateChannels(1); | 1401 CreateChannels(1); |
1402 | 1402 |
1403 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && ep1_ch1()->writable() && | 1403 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1404 ep2_ch1()->readable() && ep2_ch1()->writable(), | 1404 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1405 1000); | 1405 1000); |
1406 EXPECT_TRUE( | 1406 EXPECT_TRUE( |
1407 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1407 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
1408 LocalCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[0]) && | 1408 LocalCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[0]) && |
1409 RemoteCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[1])); | 1409 RemoteCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[1])); |
1410 | 1410 |
1411 TestSendRecv(1); | 1411 TestSendRecv(1); |
1412 DestroyChannels(); | 1412 DestroyChannels(); |
1413 } | 1413 } |
1414 | 1414 |
1415 // Testing forceful TURN connections. | 1415 // Testing forceful TURN connections. |
1416 TEST_F(P2PTransportChannelTest, TestForceTurn) { | 1416 TEST_F(P2PTransportChannelTest, TestForceTurn) { |
1417 ConfigureEndpoints(NAT_PORT_RESTRICTED, NAT_SYMMETRIC, | 1417 ConfigureEndpoints(NAT_PORT_RESTRICTED, NAT_SYMMETRIC, |
1418 kDefaultPortAllocatorFlags | | 1418 kDefaultPortAllocatorFlags | |
1419 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET, | 1419 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET, |
1420 kDefaultPortAllocatorFlags | | 1420 kDefaultPortAllocatorFlags | |
1421 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1421 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
1422 set_force_relay(true); | 1422 set_force_relay(true); |
1423 | 1423 |
1424 SetAllocationStepDelay(0, kMinimumStepDelay); | 1424 SetAllocationStepDelay(0, kMinimumStepDelay); |
1425 SetAllocationStepDelay(1, kMinimumStepDelay); | 1425 SetAllocationStepDelay(1, kMinimumStepDelay); |
1426 | 1426 |
1427 CreateChannels(1); | 1427 CreateChannels(1); |
1428 | 1428 |
1429 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && | 1429 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1430 ep1_ch1()->writable() && | 1430 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1431 ep2_ch1()->readable() && | |
1432 ep2_ch1()->writable(), | |
1433 2000); | 1431 2000); |
1434 | 1432 |
1435 EXPECT_TRUE(ep1_ch1()->best_connection() && | 1433 EXPECT_TRUE(ep1_ch1()->best_connection() && |
1436 ep2_ch1()->best_connection()); | 1434 ep2_ch1()->best_connection()); |
1437 | 1435 |
1438 EXPECT_EQ("relay", RemoteCandidate(ep1_ch1())->type()); | 1436 EXPECT_EQ("relay", RemoteCandidate(ep1_ch1())->type()); |
1439 EXPECT_EQ("relay", LocalCandidate(ep1_ch1())->type()); | 1437 EXPECT_EQ("relay", LocalCandidate(ep1_ch1())->type()); |
1440 EXPECT_EQ("relay", RemoteCandidate(ep2_ch1())->type()); | 1438 EXPECT_EQ("relay", RemoteCandidate(ep2_ch1())->type()); |
1441 EXPECT_EQ("relay", LocalCandidate(ep2_ch1())->type()); | 1439 EXPECT_EQ("relay", LocalCandidate(ep2_ch1())->type()); |
1442 | 1440 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 // priority than others. This is due to FakeNetwork::AddInterface method. | 1499 // priority than others. This is due to FakeNetwork::AddInterface method. |
1502 AddAddress(1, kAlternateAddrs[1]); | 1500 AddAddress(1, kAlternateAddrs[1]); |
1503 AddAddress(1, kPublicAddrs[1]); | 1501 AddAddress(1, kPublicAddrs[1]); |
1504 | 1502 |
1505 // Use only local ports for simplicity. | 1503 // Use only local ports for simplicity. |
1506 SetAllocatorFlags(0, kOnlyLocalPorts); | 1504 SetAllocatorFlags(0, kOnlyLocalPorts); |
1507 SetAllocatorFlags(1, kOnlyLocalPorts); | 1505 SetAllocatorFlags(1, kOnlyLocalPorts); |
1508 | 1506 |
1509 // Create channels and let them go writable, as usual. | 1507 // Create channels and let them go writable, as usual. |
1510 CreateChannels(1); | 1508 CreateChannels(1); |
1511 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && ep1_ch1()->writable() && | 1509 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1512 ep2_ch1()->readable() && ep2_ch1()->writable(), | 1510 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1513 1000); | 1511 1000); |
1514 EXPECT_TRUE( | 1512 EXPECT_TRUE( |
1515 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1513 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
1516 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1514 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
1517 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1515 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
1518 | 1516 |
1519 // Blackhole any traffic to or from the public addrs. | 1517 // Blackhole any traffic to or from the public addrs. |
1520 LOG(LS_INFO) << "Failing over..."; | 1518 LOG(LS_INFO) << "Failing over..."; |
1521 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, | 1519 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, |
1522 kPublicAddrs[1]); | 1520 kPublicAddrs[1]); |
(...skipping 22 matching lines...) Expand all Loading... |
1545 // Test that we can switch links in a coordinated fashion. | 1543 // Test that we can switch links in a coordinated fashion. |
1546 TEST_F(P2PTransportChannelMultihomedTest, TestDrain) { | 1544 TEST_F(P2PTransportChannelMultihomedTest, TestDrain) { |
1547 AddAddress(0, kPublicAddrs[0]); | 1545 AddAddress(0, kPublicAddrs[0]); |
1548 AddAddress(1, kPublicAddrs[1]); | 1546 AddAddress(1, kPublicAddrs[1]); |
1549 // Use only local ports for simplicity. | 1547 // Use only local ports for simplicity. |
1550 SetAllocatorFlags(0, kOnlyLocalPorts); | 1548 SetAllocatorFlags(0, kOnlyLocalPorts); |
1551 SetAllocatorFlags(1, kOnlyLocalPorts); | 1549 SetAllocatorFlags(1, kOnlyLocalPorts); |
1552 | 1550 |
1553 // Create channels and let them go writable, as usual. | 1551 // Create channels and let them go writable, as usual. |
1554 CreateChannels(1); | 1552 CreateChannels(1); |
1555 EXPECT_TRUE_WAIT(ep1_ch1()->readable() && ep1_ch1()->writable() && | 1553 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1556 ep2_ch1()->readable() && ep2_ch1()->writable(), | 1554 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1557 1000); | 1555 1000); |
1558 EXPECT_TRUE( | 1556 EXPECT_TRUE( |
1559 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1557 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
1560 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1558 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
1561 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1559 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
1562 | 1560 |
1563 | 1561 |
1564 // Remove the public interface, add the alternate interface, and allocate | 1562 // Remove the public interface, add the alternate interface, and allocate |
1565 // a new generation of candidates for the new interface (via Connect()). | 1563 // a new generation of candidates for the new interface (via Connect()). |
1566 LOG(LS_INFO) << "Draining..."; | 1564 LOG(LS_INFO) << "Draining..."; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1699 PrepareChannel(&ch); | 1697 PrepareChannel(&ch); |
1700 ch.Connect(); | 1698 ch.Connect(); |
1701 | 1699 |
1702 // Create conn1 and keep track of original candidate priority. | 1700 // Create conn1 and keep track of original candidate priority. |
1703 ch.OnCandidate(CreateCandidate("1.1.1.1", 1, 1)); | 1701 ch.OnCandidate(CreateCandidate("1.1.1.1", 1, 1)); |
1704 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 1702 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
1705 ASSERT_TRUE(conn1 != nullptr); | 1703 ASSERT_TRUE(conn1 != nullptr); |
1706 uint32 remote_priority = conn1->remote_candidate().priority(); | 1704 uint32 remote_priority = conn1->remote_candidate().priority(); |
1707 | 1705 |
1708 // Create a higher priority candidate and make the connection | 1706 // Create a higher priority candidate and make the connection |
1709 // readable/writable. This will prune conn1. | 1707 // receiving/writable. This will prune conn1. |
1710 ch.OnCandidate(CreateCandidate("2.2.2.2", 2, 2)); | 1708 ch.OnCandidate(CreateCandidate("2.2.2.2", 2, 2)); |
1711 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 1709 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
1712 ASSERT_TRUE(conn2 != nullptr); | 1710 ASSERT_TRUE(conn2 != nullptr); |
1713 conn2->ReceivedPing(); | 1711 conn2->ReceivedPing(); |
1714 conn2->ReceivedPingResponse(); | 1712 conn2->ReceivedPingResponse(); |
1715 | 1713 |
1716 // Wait for conn1 being destroyed. | 1714 // Wait for conn1 to be destroyed. |
1717 EXPECT_TRUE_WAIT(GetConnectionTo(&ch, "1.1.1.1", 1) == nullptr, 3000); | 1715 EXPECT_TRUE_WAIT(GetConnectionTo(&ch, "1.1.1.1", 1) == nullptr, 3000); |
1718 cricket::Port* port = GetPort(&ch); | 1716 cricket::Port* port = GetPort(&ch); |
1719 | 1717 |
1720 // Create a minimal STUN message with prflx priority. | 1718 // Create a minimal STUN message with prflx priority. |
1721 cricket::IceMessage request; | 1719 cricket::IceMessage request; |
1722 request.SetType(cricket::STUN_BINDING_REQUEST); | 1720 request.SetType(cricket::STUN_BINDING_REQUEST); |
1723 request.AddAttribute(new cricket::StunByteStringAttribute( | 1721 request.AddAttribute(new cricket::StunByteStringAttribute( |
1724 cricket::STUN_ATTR_USERNAME, kIceUfrag[1])); | 1722 cricket::STUN_ATTR_USERNAME, kIceUfrag[1])); |
1725 uint32 prflx_priority = cricket::ICE_TYPE_PREFERENCE_PRFLX << 24; | 1723 uint32 prflx_priority = cricket::ICE_TYPE_PREFERENCE_PRFLX << 24; |
1726 request.AddAttribute(new cricket::StunUInt32Attribute( | 1724 request.AddAttribute(new cricket::StunUInt32Attribute( |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1898 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 1896 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
1899 ASSERT_TRUE(conn1 != nullptr); | 1897 ASSERT_TRUE(conn1 != nullptr); |
1900 EXPECT_EQ(conn1, ch.best_connection()); | 1898 EXPECT_EQ(conn1, ch.best_connection()); |
1901 | 1899 |
1902 // If a data packet is received on conn2, the best connection should | 1900 // If a data packet is received on conn2, the best connection should |
1903 // switch to conn2 because the controlled side must mirror the media path | 1901 // switch to conn2 because the controlled side must mirror the media path |
1904 // chosen by the controlling side. | 1902 // chosen by the controlling side. |
1905 ch.OnCandidate(CreateCandidate("2.2.2.2", 2, 1)); | 1903 ch.OnCandidate(CreateCandidate("2.2.2.2", 2, 1)); |
1906 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 1904 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
1907 ASSERT_TRUE(conn2 != nullptr); | 1905 ASSERT_TRUE(conn2 != nullptr); |
1908 conn2->ReceivedPing(); // Become readable. | 1906 conn2->ReceivedPing(); // Start receiving. |
1909 // Do not switch because it is not writable. | 1907 // Do not switch because it is not writable. |
1910 conn2->OnReadPacket("ABC", 3, rtc::CreatePacketTime(0)); | 1908 conn2->OnReadPacket("ABC", 3, rtc::CreatePacketTime(0)); |
1911 EXPECT_EQ(conn1, ch.best_connection()); | 1909 EXPECT_EQ(conn1, ch.best_connection()); |
1912 | 1910 |
1913 conn2->ReceivedPingResponse(); // Become writable. | 1911 conn2->ReceivedPingResponse(); // Become writable. |
1914 // Switch because it is writable. | 1912 // Switch because it is writable. |
1915 conn2->OnReadPacket("DEF", 3, rtc::CreatePacketTime(0)); | 1913 conn2->OnReadPacket("DEF", 3, rtc::CreatePacketTime(0)); |
1916 EXPECT_EQ(conn2, ch.best_connection()); | 1914 EXPECT_EQ(conn2, ch.best_connection()); |
1917 | 1915 |
1918 // Now another STUN message with an unknown address and use_candidate will | 1916 // Now another STUN message with an unknown address and use_candidate will |
(...skipping 16 matching lines...) Expand all Loading... |
1935 conn3->ReceivedPingResponse(); // Become writable. | 1933 conn3->ReceivedPingResponse(); // Become writable. |
1936 EXPECT_EQ(conn3, ch.best_connection()); | 1934 EXPECT_EQ(conn3, ch.best_connection()); |
1937 | 1935 |
1938 // Now another data packet will not switch the best connection because the | 1936 // Now another data packet will not switch the best connection because the |
1939 // best connection was nominated by the controlling side. | 1937 // best connection was nominated by the controlling side. |
1940 conn2->ReceivedPing(); | 1938 conn2->ReceivedPing(); |
1941 conn2->ReceivedPingResponse(); | 1939 conn2->ReceivedPingResponse(); |
1942 conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); | 1940 conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); |
1943 EXPECT_EQ(conn3, ch.best_connection()); | 1941 EXPECT_EQ(conn3, ch.best_connection()); |
1944 } | 1942 } |
OLD | NEW |