diff --git a/src/core/common/time_ticker.cpp b/src/core/common/time_ticker.cpp index 5307d22e2..1d1d56224 100644 --- a/src/core/common/time_ticker.cpp +++ b/src/core/common/time_ticker.cpp @@ -124,6 +124,11 @@ void TimeTicker::HandleTimer(void) Get().HandleTimeTick(); } #endif + + if (mReceivers & Mask(kIp6Mpl)) + { + Get().HandleTimeTick(); + } } } // namespace ot diff --git a/src/core/common/time_ticker.hpp b/src/core/common/time_ticker.hpp index 38b4e9911..0ffebf1ae 100644 --- a/src/core/common/time_ticker.hpp +++ b/src/core/common/time_ticker.hpp @@ -72,6 +72,7 @@ public: kDuaManager, ///< `DuaManager` kMlrManager, ///< `MlrManager` kNetworkDataNotifier, ///< `NetworkData::Notifier` + kIp6Mpl, ///< `Ip6::Mpl` kNumReceivers, ///< Number of receivers. }; diff --git a/src/core/config/ip6.h b/src/core/config/ip6.h index 268a2cd47..a9498b5f4 100644 --- a/src/core/config/ip6.h +++ b/src/core/config/ip6.h @@ -136,7 +136,7 @@ * */ #ifndef OPENTHREAD_CONFIG_MPL_SEED_SET_ENTRIES -#define OPENTHREAD_CONFIG_MPL_SEED_SET_ENTRIES 32 +#define OPENTHREAD_CONFIG_MPL_SEED_SET_ENTRIES 35 #endif /** diff --git a/src/core/net/ip6_mpl.cpp b/src/core/net/ip6_mpl.cpp index 893c8f326..5bd3b32f9 100644 --- a/src/core/net/ip6_mpl.cpp +++ b/src/core/net/ip6_mpl.cpp @@ -46,7 +46,6 @@ namespace Ip6 { Mpl::Mpl(Instance &aInstance) : InstanceLocator(aInstance) - , mSeedSetTimer(aInstance) , mSequence(0) #if OPENTHREAD_FTD , mRetransmissionTimer(aInstance) @@ -252,19 +251,16 @@ Error Mpl::UpdateSeedSet(uint16_t aSeedId, uint8_t aSequence) insert->mSequence = aSequence; insert->mLifetime = kSeedEntryLifetime; - if (!mSeedSetTimer.IsRunning()) - { - mSeedSetTimer.Start(kSeedEntryLifetimeDt); - } + Get().RegisterReceiver(TimeTicker::kIp6Mpl); exit: return error; } -void Mpl::HandleSeedSetTimer(void) +void Mpl::HandleTimeTick(void) { - bool startTimer = false; - int j = 0; + bool continueRxingTicks = false; + int j = 0; for (int i = 0; i < kNumSeedEntries && mSeedSet[i].mLifetime; i++) { @@ -272,8 +268,8 @@ void Mpl::HandleSeedSetTimer(void) if (mSeedSet[i].mLifetime > 0) { - mSeedSet[j++] = mSeedSet[i]; - startTimer = true; + mSeedSet[j++] = mSeedSet[i]; + continueRxingTicks = true; } } @@ -282,9 +278,9 @@ void Mpl::HandleSeedSetTimer(void) mSeedSet[j].mLifetime = 0; } - if (startTimer) + if (!continueRxingTicks) { - mSeedSetTimer.Start(kSeedEntryLifetimeDt); + Get().UnregisterReceiver(TimeTicker::kIp6Mpl); } } diff --git a/src/core/net/ip6_mpl.hpp b/src/core/net/ip6_mpl.hpp index d0ffc4d35..e1fbdf7b6 100644 --- a/src/core/net/ip6_mpl.hpp +++ b/src/core/net/ip6_mpl.hpp @@ -39,6 +39,7 @@ #include "common/locator.hpp" #include "common/message.hpp" #include "common/non_copyable.hpp" +#include "common/time_ticker.hpp" #include "common/timer.hpp" #include "net/ip6_headers.hpp" @@ -185,6 +186,8 @@ private: */ class Mpl : public InstanceLocator, private NonCopyable { + friend class ot::TimeTicker; + public: /** * This constructor initializes the MPL object. @@ -244,14 +247,11 @@ private: uint8_t mLifetime; }; - void HandleSeedSetTimer(void); + void HandleTimeTick(void); Error UpdateSeedSet(uint16_t aSeedId, uint8_t aSequence); - using SeedSetTimer = TimerMilliIn; - - SeedEntry mSeedSet[kNumSeedEntries]; - SeedSetTimer mSeedSetTimer; - uint8_t mSequence; + SeedEntry mSeedSet[kNumSeedEntries]; + uint8_t mSequence; #if OPENTHREAD_FTD static constexpr uint8_t kChildTimerExpirations = 0; // MPL retransmissions for Children.