[mesh-forwarder] verify data request is ack with fp=1 (#3785)

This commit is contained in:
Yakun Xu
2019-04-30 18:37:48 -07:00
committed by Jonathan Hui
parent d348ce2bbc
commit 617f8958dd
24 changed files with 92 additions and 16 deletions
+2 -1
View File
@@ -529,7 +529,8 @@ The bit values in `MD_FLAG` are defined as follows:
15 | 0x0001 | MD_FLAG_TX | Packet was transmitted, not received.
13 | 0x0004 | MD_FLAG_BAD_FCS | Packet was received with bad FCS
12 | 0x0008 | MD_FLAG_DUPE | Packet seems to be a duplicate
0-11, 14 | 0xFFF2 | MD_FLAG_RESERVED | Flags reserved for future use.
11 | 0x0010 | MD_FLAG_ACKED_FP | Packet was acknowledged with frame pending set
0-10, 14 | 0xFFE2 | MD_FLAG_RESERVED | Flags reserved for future use.
The format of `MD_PHY` is specified by the PHY layer currently in use,
and may contain information such as the channel, LQI, antenna, or other
+3
View File
@@ -1881,6 +1881,9 @@ static void cc1352RadioProcessTransmitDone(otInstance * aInstance,
static void cc1352RadioProcessReceiveDone(otInstance *aInstance, otRadioFrame *aReceiveFrame, otError aReceiveError)
{
// TODO Set this flag only when the packet is really acknowledged with frame pending set.
// See https://github.com/openthread/openthread/pull/3785
aReceiveFrame->mInfo.mRxInfo.mAckedWithFramePending = true;
#if OPENTHREAD_ENABLE_DIAG
if (otPlatDiagModeGet())
+3
View File
@@ -711,6 +711,9 @@ void cc2538RadioProcess(otInstance *aInstance)
if ((sState == OT_RADIO_STATE_RECEIVE && sReceiveFrame.mLength > 0) ||
(sState == OT_RADIO_STATE_TRANSMIT && sReceiveFrame.mLength > IEEE802154_ACK_LENGTH))
{
// TODO Set this flag only when the packet is really acknowledged with frame pending set.
// See https://github.com/openthread/openthread/pull/3785
sReceiveFrame.mInfo.mRxInfo.mAckedWithFramePending = true;
#if OPENTHREAD_ENABLE_DIAG
if (otPlatDiagModeGet())
+3
View File
@@ -1798,6 +1798,9 @@ static void cc2650RadioProcessTransmitDone(otInstance * aInstance,
static void cc2650RadioProcessReceiveDone(otInstance *aInstance, otRadioFrame *aReceiveFrame, otError aReceiveError)
{
// TODO Set this flag only when the packet is really acknowledged with frame pending set.
// See https://github.com/openthread/openthread/pull/3785
aReceiveFrame->mInfo.mRxInfo.mAckedWithFramePending = true;
#if OPENTHREAD_ENABLE_DIAG
if (otPlatDiagModeGet())
+3
View File
@@ -1861,6 +1861,9 @@ static void cc2652RadioProcessTransmitDone(otInstance * aInstance,
static void cc2652RadioProcessReceiveDone(otInstance *aInstance, otRadioFrame *aReceiveFrame, otError aReceiveError)
{
// TODO Set this flag only when the packet is really acknowledged with frame pending set.
// See https://github.com/openthread/openthread/pull/3785
aReceiveFrame->mInfo.mRxInfo.mAckedWithFramePending = true;
#if OPENTHREAD_ENABLE_DIAG
if (otPlatDiagModeGet())
+4
View File
@@ -508,6 +508,10 @@ void da15000RadioProcess(otInstance *aInstance)
sAckFrame = true;
}
// TODO Set this flag only when the packet is really acknowledged with frame pending set.
// See https://github.com/openthread/openthread/pull/3785
sReceiveFrame[sReadFrame].mInfo.mRxInfo.mAckedWithFramePending = true;
otPlatRadioReceiveDone(sThreadInstance, &sReceiveFrame[sReadFrame], OT_ERROR_NONE);
sReadFrame = (sReadFrame + 1) % RADIO_FRAMES_BUFFER_SIZE;
+4
View File
@@ -680,6 +680,10 @@ static void processNextRxPacket(otInstance *aInstance, RAIL_Handle_t aRailHandle
sReceiveError = OT_ERROR_NONE;
// TODO Set this flag only when the packet is really acknowledged with frame pending set.
// See https://github.com/openthread/openthread/pull/3785
sReceiveFrame.mInfo.mRxInfo.mAckedWithFramePending = true;
#if OPENTHREAD_ENABLE_DIAG
if (otPlatDiagModeGet())
+3
View File
@@ -564,6 +564,9 @@ void emskRadioProcess(otInstance *aInstance)
if ((sState == OT_RADIO_STATE_RECEIVE) && (sReceiveFrame.mLength > 0))
{
// TODO Set this flag only when the packet is really acknowledged with frame pending set.
// See https://github.com/openthread/openthread/pull/3785
sReceiveFrame.mInfo.mRxInfo.mAckedWithFramePending = true;
otPlatRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError);
}
+4
View File
@@ -226,6 +226,10 @@ void cbQorvoRadioReceiveDone(otRadioFrame *aPacket, otError aError)
sLastReceivedPower = aPacket->mInfo.mRxInfo.mRssi;
}
// TODO Set this flag only when the packet is really acknowledged with frame pending set.
// See https://github.com/openthread/openthread/pull/3785
aPacket->mInfo.mRxInfo.mAckedWithFramePending = true;
otPlatRadioReceiveDone(pQorvoInstance, aPacket, aError);
}
+4
View File
@@ -987,6 +987,10 @@ void kw41zRadioProcess(otInstance *aInstance)
if (sRxDone)
{
// TODO Set this flag only when the packet is really acknowledged with frame pending set.
// See https://github.com/openthread/openthread/pull/3785
sRxFrame.mInfo.mRxInfo.mAckedWithFramePending = true;
#if OPENTHREAD_ENABLE_DIAG
if (otPlatDiagModeGet())
+4
View File
@@ -552,6 +552,10 @@ void nrf5RadioProcess(otInstance *aInstance)
{
if (sReceivedFrames[i].mPsdu != NULL)
{
// TODO Set this flag only when the packet is really acknowledged with frame pending set.
// See https://github.com/openthread/openthread/pull/3785
sReceivedFrames[i].mInfo.mRxInfo.mAckedWithFramePending = true;
#if OPENTHREAD_ENABLE_DIAG
if (otPlatDiagModeGet())
+4
View File
@@ -552,6 +552,10 @@ void nrf5RadioProcess(otInstance *aInstance)
{
if (sReceivedFrames[i].mPsdu != NULL)
{
// TODO Set this flag only when the packet is really acknowledged with frame pending set.
// See https://github.com/openthread/openthread/pull/3785
sReceivedFrames[i].mInfo.mRxInfo.mAckedWithFramePending = true;
#if OPENTHREAD_ENABLE_DIAG
if (otPlatDiagModeGet())
+2
View File
@@ -776,6 +776,7 @@ void radioSendAck(void)
if (isDataRequestAndHasFramePending(sReceiveFrame.mPsdu))
{
sAckMessage.mPsdu[0] |= IEEE802154_FRAME_PENDING;
sReceiveFrame.mInfo.mRxInfo.mAckedWithFramePending = true;
}
sAckMessage.mPsdu[1] = 0;
@@ -824,6 +825,7 @@ void radioProcessFrame(otInstance *aInstance)
sReceiveFrame.mInfo.mRxInfo.mRssi = -20;
sReceiveFrame.mInfo.mRxInfo.mLqi = OT_RADIO_LQI_NONE;
sReceiveFrame.mInfo.mRxInfo.mAckedWithFramePending = false;
// generate acknowledgment
if (isAckRequested(sReceiveFrame.mPsdu))
{
+2
View File
@@ -642,6 +642,7 @@ void radioSendAck(void)
if (isDataRequestAndHasFramePending(sReceiveFrame.mPsdu))
{
sAckMessage.mPsdu[0] |= IEEE802154_FRAME_PENDING;
sReceiveFrame.mInfo.mRxInfo.mAckedWithFramePending = true;
}
sAckMessage.mPsdu[1] = 0;
@@ -690,6 +691,7 @@ void radioProcessFrame(otInstance *aInstance)
sReceiveFrame.mInfo.mRxInfo.mRssi = -20;
sReceiveFrame.mInfo.mRxInfo.mLqi = OT_RADIO_LQI_NONE;
sReceiveFrame.mInfo.mRxInfo.mAckedWithFramePending = false;
// generate acknowledgment
if (isAckRequested(sReceiveFrame.mPsdu))
{
+4
View File
@@ -217,6 +217,10 @@ void cbQorvoRadioTransmitDone(otRadioFrame *aPacket, bool aFramePending, otError
void cbQorvoRadioReceiveDone(otRadioFrame *aPacket, otError aError)
{
// TODO Set this flag only when the packet is really acknowledged with frame pending set.
// See https://github.com/openthread/openthread/pull/3785
aPacket->mInfo.mRxInfo.mAckedWithFramePending = true;
otPlatRadioReceiveDone(pQorvoInstance, aPacket, aError);
}
+4
View File
@@ -225,6 +225,10 @@ static void handleRx(void)
sReceiveFrame.mInfo.mRxInfo.mUsec = 0; // Don't support microsecond timer for now.
}
// TODO Set this flag only when the packet is really acknowledged with frame pending set.
// See https://github.com/openthread/openthread/pull/3785
sReceiveFrame.mInfo.mRxInfo.mAckedWithFramePending = true;
#if OPENTHREAD_ENABLE_DIAG
if (otPlatDiagModeGet())
+10 -8
View File
@@ -202,8 +202,12 @@ typedef struct otRadioFrame
*/
struct
{
int8_t mRssi; ///< Received signal strength indicator in dBm for received frames.
uint8_t mLqi; ///< Link Quality Indicator for received frames.
/**
* The timestamp when the frame was received (milliseconds).
* Applicable/Required only when raw-link-api feature (`OPENTHREAD_ENABLE_RAW_LINK_API`) is enabled.
*
*/
uint32_t mMsec;
/**
* The timestamp when the frame was received (microseconds, the offset to mMsec).
@@ -211,13 +215,11 @@ typedef struct otRadioFrame
*
*/
uint16_t mUsec;
int8_t mRssi; ///< Received signal strength indicator in dBm for received frames.
uint8_t mLqi; ///< Link Quality Indicator for received frames.
/**
* The timestamp when the frame was received (milliseconds).
* Applicable/Required only when raw-link-api feature (`OPENTHREAD_ENABLE_RAW_LINK_API`) is enabled.
*
*/
uint32_t mMsec;
// Flags
bool mAckedWithFramePending : 1; /// This indicates if this frame was acknowledged with frame pending set.
} mRxInfo;
} mInfo;
} otRadioFrame;
+9
View File
@@ -1017,6 +1017,15 @@ public:
*/
bool IsARetransmission(void) const { return mInfo.mTxInfo.mIsARetx; }
/**
* This method indicates whether or not the received frame is acknowledged with frame pending set.
*
* @retval TRUE This frame is acknowledged with frame pending set.
* @retval FALSE This frame is acknowledged with frame pending not set.
*
*/
bool IsAckedWithFramePending(void) const { return mInfo.mRxInfo.mAckedWithFramePending; }
/**
* This method sets the retransmission flag attribute.
*
+1 -1
View File
@@ -1269,7 +1269,7 @@ void MeshForwarder::HandleReceivedFrame(Mac::Frame &aFrame)
if (commandId == Mac::Frame::kMacCmdDataRequest)
{
HandleDataRequest(macSource, linkInfo);
HandleDataRequest(aFrame, macSource, linkInfo);
}
else
{
+1 -1
View File
@@ -398,7 +398,7 @@ private:
const Mac::Address & aMacSource,
const Mac::Address & aMacDest,
const otThreadLinkInfo &aLinkInfo);
void HandleDataRequest(const Mac::Address &aMacSource, const otThreadLinkInfo &aLinkInfo);
void HandleDataRequest(const Mac::Frame &aFrame, const Mac::Address &aMacSource, const otThreadLinkInfo &aLinkInfo);
static otError GetFragmentHeader(const uint8_t * aFrame,
uint8_t aFrameLength,
+7 -3
View File
@@ -551,7 +551,9 @@ void MeshForwarder::SendMesh(Message &aMessage, Mac::Frame &aFrame)
mMessageNextOffset = aMessage.GetLength();
}
void MeshForwarder::HandleDataRequest(const Mac::Address &aMacSource, const otThreadLinkInfo &aLinkInfo)
void MeshForwarder::HandleDataRequest(const Mac::Frame & aFrame,
const Mac::Address & aMacSource,
const otThreadLinkInfo &aLinkInfo)
{
Child * child;
uint16_t indirectMsgCount;
@@ -568,6 +570,10 @@ void MeshForwarder::HandleDataRequest(const Mac::Address &aMacSource, const otTh
child->ResetLinkFailures();
indirectMsgCount = child->GetIndirectMessageCount();
otLogInfoMac("Rx data poll, src:0x%04x, qed_msgs:%d, rss:%d ack-fp:%d", child->GetRloc16(), indirectMsgCount,
aLinkInfo.mRss, aFrame.IsAckedWithFramePending());
VerifyOrExit(aFrame.IsAckedWithFramePending());
if (!mSourceMatchController.IsEnabled() || (indirectMsgCount > 0))
{
child->SetDataRequestPending(true);
@@ -575,8 +581,6 @@ void MeshForwarder::HandleDataRequest(const Mac::Address &aMacSource, const otTh
mScheduleTransmissionTask.Post();
otLogInfoMac("Rx data poll, src:0x%04x, qed_msgs:%d, rss:%d", child->GetRloc16(), indirectMsgCount, aLinkInfo.mRss);
exit:
return;
}
+7 -1
View File
@@ -78,7 +78,13 @@ void NcpBase::LinkRawReceiveDone(otRadioFrame *aFrame, otError aError)
// Append metadata (rssi, etc)
SuccessOrExit(mEncoder.WriteInt8(aFrame->mInfo.mRxInfo.mRssi)); // RSSI
SuccessOrExit(mEncoder.WriteInt8(-128)); // Noise Floor (Currently unused)
SuccessOrExit(mEncoder.WriteUint16(flags)); // Flags
if (aFrame->mInfo.mRxInfo.mAckedWithFramePending)
{
flags |= SPINEL_MD_FLAG_ACKED_FP;
}
SuccessOrExit(mEncoder.WriteUint16(flags)); // Flags
SuccessOrExit(mEncoder.OpenStruct()); // PHY-data
SuccessOrExit(mEncoder.WriteUint8(aFrame->mChannel)); // 802.15.4 channel (Receive channel)
+2 -1
View File
@@ -399,7 +399,8 @@ enum
SPINEL_MD_FLAG_TX = 0x0001, //!< Packet was transmitted, not received.
SPINEL_MD_FLAG_BAD_FCS = 0x0004, //!< Packet was received with bad FCS
SPINEL_MD_FLAG_DUPE = 0x0008, //!< Packet seems to be a duplicate
SPINEL_MD_FLAG_RESERVED = 0xFFF2, //!< Flags reserved for future use.
SPINEL_MD_FLAG_ACKED_FP = 0x0010, //!< Packet was acknowledged with frame pending set
SPINEL_MD_FLAG_RESERVED = 0xFFE2, //!< Flags reserved for future use.
};
enum
+2
View File
@@ -635,6 +635,8 @@ otError RadioSpinel::ParseRadioFrame(otRadioFrame &aFrame, const uint8_t *aBuffe
if (receiveError == OT_ERROR_NONE)
{
aFrame.mLength = static_cast<uint8_t>(size);
aFrame.mInfo.mRxInfo.mAckedWithFramePending = ((flags & SPINEL_MD_FLAG_ACKED_FP) != 0);
}
else if (receiveError < OT_NUM_ERRORS)
{