Skip to content

Commit

Permalink
lr-wpan: Fix association response before data request ack issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberto Gallegos Ramonet committed Feb 6, 2025
1 parent d246b8f commit 9657740
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion src/lr-wpan/doc/lr-wpan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 36 additions & 12 deletions src/lr-wpan/model/lr-wpan-mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ LrWpanMac::DoDispose()
m_scanEnergyEvent.Cancel();
m_scanOrphanEvent.Cancel();
m_beaconEvent.Cancel();
m_assocResCmdWaitTimeout.Cancel();

Object::DoDispose();
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -2312,10 +2315,28 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr<Packet> 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;
}
Expand Down Expand Up @@ -2505,15 +2526,18 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr<Packet> 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<double>(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<double>(m_assocRespCmdWaitTime) / symbolRate);
m_assocResCmdWaitTimeout =
Simulator::Schedule(waitTime,
&LrWpanMac::LostAssocRespCommand,
this);
}

if (!m_mlmePollConfirmCallback.IsNull())
{
Expand Down
8 changes: 8 additions & 0 deletions src/lr-wpan/model/lr-wpan-mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 9657740

Please sign in to comment.