wifi: Make Txop independent of MacLow

This commit is contained in:
Stefano Avallone
2020-12-03 11:39:19 +01:00
parent 2ea96f9f18
commit 557ad4c76e
4 changed files with 5 additions and 119 deletions

View File

@@ -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));

View File

@@ -62,7 +62,6 @@ RegularWifiMac::RegularWifiMac ()
m_channelAccessManager = CreateObject<ChannelAccessManager> ();
m_txop = CreateObject<Txop> ();
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<QosTxop> edca = CreateObject<QosTxop> ();
edca->SetMacLow (m_low);
edca->SetChannelAccessManager (m_channelAccessManager);
edca->SetTxMiddle (m_txMiddle);
edca->SetTxOkCallback (MakeCallback (&RegularWifiMac::TxOk, this));

View File

@@ -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<MacTxMiddle> txMiddle)
m_txMiddle = txMiddle;
}
void
Txop::SetMacLow (const Ptr<MacLow> low)
{
NS_LOG_FUNCTION (this << low);
m_low = low;
}
void
Txop::SetWifiRemoteStationManager (const Ptr<WifiRemoteStationManager> 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<MacLow>
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<WifiMacQueueItem> 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<WifiMacQueueItem> (m_currentPacket, m_currentHdr),
m_currentParams, this);
}
else
{
m_currentParams.EnableAck ();
if (NeedFragmentation ())
{
m_currentParams.DisableRts ();
WifiMacHeader hdr;
Ptr<Packet> 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<WifiMacQueueItem> (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<WifiMacQueueItem> (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<WifiMacQueueItem> (fragment, hdr), m_currentParams, this);
}
void

View File

@@ -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<MacLow> 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<MacLow> 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<WifiMacQueue> m_queue; //!< the wifi MAC queue
Ptr<MacTxMiddle> m_txMiddle; //!< the MacTxMiddle
Ptr <MacLow> m_low; //!< the MacLow
Ptr<WifiRemoteStationManager> m_stationManager; //!< the wifi remote station manager
Ptr<UniformRandomVariable> m_rng; //!< the random stream