mirror of
https://github.com/espressif/openthread.git
synced 2026-10-20 06:28:14 +00:00
[mpl] support dynamic MPL interval according to the network scale (#2220)
This commit is contained in:
@@ -48,7 +48,7 @@ namespace Ip6 {
|
|||||||
void MplBufferedMessageMetadata::GenerateNextTransmissionTime(uint32_t aCurrentTime, uint8_t aInterval)
|
void MplBufferedMessageMetadata::GenerateNextTransmissionTime(uint32_t aCurrentTime, uint8_t aInterval)
|
||||||
{
|
{
|
||||||
// Emulate Trickle timer behavior and set up the next retransmission within [0,I) range.
|
// Emulate Trickle timer behavior and set up the next retransmission within [0,I) range.
|
||||||
uint8_t t = otPlatRandomGet() % aInterval;
|
uint8_t t = aInterval == 0 ? aInterval : otPlatRandomGet() % aInterval;
|
||||||
|
|
||||||
// Set transmission time at the beginning of the next interval.
|
// Set transmission time at the beginning of the next interval.
|
||||||
SetTransmissionTime(aCurrentTime + GetIntervalOffset() + t);
|
SetTransmissionTime(aCurrentTime + GetIntervalOffset() + t);
|
||||||
@@ -171,6 +171,14 @@ void Mpl::AddBufferedMessage(Message &aMessage, uint16_t aSeedId, uint8_t aSeque
|
|||||||
uint32_t nextTransmissionTime;
|
uint32_t nextTransmissionTime;
|
||||||
uint8_t hopLimit = 0;
|
uint8_t hopLimit = 0;
|
||||||
|
|
||||||
|
#if OPENTHREAD_CONFIG_ENABLE_DYNAMIC_MPL_INTERVAL
|
||||||
|
// adjust the first MPL forward interval dynamically according to the network scale
|
||||||
|
uint8_t interval = (kDataMessageInterval / Mle::kMaxRouters) *
|
||||||
|
GetInstance().mThreadNetif.GetMle().GetActiveNeighborRouterCount();
|
||||||
|
#else
|
||||||
|
uint8_t interval = kDataMessageInterval;
|
||||||
|
#endif
|
||||||
|
|
||||||
VerifyOrExit(GetTimerExpirations() > 0);
|
VerifyOrExit(GetTimerExpirations() > 0);
|
||||||
VerifyOrExit((messageCopy = aMessage.Clone()) != NULL, error = OT_ERROR_NO_BUFS);
|
VerifyOrExit((messageCopy = aMessage.Clone()) != NULL, error = OT_ERROR_NO_BUFS);
|
||||||
|
|
||||||
@@ -184,7 +192,7 @@ void Mpl::AddBufferedMessage(Message &aMessage, uint16_t aSeedId, uint8_t aSeque
|
|||||||
messageMetadata.SetSeedId(aSeedId);
|
messageMetadata.SetSeedId(aSeedId);
|
||||||
messageMetadata.SetSequence(aSequence);
|
messageMetadata.SetSequence(aSequence);
|
||||||
messageMetadata.SetTransmissionCount(aIsOutbound ? 1 : 0);
|
messageMetadata.SetTransmissionCount(aIsOutbound ? 1 : 0);
|
||||||
messageMetadata.GenerateNextTransmissionTime(now, kDataMessageInterval);
|
messageMetadata.GenerateNextTransmissionTime(now, interval);
|
||||||
|
|
||||||
// Append the message with MplBufferedMessageMetadata and add it to the queue.
|
// Append the message with MplBufferedMessageMetadata and add it to the queue.
|
||||||
SuccessOrExit(error = messageMetadata.AppendTo(*messageCopy));
|
SuccessOrExit(error = messageMetadata.AppendTo(*messageCopy));
|
||||||
|
|||||||
@@ -985,4 +985,17 @@
|
|||||||
#define OPENTHREAD_CONFIG_ENABLE_DEBUG_UART 0
|
#define OPENTHREAD_CONFIG_ENABLE_DEBUG_UART 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def OPENTHREAD_CONFIG_ENABLE_DYNAMIC_MPL_INTERVAL
|
||||||
|
*
|
||||||
|
* Define as 1 to enable dynamic MPL interval feature.
|
||||||
|
*
|
||||||
|
* If this feature is enabled, the MPL forward interval will be adjusted dynamically according to
|
||||||
|
* the network scale, which helps to reduce multicast latency.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef OPENTHREAD_CONFIG_ENABLE_DYNAMIC_MPL_INTERVAL
|
||||||
|
#define OPENTHREAD_CONFIG_ENABLE_DYNAMIC_MPL_INTERVAL 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // OPENTHREAD_CORE_DEFAULT_CONFIG_H_
|
#endif // OPENTHREAD_CORE_DEFAULT_CONFIG_H_
|
||||||
|
|||||||
@@ -1272,6 +1272,21 @@ uint8_t MleRouter::GetActiveRouterCount(void) const
|
|||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t MleRouter::GetActiveNeighborRouterCount(void) const
|
||||||
|
{
|
||||||
|
uint8_t rval = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i <= kMaxRouterId; i++)
|
||||||
|
{
|
||||||
|
if (mRouters[i].GetState() == Neighbor::kStateValid)
|
||||||
|
{
|
||||||
|
rval++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
otError MleRouter::HandleAdvertisement(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
otError MleRouter::HandleAdvertisement(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||||
{
|
{
|
||||||
ThreadNetif &netif = GetNetif();
|
ThreadNetif &netif = GetNetif();
|
||||||
|
|||||||
@@ -141,6 +141,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
uint8_t GetActiveRouterCount(void) const;
|
uint8_t GetActiveRouterCount(void) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the number of active neighbor routers.
|
||||||
|
*
|
||||||
|
* @returns The number of active neighbor routers.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
uint8_t GetActiveNeighborRouterCount(void) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns the time in seconds since the last Router ID Sequence update.
|
* This method returns the time in seconds since the last Router ID Sequence update.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public:
|
|||||||
otError BecomeLeader(void) { return OT_ERROR_NOT_CAPABLE; }
|
otError BecomeLeader(void) { return OT_ERROR_NOT_CAPABLE; }
|
||||||
|
|
||||||
uint8_t GetActiveRouterCount(void) const { return 0; }
|
uint8_t GetActiveRouterCount(void) const { return 0; }
|
||||||
|
uint8_t GetActiveNeighborRouterCount(void) const { return 0; }
|
||||||
|
|
||||||
uint32_t GetLeaderAge(void) const { return 0; }
|
uint32_t GetLeaderAge(void) const { return 0; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user