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 2435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2446 EXPECT_EQ(conn3, ch.best_connection()); | 2446 EXPECT_EQ(conn3, ch.best_connection()); |
2447 | 2447 |
2448 // Now another data packet will not switch the best connection because the | 2448 // Now another data packet will not switch the best connection because the |
2449 // best connection was nominated by the controlling side. | 2449 // best connection was nominated by the controlling side. |
2450 conn2->ReceivedPing(); | 2450 conn2->ReceivedPing(); |
2451 conn2->ReceivedPingResponse(); | 2451 conn2->ReceivedPingResponse(); |
2452 conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); | 2452 conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); |
2453 EXPECT_EQ(conn3, ch.best_connection()); | 2453 EXPECT_EQ(conn3, ch.best_connection()); |
2454 } | 2454 } |
2455 | 2455 |
2456 // Test that if a new remote candidate has the same address and port with | |
2457 // an old one, it will be used to create a new connection. | |
2458 TEST_F(P2PTransportChannelPingTest, TestAddRemoteCandidateWithAddressReuse) { | |
2459 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); | |
2460 cricket::P2PTransportChannel ch("candidate reuse", 1, &pa); | |
2461 PrepareChannel(&ch); | |
2462 ch.Connect(); | |
2463 ch.MaybeStartGathering(); | |
2464 const std::string host_address = "1.1.1.1"; | |
2465 const int port_num = 1; | |
2466 | |
2467 // kIceUfrag[1] is the current generation ufrag. | |
2468 cricket::Candidate candidate = | |
2469 CreateHostCandidate(host_address, port_num, 1, kIceUfrag[1]); | |
2470 ch.AddRemoteCandidate(candidate); | |
2471 cricket::Connection* conn1 = WaitForConnectionTo(&ch, host_address, port_num); | |
2472 ASSERT_TRUE(conn1 != nullptr); | |
2473 EXPECT_EQ(0u, conn1->remote_candidate().generation()); | |
2474 | |
2475 // Simply adding the same candidate again won't create a new connection. | |
2476 ch.AddRemoteCandidate(candidate); | |
2477 cricket::Connection* conn2 = GetConnectionTo(&ch, host_address, port_num); | |
2478 EXPECT_EQ(conn1, conn2); | |
2479 | |
2480 // Update the ufrag of the candidate and add it again. | |
2481 candidate.set_username(kIceUfrag[2]); | |
2482 ch.AddRemoteCandidate(candidate); | |
2483 conn2 = GetConnectionTo(&ch, host_address, port_num); | |
2484 EXPECT_NE(conn1, conn2); | |
2485 EXPECT_EQ(kIceUfrag[2], conn2->remote_candidate().username()); | |
2486 EXPECT_EQ(1u, conn2->remote_candidate().generation()); | |
pthatcher1
2016/05/31 20:09:29
Can't we right here inject a STUN ping into the co
honghaiz3
2016/05/31 23:25:23
Added per your suggestion, although I still feel i
pthatcher1
2016/06/01 01:57:04
I agree it's not optimal, but I still think it's b
honghaiz3
2016/06/01 16:37:59
Acknowledged.
| |
2487 } | |
2488 | |
2456 // When the current best connection is strong, lower-priority connections will | 2489 // When the current best connection is strong, lower-priority connections will |
2457 // be pruned. Otherwise, lower-priority connections are kept. | 2490 // be pruned. Otherwise, lower-priority connections are kept. |
2458 TEST_F(P2PTransportChannelPingTest, TestDontPruneWhenWeak) { | 2491 TEST_F(P2PTransportChannelPingTest, TestDontPruneWhenWeak) { |
2459 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 2492 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
2460 cricket::P2PTransportChannel ch("test channel", 1, &pa); | 2493 cricket::P2PTransportChannel ch("test channel", 1, &pa); |
2461 PrepareChannel(&ch); | 2494 PrepareChannel(&ch); |
2462 ch.SetIceRole(cricket::ICEROLE_CONTROLLED); | 2495 ch.SetIceRole(cricket::ICEROLE_CONTROLLED); |
2463 ch.Connect(); | 2496 ch.Connect(); |
2464 ch.MaybeStartGathering(); | 2497 ch.MaybeStartGathering(); |
2465 ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 1)); | 2498 ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 1)); |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2857 | 2890 |
2858 // TCP Relay/Relay is the next. | 2891 // TCP Relay/Relay is the next. |
2859 VerifyNextPingableConnection(cricket::RELAY_PORT_TYPE, | 2892 VerifyNextPingableConnection(cricket::RELAY_PORT_TYPE, |
2860 cricket::RELAY_PORT_TYPE, | 2893 cricket::RELAY_PORT_TYPE, |
2861 cricket::TCP_PROTOCOL_NAME); | 2894 cricket::TCP_PROTOCOL_NAME); |
2862 | 2895 |
2863 // Finally, Local/Relay will be pinged. | 2896 // Finally, Local/Relay will be pinged. |
2864 VerifyNextPingableConnection(cricket::LOCAL_PORT_TYPE, | 2897 VerifyNextPingableConnection(cricket::LOCAL_PORT_TYPE, |
2865 cricket::RELAY_PORT_TYPE); | 2898 cricket::RELAY_PORT_TYPE); |
2866 } | 2899 } |
OLD | NEW |