From 29749c21b060a0be9e84cefa809a5bf59bb4c52d Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Wed, 16 Mar 2022 16:42:50 +0100 Subject: [PATCH] wifi: Pass link ID to WifiMac::Receive() --- src/mesh/model/mesh-wifi-interface-mac.cc | 2 +- src/mesh/model/mesh-wifi-interface-mac.h | 3 ++- src/wave/model/ocb-wifi-mac.cc | 6 +++--- src/wave/model/ocb-wifi-mac.h | 2 +- src/wifi/model/adhoc-wifi-mac.cc | 6 +++--- src/wifi/model/adhoc-wifi-mac.h | 2 +- src/wifi/model/ap-wifi-mac.cc | 6 +++--- src/wifi/model/ap-wifi-mac.h | 2 +- src/wifi/model/frame-exchange-manager.cc | 6 +++--- src/wifi/model/mac-rx-middle.cc | 8 ++++---- src/wifi/model/mac-rx-middle.h | 7 ++++--- src/wifi/model/qos-frame-exchange-manager.cc | 2 +- src/wifi/model/recipient-block-ack-agreement.cc | 4 ++-- src/wifi/model/sta-wifi-mac.cc | 6 +++--- src/wifi/model/sta-wifi-mac.h | 7 +------ src/wifi/model/wifi-mac.cc | 4 ++-- src/wifi/model/wifi-mac.h | 13 ++++++++++--- src/wifi/model/wifi-utils.h | 3 +++ src/wifi/test/block-ack-test-suite.cc | 7 ++++--- 19 files changed, 52 insertions(+), 44 deletions(-) diff --git a/src/mesh/model/mesh-wifi-interface-mac.cc b/src/mesh/model/mesh-wifi-interface-mac.cc index 9e7ef9ace..4b70483a5 100644 --- a/src/mesh/model/mesh-wifi-interface-mac.cc +++ b/src/mesh/model/mesh-wifi-interface-mac.cc @@ -413,7 +413,7 @@ MeshWifiInterfaceMac::SendBeacon () ScheduleNextBeacon (); } void -MeshWifiInterfaceMac::Receive (Ptr mpdu) +MeshWifiInterfaceMac::Receive (Ptr mpdu, uint8_t linkId) { const WifiMacHeader* hdr = &mpdu->GetHeader (); Ptr packet = mpdu->GetPacket ()->Copy (); diff --git a/src/mesh/model/mesh-wifi-interface-mac.h b/src/mesh/model/mesh-wifi-interface-mac.h index 15cfd1810..0e4674019 100644 --- a/src/mesh/model/mesh-wifi-interface-mac.h +++ b/src/mesh/model/mesh-wifi-interface-mac.h @@ -216,8 +216,9 @@ private: * Frame receive handler * * \param mpdu the received MPDU + * \param linkId the ID of the link the frame was received over */ - void Receive (Ptr mpdu); + void Receive (Ptr mpdu, uint8_t linkId); /** * Send frame. Frame is supposed to be tagged by routing information. * diff --git a/src/wave/model/ocb-wifi-mac.cc b/src/wave/model/ocb-wifi-mac.cc index ed6fffa52..f0d002a7b 100644 --- a/src/wave/model/ocb-wifi-mac.cc +++ b/src/wave/model/ocb-wifi-mac.cc @@ -245,9 +245,9 @@ OcbWifiMac::Enqueue (Ptr packet, Mac48Address to) * here we only care about data packet and vsa management frame */ void -OcbWifiMac::Receive (Ptr mpdu) +OcbWifiMac::Receive (Ptr mpdu, uint8_t linkId) { - NS_LOG_FUNCTION (this << *mpdu); + NS_LOG_FUNCTION (this << *mpdu << +linkId); const WifiMacHeader* hdr = &mpdu->GetHeader (); // Create a copy of the MPDU payload because non-const operations like RemovePacketTag // and RemoveHeader may need to be performed. @@ -331,7 +331,7 @@ OcbWifiMac::Receive (Ptr mpdu) // Invoke the receive handler of our parent class to deal with any // other frames. Specifically, this will handle Block Ack-related // Management Action frames. - WifiMac::Receive (Create (packet, *hdr)); + WifiMac::Receive (Create (packet, *hdr), linkId); } void diff --git a/src/wave/model/ocb-wifi-mac.h b/src/wave/model/ocb-wifi-mac.h index 0ab5b1b65..bbc7421c8 100644 --- a/src/wave/model/ocb-wifi-mac.h +++ b/src/wave/model/ocb-wifi-mac.h @@ -186,7 +186,7 @@ public: protected: virtual void DoDispose (void); private: - virtual void Receive (Ptr mpdu); + virtual void Receive (Ptr mpdu, uint8_t linkId); VendorSpecificContentManager m_vscManager; ///< VSC manager }; diff --git a/src/wifi/model/adhoc-wifi-mac.cc b/src/wifi/model/adhoc-wifi-mac.cc index 437e80ac0..ff021ce09 100644 --- a/src/wifi/model/adhoc-wifi-mac.cc +++ b/src/wifi/model/adhoc-wifi-mac.cc @@ -179,9 +179,9 @@ AdhocWifiMac::SetLinkUpCallback (Callback linkUp) } void -AdhocWifiMac::Receive (Ptr mpdu) +AdhocWifiMac::Receive (Ptr mpdu, uint8_t linkId) { - NS_LOG_FUNCTION (this << *mpdu); + NS_LOG_FUNCTION (this << *mpdu << +linkId); const WifiMacHeader* hdr = &mpdu->GetHeader (); NS_ASSERT (!hdr->IsCtl ()); Mac48Address from = hdr->GetAddr2 (); @@ -226,7 +226,7 @@ AdhocWifiMac::Receive (Ptr mpdu) //Invoke the receive handler of our parent class to deal with any //other frames. Specifically, this will handle Block Ack-related //Management Action frames. - WifiMac::Receive (mpdu); + WifiMac::Receive (mpdu, linkId); } } //namespace ns3 diff --git a/src/wifi/model/adhoc-wifi-mac.h b/src/wifi/model/adhoc-wifi-mac.h index 73dc2fdee..076094606 100644 --- a/src/wifi/model/adhoc-wifi-mac.h +++ b/src/wifi/model/adhoc-wifi-mac.h @@ -50,7 +50,7 @@ public: bool CanForwardPacketsTo (Mac48Address to) const override; private: - void Receive (Ptr mpdu) override; + void Receive (Ptr mpdu, uint8_t linkId) override; }; } //namespace ns3 diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index 5e98871a8..98a805ae6 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -1042,9 +1042,9 @@ ApWifiMac::TxFailed (WifiMacDropReason timeoutReason, Ptr mpdu) +ApWifiMac::Receive (Ptr mpdu, uint8_t linkId) { - NS_LOG_FUNCTION (this << *mpdu); + NS_LOG_FUNCTION (this << *mpdu << +linkId); const WifiMacHeader* hdr = &mpdu->GetHeader (); Ptr packet = mpdu->GetPacket (); Mac48Address from = hdr->GetAddr2 (); @@ -1487,7 +1487,7 @@ ApWifiMac::Receive (Ptr mpdu) //Invoke the receive handler of our parent class to deal with any //other frames. Specifically, this will handle Block Ack-related //Management Action frames. - WifiMac::Receive (Create (packet, *hdr)); + WifiMac::Receive (Create (packet, *hdr), linkId); } void diff --git a/src/wifi/model/ap-wifi-mac.h b/src/wifi/model/ap-wifi-mac.h index 26f69fe2b..6cfb420f1 100644 --- a/src/wifi/model/ap-wifi-mac.h +++ b/src/wifi/model/ap-wifi-mac.h @@ -164,7 +164,7 @@ protected: private: std::unique_ptr CreateLinkEntity (void) const override; - void Receive (Ptr mpdu) override; + void Receive (Ptr mpdu, uint8_t linkId) override; /** * The packet we sent was successfully received by the receiver * (i.e. we received an Ack from the receiver). If the packet diff --git a/src/wifi/model/frame-exchange-manager.cc b/src/wifi/model/frame-exchange-manager.cc index d77e3138a..0844ae893 100644 --- a/src/wifi/model/frame-exchange-manager.cc +++ b/src/wifi/model/frame-exchange-manager.cc @@ -973,7 +973,7 @@ FrameExchangeManager::Receive (Ptr psdu, RxSignalInfo rxSignalInfo, { if (m_promisc && psdu->GetNMpdus () == 1 && psdu->GetHeader (0).IsData ()) { - m_rxMiddle->Receive (*psdu->begin ()); + m_rxMiddle->Receive (*psdu->begin (), m_linkId); } return; } @@ -1154,7 +1154,7 @@ FrameExchangeManager::ReceiveMpdu (Ptr mpdu, RxSignalInfo rxSi this, hdr, txVector, rxSnr); } - m_rxMiddle->Receive (mpdu); + m_rxMiddle->Receive (mpdu, m_linkId); } else if (hdr.IsData () && !hdr.IsQosData ()) { @@ -1165,7 +1165,7 @@ FrameExchangeManager::ReceiveMpdu (Ptr mpdu, RxSignalInfo rxSi this, hdr, txVector, rxSnr); } - m_rxMiddle->Receive (mpdu); + m_rxMiddle->Receive (mpdu, m_linkId); } } diff --git a/src/wifi/model/mac-rx-middle.cc b/src/wifi/model/mac-rx-middle.cc index eac2069b9..e23873232 100644 --- a/src/wifi/model/mac-rx-middle.cc +++ b/src/wifi/model/mac-rx-middle.cc @@ -296,9 +296,9 @@ MacRxMiddle::HandleFragments (Ptr packet, const WifiMacHeader *hdr } void -MacRxMiddle::Receive (Ptr mpdu) +MacRxMiddle::Receive (Ptr mpdu, uint8_t linkId) { - NS_LOG_FUNCTION (*mpdu); + NS_LOG_FUNCTION (*mpdu << +linkId); const WifiMacHeader* hdr = &mpdu->GetHeader (); NS_ASSERT (hdr->IsData () || hdr->IsMgt ()); @@ -339,7 +339,7 @@ MacRxMiddle::Receive (Ptr mpdu) } if (aggregate == mpdu->GetPacket ()) { - m_callback (mpdu); + m_callback (mpdu, linkId); } else { @@ -347,7 +347,7 @@ MacRxMiddle::Receive (Ptr mpdu) // A-MSDUs saves us the time to deaggregate the A-MSDU in MSDUs (which are // kept separate in the received mpdu) and allows us to pass the originally // transmitted packets (i.e., with the same UID) to the receiver. - m_callback (Create (aggregate, *hdr)); + m_callback (Create (aggregate, *hdr), linkId); } } diff --git a/src/wifi/model/mac-rx-middle.h b/src/wifi/model/mac-rx-middle.h index f9dd0cbfc..451df612a 100644 --- a/src/wifi/model/mac-rx-middle.h +++ b/src/wifi/model/mac-rx-middle.h @@ -44,7 +44,7 @@ public: /** * typedef for callback */ - typedef Callback> ForwardUpCallback; + typedef Callback, uint8_t /* link ID */> ForwardUpCallback; MacRxMiddle (); ~MacRxMiddle (); @@ -57,11 +57,12 @@ public: void SetForwardCallback (ForwardUpCallback callback); /** - * Receive a packet. + * Receive an MPDU on the given link. * * \param mpdu the MPDU + * \param linkId the ID of the given link */ - void Receive (Ptr mpdu); + void Receive (Ptr mpdu, uint8_t linkId); private: diff --git a/src/wifi/model/qos-frame-exchange-manager.cc b/src/wifi/model/qos-frame-exchange-manager.cc index 6b99e4490..5f2310f0f 100644 --- a/src/wifi/model/qos-frame-exchange-manager.cc +++ b/src/wifi/model/qos-frame-exchange-manager.cc @@ -708,7 +708,7 @@ QosFrameExchangeManager::ReceiveMpdu (Ptr mpdu, RxSignalInfo r // Forward up the frame if it is not a QoS Null frame if (hdr.HasData ()) { - m_rxMiddle->Receive (mpdu); + m_rxMiddle->Receive (mpdu, m_linkId); } // the received data frame has been processed diff --git a/src/wifi/model/recipient-block-ack-agreement.cc b/src/wifi/model/recipient-block-ack-agreement.cc index 7cd26aa8b..9fb9695a4 100644 --- a/src/wifi/model/recipient-block-ack-agreement.cc +++ b/src/wifi/model/recipient-block-ack-agreement.cc @@ -86,7 +86,7 @@ RecipientBlockAckAgreement::PassBufferedMpdusUntilFirstLost (void) while (it != m_bufferedMpdus.end () && it->first.first == m_winStartB) { NS_LOG_DEBUG ("Forwarding up: " << *it->second); - m_rxMiddle->Receive (it->second); + m_rxMiddle->Receive (it->second, WIFI_LINKID_UNDEFINED); it = m_bufferedMpdus.erase (it); m_winStartB = (m_winStartB + 1) % SEQNO_SPACE_SIZE; } @@ -108,7 +108,7 @@ RecipientBlockAckAgreement::PassBufferedMpdusWithSeqNumberLessThan (uint16_t new && GetDistance (it->first.first, m_winStartB) < GetDistance (newWinStartB, m_winStartB)) { NS_LOG_DEBUG ("Forwarding up: " << *it->second); - m_rxMiddle->Receive (it->second); + m_rxMiddle->Receive (it->second, WIFI_LINKID_UNDEFINED); it = m_bufferedMpdus.erase (it); } m_winStartB = newWinStartB; diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index cb476a67c..36f440f64 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -548,9 +548,9 @@ StaWifiMac::Enqueue (Ptr packet, Mac48Address to) } void -StaWifiMac::Receive (Ptr mpdu) +StaWifiMac::Receive (Ptr mpdu, uint8_t linkId) { - NS_LOG_FUNCTION (this << *mpdu); + NS_LOG_FUNCTION (this << *mpdu << +linkId); const WifiMacHeader* hdr = &mpdu->GetHeader (); Ptr packet = mpdu->GetPacket (); NS_ASSERT (!hdr->IsCtl ()); @@ -745,7 +745,7 @@ StaWifiMac::Receive (Ptr mpdu) //Invoke the receive handler of our parent class to deal with any //other frames. Specifically, this will handle Block Ack-related //Management Action frames. - WifiMac::Receive (Create (packet, *hdr)); + WifiMac::Receive (Create (packet, *hdr), linkId); } void diff --git a/src/wifi/model/sta-wifi-mac.h b/src/wifi/model/sta-wifi-mac.h index cc9e7d57c..42e68149d 100644 --- a/src/wifi/model/sta-wifi-mac.h +++ b/src/wifi/model/sta-wifi-mac.h @@ -180,12 +180,7 @@ private: */ bool GetActiveProbing (void) const; - /** - * Handle a received packet. - * - * \param mpdu the received MPDU - */ - void Receive (Ptr mpdu) override; + void Receive (Ptr mpdu, uint8_t linkId) override; /** * Update associated AP's information from beacon. If STA is not associated, * this information will used for the association process. diff --git a/src/wifi/model/wifi-mac.cc b/src/wifi/model/wifi-mac.cc index 95f4395e9..38e16513b 100644 --- a/src/wifi/model/wifi-mac.cc +++ b/src/wifi/model/wifi-mac.cc @@ -1025,9 +1025,9 @@ WifiMac::ForwardUp (Ptr packet, Mac48Address from, Mac48Address to } void -WifiMac::Receive (Ptr mpdu) +WifiMac::Receive (Ptr mpdu, uint8_t linkId) { - NS_LOG_FUNCTION (this << *mpdu); + NS_LOG_FUNCTION (this << *mpdu << linkId); const WifiMacHeader* hdr = &mpdu->GetHeader (); Ptr packet = mpdu->GetPacket ()->Copy (); diff --git a/src/wifi/model/wifi-mac.h b/src/wifi/model/wifi-mac.h index a39be0a82..893621a45 100644 --- a/src/wifi/model/wifi-mac.h +++ b/src/wifi/model/wifi-mac.h @@ -536,8 +536,8 @@ protected: /** * This method acts as the MacRxMiddle receive callback and is - * invoked to notify us that a frame has been received. The - * implementation is intended to capture logic that is going to be + * invoked to notify us that a frame has been received on the given link. + * The implementation is intended to capture logic that is going to be * common to all (or most) derived classes. Specifically, handling * of Block Ack management frames is dealt with here. * @@ -545,9 +545,16 @@ protected: * classes so that they can perform their data handling before * invoking the base version. * + * The given link may be undefined in some cases (e.g., in case of + * QoS Data frames received in the context of a Block Ack agreement -- + * because the BlockAckManager does not have to record the link each + * buffered MPDU has been received on); in such a cases, the value + * of linkId should be WIFI_LINKID_UNDEFINED. + * * \param mpdu the MPDU that has been received. + * \param linkId the ID of the given link */ - virtual void Receive (Ptr mpdu); + virtual void Receive (Ptr mpdu, uint8_t linkId); /** * Forward the packet up to the device. * diff --git a/src/wifi/model/wifi-utils.h b/src/wifi/model/wifi-utils.h index 6fc649ea5..870eec7e7 100644 --- a/src/wifi/model/wifi-utils.h +++ b/src/wifi/model/wifi-utils.h @@ -137,6 +137,9 @@ static constexpr uint16_t SEQNO_SPACE_HALF_SIZE = SEQNO_SPACE_SIZE / 2; /// ID is to be used to support multi-link operations) static constexpr uint8_t SINGLE_LINK_OP_ID = 0; +/// Invalid link identifier +static constexpr uint8_t WIFI_LINKID_UNDEFINED = 0xff; + } // namespace ns3 #endif /* WIFI_UTILS_H */ diff --git a/src/wifi/test/block-ack-test-suite.cc b/src/wifi/test/block-ack-test-suite.cc index 64ea5ebbd..22bccc578 100644 --- a/src/wifi/test/block-ack-test-suite.cc +++ b/src/wifi/test/block-ack-test-suite.cc @@ -668,11 +668,12 @@ public: void DoRun (void) override; /** - * Keep track of MPDUs that are forwarded up. + * Keep track of MPDUs received on the given link that are forwarded up. * * \param mpdu an MPDU that is forwarded up + * \param linkId the ID of the given link */ - void ForwardUp (Ptr mpdu); + void ForwardUp (Ptr mpdu, uint8_t linkId); private: uint16_t m_ssn; //!< the Starting Sequence Number used to initialize WinStartB @@ -690,7 +691,7 @@ BlockAckRecipientBufferTest::~BlockAckRecipientBufferTest () } void -BlockAckRecipientBufferTest::ForwardUp (Ptr mpdu) +BlockAckRecipientBufferTest::ForwardUp (Ptr mpdu, uint8_t linkId) { m_fwup.push_back (mpdu); }