mirror of
https://github.com/espressif/openthread.git
synced 2026-09-13 12:40:05 +00:00
[core] update Child Update Request aggregation feature (#2874)
This commit is contained in:
+31
-27
@@ -82,12 +82,12 @@ Mle::Mle(Instance &aInstance)
|
||||
, mParentLinkQuality2(0)
|
||||
, mParentLinkQuality1(0)
|
||||
, mChildUpdateAttempts(0)
|
||||
, mChildUpdateRequestState(kChildUpdateRequestNone)
|
||||
, mParentLinkMargin(0)
|
||||
, mParentIsSingleton(false)
|
||||
, mReceivedResponseFromParent(false)
|
||||
, mSocket(aInstance.GetThreadNetif().GetIp6().GetUdp())
|
||||
, mTimeout(kMleEndDeviceTimeout)
|
||||
, mSendChildUpdateRequest(aInstance, &Mle::HandleSendChildUpdateRequest, this)
|
||||
, mDiscoverHandler(NULL)
|
||||
, mDiscoverContext(NULL)
|
||||
, mIsDiscoverInProgress(false)
|
||||
@@ -1437,6 +1437,7 @@ void Mle::HandleStateChanged(Notifier::Callback &aCallback, otChangedFlags aFlag
|
||||
void Mle::HandleStateChanged(otChangedFlags aFlags)
|
||||
{
|
||||
ThreadNetif &netif = GetNetif();
|
||||
|
||||
VerifyOrExit(mRole != OT_DEVICE_ROLE_DISABLED);
|
||||
|
||||
if ((aFlags & (OT_CHANGED_IP6_ADDRESS_ADDED | OT_CHANGED_IP6_ADDRESS_REMOVED)) != 0)
|
||||
@@ -1453,7 +1454,8 @@ void Mle::HandleStateChanged(otChangedFlags aFlags)
|
||||
|
||||
if (mRole == OT_DEVICE_ROLE_CHILD && !IsFullThreadDevice())
|
||||
{
|
||||
mSendChildUpdateRequest.Post();
|
||||
mChildUpdateRequestState = kChildUpdateRequestPending;
|
||||
mChildUpdateRequestTimer.Start(kChildUpdateRequestPendingDelay);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1461,7 +1463,8 @@ void Mle::HandleStateChanged(otChangedFlags aFlags)
|
||||
{
|
||||
if (mRole == OT_DEVICE_ROLE_CHILD && !IsFullThreadDevice() && !IsRxOnWhenIdle())
|
||||
{
|
||||
mSendChildUpdateRequest.Post();
|
||||
mChildUpdateRequestState = kChildUpdateRequestPending;
|
||||
mChildUpdateRequestTimer.Start(kChildUpdateRequestPendingDelay);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1473,7 +1476,8 @@ void Mle::HandleStateChanged(otChangedFlags aFlags)
|
||||
}
|
||||
else if ((aFlags & OT_CHANGED_THREAD_ROLE) == 0)
|
||||
{
|
||||
mSendChildUpdateRequest.Post();
|
||||
mChildUpdateRequestState = kChildUpdateRequestPending;
|
||||
mChildUpdateRequestTimer.Start(kChildUpdateRequestPendingDelay);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_ENABLE_BORDER_ROUTER || OPENTHREAD_ENABLE_SERVICE
|
||||
@@ -2037,25 +2041,6 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void Mle::HandleSendChildUpdateRequest(Tasklet &aTasklet)
|
||||
{
|
||||
aTasklet.GetOwner<Mle>().HandleSendChildUpdateRequest();
|
||||
}
|
||||
|
||||
void Mle::HandleSendChildUpdateRequest(void)
|
||||
{
|
||||
// a Network Data update can cause a change to the IPv6 address configuration
|
||||
// only send a Child Update Request after we know there are no more pending changes
|
||||
if (GetNotifier().IsPending())
|
||||
{
|
||||
mSendChildUpdateRequest.Post();
|
||||
}
|
||||
else
|
||||
{
|
||||
SendChildUpdateRequest();
|
||||
}
|
||||
}
|
||||
|
||||
void Mle::HandleChildUpdateRequestTimer(Timer &aTimer)
|
||||
{
|
||||
aTimer.GetOwner<Mle>().HandleChildUpdateRequestTimer();
|
||||
@@ -2063,7 +2048,21 @@ void Mle::HandleChildUpdateRequestTimer(Timer &aTimer)
|
||||
|
||||
void Mle::HandleChildUpdateRequestTimer(void)
|
||||
{
|
||||
if (mParent.IsStateRestoring() || IsRxOnWhenIdle())
|
||||
// Here intentionly delay another kChildUpdateRequestPending cycle to ensure
|
||||
// only send a Child Update Request after we know there are no more pending changes
|
||||
if (mChildUpdateRequestState == kChildUpdateRequestPending)
|
||||
{
|
||||
if (GetNotifier().IsPending())
|
||||
{
|
||||
mChildUpdateRequestTimer.Start(kChildUpdateRequestPendingDelay);
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
mChildUpdateAttempts = 0;
|
||||
}
|
||||
|
||||
if ((mChildUpdateRequestState == kChildUpdateRequestPending) ||
|
||||
(mChildUpdateRequestState == kChildUpdateRequestActive) || IsRxOnWhenIdle())
|
||||
{
|
||||
SendChildUpdateRequest();
|
||||
}
|
||||
@@ -2078,6 +2077,9 @@ void Mle::HandleChildUpdateRequestTimer(void)
|
||||
|
||||
SendDataRequest(destination, tlvs, sizeof(tlvs), 0);
|
||||
}
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
otError Mle::SendChildUpdateRequest(void)
|
||||
@@ -2089,7 +2091,8 @@ otError Mle::SendChildUpdateRequest(void)
|
||||
|
||||
if (mChildUpdateAttempts >= kMaxChildKeepAliveAttempts)
|
||||
{
|
||||
mChildUpdateAttempts = 0;
|
||||
mChildUpdateAttempts = 0;
|
||||
mChildUpdateRequestState = kChildUpdateRequestNone;
|
||||
BecomeDetached();
|
||||
ExitNow();
|
||||
}
|
||||
@@ -2103,6 +2106,7 @@ otError Mle::SendChildUpdateRequest(void)
|
||||
|
||||
mChildUpdateRequestTimer.Start(kUnicastRetransmissionDelay);
|
||||
mChildUpdateAttempts++;
|
||||
mChildUpdateRequestState = kChildUpdateRequestActive;
|
||||
|
||||
VerifyOrExit((message = NewMleMessage()) != NULL, error = OT_ERROR_NO_BUFS);
|
||||
message->SetSubType(Message::kSubTypeMleChildUpdateRequest);
|
||||
@@ -3444,8 +3448,8 @@ otError Mle::HandleChildUpdateResponse(const Message &aMessage, const Ip6::Messa
|
||||
netif.GetMeshForwarder().SetRxOnWhenIdle(true);
|
||||
}
|
||||
|
||||
mChildUpdateAttempts = 0;
|
||||
|
||||
mChildUpdateAttempts = 0;
|
||||
mChildUpdateRequestState = kChildUpdateRequestNone;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -1582,6 +1582,13 @@ private:
|
||||
kParentRequestTypeRoutersAndReeds, ///< Parent Request to all routers and REEDs.
|
||||
};
|
||||
|
||||
enum ChildUpdateRequestState
|
||||
{
|
||||
kChildUpdateRequestNone, ///< No pending or active Child Update Request.
|
||||
kChildUpdateRequestPending, ///< Pending Child Update Request due to relative OT_CHANGED event.
|
||||
kChildUpdateRequestActive, ///< Child Update Request has been sent and Child Update Response is expected.
|
||||
};
|
||||
|
||||
void GenerateNonce(const Mac::ExtAddress &aMacAddr,
|
||||
uint32_t aFrameCounter,
|
||||
uint8_t aSecurityLevel,
|
||||
@@ -1597,8 +1604,6 @@ private:
|
||||
void HandleChildUpdateRequestTimer(void);
|
||||
static void HandleUdpReceive(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
|
||||
void HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
|
||||
static void HandleSendChildUpdateRequest(Tasklet &aTasklet);
|
||||
void HandleSendChildUpdateRequest(void);
|
||||
|
||||
otError HandleAdvertisement(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
|
||||
otError HandleChildIdResponse(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
|
||||
@@ -1660,18 +1665,17 @@ private:
|
||||
uint8_t mParentLinkQuality2;
|
||||
uint8_t mParentLinkQuality1;
|
||||
uint8_t mChildUpdateAttempts;
|
||||
LeaderDataTlv mParentLeaderData;
|
||||
uint8_t mChildUpdateRequestState;
|
||||
uint8_t mParentLinkMargin;
|
||||
bool mParentIsSingleton;
|
||||
bool mReceivedResponseFromParent;
|
||||
LeaderDataTlv mParentLeaderData;
|
||||
|
||||
Router mParentCandidate;
|
||||
|
||||
Ip6::UdpSocket mSocket;
|
||||
uint32_t mTimeout;
|
||||
|
||||
Tasklet mSendChildUpdateRequest;
|
||||
|
||||
DiscoverHandler mDiscoverHandler;
|
||||
void * mDiscoverContext;
|
||||
bool mIsDiscoverInProgress;
|
||||
|
||||
@@ -57,22 +57,23 @@ enum
|
||||
*/
|
||||
enum
|
||||
{
|
||||
kVersion = 2, ///< MLE Version
|
||||
kUdpPort = 19788, ///< MLE UDP Port
|
||||
kParentRequestRouterTimeout = 750, ///< Router Parent Request timeout
|
||||
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
|
||||
kAnnounceTimeout = 1400, ///< Total timeout used for sending Announcement messages
|
||||
kMinAnnounceDelay = 80, ///< Minimum delay between Announcement messages
|
||||
kParentResponseMaxDelayRouters = 500, ///< Maximum delay for response for Parent Request sent to routers only
|
||||
kParentResponseMaxDelayAll = 1000, ///< Maximum delay for response for Parent Request sent to all devices
|
||||
kUnicastRetransmissionDelay = 1000, ///< Base delay before retransmitting an MLE unicast.
|
||||
kMaxTransmissionCount = 3, ///< Maximum number of times an MLE message may be transmitted.
|
||||
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
|
||||
kMaxLinkRequestTimeout = 2000, ///< Maximum delay for receiving a Link Accept
|
||||
kVersion = 2, ///< MLE Version
|
||||
kUdpPort = 19788, ///< MLE UDP Port
|
||||
kParentRequestRouterTimeout = 750, ///< Router Parent Request timeout
|
||||
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
|
||||
kAnnounceTimeout = 1400, ///< Total timeout used for sending Announcement messages
|
||||
kMinAnnounceDelay = 80, ///< Minimum delay between Announcement messages
|
||||
kParentResponseMaxDelayRouters = 500, ///< Maximum delay for response for Parent Request sent to routers only
|
||||
kParentResponseMaxDelayAll = 1000, ///< Maximum delay for response for Parent Request sent to all devices
|
||||
kUnicastRetransmissionDelay = 1000, ///< Base delay before retransmitting an MLE unicast.
|
||||
kChildUpdateRequestPendingDelay = 100, ///< Delay (in ms) for aggregating Child Update Request.
|
||||
kMaxTransmissionCount = 3, ///< Maximum number of times an MLE message may be transmitted.
|
||||
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
|
||||
kMaxLinkRequestTimeout = 2000, ///< Maximum delay for receiving a Link Accept
|
||||
kMinTimeout = (((kMaxChildKeepAliveAttempts + 1) * kUnicastRetransmissionDelay) / 1000), ///< Minimum timeout(s)
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user