wifi: Switch to using the FrameExchangeManager on non-QoS stations

This commit is contained in:
Stefano Avallone
2020-04-10 17:22:47 +02:00
parent 0e414b6c90
commit 3b0629d877
16 changed files with 191 additions and 75 deletions

View File

@@ -25,6 +25,7 @@
#include "wifi-phy-listener.h"
#include "wifi-phy.h"
#include "mac-low.h"
#include "frame-exchange-manager.h"
namespace ns3 {
@@ -136,6 +137,7 @@ ChannelAccessManager::DoDispose (void)
i = 0;
}
m_phy = 0;
m_feManager = 0;
}
void
@@ -168,6 +170,14 @@ ChannelAccessManager::SetupLow (Ptr<MacLow> low)
low->RegisterChannelAccessManager (this);
}
void
ChannelAccessManager::SetupFrameExchangeManager (Ptr<FrameExchangeManager> feManager)
{
NS_LOG_FUNCTION (this << feManager);
m_feManager = feManager;
m_feManager->SetChannelAccessManager (this);
}
Time
ChannelAccessManager::GetSlot (void) const
{
@@ -372,18 +382,37 @@ ChannelAccessManager::DoGrantDcfAccess (void)
}
/**
* Now, we notify all of these changes in one go. It is necessary to
* Now, we notify all of these changes in one go if the EDCAF winning
* the contention actually transmitted a frame. It is necessary to
* perform first the calculations of which Txops are colliding and then
* only apply the changes because applying the changes through notification
* could change the global state of the manager, and, thus, could change
* the result of the calculations.
*/
txop->NotifyAccessGranted ();
for (auto collidingTxop : internalCollisionTxops)
{
collidingTxop->NotifyInternalCollision ();
bool transmitted = true;
if (m_feManager != 0)
{
transmitted = m_feManager->StartTransmission (txop);
}
else
{
txop->NotifyAccessGranted ();
}
if (transmitted)
{
for (auto& collidingTxop : internalCollisionTxops)
{
collidingTxop->NotifyInternalCollision ();
}
break;
}
else
{
// reset the current state to the EDCAF that won the contention
// but did not transmit anything
i--;
k = std::distance (m_txops.begin (), i);
}
break;
}
i++;
}

View File

@@ -32,6 +32,7 @@ class WifiPhy;
class PhyListener;
class Txop;
class MacLow;
class FrameExchangeManager;
/**
* \brief Manage a set of ns3::Txop
@@ -72,6 +73,12 @@ public:
* \param low the MacLow to listen to
*/
void SetupLow (Ptr<MacLow> low);
/**
* Set up the Frame Exchange Manager.
*
* \param feManager the Frame Exchange Manager
*/
void SetupFrameExchangeManager (Ptr<FrameExchangeManager> feManager);
/**
* \param txop a new Txop.
@@ -291,28 +298,29 @@ private:
*/
typedef std::vector<Ptr<Txop>> Txops;
Txops m_txops; //!< the vector of managed Txops
Time m_lastAckTimeoutEnd; //!< the last Ack timeout end time
Time m_lastCtsTimeoutEnd; //!< the last CTS timeout end time
Time m_lastNavStart; //!< the last NAV start time
Time m_lastNavDuration; //!< the last NAV duration time
Time m_lastRxStart; //!< the last receive start time
Time m_lastRxDuration; //!< the last receive duration time
bool m_lastRxReceivedOk; //!< the last receive OK
Time m_lastTxStart; //!< the last transmit start time
Time m_lastTxDuration; //!< the last transmit duration time
Time m_lastBusyStart; //!< the last busy start time
Time m_lastBusyDuration; //!< the last busy duration time
Time m_lastSwitchingStart; //!< the last switching start time
Time m_lastSwitchingDuration; //!< the last switching duration time
bool m_sleeping; //!< flag whether it is in sleeping state
bool m_off; //!< flag whether it is in off state
Time m_eifsNoDifs; //!< EIFS no DIFS time
EventId m_accessTimeout; //!< the access timeout ID
Time m_slot; //!< the slot time
Time m_sifs; //!< the SIFS time
PhyListener* m_phyListener; //!< the PHY listener
Ptr<WifiPhy> m_phy; //!< pointer to the PHY
Txops m_txops; //!< the vector of managed Txops
Time m_lastAckTimeoutEnd; //!< the last Ack timeout end time
Time m_lastCtsTimeoutEnd; //!< the last CTS timeout end time
Time m_lastNavStart; //!< the last NAV start time
Time m_lastNavDuration; //!< the last NAV duration time
Time m_lastRxStart; //!< the last receive start time
Time m_lastRxDuration; //!< the last receive duration time
bool m_lastRxReceivedOk; //!< the last receive OK
Time m_lastTxStart; //!< the last transmit start time
Time m_lastTxDuration; //!< the last transmit duration time
Time m_lastBusyStart; //!< the last busy start time
Time m_lastBusyDuration; //!< the last busy duration time
Time m_lastSwitchingStart; //!< the last switching start time
Time m_lastSwitchingDuration; //!< the last switching duration time
bool m_sleeping; //!< flag whether it is in sleeping state
bool m_off; //!< flag whether it is in off state
Time m_eifsNoDifs; //!< EIFS no DIFS time
EventId m_accessTimeout; //!< the access timeout ID
Time m_slot; //!< the slot time
Time m_sifs; //!< the SIFS time
PhyListener* m_phyListener; //!< the PHY listener
Ptr<WifiPhy> m_phy; //!< pointer to the PHY
Ptr<FrameExchangeManager> m_feManager; //!< pointer to the Frame Exchange Manager
};
} //namespace ns3

View File

@@ -254,7 +254,6 @@ MacLow::SetPhy (const Ptr<WifiPhy> phy)
{
m_phy = phy;
m_phy->TraceConnectWithoutContext ("PhyRxPayloadBegin", MakeCallback (&MacLow::RxStartIndication, this));
m_phy->SetReceiveOkCallback (MakeCallback (&MacLow::DeaggregateAmpduAndReceive, this));
m_phy->SetReceiveErrorCallback (MakeCallback (&MacLow::ReceiveError, this));
SetupPhyMacLowListener (phy);
}

View File

@@ -36,6 +36,7 @@
#include "he-configuration.h"
#include <algorithm>
#include <cmath>
#include "frame-exchange-manager.h"
namespace ns3 {
@@ -108,6 +109,11 @@ RegularWifiMac::DoDispose ()
m_phy = 0;
m_stationManager = 0;
if (m_feManager != 0)
{
m_feManager->Dispose ();
}
m_feManager = 0;
m_txop->Dispose ();
m_txop = 0;
@@ -124,6 +130,49 @@ RegularWifiMac::DoDispose ()
WifiMac::DoDispose ();
}
void
RegularWifiMac::SetupFrameExchangeManager (void)
{
NS_LOG_FUNCTION (this);
if (GetHeSupported ())
{
// TODO create an HE Frame Exchange Manager
}
else if (GetVhtSupported ())
{
// TODO create a VHT Frame Exchange Manager
}
else if (GetHtSupported ())
{
// TODO create an HT Frame Exchange Manager
}
else if (GetQosSupported ())
{
// TODO create a QoS Frame Exchange Manager
}
else
{
m_feManager = CreateObject<FrameExchangeManager> ();
}
if (m_feManager != 0)
{
m_feManager->SetWifiMac (this);
m_feManager->SetMacTxMiddle (m_txMiddle);
m_feManager->SetMacRxMiddle (m_rxMiddle);
m_feManager->SetAddress (GetAddress ());
m_feManager->SetBssid (GetBssid ());
m_channelAccessManager->SetupFrameExchangeManager (m_feManager);
}
}
Ptr<FrameExchangeManager>
RegularWifiMac::GetFrameExchangeManager (void) const
{
return m_feManager;
}
void
RegularWifiMac::SetWifiRemoteStationManager (const Ptr<WifiRemoteStationManager> stationManager)
{
@@ -499,6 +548,14 @@ RegularWifiMac::SetWifiPhy (const Ptr<WifiPhy> phy)
m_phy = phy;
m_channelAccessManager->SetupPhyListener (phy);
m_low->SetPhy (phy);
if (m_feManager != 0)
{
m_feManager->SetWifiPhy (phy);
}
else
{
m_phy->SetReceiveOkCallback (MakeCallback (&MacLow::DeaggregateAmpduAndReceive, m_low));
}
}
Ptr<WifiPhy>
@@ -649,6 +706,10 @@ RegularWifiMac::SetBssid (Mac48Address bssid)
{
NS_LOG_FUNCTION (this << bssid);
m_low->SetBssid (bssid);
if (m_feManager)
{
m_feManager->SetBssid (bssid);
}
}
Mac48Address
@@ -1091,6 +1152,7 @@ RegularWifiMac::ConfigureStandard (WifiStandard standard)
NS_FATAL_ERROR ("Unsupported WifiPhyStandard in RegularWifiMac::FinishConfigureStandard ()");
}
SetupFrameExchangeManager ();
ConfigureContentionWindow (cwmin, cwmax);
}

View File

@@ -32,6 +32,7 @@ class MacRxMiddle;
class MacTxMiddle;
class ChannelAccessManager;
class ExtendedCapabilities;
class FrameExchangeManager;
/**
* \brief base class for all MAC-level wifi objects.
@@ -102,6 +103,13 @@ public:
*/
virtual void TxFailed (const WifiMacHeader &hdr);
/**
* Get the Frame Exchange Manager
*
* \return the Frame Exchange Manager
*/
Ptr<FrameExchangeManager> GetFrameExchangeManager (void) const;
/**
* Enable or disable CTS-to-self feature.
*
@@ -169,11 +177,12 @@ protected:
virtual void DoInitialize ();
virtual void DoDispose ();
Ptr<MacRxMiddle> m_rxMiddle; //!< RX middle (defragmentation etc.)
Ptr<MacTxMiddle> m_txMiddle; //!< TX middle (aggregation etc.)
Ptr<MacLow> m_low; //!< MacLow (RTS, CTS, Data, Ack etc.)
Ptr<MacRxMiddle> m_rxMiddle; //!< RX middle (defragmentation etc.)
Ptr<MacTxMiddle> m_txMiddle; //!< TX middle (aggregation etc.)
Ptr<MacLow> m_low; //!< MacLow (RTS, CTS, Data, Ack etc.)
Ptr<ChannelAccessManager> m_channelAccessManager; //!< channel access manager
Ptr<WifiPhy> m_phy; //!< Wifi PHY
Ptr<WifiPhy> m_phy; //!< Wifi PHY
Ptr<FrameExchangeManager> m_feManager; //!< Frame Exchange Manager
Ptr<WifiRemoteStationManager> m_stationManager; //!< Remote station manager (rate control, RTS/CTS/fragmentation thresholds etc.)
@@ -294,6 +303,12 @@ protected:
*/
bool GetQosSupported () const;
/**
* Create a Frame Exchange Manager depending on the supported version
* of the standard.
*/
void SetupFrameExchangeManager (void);
/**
* Return whether the device supports HT.
*

View File

@@ -21,6 +21,7 @@
#include "ns3/test.h"
#include "ns3/simulator.h"
#include "ns3/channel-access-manager.h"
#include "ns3/frame-exchange-manager.h"
#include "ns3/qos-txop.h"
#include "ns3/mac-low.h"
@@ -60,6 +61,7 @@ private:
/// Inherited
void DoDispose (void);
void NotifyChannelAccessed (void);
typedef std::pair<uint64_t,uint64_t> ExpectedGrant; //!< the expected grant typedef
typedef std::list<ExpectedGrant> ExpectedGrants; //!< the collection of expected grants typedef
@@ -75,19 +77,6 @@ private:
ExpectedBackoffs m_expectedBackoff; //!< expected backoff (not due to an internal collision)
ExpectedGrants m_expectedGrants; //!< expected grants
/**
* \returns true if access has been requested for this function and
* has not been granted already, false otherwise.
*/
bool IsAccessRequested (void) const;
/**
* Notify that access request has been received.
*/
void NotifyAccessRequested (void);
/**
* Notify the Txop that access has been granted.
*/
void NotifyAccessGranted (void);
/**
* Notify the Txop that internal collision has occurred.
*/
@@ -117,7 +106,6 @@ private:
ChannelAccessManagerTest<TxopType> *m_test; //!< the test DCF/EDCA manager
uint32_t m_i; //!< the index of the Txop
bool m_accessRequested; //!< true if access requested
};
/**
@@ -206,6 +194,32 @@ private:
Time m_eifsNoDifs; // EIFS duration minus a DIFS
};
/**
* \ingroup wifi-test
* \ingroup tests
*
* \brief Frame Exchange Manager Stub
*/
class FrameExchangeManagerStub : public FrameExchangeManager
{
public:
FrameExchangeManagerStub ()
{
}
/**
* Request the FrameExchangeManager to start a frame exchange sequence.
*
* \param dcf the channel access function that gained channel access. It is
* the DCF on non-QoS stations and an EDCA on QoS stations.
* \return true if a frame exchange sequence was started, false otherwise
*/
bool StartTransmission (Ptr<Txop> dcf)
{
dcf->NotifyChannelAccessed ();
return true;
}
};
/**
* \ingroup wifi-test
* \ingroup tests
@@ -387,6 +401,7 @@ private:
typedef std::vector<Ptr<TxopTest<TxopType>>> TxopTests; //!< the TXOP tests typedef
Ptr<MacLowStub> m_low; //!< the MAC low stubbed
Ptr<FrameExchangeManagerStub> m_feManager; //!< the Frame Exchange Manager stubbed
Ptr<ChannelAccessManagerStub> m_ChannelAccessManager; //!< the channel access manager
TxopTests m_txop; //!< the vector of Txop test instances
uint32_t m_ackTimeoutValue; //!< the Ack timeout value
@@ -402,8 +417,7 @@ TxopTest<TxopType>::QueueTx (uint64_t txTime, uint64_t expectedGrantTime)
template <typename TxopType>
TxopTest<TxopType>::TxopTest (ChannelAccessManagerTest<TxopType> *test, uint32_t i)
: m_test (test),
m_i (i),
m_accessRequested (false)
m_i (i)
{
}
@@ -415,25 +429,11 @@ TxopTest<TxopType>::DoDispose (void)
Txop::DoDispose ();
}
template <typename TxopType>
bool
TxopTest<TxopType>::IsAccessRequested (void) const
{
return m_accessRequested;
}
template <typename TxopType>
void
TxopTest<TxopType>::NotifyAccessRequested (void)
TxopTest<TxopType>::NotifyChannelAccessed (void)
{
m_accessRequested = true;
}
template <typename TxopType>
void
TxopTest<TxopType>::NotifyAccessGranted (void)
{
m_accessRequested = false;
Txop::m_access = Txop::NOT_REQUESTED;
m_test->NotifyAccessGranted (m_i);
}
@@ -549,7 +549,7 @@ ChannelAccessManagerTest<TxopType>::NotifyChannelSwitching (uint32_t i)
state->m_expectedGrants.pop_front ();
NS_TEST_EXPECT_MSG_EQ (Simulator::Now (), MicroSeconds (expected.second), "Expected grant is now");
}
state->m_accessRequested = false;
state->Txop::m_access = Txop::NOT_REQUESTED;
}
template <typename TxopType>
@@ -596,6 +596,8 @@ ChannelAccessManagerTest<TxopType>::StartTest (uint64_t slotTime, uint64_t sifs,
m_ChannelAccessManager = CreateObject<ChannelAccessManagerStub> ();
m_low = CreateObject<MacLowStub> ();
m_ChannelAccessManager->SetupLow (m_low);
m_feManager = CreateObject<FrameExchangeManagerStub> ();
m_ChannelAccessManager->SetupFrameExchangeManager (m_feManager);
m_ChannelAccessManager->SetSlot (MicroSeconds (slotTime));
m_ChannelAccessManager->SetSifs (MicroSeconds (sifs));
m_ChannelAccessManager->SetEifsNoDifs (MicroSeconds (eifsNoDifsNoSifs + sifs));
@@ -633,6 +635,7 @@ ChannelAccessManagerTest<TxopType>::EndTest (void)
m_ChannelAccessManager = 0;
m_low = 0;
m_feManager = 0;
}
template <typename TxopType>

View File

@@ -102,10 +102,10 @@ AmpduAggregationTest::DoRun (void)
*/
m_mac = CreateObject<StaWifiMac> ();
m_mac->SetDevice (m_device);
m_mac->SetWifiPhy (m_phy);
m_mac->SetWifiRemoteStationManager (m_manager);
m_mac->SetAddress (Mac48Address ("00:00:00:00:00:01"));
m_mac->ConfigureStandard (WIFI_STANDARD_80211n_5GHZ);
m_mac->SetWifiPhy (m_phy);
m_device->SetMac (m_mac);
/*
@@ -308,10 +308,10 @@ TwoLevelAggregationTest::DoRun (void)
*/
m_mac = CreateObject<StaWifiMac> ();
m_mac->SetDevice (m_device);
m_mac->SetWifiPhy (m_phy);
m_mac->SetWifiRemoteStationManager (m_manager);
m_mac->SetAddress (Mac48Address ("00:00:00:00:00:01"));
m_mac->ConfigureStandard (WIFI_STANDARD_80211n_5GHZ);
m_mac->SetWifiPhy (m_phy);
m_device->SetMac (m_mac);
/*
@@ -529,10 +529,10 @@ HeAggregationTest::DoRunSubTest (uint16_t bufferSize)
*/
m_mac = CreateObject<StaWifiMac> ();
m_mac->SetDevice (m_device);
m_mac->SetWifiPhy (m_phy);
m_mac->SetWifiRemoteStationManager (m_manager);
m_mac->SetAddress (Mac48Address ("00:00:00:00:00:01"));
m_mac->ConfigureStandard (WIFI_STANDARD_80211ax_5GHZ);
m_mac->SetWifiPhy (m_phy);
m_device->SetMac (m_mac);
/*

View File

@@ -1580,10 +1580,10 @@ private:
Ptr<YansWifiPhy> m_apPhy; ///< AP PHY
Ptr<YansWifiPhy> m_staPhy; ///< STA PHY
uint8_t m_reassocReqCount; ///< count number of reassociation requests
uint8_t m_reassocRespCount; ///< count number of reassociation responses
uint8_t m_countOperationalChannelWidth20; ///< count number of beacon frames announcing a 20 MHz operating channel width
uint8_t m_countOperationalChannelWidth40; ///< count number of beacon frames announcing a 40 MHz operating channel width
uint16_t m_reassocReqCount; ///< count number of reassociation requests
uint16_t m_reassocRespCount; ///< count number of reassociation responses
uint16_t m_countOperationalChannelWidth20; ///< count number of beacon frames announcing a 20 MHz operating channel width
uint16_t m_countOperationalChannelWidth40; ///< count number of beacon frames announcing a 40 MHz operating channel width
};
Bug2831TestCase::Bug2831TestCase ()
@@ -1658,6 +1658,7 @@ Bug2831TestCase::DoRun (void)
mac.Set ("EnableBeaconJitter", BooleanValue (false));
Ptr<WifiMac> apMac = mac.Create<WifiMac> ();
apMac->SetDevice (apDev);
apMac->SetAddress (Mac48Address::Allocate ());
apMac->ConfigureStandard (WIFI_STANDARD_80211ax_5GHZ);
Ptr<Node> staNode = CreateObject<Node> ();
@@ -1667,6 +1668,7 @@ Bug2831TestCase::DoRun (void)
mac.SetTypeId ("ns3::StaWifiMac");
Ptr<WifiMac> staMac = mac.Create<WifiMac> ();
staMac->SetDevice (staDev);
staMac->SetAddress (Mac48Address::Allocate ());
staMac->ConfigureStandard (WIFI_STANDARD_80211ax_5GHZ);
Ptr<ConstantPositionMobilityModel> apMobility = CreateObject<ConstantPositionMobilityModel> ();
@@ -1696,7 +1698,6 @@ Bug2831TestCase::DoRun (void)
m_staPhy->SetChannelNumber (36);
m_staPhy->SetChannelWidth (20);
apMac->SetAddress (Mac48Address::Allocate ());
apDev->SetMac (apMac);
apDev->SetPhy (m_apPhy);
ObjectFactory manager;
@@ -1704,7 +1705,6 @@ Bug2831TestCase::DoRun (void)
apDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());
apNode->AddDevice (apDev);
staMac->SetAddress (Mac48Address::Allocate ());
staDev->SetMac (staMac);
staDev->SetPhy (m_staPhy);
staDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());