diff --git a/src/mesh/model/mesh-wifi-interface-mac.cc b/src/mesh/model/mesh-wifi-interface-mac.cc index e04f20b0f..d23708125 100644 --- a/src/mesh/model/mesh-wifi-interface-mac.cc +++ b/src/mesh/model/mesh-wifi-interface-mac.cc @@ -89,6 +89,11 @@ MeshWifiInterfaceMac::~MeshWifiInterfaceMac () //----------------------------------------------------------------------------- // WifiMac inherited //----------------------------------------------------------------------------- +bool +MeshWifiInterfaceMac::CanForwardPacketsTo (Mac48Address to) const +{ + return true; +} void MeshWifiInterfaceMac::Enqueue (Ptr packet, Mac48Address to, Mac48Address from) { diff --git a/src/mesh/model/mesh-wifi-interface-mac.h b/src/mesh/model/mesh-wifi-interface-mac.h index d842824ac..01099fc10 100644 --- a/src/mesh/model/mesh-wifi-interface-mac.h +++ b/src/mesh/model/mesh-wifi-interface-mac.h @@ -65,6 +65,7 @@ public: virtual void Enqueue (Ptr packet, Mac48Address to); virtual bool SupportsSendFrom () const; virtual void SetLinkUpCallback (Callback linkUp); + virtual bool CanForwardPacketsTo (Mac48Address to) const; /// \name Each mesh point interface must know the mesh point address ///@{ diff --git a/src/wave/model/ocb-wifi-mac.cc b/src/wave/model/ocb-wifi-mac.cc index e010653dd..037de889e 100644 --- a/src/wave/model/ocb-wifi-mac.cc +++ b/src/wave/model/ocb-wifi-mac.cc @@ -156,6 +156,12 @@ OcbWifiMac::SetLinkDownCallback (Callback linkDown) NS_LOG_WARN ("in OCB mode the like will never down, so linkDown will never be called"); } +bool +OcbWifiMac::CanForwardPacketsTo (Mac48Address to) const +{ + return true; +} + void OcbWifiMac::Enqueue (Ptr packet, Mac48Address to) { diff --git a/src/wave/model/ocb-wifi-mac.h b/src/wave/model/ocb-wifi-mac.h index 551f54654..f84d660b1 100644 --- a/src/wave/model/ocb-wifi-mac.h +++ b/src/wave/model/ocb-wifi-mac.h @@ -126,6 +126,7 @@ public: * access is granted to this MAC. */ virtual void Enqueue (Ptr packet, Mac48Address to); + virtual bool CanForwardPacketsTo (Mac48Address to) const; /** * \param cwmin the min contention window * \param cwmax the max contention window diff --git a/src/wifi/model/adhoc-wifi-mac.cc b/src/wifi/model/adhoc-wifi-mac.cc index 8bbbb7350..9c23310de 100644 --- a/src/wifi/model/adhoc-wifi-mac.cc +++ b/src/wifi/model/adhoc-wifi-mac.cc @@ -70,6 +70,12 @@ AdhocWifiMac::SetAddress (Mac48Address address) RegularWifiMac::SetBssid (address); } +bool +AdhocWifiMac::CanForwardPacketsTo (Mac48Address to) const +{ + return true; +} + void AdhocWifiMac::Enqueue (Ptr packet, Mac48Address to) { diff --git a/src/wifi/model/adhoc-wifi-mac.h b/src/wifi/model/adhoc-wifi-mac.h index b568b5eff..e2a60c7e7 100644 --- a/src/wifi/model/adhoc-wifi-mac.h +++ b/src/wifi/model/adhoc-wifi-mac.h @@ -47,6 +47,7 @@ public: void SetAddress (Mac48Address address) override; void SetLinkUpCallback (Callback linkUp) override; void Enqueue (Ptr packet, Mac48Address to) override; + bool CanForwardPacketsTo (Mac48Address to) const override; private: void Receive (Ptr mpdu) override; diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index 22b3b9a90..84541954e 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -348,11 +348,17 @@ ApWifiMac::ForwardDown (Ptr packet, Mac48Address from, } } +bool +ApWifiMac::CanForwardPacketsTo (Mac48Address to) const +{ + return (to.IsGroup () || m_stationManager->IsAssociated (to)); +} + void ApWifiMac::Enqueue (Ptr packet, Mac48Address to, Mac48Address from) { NS_LOG_FUNCTION (this << packet << to << from); - if (to.IsGroup () || m_stationManager->IsAssociated (to)) + if (CanForwardPacketsTo (to)) { ForwardDown (packet, from, to); } diff --git a/src/wifi/model/ap-wifi-mac.h b/src/wifi/model/ap-wifi-mac.h index 14c6312df..a2d3d1f5d 100644 --- a/src/wifi/model/ap-wifi-mac.h +++ b/src/wifi/model/ap-wifi-mac.h @@ -59,6 +59,7 @@ public: virtual ~ApWifiMac (); void SetLinkUpCallback (Callback linkUp) override; + bool CanForwardPacketsTo (Mac48Address to) const override; void Enqueue (Ptr packet, Mac48Address to) override; void Enqueue (Ptr packet, Mac48Address to, Mac48Address from) override; bool SupportsSendFrom (void) const override; diff --git a/src/wifi/model/qos-txop.cc b/src/wifi/model/qos-txop.cc index d0e194644..254b3dc1f 100644 --- a/src/wifi/model/qos-txop.cc +++ b/src/wifi/model/qos-txop.cc @@ -394,6 +394,12 @@ QosTxop::PeekNextMpdu (uint8_t tid, Mac48Address recipient, PtrGetHeader ().HasData () + && !m_mac->CanForwardPacketsTo (item->GetHeader ().GetAddr1 ())) + { + NS_LOG_DEBUG ("Skipping frame that cannot be forwarded: " << *item); + item = peek (); + } else { break; diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index a58524bca..a38038674 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -454,11 +454,17 @@ StaWifiMac::IsWaitAssocResp (void) const return m_state == WAIT_ASSOC_RESP; } +bool +StaWifiMac::CanForwardPacketsTo (Mac48Address to) const +{ + return (IsAssociated ()); +} + void StaWifiMac::Enqueue (Ptr packet, Mac48Address to) { NS_LOG_FUNCTION (this << packet << to); - if (!IsAssociated ()) + if (!CanForwardPacketsTo (to)) { NotifyTxDrop (packet); TryToEnsureAssociated (); diff --git a/src/wifi/model/sta-wifi-mac.h b/src/wifi/model/sta-wifi-mac.h index 0010b52ef..238847fc6 100644 --- a/src/wifi/model/sta-wifi-mac.h +++ b/src/wifi/model/sta-wifi-mac.h @@ -130,6 +130,7 @@ public: * access is granted to this MAC. */ void Enqueue (Ptr packet, Mac48Address to) override; + bool CanForwardPacketsTo (Mac48Address to) const override; /** * \param phy the physical layer attached to this MAC. diff --git a/src/wifi/model/wifi-mac.h b/src/wifi/model/wifi-mac.h index 119dad406..d8b25876e 100644 --- a/src/wifi/model/wifi-mac.h +++ b/src/wifi/model/wifi-mac.h @@ -148,6 +148,14 @@ public: */ virtual bool GetShortSlotTimeSupported (void) const = 0; + /** + * Return true if packets can be forwarded to the given destination, + * false otherwise. + * + * \param to the address to which the packet should be sent + * \return whether packets can be forwarded to the given destination + */ + virtual bool CanForwardPacketsTo (Mac48Address to) const = 0; /** * \param packet the packet to send. * \param to the address to which the packet should be sent. diff --git a/src/wifi/test/wifi-aggregation-test.cc b/src/wifi/test/wifi-aggregation-test.cc index ebafd5c2f..49e158a08 100644 --- a/src/wifi/test/wifi-aggregation-test.cc +++ b/src/wifi/test/wifi-aggregation-test.cc @@ -133,6 +133,7 @@ AmpduAggregationTest::DoRun (void) fem->SetAckManager (ackManager); m_mac->SetWifiPhy (m_phy); m_device->SetMac (m_mac); + m_mac->SetState (StaWifiMac::ASSOCIATED); /* * Configure MPDU aggregation. @@ -381,6 +382,7 @@ TwoLevelAggregationTest::DoRun (void) fem->SetAckManager (ackManager); m_mac->SetWifiPhy (m_phy); m_device->SetMac (m_mac); + m_mac->SetState (StaWifiMac::ASSOCIATED); /* * Configure aggregation. @@ -614,6 +616,7 @@ HeAggregationTest::DoRunSubTest (uint16_t bufferSize) fem->SetAckManager (ackManager); m_mac->SetWifiPhy (m_phy); m_device->SetMac (m_mac); + m_mac->SetState (StaWifiMac::ASSOCIATED); /* * Configure aggregation.