[mac] enable broadcast message retransmission in MAC layer (#2815)

This commit is contained in:
Zhanglong Xia
2018-07-11 16:03:19 -05:00
committed by Jonathan Hui
parent c0454408a8
commit b5dd84222f
4 changed files with 45 additions and 10 deletions
+21 -10
View File
@@ -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)
+7
View File
@@ -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;
+13
View File
@@ -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
*
+4
View File
@@ -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())
{