mirror of
https://github.com/espressif/openthread.git
synced 2026-09-02 07:10:08 +00:00
[mesh-forwarder] Drop a message if all tx attempts fail for one of its fragments (#1933)
Existing code already enables this behavior for indirect message transmissions. This commits adds support for direct transmission and also introduces `OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE` as a new configuration option to control this feature. If enabled OpenThread will drop a message (and not send any remaining fragments of the message) if all transmit attempts fail for a fragment of the message. For a direct transmission, a failure occurs after all MAC transmission attempts for a given fragment are unsuccessful. For an indirect transmission, a failure occurs after all data poll triggered transmission attempts for a given fragment fail. If this feature is disabled, OpenThread will attempt to send subsequent fragments, whether or not all transmission attempts fail for a given fragment. Default setting enables this behavior.
This commit is contained in:
committed by
Jonathan Hui
parent
c05a723f70
commit
c79a905528
@@ -149,6 +149,22 @@
|
||||
#define OPENTHREAD_CONFIG_MAX_TX_ATTEMPTS_INDIRECT_POLLS 4
|
||||
#endif // OPENTHREAD_CONFIG_MAX_TX_ATTEMPTS_INDIRECT_POLLS
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE
|
||||
*
|
||||
* Define as 1 for OpenThread to drop a message (and not send any remaining fragments of the message) if all transmit
|
||||
* attempts fail for a fragment of the message. For a direct transmission, a failure occurs after all MAC transmission
|
||||
* attempts for a given fragment are unsuccessful. For an indirect transmission, a failure occurs after all data poll
|
||||
* triggered transmission attempts for a given fragment fail.
|
||||
*
|
||||
* If set to zero (disabled), OpenThread will attempt to send subsequent fragments, whether or not all transmission
|
||||
* attempts fail for a given fragment.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE
|
||||
#define OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE 1
|
||||
#endif // OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ATTACH_DATA_POLL_PERIOD
|
||||
*
|
||||
|
||||
@@ -1491,13 +1491,12 @@ void MeshForwarder::HandleSentFrame(Mac::Frame &aFrame, otError aError)
|
||||
|
||||
if (mSendMessage == child->GetIndirectMessage())
|
||||
{
|
||||
switch (aError)
|
||||
if (aError == OT_ERROR_NONE)
|
||||
{
|
||||
case OT_ERROR_NONE:
|
||||
child->ResetIndirectTxAttempts();
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
else
|
||||
{
|
||||
child->IncrementIndirectTxAttempts();
|
||||
|
||||
if (child->GetIndirectTxAttempts() < kMaxPollTriggeredTxAttempts)
|
||||
@@ -1526,13 +1525,13 @@ void MeshForwarder::HandleSentFrame(Mac::Frame &aFrame, otError aError)
|
||||
|
||||
child->ResetIndirectTxAttempts();
|
||||
|
||||
#if OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE
|
||||
// We set the NextOffset to end of message, since there is no need to
|
||||
// send any remaining fragments in the message to the child, if all tx
|
||||
// attempts of current frame already failed.
|
||||
|
||||
mMessageNextOffset = mSendMessage->GetLength();
|
||||
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1581,6 +1580,19 @@ void MeshForwarder::HandleSentFrame(Mac::Frame &aFrame, otError aError)
|
||||
|
||||
if (mSendMessage->GetDirectTransmission())
|
||||
{
|
||||
|
||||
#if OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE
|
||||
|
||||
if (aError != OT_ERROR_NONE)
|
||||
{
|
||||
// We set the NextOffset to end of message to avoid sending
|
||||
// any remaining fragments in the message.
|
||||
|
||||
mMessageNextOffset = mSendMessage->GetLength();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (mMessageNextOffset < mSendMessage->GetLength())
|
||||
{
|
||||
mSendMessage->SetOffset(mMessageNextOffset);
|
||||
|
||||
Reference in New Issue
Block a user