From c646e6f57af1fb409a5050f5b05ce7ce4e37cfb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Wa=C5=84czyk?= Date: Wed, 18 Dec 2019 19:23:43 +0100 Subject: [PATCH] [mac] TxRetry histogram and maximal TxRetry expiry counter added (#4382) --- .travis/script.sh | 5 ++ include/openthread/link.h | 49 +++++++++++++++++ src/core/api/link_api.cpp | 32 +++++++++++ src/core/config/mac.h | 36 ++++++++++++ src/core/mac/mac.cpp | 61 +++++++++++++++++++++ src/core/mac/mac.hpp | 58 ++++++++++++++++++++ src/core/mac/sub_mac.cpp | 2 - src/core/mac/sub_mac.hpp | 8 +++ src/ncp/ncp_base.cpp | 4 ++ src/ncp/ncp_base_dispatcher.cpp | 6 ++ src/ncp/ncp_base_mtd.cpp | 48 ++++++++++++++++ src/ncp/spinel.c | 8 +++ src/ncp/spinel.h | 97 ++++++++++++++++++++++----------- 13 files changed, 380 insertions(+), 34 deletions(-) diff --git a/.travis/script.sh b/.travis/script.sh index 0816e4663..0ffbed9c3 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -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 diff --git a/include/openthread/link.h b/include/openthread/link.h index 0e0024626..98fff206d 100644 --- a/include/openthread/link.h +++ b/include/openthread/link.h @@ -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. * diff --git a/src/core/api/link_api.cpp b/src/core/api/link_api.cpp index 4bd975829..eaf47b32a 100644 --- a/src/core/api/link_api.cpp +++ b/src/core/api/link_api.cpp @@ -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(aInstance); + + return instance.Get().GetDirectRetrySuccessHistogram(*aNumberOfEntries); +} + +const uint32_t *otLinkGetTxIndirectRetrySuccessHistogram(otInstance *aInstance, uint8_t *aNumberOfEntries) +{ + const uint32_t *histogram = NULL; + +#if OPENTHREAD_FTD + Instance &instance = *static_cast(aInstance); + + histogram = instance.Get().GetIndirectRetrySuccessHistogram(*aNumberOfEntries); +#else + OT_UNUSED_VARIABLE(aInstance); + *aNumberOfEntries = 0; +#endif + + return histogram; +} + +void otLinkResetTxRetrySuccessHistogram(otInstance *aInstance) +{ + Instance &instance = *static_cast(aInstance); + + instance.Get().ResetRetrySuccessHistogram(); +} +#endif // OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE + void otLinkSetPcapCallback(otInstance *aInstance, otLinkPcapCallback aPcapCallback, void *aCallbackContext) { Instance &instance = *static_cast(aInstance); diff --git a/src/core/config/mac.h b/src/core/config/mac.h index f9b2c89c3..abc9ba001 100644 --- a/src/core/config/mac.h +++ b/src/core/config/mac.h @@ -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 * diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 6134419dd..731be96cb 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -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().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().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().GetReceiveSensitivity(); diff --git a/src/core/mac/mac.hpp b/src/core/mac/mac.hpp index 9ba478a86..00c988804 100644 --- a/src/core/mac/mac.hpp +++ b/src/core/mac/mac.hpp @@ -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; diff --git a/src/core/mac/sub_mac.cpp b/src/core/mac/sub_mac.cpp index 57b70d504..747069ebc 100644 --- a/src/core/mac/sub_mac.cpp +++ b/src/core/mac/sub_mac.cpp @@ -374,8 +374,6 @@ void SubMac::HandleTransmitDone(TxFrame &aFrame, RxFrame *aAckFrame, otError aEr ExitNow(); } - mTransmitRetries = 0; - SetState(kStateReceive); mCallbacks.TransmitDone(aFrame, aAckFrame, aError); diff --git a/src/core/mac/sub_mac.hpp b/src/core/mac/sub_mac.hpp index e406e9dd5..6c086431d 100644 --- a/src/core/mac/sub_mac.hpp +++ b/src/core/mac/sub_mac.hpp @@ -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. * diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp index 20693f16d..11bbe5179 100644 --- a/src/ncp/ncp_base.cpp +++ b/src/ncp/ncp_base.cpp @@ -1825,6 +1825,10 @@ template <> otError NcpBase::HandlePropertyGet(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 diff --git a/src/ncp/ncp_base_dispatcher.cpp b/src/ncp/ncp_base_dispatcher.cpp index 00547cc9d..2bb631a6c 100644 --- a/src/ncp/ncp_base_dispatcher.cpp +++ b/src/ncp/ncp_base_dispatcher.cpp @@ -199,6 +199,9 @@ NcpBase::PropertyHandler NcpBase::FindGetPropertyHandler(spinel_prop_key_t aKey) {SPINEL_PROP_CNTR_ALL_MAC_COUNTERS, &NcpBase::HandlePropertyGet}, {SPINEL_PROP_CNTR_MLE_COUNTERS, &NcpBase::HandlePropertyGet}, {SPINEL_PROP_CNTR_ALL_IP_COUNTERS, &NcpBase::HandlePropertyGet}, +#if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE + {SPINEL_PROP_CNTR_MAC_RETRY_HISTOGRAM, &NcpBase::HandlePropertyGet}, +#endif {SPINEL_PROP_UNSOL_UPDATE_FILTER, &NcpBase::HandlePropertyGet}, {SPINEL_PROP_UNSOL_UPDATE_LIST, &NcpBase::HandlePropertyGet}, #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_MLE_COUNTERS, &NcpBase::HandlePropertySet}, {SPINEL_PROP_CNTR_ALL_IP_COUNTERS, &NcpBase::HandlePropertySet}, +#if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE + {SPINEL_PROP_CNTR_MAC_RETRY_HISTOGRAM, &NcpBase::HandlePropertySet}, +#endif {SPINEL_PROP_UNSOL_UPDATE_FILTER, &NcpBase::HandlePropertySet}, #if OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE {SPINEL_PROP_JAM_DETECT_ENABLE, &NcpBase::HandlePropertySet}, diff --git a/src/ncp/ncp_base_mtd.cpp b/src/ncp/ncp_base_mtd.cpp index 694618f33..af5bea159 100644 --- a/src/ncp/ncp_base_mtd.cpp +++ b/src/ncp/ncp_base_mtd.cpp @@ -2445,6 +2445,8 @@ template <> otError NcpBase::HandlePropertyGetmTxErrCca)); 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(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(void) +{ + otLinkResetTxRetrySuccessHistogram(mInstance); + + return OT_ERROR_NONE; +} +#endif // OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE + template <> otError NcpBase::HandlePropertySet(void) { otThreadResetIp6Counters(mInstance); @@ -2900,6 +2945,9 @@ exit: template <> otError NcpBase::HandlePropertySet(void) { otLinkResetCounters(mInstance); +#if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE + otLinkResetTxRetrySuccessHistogram(mInstance); +#endif otThreadResetIp6Counters(mInstance); otThreadResetMleCounters(mInstance); ResetCounters(); diff --git a/src/ncp/spinel.c b/src/ncp/spinel.c index 08bcc2bff..0698881de 100644 --- a/src/ncp/spinel.c +++ b/src/ncp/spinel.c @@ -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; diff --git a/src/ncp/spinel.h b/src/ncp/spinel.h index 001a4f80c..1827806c5 100644 --- a/src/ncp/spinel.h +++ b/src/ncp/spinel.h @@ -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,