[network-data] introduce 5s delay between SRV_DATA.ntf when deregister for child (#4485)

This commit is contained in:
Rongli Sun
2020-02-24 13:13:01 -08:00
committed by Jonathan Hui
parent b2024b8153
commit 2bc32a36d1
2 changed files with 19 additions and 12 deletions
+16 -11
View File
@@ -977,8 +977,16 @@ otError NetworkData::SendServerDataNotification(uint16_t aRloc16)
Coap::Message * message = NULL;
Ip6::MessageInfo messageInfo;
VerifyOrExit(mLastAttempt.GetValue() == 0 || ((TimerMilli::GetNow() - mLastAttempt) > kDataResubmitDelay),
error = OT_ERROR_ALREADY);
if (mLastAttempt.GetValue() != 0)
{
uint32_t diff = TimerMilli::GetNow() - mLastAttempt;
if (((mType == kTypeLocal) && (diff > kDataResubmitDelay)) ||
((mType == kTypeLeader) && (diff > kProxyResubmitDelay)))
{
ExitNow(error = OT_ERROR_ALREADY);
}
}
VerifyOrExit((message = Get<Coap::Coap>().NewMessage()) != NULL, error = OT_ERROR_NO_BUFS);
@@ -1007,16 +1015,13 @@ otError NetworkData::SendServerDataNotification(uint16_t aRloc16)
messageInfo.SetPeerPort(kCoapUdpPort);
SuccessOrExit(error = Get<Coap::Coap>().SendMessage(*message, messageInfo));
if (mType == kTypeLocal)
{
mLastAttempt = TimerMilli::GetNow();
mLastAttempt = TimerMilli::GetNow();
// `0` is a special value to indicate no delay limitation on sending SRV_DATA.ntf.
// Here avoids possible impact in rate limitation of SRV_DATA.ntf in case of wrap.
if (mLastAttempt.GetValue() == 0)
{
mLastAttempt.SetValue(1);
}
// `0` is a special value to indicate no delay limitation on sending SRV_DATA.ntf.
// Here avoids possible impact in rate limitation of SRV_DATA.ntf in case of wrap.
if (mLastAttempt.GetValue() == 0)
{
mLastAttempt.SetValue(1);
}
otLogInfoNetData("Sent server data notification");
+3 -1
View File
@@ -496,7 +496,9 @@ protected:
private:
enum
{
kDataResubmitDelay = 300000, ///< DATA_RESUBMIT_DELAY (milliseconds)
kDataResubmitDelay = 300000, ///< DATA_RESUBMIT_DELAY (milliseconds) if the device itself is the server.
kProxyResubmitDelay = 5000, ///< Resubmit delay (milliseconds) if deregister as the child server proxy.
};
class NetworkDataIterator