From 21d73e5386bfb3144dba7905e8f5127d014e31df Mon Sep 17 00:00:00 2001 From: rongli Date: Thu, 4 May 2017 14:03:13 +0800 Subject: [PATCH] Update child's keep-alive period (#1676) * Update child's keep-alive period * Python Cert: correct sed1 index * update for comments --- src/core/thread/data_poll_manager.cpp | 2 +- src/core/thread/mle.cpp | 8 ++++---- src/core/thread/mle_constants.hpp | 1 + tests/scripts/thread-cert/Cert_5_1_07_MaxChildCount.py | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core/thread/data_poll_manager.cpp b/src/core/thread/data_poll_manager.cpp index 612672925..5223cdc30 100644 --- a/src/core/thread/data_poll_manager.cpp +++ b/src/core/thread/data_poll_manager.cpp @@ -388,7 +388,7 @@ uint32_t DataPollManager::CalculatePollPeriod(void) const if (period == 0) { - period = Timer::SecToMsec(mMeshForwarder.GetNetif().GetMle().GetTimeout() / Mle::kMaxChildKeepAliveAttempts); + period = Timer::SecToMsec(mMeshForwarder.GetNetif().GetMle().GetTimeout()) - kRetxPollPeriod * kMaxPollRetxAttempts; if (period == 0) { diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index dc5d67346..5bfad985f 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -588,7 +588,7 @@ ThreadError Mle::SetStateChild(uint16_t aRloc16) if ((mDeviceMode & ModeTlv::kModeRxOnWhenIdle) != 0) { - mParentRequestTimer.Start(Timer::SecToMsec(mTimeout / kMaxChildKeepAliveAttempts)); + mParentRequestTimer.Start(Timer::SecToMsec(mTimeout) - kUnicastRetransmissionDelay * kMaxChildKeepAliveAttempts); } if ((mDeviceMode & ModeTlv::kModeFFD) != 0) @@ -616,9 +616,9 @@ ThreadError Mle::SetTimeout(uint32_t aTimeout) { VerifyOrExit(mTimeout != aTimeout); - if (aTimeout < 4) + if (aTimeout < kMinTimeout) { - aTimeout = 4; + aTimeout = kMinTimeout; } mTimeout = aTimeout; @@ -2968,7 +2968,7 @@ ThreadError Mle::HandleChildUpdateResponse(const Message &aMessage, const Ip6::M } else { - mParentRequestTimer.Start(Timer::SecToMsec(mTimeout / kMaxChildKeepAliveAttempts)); + mParentRequestTimer.Start(Timer::SecToMsec(mTimeout) - kUnicastRetransmissionDelay * kMaxChildKeepAliveAttempts); mNetif.GetMeshForwarder().SetRxOnWhenIdle(true); } diff --git a/src/core/thread/mle_constants.hpp b/src/core/thread/mle_constants.hpp index 94f66d32f..8934a1d64 100644 --- a/src/core/thread/mle_constants.hpp +++ b/src/core/thread/mle_constants.hpp @@ -65,6 +65,7 @@ enum kMaxResponseDelay = 1000, ///< Maximum delay before responding to a multicast request kMaxChildIdRequestTimeout = 5000, ///< Maximum delay for receiving a Child ID Request kMaxChildUpdateResponseTimeout = 2000, ///< Maximum delay for receiving a Child Update Response + kMinTimeout = (((kMaxChildKeepAliveAttempts + 1) * kUnicastRetransmissionDelay) / 1000), ///< Minimum timeout(s) }; enum diff --git a/tests/scripts/thread-cert/Cert_5_1_07_MaxChildCount.py b/tests/scripts/thread-cert/Cert_5_1_07_MaxChildCount.py index ed4cb915b..146094b76 100755 --- a/tests/scripts/thread-cert/Cert_5_1_07_MaxChildCount.py +++ b/tests/scripts/thread-cert/Cert_5_1_07_MaxChildCount.py @@ -34,7 +34,7 @@ import node LEADER = 1 ROUTER = 2 -SED1 = 6 +SED1 = 7 class Cert_5_1_07_MaxChildCount(unittest.TestCase): def setUp(self):