wave: Replace WaveMacLow with WaveFrameExchangeManager
This commit is contained in:
@@ -422,37 +422,8 @@ WaveHelper::Install (const WifiPhyHelper &phyHelper, const WifiMacHelper &macHe
|
||||
{
|
||||
Ptr<WifiMac> wifiMac = macHelper.Create (device, WIFI_STANDARD_80211p);
|
||||
Ptr<OcbWifiMac> ocbMac = DynamicCast<OcbWifiMac> (wifiMac);
|
||||
// we use WaveMacLow to replace original MacLow
|
||||
ocbMac->EnableForWave (device);
|
||||
ocbMac->SetWifiRemoteStationManager (m_stationManager.Create<WifiRemoteStationManager> ());
|
||||
// Install ack policy selector
|
||||
BooleanValue qosSupported;
|
||||
PointerValue ptr;
|
||||
Ptr<WifiAckPolicySelector> ackSelector;
|
||||
|
||||
ocbMac->GetAttributeFailSafe ("QosSupported", qosSupported);
|
||||
if (qosSupported.Get ())
|
||||
{
|
||||
ocbMac->GetAttributeFailSafe ("BE_Txop", ptr);
|
||||
ackSelector = m_ackPolicySelector[AC_BE].Create<WifiAckPolicySelector> ();
|
||||
ackSelector->SetQosTxop (ptr.Get<QosTxop> ());
|
||||
ptr.Get<QosTxop> ()->SetAckPolicySelector (ackSelector);
|
||||
|
||||
ocbMac->GetAttributeFailSafe ("BK_Txop", ptr);
|
||||
ackSelector = m_ackPolicySelector[AC_BK].Create<WifiAckPolicySelector> ();
|
||||
ackSelector->SetQosTxop (ptr.Get<QosTxop> ());
|
||||
ptr.Get<QosTxop> ()->SetAckPolicySelector (ackSelector);
|
||||
|
||||
ocbMac->GetAttributeFailSafe ("VI_Txop", ptr);
|
||||
ackSelector = m_ackPolicySelector[AC_VI].Create<WifiAckPolicySelector> ();
|
||||
ackSelector->SetQosTxop (ptr.Get<QosTxop> ());
|
||||
ptr.Get<QosTxop> ()->SetAckPolicySelector (ackSelector);
|
||||
|
||||
ocbMac->GetAttributeFailSafe ("VO_Txop", ptr);
|
||||
ackSelector = m_ackPolicySelector[AC_VO].Create<WifiAckPolicySelector> ();
|
||||
ackSelector->SetQosTxop (ptr.Get<QosTxop> ());
|
||||
ptr.Get<QosTxop> ()->SetAckPolicySelector (ackSelector);
|
||||
}
|
||||
ocbMac->EnableForWave (device);
|
||||
device->AddMac (*k, ocbMac);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
#include "ns3/mac-rx-middle.h"
|
||||
#include "ns3/ht-capabilities.h"
|
||||
#include "ns3/vht-capabilities.h"
|
||||
#include "wave-mac-low.h"
|
||||
#include "ns3/channel-access-manager.h"
|
||||
#include "wave-frame-exchange-manager.h"
|
||||
#include "ocb-wifi-mac.h"
|
||||
#include "vendor-specific-action.h"
|
||||
#include "higher-tx-tag.h"
|
||||
@@ -390,6 +391,21 @@ OcbWifiMac::ConfigureStandard (enum WifiStandard standard)
|
||||
ConfigureEdca (cwmin, cwmax, 3, AC_VI);
|
||||
ConfigureEdca (cwmin, cwmax, 6, AC_BE);
|
||||
ConfigureEdca (cwmin, cwmax, 9, AC_BK);
|
||||
|
||||
// Setup FrameExchangeManager
|
||||
m_feManager = CreateObject<WaveFrameExchangeManager> ();
|
||||
m_feManager->SetWifiMac (this);
|
||||
m_feManager->SetMacTxMiddle (m_txMiddle);
|
||||
m_feManager->SetMacRxMiddle (m_rxMiddle);
|
||||
m_feManager->SetAddress (GetAddress ());
|
||||
m_channelAccessManager->SetupFrameExchangeManager (m_feManager);
|
||||
if (GetQosSupported ())
|
||||
{
|
||||
for (const auto& pair : m_edca)
|
||||
{
|
||||
pair.second->SetQosFrameExchangeManager (DynamicCast<QosFrameExchangeManager> (m_feManager));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -398,7 +414,7 @@ OcbWifiMac::Suspend (void)
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
m_channelAccessManager->NotifySleepNow ();
|
||||
m_low->NotifySleepNow ();
|
||||
m_feManager->NotifySleepNow ();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -432,23 +448,15 @@ OcbWifiMac::Reset (void)
|
||||
NS_LOG_FUNCTION (this);
|
||||
// The switching event is used to notify MAC entity reset its operation.
|
||||
m_channelAccessManager->NotifySwitchingStartNow (Time (0));
|
||||
m_low->NotifySwitchingStartNow (Time (0));
|
||||
m_feManager->NotifySwitchingStartNow (Time (0));
|
||||
}
|
||||
|
||||
void
|
||||
OcbWifiMac::EnableForWave (Ptr<WaveNetDevice> device)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << device);
|
||||
// To extend current OcbWifiMac for WAVE 1609.4, we shall use WaveMacLow instead of MacLow
|
||||
m_low = CreateObject<WaveMacLow> ();
|
||||
(DynamicCast<WaveMacLow> (m_low))->SetWaveNetDevice (device);
|
||||
m_low->SetRxCallback (MakeCallback (&MacRxMiddle::Receive, m_rxMiddle));
|
||||
m_channelAccessManager->SetupLow (m_low);
|
||||
m_txop->SetMacLow (m_low);
|
||||
for (EdcaQueues::iterator i = m_edca.begin (); i != m_edca.end (); ++i)
|
||||
{
|
||||
i->second->SetMacLow (m_low);
|
||||
i->second->CompleteConfig ();
|
||||
}
|
||||
// To extend current OcbWifiMac for WAVE 1609.4, we shall use WaveFrameExchangeManager
|
||||
StaticCast<WaveFrameExchangeManager> (m_feManager)->SetWaveNetDevice (device);
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2008 INRIA
|
||||
* Copyright (c) 2013 Dalian University of Technology
|
||||
* Copyright (c) 2020 Universita' degli Studi di Napoli Federico II
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -16,51 +15,54 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
* Junling Bu <linlinjavaer@gmail.com>
|
||||
* Author: Stefano Avallone <stavallo@unina.it>
|
||||
*/
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/event-id.h"
|
||||
#include "ns3/wifi-phy.h"
|
||||
#include "wave-mac-low.h"
|
||||
#include "ns3/abort.h"
|
||||
#include "ns3/wifi-protection.h"
|
||||
#include "ns3/wifi-acknowledgment.h"
|
||||
#include "wave-frame-exchange-manager.h"
|
||||
#include "higher-tx-tag.h"
|
||||
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("WaveMacLow");
|
||||
NS_LOG_COMPONENT_DEFINE ("WaveFrameExchangeManager");
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (WaveMacLow);
|
||||
NS_OBJECT_ENSURE_REGISTERED (WaveFrameExchangeManager);
|
||||
|
||||
TypeId
|
||||
WaveMacLow::GetTypeId (void)
|
||||
WaveFrameExchangeManager::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::WaveMacLow")
|
||||
.SetParent<MacLow> ()
|
||||
static TypeId tid = TypeId ("ns3::WaveFrameExchangeManager")
|
||||
.SetParent<QosFrameExchangeManager> ()
|
||||
.AddConstructor<WaveFrameExchangeManager> ()
|
||||
.SetGroupName ("Wave")
|
||||
.AddConstructor<WaveMacLow> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
WaveMacLow::WaveMacLow ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
WaveMacLow::~WaveMacLow ()
|
||||
|
||||
WaveFrameExchangeManager::WaveFrameExchangeManager ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
|
||||
void
|
||||
WaveMacLow::SetWaveNetDevice (Ptr<WaveNetDevice> device)
|
||||
WaveFrameExchangeManager::~WaveFrameExchangeManager ()
|
||||
{
|
||||
m_scheduler = device->GetChannelScheduler ();
|
||||
m_coordinator = device->GetChannelCoordinator ();
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
|
||||
void
|
||||
WaveFrameExchangeManager::SetWaveNetDevice (Ptr<WaveNetDevice> device)
|
||||
{
|
||||
m_scheduler = device->GetChannelScheduler ();
|
||||
m_coordinator = device->GetChannelCoordinator ();
|
||||
NS_ASSERT (m_scheduler != 0 && m_coordinator != 0);
|
||||
}
|
||||
|
||||
WifiTxVector
|
||||
WaveMacLow::GetDataTxVector (Ptr<const WifiMacQueueItem> item) const
|
||||
WaveFrameExchangeManager::GetDataTxVector (Ptr<const WifiMacQueueItem> item) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this << *item);
|
||||
HigherLayerTxVectorTag datatag;
|
||||
@@ -70,7 +72,7 @@ WaveMacLow::GetDataTxVector (Ptr<const WifiMacQueueItem> item) const
|
||||
// will be determined by MAC layer itself.
|
||||
if (!found)
|
||||
{
|
||||
return MacLow::GetDataTxVector (item);
|
||||
return m_mac->GetWifiRemoteStationManager ()->GetDataTxVector (item->GetHeader ());
|
||||
}
|
||||
|
||||
// if high layer has set the transmit parameters with non-adaption mode,
|
||||
@@ -83,7 +85,7 @@ WaveMacLow::GetDataTxVector (Ptr<const WifiMacQueueItem> item) const
|
||||
// if high layer has set the transmit parameters with non-adaption mode,
|
||||
// the real transmit parameters are determined by both high layer and MAC layer.
|
||||
WifiTxVector txHigher = datatag.GetTxVector ();
|
||||
WifiTxVector txMac = MacLow::GetDataTxVector (item);
|
||||
WifiTxVector txMac = m_mac->GetWifiRemoteStationManager ()->GetDataTxVector (item->GetHeader ());
|
||||
WifiTxVector txAdapter;
|
||||
txAdapter.SetChannelWidth (10);
|
||||
// the DataRate set by higher layer is the minimum data rate
|
||||
@@ -105,36 +107,61 @@ WaveMacLow::GetDataTxVector (Ptr<const WifiMacQueueItem> item) const
|
||||
return txAdapter;
|
||||
}
|
||||
|
||||
void
|
||||
WaveMacLow::StartTransmission (Ptr<WifiMacQueueItem> mpdu,
|
||||
MacLowTransmissionParameters params,
|
||||
Ptr<Txop> dca)
|
||||
bool
|
||||
WaveFrameExchangeManager::StartTransmission (Ptr<Txop> dcf)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << *mpdu << params << dca);
|
||||
Ptr<WifiPhy> phy = MacLow::GetPhy ();
|
||||
uint32_t curChannel = phy->GetChannelNumber ();
|
||||
// if current channel access is not AlternatingAccess, just do as MacLow.
|
||||
if (!m_scheduler->IsAlternatingAccessAssigned (curChannel))
|
||||
NS_LOG_FUNCTION (this << dcf);
|
||||
|
||||
uint32_t curChannel = m_phy->GetChannelNumber ();
|
||||
// if current channel access is not AlternatingAccess, just do as FrameExchangeManager.
|
||||
if (m_scheduler == 0 || !m_scheduler->IsAlternatingAccessAssigned (curChannel))
|
||||
{
|
||||
MacLow::StartTransmission (mpdu, params, dca);
|
||||
return;
|
||||
return FrameExchangeManager::StartTransmission (dcf);
|
||||
}
|
||||
|
||||
Time transmissionTime = MacLow::CalculateTransmissionTime (mpdu->GetPacket (), &mpdu->GetHeader (), params);
|
||||
m_txTimer.Cancel ();
|
||||
m_dcf = dcf;
|
||||
|
||||
Ptr<WifiMacQueue> queue = dcf->GetWifiMacQueue ();
|
||||
|
||||
if (queue->IsEmpty ())
|
||||
{
|
||||
NS_LOG_DEBUG ("Queue empty");
|
||||
m_dcf->NotifyChannelReleased ();
|
||||
m_dcf = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dcf->NotifyChannelAccessed ();
|
||||
Ptr<WifiMacQueueItem> mpdu = *queue->Peek ()->GetQueueIteratorPairs ().front ().it;
|
||||
NS_ASSERT (mpdu != 0);
|
||||
|
||||
// assign a sequence number if this is not a fragment nor a retransmission
|
||||
if (!mpdu->IsFragment () && !mpdu->GetHeader ().IsRetry ())
|
||||
{
|
||||
uint16_t sequence = m_txMiddle->GetNextSequenceNumberFor (&mpdu->GetHeader ());
|
||||
mpdu->GetHeader ().SetSequenceNumber (sequence);
|
||||
}
|
||||
|
||||
WifiTxParameters txParams;
|
||||
txParams.m_txVector = GetDataTxVector (mpdu);
|
||||
Time remainingTime = m_coordinator->NeedTimeToGuardInterval ();
|
||||
|
||||
if (transmissionTime > remainingTime)
|
||||
if (!TryAddMpdu (mpdu, txParams, remainingTime))
|
||||
{
|
||||
// The attempt for this transmission will be canceled;
|
||||
// and this packet will be pending for next transmission by QosTxop class
|
||||
NS_LOG_DEBUG ("Because the required transmission time = " << transmissionTime.As (Time::MS)
|
||||
<< " exceeds the remainingTime = " << remainingTime.As (Time::MS)
|
||||
<< ", currently this packet will not be transmitted.");
|
||||
NS_LOG_DEBUG ("Because the required transmission time exceeds the remainingTime = "
|
||||
<< remainingTime.As (Time::MS)
|
||||
<< ", currently this packet will not be transmitted.");
|
||||
}
|
||||
else
|
||||
{
|
||||
MacLow::StartTransmission (mpdu, params, dca);
|
||||
SendMpduWithProtection (mpdu, txParams);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
} //namespace ns3
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2008 INRIA
|
||||
* Copyright (c) 2020 Universita' degli Studi di Napoli Federico II
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -17,23 +17,21 @@
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
* Junling Bu <linlinjavaer@gmail.com>
|
||||
* Stefano Avallone <stavallo@unina.it>
|
||||
*/
|
||||
#ifndef WAVE_MAC_LOW_H
|
||||
#define WAVE_MAC_LOW_H
|
||||
|
||||
#include "ns3/mac-low.h"
|
||||
#include "ns3/msdu-aggregator.h"
|
||||
#include "ns3/mpdu-aggregator.h"
|
||||
#include "ns3/wifi-psdu.h"
|
||||
#ifndef WAVE_FRAME_EXCHANGE_MANAGER_H
|
||||
#define WAVE_FRAME_EXCHANGE_MANAGER_H
|
||||
|
||||
#include "ns3/qos-frame-exchange-manager.h"
|
||||
#include "wave-net-device.h"
|
||||
|
||||
namespace ns3 {
|
||||
class WaveNetDevice;
|
||||
class WifiMacQueueItem;
|
||||
|
||||
/**
|
||||
* \ingroup wave
|
||||
* This class is the subclass of MacLow to provide support for MAC extension
|
||||
*
|
||||
* This class is the subclass of QosFrameExchangeManager to provide support for MAC extension
|
||||
* (1) allows higher layer control data rate and tx power level.
|
||||
* If higher layer does not set, they will be determined by WifiRemoteStationManager
|
||||
* of MAC layer;
|
||||
@@ -46,7 +44,7 @@ class WifiMacQueueItem;
|
||||
* However, the feature is extended further here that the required transmit time is determined
|
||||
* by MAC layer itself rather than PHY layer, which contains RTS/CTS, DATA and ACK time.
|
||||
*/
|
||||
class WaveMacLow : public MacLow
|
||||
class WaveFrameExchangeManager : public QosFrameExchangeManager
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@@ -54,25 +52,17 @@ public:
|
||||
* \return the object TypeId
|
||||
*/
|
||||
static TypeId GetTypeId (void);
|
||||
WaveMacLow ();
|
||||
virtual ~WaveMacLow ();
|
||||
WaveFrameExchangeManager ();
|
||||
virtual ~WaveFrameExchangeManager ();
|
||||
|
||||
// Overridden from FrameExchangeManager
|
||||
virtual bool StartTransmission (Ptr<Txop> dcf);
|
||||
|
||||
/**
|
||||
* \param device WaveNetDevice associated with WaveMacLow
|
||||
* \param device WaveNetDevice associated with WaveFrameExchangeManager
|
||||
*/
|
||||
void SetWaveNetDevice (Ptr<WaveNetDevice> device);
|
||||
|
||||
/**
|
||||
* \param mpdu packet to send
|
||||
* \param parameters the transmission parameters to use for this packet.
|
||||
* \param txop pointer to the calling Txop.
|
||||
*
|
||||
* Start the transmission of the input packet and notify the listener
|
||||
* of transmission events.
|
||||
*/
|
||||
virtual void StartTransmission (Ptr<WifiMacQueueItem> mpdu,
|
||||
MacLowTransmissionParameters parameters,
|
||||
Ptr<Txop> txop);
|
||||
private:
|
||||
/**
|
||||
* Return a TXVECTOR for the DATA frame given the destination.
|
||||
@@ -84,10 +74,10 @@ private:
|
||||
*/
|
||||
virtual WifiTxVector GetDataTxVector (Ptr<const WifiMacQueueItem> item) const;
|
||||
|
||||
Ptr<ChannelScheduler> m_scheduler; ///< the channel scheduler
|
||||
Ptr<ChannelScheduler> m_scheduler; ///< the channel scheduler
|
||||
Ptr<ChannelCoordinator> m_coordinator; ///< the channel coordinator
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
} //namespace ns3
|
||||
|
||||
#endif /* WAVE_MAC_LOW_H*/
|
||||
#endif /* VHT_FRAME_EXCHANGE_MANAGER_H */
|
||||
@@ -9,7 +9,7 @@
|
||||
def build(bld):
|
||||
module = bld.create_ns3_module('wave', ['core','wifi', 'propagation', 'internet'])
|
||||
module.source = [
|
||||
'model/wave-mac-low.cc',
|
||||
'model/wave-frame-exchange-manager.cc',
|
||||
'model/ocb-wifi-mac.cc',
|
||||
'model/vendor-specific-action.cc',
|
||||
'model/channel-coordinator.cc',
|
||||
@@ -42,7 +42,7 @@ def build(bld):
|
||||
headers = bld(features='ns3header')
|
||||
headers.module = 'wave'
|
||||
headers.source = [
|
||||
'model/wave-mac-low.h',
|
||||
'model/wave-frame-exchange-manager.h',
|
||||
'model/ocb-wifi-mac.h',
|
||||
'model/vendor-specific-action.h',
|
||||
'model/channel-coordinator.h',
|
||||
|
||||
Reference in New Issue
Block a user