Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Unified Diff: webrtc/p2p/base/p2ptransportchannel_unittest.cc

Issue 1944003002: Increase the stun ping interval. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Modified TestInitialPingInterval. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/p2p/base/p2ptransportchannel_unittest.cc
diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
index cbf5e76a7ae23a13376e6f8aa76ad10559978fbe..0ec4a3c6543a753dec663192ecee2ba8e3ddfabd 100644
--- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc
+++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
@@ -38,6 +38,7 @@ using cricket::kDefaultStepDelay;
using cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET;
using cricket::ServerAddresses;
using cricket::MIN_PINGS_AT_WEAK_PING_INTERVAL;
+using cricket::MIN_PINGS_TO_STABILIZE;
using rtc::SocketAddress;
static const int kDefaultTimeout = 1000;
@@ -2077,6 +2078,112 @@ TEST_F(P2PTransportChannelPingTest, TestAllConnectionsPingedSufficiently) {
kDefaultTimeout);
}
+TEST_F(P2PTransportChannelPingTest, TestInitialPingInterval) {
+ rtc::ScopedFakeClock clock;
+
+ cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
+ cricket::P2PTransportChannel ch("TestChannel", 1, &pa);
+ PrepareChannel(&ch);
+ ch.Connect();
+ ch.MaybeStartGathering();
+ ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 1));
+ cricket::Connection* conn = WaitForConnectionTo(&ch, "1.1.1.1", 1);
+ ASSERT_TRUE(conn != nullptr);
+
+ SIMULATED_WAIT(conn->num_pings_sent() == 1, kDefaultTimeout, clock);
+ int64_t start = clock.TimeNanos() / 1000000;
+ // Wait for the connection to send MIN_PINGS_AT_WEAK_PING_INTERVAL pings.
+ SIMULATED_WAIT(conn->num_pings_sent() >= MIN_PINGS_AT_WEAK_PING_INTERVAL,
+ kDefaultTimeout, clock);
+ int64_t duration = clock.TimeNanos() / 1000000 - start;
+ EXPECT_EQ((MIN_PINGS_AT_WEAK_PING_INTERVAL - 1) * cricket::WEAK_PING_INTERVAL,
+ duration);
pthatcher1 2016/06/14 00:44:28 If you use X * cricket::WEAK_PING_INTERVAL * kNum
+}
+
+TEST_F(P2PTransportChannelPingTest, TestStabilizingPingInterval) {
+ rtc::ScopedFakeClock clock;
+ int stablilizing_timeout = 2000;
+
+ cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
+ cricket::P2PTransportChannel ch("TestChannel", 1, &pa);
+ PrepareChannel(&ch);
+ ch.Connect();
+ ch.MaybeStartGathering();
+ ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 1));
+ cricket::Connection* conn = WaitForConnectionTo(&ch, "1.1.1.1", 1);
+
+ ASSERT_TRUE(conn != nullptr);
+ // Wait for the connection to send MIN_PINGS_AT_WEAK_PING_INTERVAL pings.
+ SIMULATED_WAIT(conn->num_pings_sent() >= MIN_PINGS_AT_WEAK_PING_INTERVAL,
+ kDefaultTimeout, clock);
+ // The connection become strong but not stabilized. The ping interval is
pthatcher1 2016/06/14 00:44:28 not stabilized because we haven't been able to con
+ // expected to be STABLIZING_WRITABLE_CONNECTION_PING_INTERVAL.
+ conn->ReceivedPingResponse();
+ int ping_sent_before = conn->num_pings_sent();
+ int64_t start = clock.TimeNanos() / 1000000;
+ SIMULATED_WAIT(conn->num_pings_sent() == ping_sent_before + 1,
+ stablilizing_timeout, clock);
pthatcher1 2016/06/14 00:44:28 Just use 2000 here :)
+ int64_t duration = clock.TimeNanos() / 1000000 - start;
+ EXPECT_TRUE(duration >= 900 && duration <= 1100);
pthatcher1 2016/06/14 00:44:27 EXPECT_GT(STABLIZING_INTERVAL, duration); EXPECT_L
+}
+
+TEST_F(P2PTransportChannelPingTest, TestStabilizedPingInterval) {
+ rtc::ScopedFakeClock clock;
+ int stabilized_timeout = 3000;
+
+ cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
+ cricket::P2PTransportChannel ch("TestChannel", 1, &pa);
+ PrepareChannel(&ch);
+ ch.Connect();
+ ch.MaybeStartGathering();
+ ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 1));
+ cricket::Connection* conn = WaitForConnectionTo(&ch, "1.1.1.1", 1);
+ ASSERT_TRUE(conn != nullptr);
+
+ // Wait for the connection to send MIN_PINGS_TO_STABILIZE pings to stablize.
+ SIMULATED_WAIT(conn->num_pings_sent() > MIN_PINGS_TO_STABILIZE,
+ kDefaultTimeout, clock);
+ // The connection become writable and receiving.
+ conn->ReceivedPingResponse();
pthatcher1 2016/06/14 00:44:28 You'll need to call this 4 times now to become sta
+ int ping_sent_before = conn->num_pings_sent();
+ int64_t start = clock.TimeNanos() / 1000000;
+ SIMULATED_WAIT(conn->num_pings_sent() == ping_sent_before + 1,
+ stabilized_timeout, clock);
+ int64_t duration = clock.TimeNanos() / 1000000 - start;
+ EXPECT_TRUE(duration >= 2500 && duration <= 2600);
pthatcher1 2016/06/14 00:44:27 Can you combine the two tests above?
+}
+
+// Verify that a stabilized connection will ping faster if a in-flight ping time
+// out.
+TEST_F(P2PTransportChannelPingTest, TestTimeoutPingInterval) {
+ rtc::ScopedFakeClock clock;
+ int stablilizing_timeout = 2000;
+
+ cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
+ cricket::P2PTransportChannel ch("TestChannel", 1, &pa);
+ PrepareChannel(&ch);
+ ch.Connect();
+ ch.MaybeStartGathering();
+ ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 1));
+ cricket::Connection* conn = WaitForConnectionTo(&ch, "1.1.1.1", 1);
+ ASSERT_TRUE(conn != nullptr);
+
+ // Wait for the connection to send MIN_PINGS_TO_STABILIZE pings to stablize.
+ SIMULATED_WAIT(conn->num_pings_sent() >= MIN_PINGS_TO_STABILIZE,
+ kDefaultTimeout, clock);
+ // The connection become writable and receiving.
+ conn->ReceivedPingResponse();
+
+ // Create a in-flight ping.
+ conn->Ping(clock.TimeNanos() / 1000000);
+ int ping_sent_before = conn->num_pings_sent();
+ int64_t start = clock.TimeNanos() / 1000000;
+ SIMULATED_WAIT(conn->num_pings_sent() == ping_sent_before + 1,
+ stablilizing_timeout, clock);
pthatcher1 2016/06/14 00:44:28 Just use clock.AdvanceTime(2*conn->rtt());
+ int64_t duration = clock.TimeNanos() / 1000000 - start;
+ EXPECT_TRUE(duration >= 900 && duration <= 1100);
pthatcher1 2016/06/14 00:44:27 Actually, can you combine all three tests?
+}
+
TEST_F(P2PTransportChannelPingTest, TestNoTriggeredChecksWhenWritable) {
cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
cricket::P2PTransportChannel ch("trigger checks", 1, &pa);
@@ -2708,13 +2815,14 @@ class P2PTransportChannelMostLikelyToWorkFirstTest
cricket::P2PTransportChannel& StartTransportChannel(
bool prioritize_most_likely_to_work,
- int max_strong_interval) {
+ int stable_writable_connection_ping_interval) {
channel_.reset(
new cricket::P2PTransportChannel("checks", 1, nullptr, allocator()));
cricket::IceConfig config = channel_->config();
config.prioritize_most_likely_candidate_pairs =
prioritize_most_likely_to_work;
- config.max_strong_interval = max_strong_interval;
+ config.stable_writable_connection_ping_interval =
+ stable_writable_connection_ping_interval;
channel_->SetIceConfig(config);
PrepareChannel(channel_.get());
channel_->Connect();

Powered by Google App Engine
This is Rietveld 408576698