From 557ad4c76e1886d9e56a348ee8ef43c4bf0d698f Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Thu, 3 Dec 2020 11:39:19 +0100 Subject: [PATCH] wifi: Make Txop independent of MacLow --- src/wifi/model/ap-wifi-mac.cc | 1 - src/wifi/model/regular-wifi-mac.cc | 2 - src/wifi/model/txop.cc | 102 ++--------------------------- src/wifi/model/txop.h | 19 ------ 4 files changed, 5 insertions(+), 119 deletions(-) diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index 5e35edfa0..822d7aaaa 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -95,7 +95,6 @@ ApWifiMac::ApWifiMac () m_beaconTxop->SetAifsn (1); m_beaconTxop->SetMinCw (0); m_beaconTxop->SetMaxCw (0); - m_beaconTxop->SetMacLow (m_low); m_beaconTxop->SetChannelAccessManager (m_channelAccessManager); m_beaconTxop->SetTxMiddle (m_txMiddle); m_beaconTxop->SetTxOkCallback (MakeCallback (&ApWifiMac::TxOk, this)); diff --git a/src/wifi/model/regular-wifi-mac.cc b/src/wifi/model/regular-wifi-mac.cc index e7f183c1f..1f1a0419e 100644 --- a/src/wifi/model/regular-wifi-mac.cc +++ b/src/wifi/model/regular-wifi-mac.cc @@ -62,7 +62,6 @@ RegularWifiMac::RegularWifiMac () m_channelAccessManager = CreateObject (); m_txop = CreateObject (); - m_txop->SetMacLow (m_low); m_txop->SetChannelAccessManager (m_channelAccessManager); m_txop->SetTxMiddle (m_txMiddle); m_txop->SetTxOkCallback (MakeCallback (&RegularWifiMac::TxOk, this)); @@ -480,7 +479,6 @@ RegularWifiMac::SetupEdcaQueue (AcIndex ac) NS_ASSERT (m_edca.find (ac) == m_edca.end ()); Ptr edca = CreateObject (); - edca->SetMacLow (m_low); edca->SetChannelAccessManager (m_channelAccessManager); edca->SetTxMiddle (m_txMiddle); edca->SetTxOkCallback (MakeCallback (&RegularWifiMac::TxOk, this)); diff --git a/src/wifi/model/txop.cc b/src/wifi/model/txop.cc index 35d48c855..2225c49de 100644 --- a/src/wifi/model/txop.cc +++ b/src/wifi/model/txop.cc @@ -25,14 +25,15 @@ #include "ns3/socket.h" #include "txop.h" #include "channel-access-manager.h" +#include "wifi-mac.h" #include "wifi-mac-queue.h" #include "mac-tx-middle.h" -#include "mac-low.h" #include "wifi-remote-station-manager.h" #include "wifi-mac-trailer.h" +#include "wifi-tx-vector.h" // to be removed #undef NS_LOG_APPEND_CONTEXT -#define NS_LOG_APPEND_CONTEXT if (m_low != 0) { std::clog << "[mac=" << m_low->GetAddress () << "] "; } +#define NS_LOG_APPEND_CONTEXT if (m_stationManager != 0 && m_stationManager->GetMac () != 0) { std::clog << "[mac=" << m_stationManager->GetMac ()->GetAddress () << "] "; } namespace ns3 { @@ -109,7 +110,6 @@ Txop::DoDispose (void) { NS_LOG_FUNCTION (this); m_queue = 0; - m_low = 0; m_stationManager = 0; m_rng = 0; m_txMiddle = 0; @@ -130,13 +130,6 @@ void Txop::SetTxMiddle (const Ptr txMiddle) m_txMiddle = txMiddle; } -void -Txop::SetMacLow (const Ptr low) -{ - NS_LOG_FUNCTION (this << low); - m_low = low; -} - void Txop::SetWifiRemoteStationManager (const Ptr remoteManager) { @@ -342,8 +335,7 @@ Txop::RestartAccessIfNeeded (void) NS_LOG_FUNCTION (this); if ((m_currentPacket != 0 || !m_queue->IsEmpty ()) - && m_access == NOT_REQUESTED - && !m_low->IsCfPeriod ()) + && m_access == NOT_REQUESTED) { m_channelAccessManager->RequestAccess (this); } @@ -355,19 +347,12 @@ Txop::StartAccessIfNeeded (void) NS_LOG_FUNCTION (this); if (m_currentPacket == 0 && !m_queue->IsEmpty () - && m_access == NOT_REQUESTED - && !m_low->IsCfPeriod ()) + && m_access == NOT_REQUESTED) { m_channelAccessManager->RequestAccess (this); } } -Ptr -Txop::GetLow (void) const -{ - return m_low; -} - void Txop::DoInitialize () { @@ -498,82 +483,6 @@ Txop::RequestAccess (void) } } -void -Txop::NotifyAccessGranted (void) -{ - NS_LOG_FUNCTION (this); -// NS_ASSERT (m_access == REQUESTED); FEM may have changed m_access to GRANTED - m_access = NOT_REQUESTED; - if (m_currentPacket == 0) - { - if (m_queue->IsEmpty ()) - { - NS_LOG_DEBUG ("queue empty"); - return; - } - Ptr item = m_queue->Dequeue (); - NS_ASSERT (item != 0); - m_currentPacket = item->GetPacket (); - m_currentHdr = item->GetHeader (); - NS_ASSERT (m_currentPacket != 0); - uint16_t sequence = m_txMiddle->GetNextSequenceNumberFor (&m_currentHdr); - m_currentHdr.SetSequenceNumber (sequence); - m_currentHdr.SetFragmentNumber (0); - m_currentHdr.SetNoMoreFragments (); - m_currentHdr.SetNoRetry (); - m_fragmentNumber = 0; - NS_LOG_DEBUG ("dequeued size=" << m_currentPacket->GetSize () << - ", to=" << m_currentHdr.GetAddr1 () << - ", seq=" << m_currentHdr.GetSequenceControl ()); - } - if (m_currentHdr.GetAddr1 ().IsGroup ()) - { - m_currentParams.DisableRts (); - m_currentParams.DisableAck (); - m_currentParams.DisableNextData (); - NS_LOG_DEBUG ("tx broadcast"); - GetLow ()->StartTransmission (Create (m_currentPacket, m_currentHdr), - m_currentParams, this); - } - else - { - m_currentParams.EnableAck (); - if (NeedFragmentation ()) - { - m_currentParams.DisableRts (); - WifiMacHeader hdr; - Ptr fragment = GetFragmentPacket (&hdr); - if (IsLastFragment ()) - { - NS_LOG_DEBUG ("fragmenting last fragment size=" << fragment->GetSize ()); - m_currentParams.DisableNextData (); - } - else - { - NS_LOG_DEBUG ("fragmenting size=" << fragment->GetSize ()); - m_currentParams.EnableNextData (GetNextFragmentSize ()); - } - GetLow ()->StartTransmission (Create (fragment, hdr), - m_currentParams, this); - } - else - { - uint32_t size = m_currentHdr.GetSize () + m_currentPacket->GetSize () + WIFI_MAC_FCS_LENGTH; - if (m_stationManager->NeedRts (m_currentHdr, size) && !m_low->IsCfPeriod ()) - { - m_currentParams.EnableRts (); - } - else - { - m_currentParams.DisableRts (); - } - m_currentParams.DisableNextData (); - GetLow ()->StartTransmission (Create (m_currentPacket, m_currentHdr), - m_currentParams, this); - } - } -} - void Txop::GenerateBackoff (void) { @@ -733,7 +642,6 @@ Txop::StartNextFragment (void) { m_currentParams.EnableNextData (GetNextFragmentSize ()); } - GetLow ()->StartTransmission (Create (fragment, hdr), m_currentParams, this); } void diff --git a/src/wifi/model/txop.h b/src/wifi/model/txop.h index e8ebe4577..c68e781c1 100644 --- a/src/wifi/model/txop.h +++ b/src/wifi/model/txop.h @@ -30,7 +30,6 @@ namespace ns3 { class Packet; class ChannelAccessManager; class MacTxMiddle; -class MacLow; class WifiMode; class WifiMacQueue; class WifiMacQueueItem; @@ -111,12 +110,6 @@ public: */ virtual bool IsQosTxop () const; - /** - * Set MacLow associated with this Txop. - * - * \param low MacLow to associate. - */ - void SetMacLow (const Ptr low); /** * Set ChannelAccessManager this Txop is associated to. * @@ -152,13 +145,6 @@ public: */ void SetTxDroppedCallback (TxDropped callback); - /** - * Return the MacLow associated with this Txop. - * - * \return the associated MacLow - */ - Ptr GetLow (void) const; - /** * Return the packet queue associated with this Txop. * @@ -370,10 +356,6 @@ protected: * Notify that access request has been received. */ virtual void NotifyAccessRequested (void); - /** - * Notify the Txop that access has been granted. - */ - virtual void NotifyAccessGranted (void); /** * Notify the Txop that internal collision has occurred. */ @@ -507,7 +489,6 @@ protected: TxDropped m_txDroppedCallback; //!< the packet dropped callback Ptr m_queue; //!< the wifi MAC queue Ptr m_txMiddle; //!< the MacTxMiddle - Ptr m_low; //!< the MacLow Ptr m_stationManager; //!< the wifi remote station manager Ptr m_rng; //!< the random stream