[mle] maintain best parent candidate during router-only search (#3803)

* maintain best parent candidate during router-only search
* add margin for duplicate parent request check
This commit is contained in:
Jiacheng Guo
2019-05-11 09:56:26 -07:00
committed by Jonathan Hui
parent 55da08861e
commit 5a7faa539f
3 changed files with 8 additions and 4 deletions
+6 -3
View File
@@ -1606,8 +1606,13 @@ void Mle::HandleAttachTimer(void)
// to which the device is attached. This ensures that the
// new parent candidate is compared with the current parent
// and that it is indeed preferred over the current one.
// If we are in kAttachStateParentRequestRouter and cannot
// find a parent with best link quality(3), we will keep
// the candidate and forward to REED stage to find a better
// parent.
if (mParentCandidate.GetState() == Neighbor::kStateParentResponse &&
if ((mParentCandidate.GetLinkInfo().GetLinkQuality() == 3 || mAttachState != kAttachStateParentRequestRouter) &&
mParentCandidate.GetState() == Neighbor::kStateParentResponse &&
(mRole != OT_DEVICE_ROLE_CHILD || mReceivedResponseFromParent || mParentRequestMode == kAttachBetter) &&
SendChildIdRequest() == OT_ERROR_NONE)
{
@@ -3133,8 +3138,6 @@ otError Mle::HandleParentResponse(const Message &aMessage, const Ip6::MessageInf
linkQuality = LinkQualityInfo::ConvertLinkMarginToLinkQuality(linkMargin);
VerifyOrExit(mAttachState != kAttachStateParentRequestRouter || linkQuality == 3);
// Connectivity
SuccessOrExit(error = Tlv::GetTlv(aMessage, Tlv::kConnectivity, sizeof(connectivity), connectivity));
VerifyOrExit(connectivity.IsValid(), error = OT_ERROR_PARSE);
+1
View File
@@ -60,6 +60,7 @@ enum
kThreadVersion = 2, ///< Thread Version
kUdpPort = 19788, ///< MLE UDP Port
kParentRequestRouterTimeout = 750, ///< Router Parent Request timeout
kParentRequestDuplicateMargin = 50, ///< Margin for duplicate parent request
kParentRequestReedTimeout = 1250, ///< Router and REEDs Parent Request timeout
kAttachStartJitter = 50, ///< Maximum jitter time added to start of attach.
kAnnounceProcessTimeout = 250, ///< Timeout after receiving Announcement before channel/pan-id change
+1 -1
View File
@@ -1649,7 +1649,7 @@ otError MleRouter::HandleParentRequest(const Message &aMessage, const Ip6::Messa
}
#endif
}
else if (TimerMilli::Elapsed(child->GetLastHeard()) < kParentRequestRouterTimeout)
else if (TimerMilli::Elapsed(child->GetLastHeard()) < kParentRequestRouterTimeout - kParentRequestDuplicateMargin)
{
ExitNow(error = OT_ERROR_DUPLICATED);
}