From 96577400e1515464febef7db3709cb1b0d087304 Mon Sep 17 00:00:00 2001 From: Alberto Gallegos Ramonet Date: Wed, 5 Feb 2025 17:47:10 +0900 Subject: [PATCH] lr-wpan: Fix association response before data request ack issue --- CHANGES.md | 2 ++ RELEASE_NOTES.md | 9 +++--- src/lr-wpan/doc/lr-wpan.rst | 8 +++++- src/lr-wpan/model/lr-wpan-mac.cc | 48 ++++++++++++++++++++++++-------- src/lr-wpan/model/lr-wpan-mac.h | 8 ++++++ 5 files changed, 58 insertions(+), 17 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d369cb34a5..ab6c78557e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -37,6 +37,8 @@ This file is a best-effort approach to solving this issue; we will do our best b ### Changed behavior +* (lr-wpan) Association: Fix the handling of situations where the association response commands arrives before the data request command acknowledgment that is supposed to precede it. + ## Changes from ns-3.42 to ns-3.43 ### New API diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index f856053af2..8a9e3a0455 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -49,14 +49,15 @@ The required Doxygen version for documentation generation is version 1.11. ### Bugs fixed +- (lr-wpan) !2334 - Fix the MAC reaction to an association issue in which association response commands might be received before data request command acks. +- (propagation) Scale the NTN LOS probabilities from percentages [0, 100] to probabilities [0, 1] +- (spectrum) Calculate PSD by combining received power on ports, even when no precoding matrix is set +- (spectrum) Scale the CDS parameter of V2V models to nanoseconds +- (spectrum) Add missing K-factor fields (uk, sigK) for NTN NLOS 3GPP channel model - (wifi) Retransmit procedures have been aligned with the standard specifications. - (wifi) Clear PSDU map if no immediate response expected with BAR-BA ack sequence - (wifi) Fix S-MPDU TX duration computation with BlockAck ack policy - (wifi) Fix missing DSSS Param Set in Probe Request sent over 2.4 GHz links -- (spectrum) Calculate PSD by combining received power on ports, even when no precoding matrix is set -- (spectrum) Scale the CDS parameter of V2V models to nanoseconds -- (spectrum) Add missing K-factor fields (uk, sigK) for NTN NLOS 3GPP channel model -- (propagation) Scale the NTN LOS probabilities from percentages [0, 100] to probabilities [0, 1] ## Release 3.43 diff --git a/src/lr-wpan/doc/lr-wpan.rst b/src/lr-wpan/doc/lr-wpan.rst index fe59835197..d30d4cdbcd 100644 --- a/src/lr-wpan/doc/lr-wpan.rst +++ b/src/lr-wpan/doc/lr-wpan.rst @@ -260,7 +260,13 @@ Devices that have the short address ``FF:FF`` are not associated an cannot parti Devices that have the short address ``FF:FE`` and have a valid PAN ID can communicate with other devices in the network using the extended address mode. In this mode, devices will use its 64 bit address (A.K.A. extended address) to communicate in the network. -A fixed association is possible in |ns3| without the use of the bootstrap process. For this purpose, the ``LrWpanHelper::CreateAssociatedPan`` +Before ns-3.44, the MAC association struggled to handle scenarios where the association response command arrived before the acknowledgment (ACK) +for a data request command. This issue could arise in saturated networks and is caused by a delayed data request command ACK +(which do not use CSMA/CA but can be retried several times if necessary). This situation highlighted a problem and a design flaw in the original standard, where association responses +are sent immediately after sending a data request acknowledgments. As a result, their arrival could become inverted. However, +the current MAC implementation is now capable of correctly reacting to this delayed ACK issue. + +Finally, a fixed association is possible in |ns3| without the use of the bootstrap process. For this purpose, the ``LrWpanHelper::CreateAssociatedPan`` is used. See the Helpers subsection for more details. MAC transmission Queues diff --git a/src/lr-wpan/model/lr-wpan-mac.cc b/src/lr-wpan/model/lr-wpan-mac.cc index 482e697ca6..cc0c8893b4 100644 --- a/src/lr-wpan/model/lr-wpan-mac.cc +++ b/src/lr-wpan/model/lr-wpan-mac.cc @@ -319,6 +319,7 @@ LrWpanMac::DoDispose() m_scanEnergyEvent.Cancel(); m_scanOrphanEvent.Cancel(); m_beaconEvent.Cancel(); + m_assocResCmdWaitTimeout.Cancel(); Object::DoDispose(); } @@ -681,6 +682,8 @@ LrWpanMac::MlmeAssociateRequest(MlmeAssociateRequestParams params) // obtained from those operations. m_pendPrimitive = MLME_ASSOC_REQ; m_associateParams = params; + m_ignoreDataCmdAck = false; + bool invalidRequest = false; if (params.m_coordPanId == 0xffff) @@ -2312,10 +2315,28 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) case CommandPayloadHeader::ASSOCIATION_REQ: NS_LOG_DEBUG("Association Request Command Received; processing ACK"); break; - case CommandPayloadHeader::ASSOCIATION_RESP: - m_assocResCmdWaitTimeout.Cancel(); // cancel event to a lost assoc resp cmd. - NS_LOG_DEBUG("Association Response Command Received; processing ACK"); + case CommandPayloadHeader::ASSOCIATION_RESP: { + if (m_assocResCmdWaitTimeout.IsPending()) + { + m_assocResCmdWaitTimeout + .Cancel(); // cancel event to a lost assoc resp cmd. + NS_LOG_DEBUG("Association Response Command Received; processing ACK"); + } + else + { + // Association response command was received before (or never received) + // a Data request command ACK. This is an extreme case and it is + // essentially caused by saturation in the network. + // We turn a flag ON to not react once + // we finally receive the Data request command ACK. This behavior is not + // standard, but necessary to address this flaw in design of the + // original association process. + m_ignoreDataCmdAck = true; + NS_LOG_DEBUG("Assoc. Resp Cmd received before Data Req. Cmd. in " + "Association request"); + } break; + } default: break; } @@ -2505,15 +2526,18 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) } case CommandPayloadHeader::DATA_REQ: { - // Schedule an event in case the Association Response Command never - // reached this device during an association process. - double symbolRate = m_phy->GetDataOrSymbolRate(false); - Time waitTime = Seconds( - static_cast(m_assocRespCmdWaitTime) / symbolRate); - m_assocResCmdWaitTimeout = - Simulator::Schedule(waitTime, - &LrWpanMac::LostAssocRespCommand, - this); + if (!m_ignoreDataCmdAck) + { + // Schedule an event in case the Association Response Command + // never reached this device during an association process. + double symbolRate = m_phy->GetDataOrSymbolRate(false); + Time waitTime = Seconds( + static_cast(m_assocRespCmdWaitTime) / symbolRate); + m_assocResCmdWaitTimeout = + Simulator::Schedule(waitTime, + &LrWpanMac::LostAssocRespCommand, + this); + } if (!m_mlmePollConfirmCallback.IsNull()) { diff --git a/src/lr-wpan/model/lr-wpan-mac.h b/src/lr-wpan/model/lr-wpan-mac.h index 90bef23d02..4c0a7e0b68 100644 --- a/src/lr-wpan/model/lr-wpan-mac.h +++ b/src/lr-wpan/model/lr-wpan-mac.h @@ -1261,6 +1261,14 @@ class LrWpanMac : public LrWpanMacBase */ uint8_t m_lastRxFrameLqi; + /** + * This flag informs the MAC that an association response command was received + * before the acknowledgment (ACK) for the data request command that + * should precede it. This situation typically occurs due to network saturation. + */ + + bool m_ignoreDataCmdAck; + /** * Scheduler event for the ACK timeout of the currently transmitted data * packet.