[nrf528xx] set frame counter and key idx in otPlatRadioTransmit() (#6458)

This change tackles both problems resolved and introduced by #6427.

For direct transmissions, if the first frame transmission fails,
e.g. due to a CCA failure then retransmissions will contain an invalid
frame counter. It causes problems especially for long IP packets - the
receiver drops a fragment but the transmitter will flood it with the
next fragments since it is not aware that the other party dropped a
fragment. We have identified that it's a root cause of the problem
reported in #6337.

Previous solution (remove the check if a frame is retransmitted) may
cause problems with indirect transmissions where radio frames are
created from scratch and then their frame counter would be
overridden. That is why the best place for setting frame counter and
key index in otPlatRadioTransmit().
This commit is contained in:
konradderda
2021-04-15 22:52:39 -07:00
committed by GitHub
parent a913784cc0
commit 23bbde5c96
+6 -3
View File
@@ -509,6 +509,12 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
}
#if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2
if (otMacFrameIsSecurityEnabled(aFrame) && otMacFrameIsKeyIdMode1(aFrame) && !aFrame->mInfo.mTxInfo.mIsARetx)
{
otMacFrameSetKeyId(aFrame, sKeyId);
otMacFrameSetFrameCounter(aFrame, sMacFrameCounter++);
}
if (aFrame->mInfo.mTxInfo.mTxDelay != 0)
{
if (!nrf_802154_transmit_raw_at(&aFrame->mPsdu[-1], true, aFrame->mInfo.mTxInfo.mTxDelayBaseTime,
@@ -1222,9 +1228,6 @@ void nrf_802154_tx_started(const uint8_t *aFrame)
sTransmitFrame.mInfo.mTxInfo.mAesKey = &sCurrKey;
otMacFrameSetKeyId(&sTransmitFrame, sKeyId);
otMacFrameSetFrameCounter(&sTransmitFrame, sMacFrameCounter++);
processSecurity = true;
#endif // OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2