diff --git a/src/mesh/model/mesh-wifi-interface-mac.cc b/src/mesh/model/mesh-wifi-interface-mac.cc index cf34e50ed..3f486dc80 100644 --- a/src/mesh/model/mesh-wifi-interface-mac.cc +++ b/src/mesh/model/mesh-wifi-interface-mac.cc @@ -23,7 +23,6 @@ #include "ns3/mesh-wifi-beacon.h" #include "ns3/log.h" #include "ns3/boolean.h" -#include "ns3/mac-low.h" #include "ns3/random-variable-stream.h" #include "ns3/simulator.h" #include "ns3/yans-wifi-phy.h" @@ -33,6 +32,7 @@ #include "ns3/trace-source-accessor.h" #include "ns3/socket.h" #include "ns3/wifi-net-device.h" +#include "ns3/channel-access-manager.h" namespace ns3 { @@ -98,7 +98,7 @@ void MeshWifiInterfaceMac::Enqueue (Ptr packet, Mac48Address to) { NS_LOG_FUNCTION (this << packet << to); - ForwardDown (packet, m_low->GetAddress (), to); + ForwardDown (packet, GetAddress (), to); } bool MeshWifiInterfaceMac::SupportsSendFrom () const diff --git a/src/wifi/model/adhoc-wifi-mac.cc b/src/wifi/model/adhoc-wifi-mac.cc index b93f3e15d..a8a687029 100644 --- a/src/wifi/model/adhoc-wifi-mac.cc +++ b/src/wifi/model/adhoc-wifi-mac.cc @@ -26,7 +26,6 @@ #include "ht-capabilities.h" #include "vht-capabilities.h" #include "he-capabilities.h" -#include "mac-low.h" namespace ns3 { @@ -138,7 +137,7 @@ AdhocWifiMac::Enqueue (Ptr packet, Mac48Address to) hdr.SetNoOrder (); // explicitly set to 0 for the time being since HT control field is not yet implemented (set it to 1 when implemented) } hdr.SetAddr1 (to); - hdr.SetAddr2 (m_low->GetAddress ()); + hdr.SetAddr2 (GetAddress ()); hdr.SetAddr3 (GetBssid ()); hdr.SetDsNotFrom (); hdr.SetDsNotTo (); diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index 822d7aaaa..2ce85e52a 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -27,7 +27,7 @@ #include "ns3/string.h" #include "ns3/random-variable-stream.h" #include "ap-wifi-mac.h" -#include "mac-low.h" +#include "channel-access-manager.h" #include "mac-tx-middle.h" #include "mac-rx-middle.h" #include "mgt-headers.h" @@ -155,7 +155,7 @@ Time ApWifiMac::GetBeaconInterval (void) const { NS_LOG_FUNCTION (this); - return m_low->GetBeaconInterval (); + return m_beaconInterval; } void @@ -191,7 +191,7 @@ ApWifiMac::SetBeaconInterval (Time interval) { NS_FATAL_ERROR ("beacon interval should be smaller then or equal to 65535 * 1024us (802.11 time unit)"); } - m_low->SetBeaconInterval (interval); + m_beaconInterval = interval; } int64_t @@ -370,7 +370,7 @@ ApWifiMac::Enqueue (Ptr packet, Mac48Address to) //We're sending this packet with a from address that is our own. We //get that address from the lower MAC and make use of the //from-spoofing Enqueue() method to avoid duplicated code. - Enqueue (packet, to, m_low->GetAddress ()); + Enqueue (packet, to, GetAddress ()); } bool diff --git a/src/wifi/model/ap-wifi-mac.h b/src/wifi/model/ap-wifi-mac.h index 542c6e44f..3e5685aa1 100644 --- a/src/wifi/model/ap-wifi-mac.h +++ b/src/wifi/model/ap-wifi-mac.h @@ -294,6 +294,7 @@ private: Ptr m_beaconTxop; //!< Dedicated Txop for beacons bool m_enableBeaconGeneration; //!< Flag whether beacons are being generated + Time m_beaconInterval; //!< Beacon interval EventId m_beaconEvent; //!< Event to generate one beacon EventId m_cfpEvent; //!< Event to generate one PCF frame Ptr m_beaconJitter; //!< UniformRandomVariable used to randomize the time of the first beacon diff --git a/src/wifi/model/frame-exchange-manager.cc b/src/wifi/model/frame-exchange-manager.cc index 2160c2564..8d6e89506 100644 --- a/src/wifi/model/frame-exchange-manager.cc +++ b/src/wifi/model/frame-exchange-manager.cc @@ -56,6 +56,7 @@ FrameExchangeManager::GetTypeId (void) FrameExchangeManager::FrameExchangeManager () : m_navEnd (Seconds (0)), + m_promisc (false), m_moreFragments (false) { NS_LOG_FUNCTION (this); @@ -166,6 +167,15 @@ FrameExchangeManager::SetWifiPhy (Ptr phy) m_phy->SetReceiveOkCallback (MakeCallback (&FrameExchangeManager::Receive, this)); } +void +FrameExchangeManager::ResetPhy (void) +{ + m_phy->TraceDisconnectWithoutContext ("PhyRxPayloadBegin", + MakeCallback (&FrameExchangeManager::RxStartIndication, this)); + m_phy->SetReceiveOkCallback (MakeNullCallback, double, WifiTxVector, std::vector> ()); + m_phy = 0; +} + void FrameExchangeManager::SetAddress (Mac48Address address) { @@ -180,6 +190,18 @@ FrameExchangeManager::SetBssid (Mac48Address bssid) m_bssid = bssid; } +void +FrameExchangeManager::SetPromisc (void) +{ + m_promisc = true; +} + +bool +FrameExchangeManager::IsPromisc (void) const +{ + return m_promisc; +} + void FrameExchangeManager::NotifyPacketDiscarded (Ptr mpdu) { @@ -841,6 +863,10 @@ FrameExchangeManager::Receive (Ptr psdu, double rxSnr, Mac48Address addr1 = psdu->GetAddr1 (); if (!addr1.IsGroup () && addr1 != m_self) { + if (m_promisc && psdu->GetNMpdus () == 1 && psdu->GetHeader (0).IsData ()) + { + m_rxMiddle->Receive (*psdu->begin ()); + } return; } diff --git a/src/wifi/model/frame-exchange-manager.h b/src/wifi/model/frame-exchange-manager.h index 78235e852..02397710f 100644 --- a/src/wifi/model/frame-exchange-manager.h +++ b/src/wifi/model/frame-exchange-manager.h @@ -110,6 +110,10 @@ public: * \param phy the PHY layer to use */ virtual void SetWifiPhy (const Ptr phy); + /** + * Remove WifiPhy associated with this MacLow. + */ + virtual void ResetPhy (void); /** * Set the Protection Manager to use * @@ -134,6 +138,17 @@ public: * \param bssid the BSSID */ virtual void SetBssid (Mac48Address bssid); + /** + * Enable promiscuous mode. + */ + void SetPromisc (void); + /** + * Check if the device is operating in promiscuous mode. + * + * \return true if the device is operating in promiscuous mode, + * false otherwise + */ + bool IsPromisc (void) const; /** * Get the Protection Manager used by this node. @@ -334,6 +349,7 @@ protected: Mac48Address m_self; //!< the MAC address of this device Mac48Address m_bssid; //!< BSSID address (Mac48Address) Time m_navEnd; //!< NAV expiration time + bool m_promisc; //!< Flag if the device is operating in promiscuous mode /** * Forward an MPDU down to the PHY layer. diff --git a/src/wifi/model/regular-wifi-mac.cc b/src/wifi/model/regular-wifi-mac.cc index 1f1a0419e..e32417ba3 100644 --- a/src/wifi/model/regular-wifi-mac.cc +++ b/src/wifi/model/regular-wifi-mac.cc @@ -25,7 +25,6 @@ #include "wifi-phy.h" #include "mac-rx-middle.h" #include "mac-tx-middle.h" -#include "mac-low.h" #include "msdu-aggregator.h" #include "mpdu-aggregator.h" #include "mgt-headers.h" @@ -37,6 +36,7 @@ #include #include #include "he-frame-exchange-manager.h" +#include "channel-access-manager.h" namespace ns3 { @@ -55,10 +55,6 @@ RegularWifiMac::RegularWifiMac () m_txMiddle = Create (); - m_low = CreateObject (); - m_low->SetRxCallback (MakeCallback (&MacRxMiddle::Receive, m_rxMiddle)); - m_low->SetMac (this); - m_channelAccessManager = CreateObject (); m_txop = CreateObject (); @@ -102,9 +98,6 @@ RegularWifiMac::DoDispose () m_rxMiddle = 0; m_txMiddle = 0; - m_low->Dispose (); - m_low = 0; - m_phy = 0; m_stationManager = 0; if (m_feManager != 0) @@ -180,7 +173,6 @@ RegularWifiMac::SetWifiRemoteStationManager (const Ptr { NS_LOG_FUNCTION (this << stationManager); m_stationManager = stationManager; - m_low->SetWifiRemoteStationManager (stationManager); m_txop->SetWifiRemoteStationManager (stationManager); for (EdcaQueues::const_iterator i = m_edca.begin (); i != m_edca.end (); ++i) { @@ -548,7 +540,6 @@ RegularWifiMac::SetWifiPhy (const Ptr phy) NS_LOG_FUNCTION (this << phy); m_phy = phy; m_channelAccessManager->SetupPhyListener (phy); - m_low->SetPhy (phy); NS_ASSERT (m_feManager != 0); m_feManager->SetWifiPhy (phy); } @@ -564,7 +555,8 @@ void RegularWifiMac::ResetWifiPhy (void) { NS_LOG_FUNCTION (this); - m_low->ResetPhy (); + NS_ASSERT (m_feManager != 0); + m_feManager->ResetPhy (); m_channelAccessManager->RemovePhyListener (m_phy); m_phy = 0; } @@ -667,20 +659,20 @@ void RegularWifiMac::SetCtsToSelfSupported (bool enable) { NS_LOG_FUNCTION (this); - m_low->SetCtsToSelfSupported (enable); + m_ctsToSelfSupported = enable; } void RegularWifiMac::SetAddress (Mac48Address address) { NS_LOG_FUNCTION (this << address); - m_low->SetAddress (address); + m_address = address; } Mac48Address RegularWifiMac::GetAddress (void) const { - return m_low->GetAddress (); + return m_address; } void @@ -700,7 +692,7 @@ void RegularWifiMac::SetBssid (Mac48Address bssid) { NS_LOG_FUNCTION (this << bssid); - m_low->SetBssid (bssid); + m_bssid = bssid; if (m_feManager) { m_feManager->SetBssid (bssid); @@ -710,13 +702,14 @@ RegularWifiMac::SetBssid (Mac48Address bssid) Mac48Address RegularWifiMac::GetBssid (void) const { - return m_low->GetBssid (); + return m_bssid; } void RegularWifiMac::SetPromisc (void) { - m_low->SetPromisc (); + NS_ASSERT (m_feManager != 0); + m_feManager->SetPromisc (); } void @@ -830,9 +823,11 @@ RegularWifiMac::Receive (Ptr mpdu) { //This DELBA frame was sent by the originator, so //this means that an ingoing established - //agreement exists in MacLow and we need to + //agreement exists in HtFrameExchangeManager and we need to //destroy it. - m_low->DestroyBlockAckAgreement (from, delBaHdr.GetTid ()); + NS_ASSERT (m_feManager != 0); + Ptr htFem = StaticCast (m_feManager); + htFem->DestroyBlockAckAgreement (from, delBaHdr.GetTid ()); } else { @@ -1119,7 +1114,6 @@ RegularWifiMac::ConfigureStandard (WifiStandard standard) case WIFI_STANDARD_80211ax_5GHZ: case WIFI_STANDARD_80211ax_6GHZ: { - EnableAggregation (); SetQosSupported (true); cwmin = 15; cwmax = 1023; @@ -1128,7 +1122,6 @@ RegularWifiMac::ConfigureStandard (WifiStandard standard) case WIFI_STANDARD_80211ax_2_4GHZ: case WIFI_STANDARD_80211n_2_4GHZ: { - EnableAggregation (); SetQosSupported (true); } case WIFI_STANDARD_80211g: @@ -1181,30 +1174,4 @@ RegularWifiMac::TxFailed (const WifiMacHeader &hdr) m_txErrCallback (hdr); } -void -RegularWifiMac::EnableAggregation (void) -{ - NS_LOG_FUNCTION (this); - if (m_low->GetMsduAggregator () == 0) - { - Ptr msduAggregator = CreateObject (); - msduAggregator->SetWifiMac (this); - m_low->SetMsduAggregator (msduAggregator); - } - if (m_low->GetMpduAggregator () == 0) - { - Ptr mpduAggregator = CreateObject (); - mpduAggregator->SetWifiMac (this); - m_low->SetMpduAggregator (mpduAggregator); - } -} - -void -RegularWifiMac::DisableAggregation (void) -{ - NS_LOG_FUNCTION (this); - m_low->SetMsduAggregator (0); - m_low->SetMpduAggregator (0); -} - } //namespace ns3 diff --git a/src/wifi/model/regular-wifi-mac.h b/src/wifi/model/regular-wifi-mac.h index d10c3eebe..334e9ffff 100644 --- a/src/wifi/model/regular-wifi-mac.h +++ b/src/wifi/model/regular-wifi-mac.h @@ -27,7 +27,6 @@ namespace ns3 { -class MacLow; class MacRxMiddle; class MacTxMiddle; class ChannelAccessManager; @@ -179,7 +178,6 @@ protected: Ptr m_rxMiddle; //!< RX middle (defragmentation etc.) Ptr m_txMiddle; //!< TX middle (aggregation etc.) - Ptr m_low; //!< MacLow (RTS, CTS, Data, Ack etc.) Ptr m_channelAccessManager; //!< channel access manager Ptr m_phy; //!< Wifi PHY Ptr m_feManager; //!< Frame Exchange Manager @@ -450,10 +448,8 @@ private: */ bool m_dsssSupported; - /// Enable aggregation function - void EnableAggregation (void); - /// Disable aggregation function - void DisableAggregation (void); + Mac48Address m_address; ///< MAC address of this station + Mac48Address m_bssid; ///< the BSSID uint16_t m_voMaxAmsduSize; ///< maximum A-MSDU size for AC_VO (in bytes) uint16_t m_viMaxAmsduSize; ///< maximum A-MSDU size for AC_VI (in bytes) @@ -469,6 +465,7 @@ private: TracedCallback m_txErrCallback; ///< transmit error callback bool m_shortSlotTimeSupported; ///< flag whether short slot time is supported + bool m_ctsToSelfSupported; ///< flag indicating whether CTS-To-Self is supported }; } //namespace ns3 diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index 43b3ab8e3..00cb689e7 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -25,7 +25,6 @@ #include "ns3/simulator.h" #include "sta-wifi-mac.h" #include "wifi-phy.h" -#include "mac-low.h" #include "mgt-headers.h" #include "snr-tag.h" #include "wifi-net-device.h" @@ -476,7 +475,7 @@ StaWifiMac::Enqueue (Ptr packet, Mac48Address to) } hdr.SetAddr1 (GetBssid ()); - hdr.SetAddr2 (m_low->GetAddress ()); + hdr.SetAddr2 (GetAddress ()); hdr.SetAddr3 (to); hdr.SetDsNotFrom (); hdr.SetDsTo ();