mirror of
https://github.com/espressif/openthread.git
synced 2026-09-11 11:40:06 +00:00
[mac] enable broadcast message retransmission in MAC layer (#2815)
This commit is contained in:
committed by
Jonathan Hui
parent
c0454408a8
commit
b5dd84222f
+21
-10
@@ -179,6 +179,7 @@ Mac::Mac(Instance &aInstance)
|
||||
, mDataSequence(Random::GetUint8())
|
||||
, mCsmaAttempts(0)
|
||||
, mTransmitAttempts(0)
|
||||
, mBroadcastTransmitCount(0)
|
||||
, mScanChannelMask()
|
||||
, mScanDuration(0)
|
||||
, mScanChannel(OT_RADIO_CHANNEL_MIN)
|
||||
@@ -1154,7 +1155,7 @@ void Mac::BeginTransmit(void)
|
||||
sendFrame.SetCsmaCaEnabled(true);
|
||||
}
|
||||
|
||||
if (mCsmaAttempts == 0 && mTransmitAttempts == 0)
|
||||
if (mCsmaAttempts == 0 && mTransmitAttempts == 0 && mBroadcastTransmitCount == 0)
|
||||
{
|
||||
switch (mOperation)
|
||||
{
|
||||
@@ -1418,15 +1419,6 @@ void Mac::HandleTransmitDone(otRadioFrame *aFrame, otRadioFrame *aAckFrame, otEr
|
||||
mCounters.mTxErrBusyChannel++;
|
||||
}
|
||||
|
||||
if (dstAddr.IsBroadcast())
|
||||
{
|
||||
mCounters.mTxBroadcast++;
|
||||
}
|
||||
else
|
||||
{
|
||||
mCounters.mTxUnicast++;
|
||||
}
|
||||
|
||||
if (ackRequested)
|
||||
{
|
||||
mCounters.mTxAckRequested++;
|
||||
@@ -1441,6 +1433,25 @@ void Mac::HandleTransmitDone(otRadioFrame *aFrame, otRadioFrame *aAckFrame, otEr
|
||||
mCounters.mTxNoAckRequested++;
|
||||
}
|
||||
|
||||
if (dstAddr.IsBroadcast())
|
||||
{
|
||||
mCounters.mTxBroadcast++;
|
||||
|
||||
// Determine whether to re-transmit the broadcast frame.
|
||||
mBroadcastTransmitCount++;
|
||||
if (mBroadcastTransmitCount < kTxNumBcast)
|
||||
{
|
||||
StartCsmaBackoff();
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
mBroadcastTransmitCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
mCounters.mTxUnicast++;
|
||||
}
|
||||
|
||||
// Determine next action based on current operation.
|
||||
|
||||
switch (mOperation)
|
||||
|
||||
@@ -96,6 +96,12 @@ enum
|
||||
*
|
||||
*/
|
||||
kIndirectFrameMacTxAttempts = OPENTHREAD_CONFIG_MAX_TX_ATTEMPTS_INDIRECT_PER_POLL,
|
||||
|
||||
/**
|
||||
* The transmit number of a broadcast frame in MAC layer.
|
||||
*
|
||||
*/
|
||||
kTxNumBcast = OPENTHREAD_CONFIG_TX_NUM_BCAST,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1055,6 +1061,7 @@ private:
|
||||
uint8_t mDataSequence;
|
||||
uint8_t mCsmaAttempts;
|
||||
uint8_t mTransmitAttempts;
|
||||
uint8_t mBroadcastTransmitCount;
|
||||
|
||||
ChannelMask mScanChannelMask;
|
||||
uint16_t mScanDuration;
|
||||
|
||||
@@ -159,6 +159,19 @@
|
||||
#define OPENTHREAD_CONFIG_MAX_TX_ATTEMPTS_INDIRECT_POLLS 4
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_TX_NUM_BCAST
|
||||
*
|
||||
* The number of times each IEEE 802.15.4 broadcast frame is transmitted.
|
||||
*
|
||||
* The minimum value is 1. Values larger than 1 may improve broadcast reliability by increasing redundancy, but may also
|
||||
* increase congestion.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_TX_NUM_BCAST
|
||||
#define OPENTHREAD_CONFIG_TX_NUM_BCAST 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE
|
||||
*
|
||||
|
||||
@@ -1637,6 +1637,10 @@ otError MleRouter::HandleParentRequest(const Message &aMessage, const Ip6::Messa
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if ((TimerMilli::GetNow() - child->GetLastHeard()) < kParentRequestRouterTimeout)
|
||||
{
|
||||
ExitNow(error = OT_ERROR_DUPLICATED);
|
||||
}
|
||||
|
||||
if (!child->IsStateValidOrRestoring())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user