diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 0152854f4..91098052a 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -4236,7 +4236,7 @@ Error Mle::PrevRoleRestorer::Start(void) Get().SetRxOnWhenIdle(true); SetState(kRestoringRouterOrLeaderRole); - DetermineMaxLinkRequestAttempts(); + mAttempts = kRestoreLinkRequestAttempts; mTimer.Start(Get().GenerateRandomDelay(kMaxStartDelay)); error = kErrorNone; #endif @@ -4381,23 +4381,19 @@ exit: #if OPENTHREAD_FTD -void Mle::PrevRoleRestorer::DetermineMaxLinkRequestAttempts(void) -{ - mAttempts = kMaxCriticalTxCount; - - if ((Get().mLastSavedRole == kRoleRouter) && - (Get().mChildTable.GetNumChildren(Child::kInStateValidOrRestoring) < kMinCriticalChildrenCount)) - { - mAttempts = kMaxTxCount; - } -} - void Mle::PrevRoleRestorer::SendMulticastLinkRequest(void) { uint32_t delay; + uint32_t retxDelayMin = kMulticastRetxDelayMin; + uint32_t retxDelayMax = kMulticastRetxDelayMax; - delay = (mAttempts == 0) ? kLinkRequestTimeout - : Random::NonCrypto::GetUint32InRange(kMulticastRetxDelayMin, kMulticastRetxDelayMax); + if (Get().mLastSavedRole == kRoleLeader) + { + retxDelayMin = kLeaderRetxDelayMin; + retxDelayMax = kLeaderRetxDelayMax; + } + + delay = (mAttempts == 0) ? kLinkRequestTimeout : Random::NonCrypto::GetUint32InRange(retxDelayMin, retxDelayMax); mTimer.Start(delay); diff --git a/src/core/thread/mle.hpp b/src/core/thread/mle.hpp index 72732701d..7eccb6fea 100644 --- a/src/core/thread/mle.hpp +++ b/src/core/thread/mle.hpp @@ -1857,6 +1857,9 @@ private: static constexpr uint16_t kChildUpdateMinTimeout = 1000; // in ms static constexpr uint16_t kChildUpdateStartTimeout = 4000; // in ms static constexpr uint16_t kChildUpdateRetxJitter = 25; // in ms + static constexpr uint8_t kRestoreLinkRequestAttempts = 4; + static constexpr uint32_t kLeaderRetxDelayMin = kLinkRequestTimeout * 9 / 10; // 0.9 * base delay + static constexpr uint32_t kLeaderRetxDelayMax = kLinkRequestTimeout * 11 / 10; // 1.1 * base delay enum State : uint8_t { @@ -1869,7 +1872,6 @@ private: void SendChildUpdate(void); void CheckIfMessageIsFromParent(RxInfo &aRxInfo); #if OPENTHREAD_FTD - void DetermineMaxLinkRequestAttempts(void); void SendMulticastLinkRequest(void); #endif diff --git a/tests/scripts/thread-cert/config.py b/tests/scripts/thread-cert/config.py index ad4bfa22b..b963cf6c4 100644 --- a/tests/scripts/thread-cert/config.py +++ b/tests/scripts/thread-cert/config.py @@ -122,9 +122,10 @@ SECURITY_POLICY = [672, 'onrc'] LEADER_STARTUP_DELAY = 12 ROUTER_STARTUP_DELAY = 10 # See logic of RouterRoleRestorer -# ((kMaxTxCount=6) - 1) * 1.1 * (kMulticastRetxDelay=5) + 2 + ROUTER_STARTUP_DELAY -ROUTER_RESTORE_DELAY = 40 -LEADER_REBOOT_DELAY = 40 +# (MLE_MAX_RESTORING_TRANSMISSION_COUNT - 1) * 1.1 * (kMulticastRetxDelay=5s) + 2s + ROUTER_STARTUP_DELAY +ROUTER_RESTORE_DELAY = 29 +# (MLE_MAX_RESTORING_TRANSMISSION_COUNT - 1) * 1.1 * (kLinkRequestTimeout=2s) + 2s + LEADER_STARTUP_DELAY +LEADER_REBOOT_DELAY = 21 ED_STARTUP_DELAY = 5 BORDER_ROUTER_STARTUP_DELAY = 20 MAX_NEIGHBOR_AGE = 100 @@ -153,11 +154,11 @@ PACKET_VERIFICATION_NONE = 0 PACKET_VERIFICATION_DEFAULT = 1 PACKET_VERIFICATION_TREL = 2 -# After leader reset it may retransmit link request 6 times with max 5.5s interval -LEADER_RESET_DELAY = 41 -# After router reset it may retransmit link request 3 times with max 5.5s interval -ROUTER_RESET_DELAY = 23 -MLE_MAX_CRITICAL_TRANSMISSION_COUNT = 6 +# After leader reset it may retransmit link request 4 times with max 2.2s interval +LEADER_RESET_DELAY = 17 +# After router reset it may retransmit link request 4 times with max 5.5s interval +ROUTER_RESET_DELAY = 30 +MLE_MAX_RESTORING_TRANSMISSION_COUNT = 4 MLE_MAX_TRANSMISSION_COUNT = 3 diff --git a/tests/scripts/thread-cert/test_leader_reboot_multiple_link_request.py b/tests/scripts/thread-cert/test_leader_reboot_multiple_link_request.py index ad9f00e26..7cb4524d7 100755 --- a/tests/scripts/thread-cert/test_leader_reboot_multiple_link_request.py +++ b/tests/scripts/thread-cert/test_leader_reboot_multiple_link_request.py @@ -43,7 +43,7 @@ DUT_ROUTER1 = 2 # Test Purpose and Description: # ----------------------------- -# The purpose of this test case is to show that when the Leader is rebooted, it sends MLE_MAX_CRITICAL_TRANSMISSION_COUNT MLE link request packets if no response is received. +# The purpose of this test case is to show that when the Leader is rebooted, it sends MLE_MAX_RESTORING_TRANSMISSION_COUNT MLE link request packets if no response is received. # # Test Topology: # ------------- @@ -129,12 +129,12 @@ class Test_LeaderRebootMultipleLinkRequest(thread_cert.TestCase): filter_wpan_src64(ROUTER).\ must_next() - # The Leader MUST send MLE_MAX_CRITICAL_TRANSMISSION_COUNT multicast Link Request + # The Leader MUST send MLE_MAX_RESTORING_TRANSMISSION_COUNT multicast Link Request # The following TLVs MUST be present in the Link Request: # - Challenge TLV # - Version TLV # - TLV Request TLV: Address16 TLV, Route64 TLV - for i in range(0, config.MLE_MAX_CRITICAL_TRANSMISSION_COUNT): + for i in range(0, config.MLE_MAX_RESTORING_TRANSMISSION_COUNT): pkts.filter_wpan_src64(LEADER).\ filter_LLARMA().\ filter_mle_cmd(MLE_LINK_REQUEST).\ diff --git a/tests/scripts/thread-cert/test_router_reboot_multiple_link_request.py b/tests/scripts/thread-cert/test_router_reboot_multiple_link_request.py index 6773b65a7..cf4d32ea4 100755 --- a/tests/scripts/thread-cert/test_router_reboot_multiple_link_request.py +++ b/tests/scripts/thread-cert/test_router_reboot_multiple_link_request.py @@ -49,7 +49,7 @@ MED6 = 8 # Test Purpose and Description: # ----------------------------- -# The purpose of this test case is to show that when a router with > 5 children is rebooted, it sends MLE_MAX_CRITICAL_TRANSMISSION_COUNT MLE link request packets if no response is received. +# The purpose of this test case is to show that when a router is rebooted, it sends MLE_MAX_RESTORING_TRANSMISSION_COUNT MLE link request packets if no response is received. # # Test Topology: # ------------- @@ -150,12 +150,12 @@ class Test_LeaderRebootMultipleLinkRequest(thread_cert.TestCase): filter_mle_advertisement('Router').\ must_next() - # The router MUST send MLE_MAX_CRITICAL_TRANSMISSION_COUNT multicast Link Request + # The router MUST send MLE_MAX_RESTORING_TRANSMISSION_COUNT multicast Link Request # The following TLVs MUST be present in the Link Request: # - Challenge TLV # - Version TLV # - TLV Request TLV: Address16 TLV, Route64 TLV - for i in range(0, config.MLE_MAX_CRITICAL_TRANSMISSION_COUNT): + for i in range(0, config.MLE_MAX_RESTORING_TRANSMISSION_COUNT): pkts.filter_wpan_src64(ROUTER).\ filter_LLARMA().\ filter_mle_cmd(MLE_LINK_REQUEST).\