mirror of
https://github.com/espressif/openthread.git
synced 2026-08-20 01:19:51 +00:00
[mac] TxRetry histogram and maximal TxRetry expiry counter added (#4382)
This commit is contained in:
committed by
Jonathan Hui
parent
ed34a53829
commit
c646e6f57a
@@ -450,6 +450,11 @@ build_samr21() {
|
||||
./bootstrap || die
|
||||
CPPFLAGS=-DOPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=1 make -f examples/Makefile-posix || die
|
||||
|
||||
git checkout -- . || die
|
||||
git clean -xfd || die
|
||||
./bootstrap || die
|
||||
CPPFLAGS=-DOPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE=1 make -f examples/Makefile-posix || die
|
||||
|
||||
git checkout -- . || die
|
||||
git clean -xfd || die
|
||||
./bootstrap || die
|
||||
|
||||
@@ -216,6 +216,18 @@ typedef struct otMacCounters
|
||||
*/
|
||||
uint32_t mTxRetry;
|
||||
|
||||
/**
|
||||
* The total number of unique MAC transmission packets that meet maximal retry limit for direct packets.
|
||||
*
|
||||
*/
|
||||
uint32_t mTxDirectMaxRetryExpiry;
|
||||
|
||||
/**
|
||||
* The total number of unique MAC transmission packets that meet maximal retry limit for indirect packets.
|
||||
*
|
||||
*/
|
||||
uint32_t mTxIndirectMaxRetryExpiry;
|
||||
|
||||
/**
|
||||
* The total number of CCA failures.
|
||||
*
|
||||
@@ -955,6 +967,43 @@ uint8_t otLinkConvertRssToLinkQuality(otInstance *aInstance, int8_t aRss);
|
||||
*/
|
||||
int8_t otLinkConvertLinkQualityToRss(otInstance *aInstance, uint8_t aLinkQuality);
|
||||
|
||||
/**
|
||||
* This method gets histogram of retries for a single direct packet until success.
|
||||
*
|
||||
* This function is valid when OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE configuration is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aNumberOfEntries A pointer to where the size of returned histogram array is placed.
|
||||
*
|
||||
* @returns A pointer to the histogram of retries (in a form of an array).
|
||||
* The n-th element indicates that the packet has been sent with n-th retry.
|
||||
*/
|
||||
const uint32_t *otLinkGetTxDirectRetrySuccessHistogram(otInstance *aInstance, uint8_t *aNumberOfEntries);
|
||||
|
||||
/**
|
||||
* This method gets histogram of retries for a single indirect packet until success.
|
||||
*
|
||||
* This function is valid when OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE configuration is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[out] aNumberOfEntries A pointer to where the size of returned histogram array is placed.
|
||||
*
|
||||
* @returns A pointer to the histogram of retries (in a form of an array).
|
||||
* The n-th element indicates that the packet has been sent with n-th retry.
|
||||
*
|
||||
*/
|
||||
const uint32_t *otLinkGetTxIndirectRetrySuccessHistogram(otInstance *aInstance, uint8_t *aNumberOfEntries);
|
||||
|
||||
/**
|
||||
* This method clears histogram statistics for direct and indirect transmissions.
|
||||
*
|
||||
* This function is valid when OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE configuration is enabled.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*
|
||||
*/
|
||||
void otLinkResetTxRetrySuccessHistogram(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the MAC layer counters.
|
||||
*
|
||||
|
||||
@@ -315,6 +315,38 @@ int8_t otLinkConvertLinkQualityToRss(otInstance *aInstance, uint8_t aLinkQuality
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_MAC_FILTER_ENABLE
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
const uint32_t *otLinkGetTxDirectRetrySuccessHistogram(otInstance *aInstance, uint8_t *aNumberOfEntries)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.Get<Mac::Mac>().GetDirectRetrySuccessHistogram(*aNumberOfEntries);
|
||||
}
|
||||
|
||||
const uint32_t *otLinkGetTxIndirectRetrySuccessHistogram(otInstance *aInstance, uint8_t *aNumberOfEntries)
|
||||
{
|
||||
const uint32_t *histogram = NULL;
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
histogram = instance.Get<Mac::Mac>().GetIndirectRetrySuccessHistogram(*aNumberOfEntries);
|
||||
#else
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
*aNumberOfEntries = 0;
|
||||
#endif
|
||||
|
||||
return histogram;
|
||||
}
|
||||
|
||||
void otLinkResetTxRetrySuccessHistogram(otInstance *aInstance)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
instance.Get<Mac::Mac>().ResetRetrySuccessHistogram();
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
|
||||
void otLinkSetPcapCallback(otInstance *aInstance, otLinkPcapCallback aPcapCallback, void *aCallbackContext)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
@@ -83,6 +83,42 @@
|
||||
#define OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
*
|
||||
* Define to 1 to enable MAC retry packets histogram analysis.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
#define OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_DIRECT
|
||||
*
|
||||
* The default size of MAC histogram array for success message retry direct transmission.
|
||||
*
|
||||
* Default value is (OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_DIRECT + 1).
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_DIRECT
|
||||
#define OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_DIRECT \
|
||||
(OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_DIRECT + 1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_INDIRECT
|
||||
*
|
||||
* The default size of MAC histogram array for success message retry direct transmission.
|
||||
*
|
||||
* Default value is (OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT + 1).
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_INDIRECT
|
||||
#define OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_INDIRECT \
|
||||
(OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT + 1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MAC_MAX_TX_ATTEMPTS_INDIRECT_POLLS
|
||||
*
|
||||
|
||||
@@ -1261,6 +1261,18 @@ void Mac::HandleTransmitDone(TxFrame &aFrame, RxFrame *aAckFrame, otError aError
|
||||
|
||||
case kOperationTransmitDataDirect:
|
||||
mCounters.mTxData++;
|
||||
|
||||
if (aError != OT_ERROR_NONE)
|
||||
{
|
||||
mCounters.mTxDirectMaxRetryExpiry++;
|
||||
}
|
||||
#if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
else if (mSubMac.GetTransmitRetries() < OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_DIRECT)
|
||||
{
|
||||
mRetryHistogram.mTxDirectRetrySuccess[mSubMac.GetTransmitRetries()]++;
|
||||
}
|
||||
#endif
|
||||
|
||||
otDumpDebgMac("TX", aFrame.GetHeader(), aFrame.GetLength());
|
||||
FinishOperation();
|
||||
Get<MeshForwarder>().HandleSentFrame(aFrame, aError);
|
||||
@@ -1270,6 +1282,18 @@ void Mac::HandleTransmitDone(TxFrame &aFrame, RxFrame *aAckFrame, otError aError
|
||||
#if OPENTHREAD_FTD
|
||||
case kOperationTransmitDataIndirect:
|
||||
mCounters.mTxData++;
|
||||
|
||||
if (aError != OT_ERROR_NONE)
|
||||
{
|
||||
mCounters.mTxIndirectMaxRetryExpiry++;
|
||||
}
|
||||
#if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
else if (mSubMac.GetTransmitRetries() < OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_INDIRECT)
|
||||
{
|
||||
mRetryHistogram.mTxIndirectRetrySuccess[mSubMac.GetTransmitRetries()]++;
|
||||
}
|
||||
#endif
|
||||
|
||||
otDumpDebgMac("TX", aFrame.GetHeader(), aFrame.GetLength());
|
||||
FinishOperation();
|
||||
Get<DataPollHandler>().HandleSentFrame(aFrame, aError);
|
||||
@@ -1789,6 +1813,43 @@ void Mac::SetPromiscuous(bool aPromiscuous)
|
||||
UpdateIdleMode();
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
const uint32_t *Mac::GetDirectRetrySuccessHistogram(uint8_t &aNumberOfEntries)
|
||||
{
|
||||
if (mMaxFrameRetriesDirect >= OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_DIRECT)
|
||||
{
|
||||
aNumberOfEntries = OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_DIRECT;
|
||||
}
|
||||
else
|
||||
{
|
||||
aNumberOfEntries = mMaxFrameRetriesDirect + 1;
|
||||
}
|
||||
|
||||
return mRetryHistogram.mTxDirectRetrySuccess;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
const uint32_t *Mac::GetIndirectRetrySuccessHistogram(uint8_t &aNumberOfEntries)
|
||||
{
|
||||
if (mMaxFrameRetriesIndirect >= OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_INDIRECT)
|
||||
{
|
||||
aNumberOfEntries = OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_INDIRECT;
|
||||
}
|
||||
else
|
||||
{
|
||||
aNumberOfEntries = mMaxFrameRetriesIndirect + 1;
|
||||
}
|
||||
|
||||
return mRetryHistogram.mTxIndirectRetrySuccess;
|
||||
}
|
||||
#endif
|
||||
|
||||
void Mac::ResetRetrySuccessHistogram()
|
||||
{
|
||||
memset(&mRetryHistogram, 0, sizeof(mRetryHistogram));
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
|
||||
int8_t Mac::GetNoiseFloor(void)
|
||||
{
|
||||
return Get<Radio>().GetReceiveSensitivity();
|
||||
|
||||
@@ -577,6 +577,38 @@ public:
|
||||
*/
|
||||
otMacCounters &GetCounters(void) { return mCounters; }
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
/**
|
||||
* This method returns the MAC retry histogram for direct transmission.
|
||||
*
|
||||
* @param[out] aNumberOfEntries A reference to where the size of returned histogram array is placed.
|
||||
*
|
||||
* @returns A pointer to the histogram of retries (in a form of an array).
|
||||
* The n-th element indicates that the packet has been sent with n-th retry.
|
||||
*
|
||||
*/
|
||||
const uint32_t *GetDirectRetrySuccessHistogram(uint8_t &aNumberOfEntries);
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
/**
|
||||
* This method returns the MAC retry histogram for indirect transmission.
|
||||
*
|
||||
* @param[out] aNumberOfEntries A reference to where the size of returned histogram array is placed.
|
||||
*
|
||||
* @returns A pointer to the histogram of retries (in a form of an array).
|
||||
* The n-th element indicates that the packet has been sent with n-th retry.
|
||||
*
|
||||
*/
|
||||
const uint32_t *GetIndirectRetrySuccessHistogram(uint8_t &aNumberOfEntries);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This method resets MAC retry histogram.
|
||||
*
|
||||
*/
|
||||
void ResetRetrySuccessHistogram(void);
|
||||
#endif // OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
|
||||
/**
|
||||
* This method returns the noise floor value (currently use the radio receive sensitivity value).
|
||||
*
|
||||
@@ -636,6 +668,29 @@ private:
|
||||
kOperationTransmitOutOfBandFrame,
|
||||
};
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
struct RetryHistogram
|
||||
{
|
||||
/**
|
||||
* Histogram of number of retries for a single direct packet until success
|
||||
* [0 retry: packet count, 1 retry: packet count, 2 retry : packet count ...
|
||||
* until max retry limit: packet count]
|
||||
*
|
||||
* The size of the array is OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_DIRECT.
|
||||
*/
|
||||
uint32_t mTxDirectRetrySuccess[OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_DIRECT];
|
||||
|
||||
/**
|
||||
* Histogram of number of retries for a single indirect packet until success
|
||||
* [0 retry: packet count, 1 retry: packet count, 2 retry : packet count ...
|
||||
* until max retry limit: packet count]
|
||||
*
|
||||
* The size of the array is OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_INDIRECT.
|
||||
*/
|
||||
uint32_t mTxIndirectRetrySuccess[OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_INDIRECT];
|
||||
};
|
||||
#endif // OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
|
||||
/**
|
||||
* This method processes transmit security on the frame which is going to be sent.
|
||||
*
|
||||
@@ -739,6 +794,9 @@ private:
|
||||
uint32_t mKeyIdMode2FrameCounter;
|
||||
SuccessRateTracker mCcaSuccessRateTracker;
|
||||
uint16_t mCcaSampleCount;
|
||||
#if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
RetryHistogram mRetryHistogram;
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE
|
||||
Filter mFilter;
|
||||
|
||||
@@ -374,8 +374,6 @@ void SubMac::HandleTransmitDone(TxFrame &aFrame, RxFrame *aAckFrame, otError aEr
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
mTransmitRetries = 0;
|
||||
|
||||
SetState(kStateReceive);
|
||||
|
||||
mCallbacks.TransmitDone(aFrame, aAckFrame, aError);
|
||||
|
||||
@@ -310,6 +310,14 @@ public:
|
||||
*/
|
||||
otError Send(void);
|
||||
|
||||
/**
|
||||
* This method gets the number of transmit retries of last transmit packet.
|
||||
*
|
||||
* @returns Number of transmit retries.
|
||||
*
|
||||
*/
|
||||
uint8_t GetTransmitRetries(void) const { return mTransmitRetries; }
|
||||
|
||||
/**
|
||||
* This method gets the most recent RSSI measurement.
|
||||
*
|
||||
|
||||
@@ -1825,6 +1825,10 @@ template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_CAPS>(void)
|
||||
SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_RADIO_COEX));
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_MAC_RETRY_HISTOGRAM));
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE
|
||||
SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_PEEK_POKE));
|
||||
#endif
|
||||
|
||||
@@ -199,6 +199,9 @@ NcpBase::PropertyHandler NcpBase::FindGetPropertyHandler(spinel_prop_key_t aKey)
|
||||
{SPINEL_PROP_CNTR_ALL_MAC_COUNTERS, &NcpBase::HandlePropertyGet<SPINEL_PROP_CNTR_ALL_MAC_COUNTERS>},
|
||||
{SPINEL_PROP_CNTR_MLE_COUNTERS, &NcpBase::HandlePropertyGet<SPINEL_PROP_CNTR_MLE_COUNTERS>},
|
||||
{SPINEL_PROP_CNTR_ALL_IP_COUNTERS, &NcpBase::HandlePropertyGet<SPINEL_PROP_CNTR_ALL_IP_COUNTERS>},
|
||||
#if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
{SPINEL_PROP_CNTR_MAC_RETRY_HISTOGRAM, &NcpBase::HandlePropertyGet<SPINEL_PROP_CNTR_MAC_RETRY_HISTOGRAM>},
|
||||
#endif
|
||||
{SPINEL_PROP_UNSOL_UPDATE_FILTER, &NcpBase::HandlePropertyGet<SPINEL_PROP_UNSOL_UPDATE_FILTER>},
|
||||
{SPINEL_PROP_UNSOL_UPDATE_LIST, &NcpBase::HandlePropertyGet<SPINEL_PROP_UNSOL_UPDATE_LIST>},
|
||||
#if OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE
|
||||
@@ -432,6 +435,9 @@ NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey)
|
||||
{SPINEL_PROP_CNTR_ALL_MAC_COUNTERS, &NcpBase::HandlePropertySet<SPINEL_PROP_CNTR_ALL_MAC_COUNTERS>},
|
||||
{SPINEL_PROP_CNTR_MLE_COUNTERS, &NcpBase::HandlePropertySet<SPINEL_PROP_CNTR_MLE_COUNTERS>},
|
||||
{SPINEL_PROP_CNTR_ALL_IP_COUNTERS, &NcpBase::HandlePropertySet<SPINEL_PROP_CNTR_ALL_IP_COUNTERS>},
|
||||
#if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
{SPINEL_PROP_CNTR_MAC_RETRY_HISTOGRAM, &NcpBase::HandlePropertySet<SPINEL_PROP_CNTR_MAC_RETRY_HISTOGRAM>},
|
||||
#endif
|
||||
{SPINEL_PROP_UNSOL_UPDATE_FILTER, &NcpBase::HandlePropertySet<SPINEL_PROP_UNSOL_UPDATE_FILTER>},
|
||||
#if OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE
|
||||
{SPINEL_PROP_JAM_DETECT_ENABLE, &NcpBase::HandlePropertySet<SPINEL_PROP_JAM_DETECT_ENABLE>},
|
||||
|
||||
@@ -2445,6 +2445,8 @@ template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_CNTR_ALL_MAC_COUNTERS
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxErrCca));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxErrAbort));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxErrBusyChannel));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxDirectMaxRetryExpiry));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxIndirectMaxRetryExpiry));
|
||||
SuccessOrExit(error = mEncoder.CloseStruct());
|
||||
|
||||
// Encode Rx related counters
|
||||
@@ -2530,6 +2532,49 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_CNTR_MAC_RETRY_HISTOGRAM>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
const uint32_t *histogramDirect;
|
||||
const uint32_t *histogramIndirect;
|
||||
uint8_t histogramDirectEntries;
|
||||
uint8_t histogramIndirectEntries;
|
||||
|
||||
histogramDirect = otLinkGetTxDirectRetrySuccessHistogram(mInstance, &histogramDirectEntries);
|
||||
histogramIndirect = otLinkGetTxIndirectRetrySuccessHistogram(mInstance, &histogramIndirectEntries);
|
||||
|
||||
assert((histogramDirectEntries == 0) || (histogramDirect != NULL));
|
||||
assert((histogramIndirectEntries == 0) || (histogramIndirect != NULL));
|
||||
|
||||
// Encode direct message retries histogram
|
||||
SuccessOrExit(error = mEncoder.OpenStruct());
|
||||
for (uint8_t i = 0; i < histogramDirectEntries; i++)
|
||||
{
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(histogramDirect[i]));
|
||||
}
|
||||
SuccessOrExit(error = mEncoder.CloseStruct());
|
||||
|
||||
// Encode indirect message retries histogram
|
||||
SuccessOrExit(error = mEncoder.OpenStruct());
|
||||
for (uint8_t i = 0; i < histogramIndirectEntries; i++)
|
||||
{
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(histogramIndirect[i]));
|
||||
}
|
||||
SuccessOrExit(error = mEncoder.CloseStruct());
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_CNTR_MAC_RETRY_HISTOGRAM>(void)
|
||||
{
|
||||
otLinkResetTxRetrySuccessHistogram(mInstance);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_CNTR_ALL_IP_COUNTERS>(void)
|
||||
{
|
||||
otThreadResetIp6Counters(mInstance);
|
||||
@@ -2900,6 +2945,9 @@ exit:
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_CNTR_RESET>(void)
|
||||
{
|
||||
otLinkResetCounters(mInstance);
|
||||
#if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE
|
||||
otLinkResetTxRetrySuccessHistogram(mInstance);
|
||||
#endif
|
||||
otThreadResetIp6Counters(mInstance);
|
||||
otThreadResetMleCounters(mInstance);
|
||||
ResetCounters();
|
||||
|
||||
@@ -2183,6 +2183,10 @@ const char *spinel_prop_key_to_cstr(spinel_prop_key_t prop_key)
|
||||
ret = "CNTR_ALL_IP_COUNTERS";
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_CNTR_MAC_RETRY_HISTOGRAM:
|
||||
ret = "CNTR_MAC_RETRY_HISTOGRAM";
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_NEST_STREAM_MFG:
|
||||
ret = "NEST_STREAM_MFG";
|
||||
break;
|
||||
@@ -2607,6 +2611,10 @@ const char *spinel_capability_to_cstr(spinel_capability_t capability)
|
||||
ret = "RADIO_COEX";
|
||||
break;
|
||||
|
||||
case SPINEL_CAP_MAC_RETRY_HISTOGRAM:
|
||||
ret = "MAC_RETRY_HISTOGRAM";
|
||||
break;
|
||||
|
||||
case SPINEL_CAP_ERROR_RATE_TRACKING:
|
||||
ret = "ERROR_RATE_TRACKING";
|
||||
break;
|
||||
|
||||
+65
-32
@@ -1058,6 +1058,7 @@ enum
|
||||
SPINEL_CAP_POSIX_APP = (SPINEL_CAP_OPENTHREAD__BEGIN + 9),
|
||||
SPINEL_CAP_SLAAC = (SPINEL_CAP_OPENTHREAD__BEGIN + 10),
|
||||
SPINEL_CAP_RADIO_COEX = (SPINEL_CAP_OPENTHREAD__BEGIN + 11),
|
||||
SPINEL_CAP_MAC_RETRY_HISTOGRAM = (SPINEL_CAP_OPENTHREAD__BEGIN + 12),
|
||||
SPINEL_CAP_OPENTHREAD__END = 640,
|
||||
|
||||
SPINEL_CAP_THREAD__BEGIN = 1024,
|
||||
@@ -3775,41 +3776,44 @@ enum
|
||||
*
|
||||
* The transmit structure includes:
|
||||
*
|
||||
* 'L': TxTotal (The total number of transmissions).
|
||||
* 'L': TxUnicast (The total number of unicast transmissions).
|
||||
* 'L': TxBroadcast (The total number of broadcast transmissions).
|
||||
* 'L': TxAckRequested (The number of transmissions with ack request).
|
||||
* 'L': TxAcked (The number of transmissions that were acked).
|
||||
* 'L': TxNoAckRequested (The number of transmissions without ack request).
|
||||
* 'L': TxData (The number of transmitted data).
|
||||
* 'L': TxDataPoll (The number of transmitted data poll).
|
||||
* 'L': TxBeacon (The number of transmitted beacon).
|
||||
* 'L': TxBeaconRequest (The number of transmitted beacon request).
|
||||
* 'L': TxOther (The number of transmitted other types of frames).
|
||||
* 'L': TxRetry (The number of retransmission times).
|
||||
* 'L': TxErrCca (The number of CCA failure times).
|
||||
* 'L': TxErrAbort (The number of frame transmission failures due to abort error).
|
||||
* 'L': TxErrBusyChannel (The number of frames that were dropped due to a busy channel).
|
||||
* 'L': TxTotal (The total number of transmissions).
|
||||
* 'L': TxUnicast (The total number of unicast transmissions).
|
||||
* 'L': TxBroadcast (The total number of broadcast transmissions).
|
||||
* 'L': TxAckRequested (The number of transmissions with ack request).
|
||||
* 'L': TxAcked (The number of transmissions that were acked).
|
||||
* 'L': TxNoAckRequested (The number of transmissions without ack request).
|
||||
* 'L': TxData (The number of transmitted data).
|
||||
* 'L': TxDataPoll (The number of transmitted data poll).
|
||||
* 'L': TxBeacon (The number of transmitted beacon).
|
||||
* 'L': TxBeaconRequest (The number of transmitted beacon request).
|
||||
* 'L': TxOther (The number of transmitted other types of frames).
|
||||
* 'L': TxRetry (The number of retransmission times).
|
||||
* 'L': TxErrCca (The number of CCA failure times).
|
||||
* 'L': TxErrAbort (The number of frame transmission failures due to abort error).
|
||||
* 'L': TxErrBusyChannel (The number of frames that were dropped due to a busy channel).
|
||||
* 'L': TxDirectMaxRetryExpiry (The number of expired retransmission retries for direct message).
|
||||
* 'L': TxIndirectMaxRetryExpiry (The number of expired retransmission retries for indirect message).
|
||||
*
|
||||
* The receive structure includes:
|
||||
*
|
||||
* 'L': RxTotal (The total number of received packets).
|
||||
* 'L': RxUnicast (The total number of unicast packets received).
|
||||
* 'L': RxBroadcast (The total number of broadcast packets received).
|
||||
* 'L': RxData (The number of received data).
|
||||
* 'L': RxDataPoll (The number of received data poll).
|
||||
* 'L': RxBeacon (The number of received beacon).
|
||||
* 'L': RxBeaconRequest (The number of received beacon request).
|
||||
* 'L': RxOther (The number of received other types of frames).
|
||||
* 'L': RxAddressFiltered (The number of received packets filtered by address filter (whitelist or blacklist)).
|
||||
* 'L': RxDestAddrFiltered (The number of received packets filtered by destination check).
|
||||
* 'L': RxDuplicated (The number of received duplicated packets).
|
||||
* 'L': RxErrNoFrame (The number of received packets with no or malformed content).
|
||||
* 'L': RxErrUnknownNeighbor (The number of received packets from unknown neighbor).
|
||||
* 'L': RxErrInvalidSrcAddr (The number of received packets whose source address is invalid).
|
||||
* 'L': RxErrSec (The number of received packets with security error).
|
||||
* 'L': RxErrFcs (The number of received packets with FCS error).
|
||||
* 'L': RxErrOther (The number of received packets with other error).
|
||||
* 'L': RxTotal (The total number of received packets).
|
||||
* 'L': RxUnicast (The total number of unicast packets received).
|
||||
* 'L': RxBroadcast (The total number of broadcast packets received).
|
||||
* 'L': RxData (The number of received data).
|
||||
* 'L': RxDataPoll (The number of received data poll).
|
||||
* 'L': RxBeacon (The number of received beacon).
|
||||
* 'L': RxBeaconRequest (The number of received beacon request).
|
||||
* 'L': RxOther (The number of received other types of frames).
|
||||
* 'L': RxAddressFiltered (The number of received packets filtered by address filter
|
||||
* (whitelist or blacklist)).
|
||||
* 'L': RxDestAddrFiltered (The number of received packets filtered by destination check).
|
||||
* 'L': RxDuplicated (The number of received duplicated packets).
|
||||
* 'L': RxErrNoFrame (The number of received packets with no or malformed content).
|
||||
* 'L': RxErrUnknownNeighbor (The number of received packets from unknown neighbor).
|
||||
* 'L': RxErrInvalidSrcAddr (The number of received packets whose source address is invalid).
|
||||
* 'L': RxErrSec (The number of received packets with security error).
|
||||
* 'L': RxErrFcs (The number of received packets with FCS error).
|
||||
* 'L': RxErrOther (The number of received packets with other error).
|
||||
*
|
||||
* Writing to this property with any value would reset all MAC counters to zero.
|
||||
*
|
||||
@@ -3854,6 +3858,35 @@ enum
|
||||
*/
|
||||
SPINEL_PROP_CNTR_ALL_IP_COUNTERS = SPINEL_PROP_CNTR__BEGIN + 403,
|
||||
|
||||
/// MAC retry histogram.
|
||||
/** Format: t(A(L))t(A(L))
|
||||
*
|
||||
* Required capability: SPINEL_CAP_MAC_RETRY_HISTOGRAM
|
||||
*
|
||||
* The contents include two structs, first one is histogram which corresponds to retransmissions number of direct
|
||||
* messages, second one provides the histogram of retransmissions for indirect messages.
|
||||
*
|
||||
* The first structure includes:
|
||||
* 'L': DirectRetry[0] (The number of packets after 0 retry).
|
||||
* 'L': DirectRetry[1] (The number of packets after 1 retry).
|
||||
* ...
|
||||
* 'L': DirectRetry[n] (The number of packets after n retry).
|
||||
*
|
||||
* The size of the array is OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_DIRECT.
|
||||
*
|
||||
* The second structure includes:
|
||||
* 'L': IndirectRetry[0] (The number of packets after 0 retry).
|
||||
* 'L': IndirectRetry[1] (The number of packets after 1 retry).
|
||||
* ...
|
||||
* 'L': IndirectRetry[m] (The number of packets after m retry).
|
||||
*
|
||||
* The size of the array is OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_INDIRECT.
|
||||
*
|
||||
* Writing to this property with any value would reset MAC retry histogram.
|
||||
*
|
||||
*/
|
||||
SPINEL_PROP_CNTR_MAC_RETRY_HISTOGRAM = SPINEL_PROP_CNTR__BEGIN + 404,
|
||||
|
||||
SPINEL_PROP_CNTR__END = 0x800,
|
||||
|
||||
SPINEL_PROP_NEST__BEGIN = 0x3BC0,
|
||||
|
||||
Reference in New Issue
Block a user