mirror of
https://github.com/espressif/openthread.git
synced 2026-10-31 03:26:37 +00:00
Add delay to unsolicited Data Response sent by Router (not Leader) (#1293)
This commit is contained in:
@@ -2476,7 +2476,7 @@ ThreadError MleRouter::HandleDataRequest(const Message &aMessage, const Ip6::Mes
|
||||
tlvs[numTlvs++] = Tlv::kPendingDataset;
|
||||
}
|
||||
|
||||
SendDataResponse(aMessageInfo.GetPeerAddr(), tlvs, numTlvs);
|
||||
SendDataResponse(aMessageInfo.GetPeerAddr(), tlvs, numTlvs, 0);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -2486,6 +2486,7 @@ ThreadError MleRouter::HandleNetworkDataUpdateRouter(void)
|
||||
{
|
||||
static const uint8_t tlvs[] = {Tlv::kNetworkData};
|
||||
Ip6::Address destination;
|
||||
uint16_t delay;
|
||||
|
||||
VerifyOrExit(mDeviceState == kDeviceStateRouter || mDeviceState == kDeviceStateLeader, ;);
|
||||
|
||||
@@ -2493,7 +2494,8 @@ ThreadError MleRouter::HandleNetworkDataUpdateRouter(void)
|
||||
destination.mFields.m16[0] = HostSwap16(0xff02);
|
||||
destination.mFields.m16[7] = HostSwap16(0x0001);
|
||||
|
||||
SendDataResponse(destination, tlvs, sizeof(tlvs));
|
||||
delay = (mDeviceState == kDeviceStateLeader) ? 0 : (otPlatRandomGet() % kUnsolicitedDataResponseJitter);
|
||||
SendDataResponse(destination, tlvs, sizeof(tlvs), delay);
|
||||
|
||||
for (uint8_t i = 0; i < mMaxChildrenAllowed; i++)
|
||||
{
|
||||
@@ -2512,7 +2514,7 @@ ThreadError MleRouter::HandleNetworkDataUpdateRouter(void)
|
||||
{
|
||||
if (child->mNetworkDataVersion != mNetif.GetNetworkDataLeader().GetVersion())
|
||||
{
|
||||
SendDataResponse(destination, tlvs, sizeof(tlvs));
|
||||
SendDataResponse(destination, tlvs, sizeof(tlvs), 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2521,7 +2523,7 @@ ThreadError MleRouter::HandleNetworkDataUpdateRouter(void)
|
||||
{
|
||||
static const uint8_t responseTlvs[] = {Tlv::kNetworkData, Tlv::kActiveDataset, Tlv::kPendingDataset};
|
||||
|
||||
SendDataResponse(destination, responseTlvs, sizeof(responseTlvs));
|
||||
SendDataResponse(destination, responseTlvs, sizeof(responseTlvs), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2879,7 +2881,8 @@ exit:
|
||||
return kThreadError_None;
|
||||
}
|
||||
|
||||
ThreadError MleRouter::SendDataResponse(const Ip6::Address &aDestination, const uint8_t *aTlvs, uint8_t aTlvsLength)
|
||||
ThreadError MleRouter::SendDataResponse(const Ip6::Address &aDestination, const uint8_t *aTlvs, uint8_t aTlvsLength,
|
||||
uint16_t aDelay)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
Message *message;
|
||||
@@ -2913,7 +2916,14 @@ ThreadError MleRouter::SendDataResponse(const Ip6::Address &aDestination, const
|
||||
}
|
||||
}
|
||||
|
||||
SuccessOrExit(error = SendMessage(*message, aDestination));
|
||||
if (aDelay)
|
||||
{
|
||||
SuccessOrExit(error = AddDelayedResponse(*message, aDestination, aDelay));
|
||||
}
|
||||
else
|
||||
{
|
||||
SuccessOrExit(error = SendMessage(*message, aDestination));
|
||||
}
|
||||
|
||||
otLogInfoMle("Sent Data Response");
|
||||
|
||||
|
||||
@@ -720,6 +720,7 @@ private:
|
||||
{
|
||||
kDiscoveryMaxJitter = 250u, ///< Maximum jitter time used to delay Discovery Responses in milliseconds.
|
||||
kStateUpdatePeriod = 1000u, ///< State update period in milliseconds.
|
||||
kUnsolicitedDataResponseJitter = 500u, ///< Maximum delay before unsolicited Data Response in milliseconds.
|
||||
};
|
||||
|
||||
ThreadError AppendConnectivity(Message &aMessage);
|
||||
@@ -762,7 +763,8 @@ private:
|
||||
ThreadError SendChildUpdateRequest(Child *aChild);
|
||||
ThreadError SendChildUpdateResponse(Child *aChild, const Ip6::MessageInfo &aMessageInfo,
|
||||
const uint8_t *aTlvs, uint8_t aTlvsLength, const ChallengeTlv *challenge);
|
||||
ThreadError SendDataResponse(const Ip6::Address &aDestination, const uint8_t *aTlvs, uint8_t aTlvsLength);
|
||||
ThreadError SendDataResponse(const Ip6::Address &aDestination, const uint8_t *aTlvs, uint8_t aTlvsLength,
|
||||
uint16_t aDelay);
|
||||
ThreadError SendDiscoveryResponse(const Ip6::Address &aDestination, uint16_t aPanId);
|
||||
|
||||
ThreadError SetStateRouter(uint16_t aRloc16);
|
||||
|
||||
Reference in New Issue
Block a user