patch to support IEEE 1609.4 MAC extension in wave module

This commit is contained in:
Junling Bu
2015-01-26 15:17:35 -08:00
parent d2379471c7
commit a31a3245f2
23 changed files with 300 additions and 19 deletions

View File

@@ -55,8 +55,12 @@ public:
*
* Subclasses must implement this method to allow the ns3::WifiHelper class
* to create PHY objects from ns3::WifiHelper::Install.
*
* Typically the device type will be of class WifiNetDevice but the
* type of the pointer is generalized so that this method may be used
* by other Wifi device variants such as WaveNetDevice.
*/
virtual Ptr<WifiPhy> Create (Ptr<Node> node, Ptr<WifiNetDevice> device) const = 0;
virtual Ptr<WifiPhy> Create (Ptr<Node> node, Ptr<NetDevice> device) const = 0;
};
/**

View File

@@ -234,7 +234,7 @@ YansWifiPhyHelper::SetErrorRateModel (std::string name,
}
Ptr<WifiPhy>
YansWifiPhyHelper::Create (Ptr<Node> node, Ptr<WifiNetDevice> device) const
YansWifiPhyHelper::Create (Ptr<Node> node, Ptr<NetDevice> device) const
{
Ptr<YansWifiPhy> phy = m_phy.Create<YansWifiPhy> ();
Ptr<ErrorRateModel> error = m_errorRateModel.Create<ErrorRateModel> ();
@@ -419,6 +419,12 @@ YansWifiPhyHelper::SetPcapDataLinkType (enum SupportedPcapDataLinkTypes dlt)
}
}
uint32_t
YansWifiPhyHelper::GetPcapDataLinkType (void) const
{
return m_pcapDlt;
}
void
YansWifiPhyHelper::EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool promiscuous, bool explicitFilename)
{

View File

@@ -243,6 +243,15 @@ public:
*/
void SetPcapDataLinkType (enum SupportedPcapDataLinkTypes dlt);
/**
* Get the data link type of PCAP traces to be used.
*
* @see SupportedPcapDataLinkTypes
*
* @returns The data link type of the pcap file (and packets) to be used
*/
uint32_t GetPcapDataLinkType (void) const;
private:
/**
* \param node the node on which we wish to create a wifi PHY
@@ -251,7 +260,7 @@ private:
*
* This method implements the pure virtual method defined in \ref ns3::WifiPhyHelper.
*/
virtual Ptr<WifiPhy> Create (Ptr<Node> node, Ptr<WifiNetDevice> device) const;
virtual Ptr<WifiPhy> Create (Ptr<Node> node, Ptr<NetDevice> device) const;
/**
* @brief Enable pcap output the indicated net device.

View File

@@ -87,10 +87,7 @@ AdhocWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
{
// In ad hoc mode, we assume that every destination supports all
// the rates we support.
for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
{
m_stationManager->AddSupportedMode (to, m_phy->GetMode (i));
}
m_stationManager->AddAllSupportedModes (to);
m_stationManager->RecordDisassociated (to);
}

View File

@@ -66,6 +66,14 @@ private:
{
m_txop->NotifyChannelSwitching ();
}
virtual void DoNotifySleep (void)
{
m_txop->NotifySleep ();
}
virtual void DoNotifyWakeUp (void)
{
m_txop->NotifyWakeUp ();
}
DcaTxop *m_txop;
};
@@ -512,6 +520,22 @@ DcaTxop::NotifyChannelSwitching (void)
m_queue->Flush ();
m_currentPacket = 0;
}
void
DcaTxop::NotifySleep (void)
{
NS_LOG_FUNCTION (this);
if (m_currentPacket != 0)
{
m_queue->PushFront (m_currentPacket, m_currentHdr);
m_currentPacket = 0;
}
}
void
DcaTxop::NotifyWakeUp (void)
{
NS_LOG_FUNCTION (this);
RestartAccessIfNeeded ();
}
void
DcaTxop::GotCts (double snr, WifiMode txMode)

View File

@@ -194,6 +194,15 @@ private:
* When a channel switching occurs, enqueued packets are removed.
*/
void NotifyChannelSwitching (void);
/**
* When sleep operation occurs, if there is a pending packet transmission,
* it will be reinserted to the front of the queue.
*/
void NotifySleep (void);
/**
* When wake up operation occurs, channel access will be restarted
*/
void NotifyWakeUp (void);
/* Event handlers */
/**

View File

@@ -161,6 +161,16 @@ DcfState::NotifyChannelSwitching (void)
{
DoNotifyChannelSwitching ();
}
void
DcfState::NotifySleep (void)
{
DoNotifySleep ();
}
void
DcfState::NotifyWakeUp (void)
{
DoNotifyWakeUp ();
}
/**
@@ -311,6 +321,19 @@ DcfManager::SetupPhyListener (Ptr<WifiPhy> phy)
m_phyListener = new PhyListener (this);
phy->RegisterListener (m_phyListener);
}
void
DcfManager::RemovePhyListener (Ptr<WifiPhy> phy)
{
NS_LOG_FUNCTION (this << phy);
if (m_phyListener != 0)
{
phy->UnregisterListener (m_phyListener);
delete m_phyListener;
m_phyListener = 0;
}
}
void
DcfManager::SetupLowListener (Ptr<MacLow> low)
{
@@ -765,6 +788,13 @@ DcfManager::NotifySleepNow (void)
{
m_accessTimeout.Cancel ();
}
// Reset backoffs
for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
{
DcfState *state = *i;
state->NotifySleep ();
}
}
void
@@ -772,7 +802,6 @@ DcfManager::NotifyWakeupNow (void)
{
NS_LOG_FUNCTION (this);
m_sleeping = false;
// Reset backoffs
for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
{
DcfState *state = *i;
@@ -784,6 +813,7 @@ DcfManager::NotifyWakeupNow (void)
}
state->ResetCw ();
state->m_accessRequested = false;
state->NotifyWakeUp ();
}
}

View File

@@ -160,6 +160,14 @@ private:
* Notify that the device is switching channel.
*/
void NotifyChannelSwitching (void);
/**
* Notify that the device has started to sleep.
*/
void NotifySleep (void);
/**
* Notify that the device has started to wake up
*/
void NotifyWakeUp (void);
/**
@@ -194,10 +202,25 @@ private:
* Called by DcfManager to notify a DcfState subclass
* that a channel switching occured.
*
* The subclass is expected to flush the queue of
* packets.
* The subclass is expected to flush the queue of packets.
*/
virtual void DoNotifyChannelSwitching () = 0;
virtual void DoNotifyChannelSwitching (void) = 0;
/**
* Called by DcfManager to notify a DcfState subclass that the device has
* begun to sleep.
*
* The subclass is expected to re-insert the pending packet into the queue
*/
virtual void DoNotifySleep (void) = 0;
/**
* Called by DcfManager to notify a DcfState subclass that the device
* has begun to wake up.
*
* The subclass is expected to restart a new backoff by
* calling DcfState::StartBackoffNow and DcfManager::RequestAccess
* is access is still needed.
*/
virtual void DoNotifyWakeUp (void) = 0;
uint32_t m_aifsn;
uint32_t m_backoffSlots;
@@ -238,6 +261,12 @@ public:
* \param phy
*/
void SetupPhyListener (Ptr<WifiPhy> phy);
/**
* Remove current registered listener for Phy events.
*
* \param phy
*/
void RemovePhyListener (Ptr<WifiPhy> phy);
/**
* Set up listener for MacLow events.
*

View File

@@ -66,6 +66,14 @@ private:
{
m_txop->NotifyChannelSwitching ();
}
virtual void DoNotifySleep (void)
{
m_txop->NotifySleep ();
}
virtual void DoNotifyWakeUp (void)
{
m_txop->NotifyWakeUp ();
}
EdcaTxopN *m_txop;
};
@@ -554,6 +562,22 @@ EdcaTxopN::NotifyChannelSwitching (void)
m_queue->Flush ();
m_currentPacket = 0;
}
void
EdcaTxopN::NotifySleep (void)
{
NS_LOG_FUNCTION (this);
if (m_currentPacket != 0)
{
m_queue->PushFront (m_currentPacket, m_currentHdr);
m_currentPacket = 0;
}
}
void
EdcaTxopN::NotifyWakeUp (void)
{
NS_LOG_FUNCTION (this);
RestartAccessIfNeeded ();
}
void
EdcaTxopN::Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr)

View File

@@ -187,6 +187,14 @@ public:
* When a channel switching occurs, enqueued packets are removed.
*/
void NotifyChannelSwitching (void);
/**
* When sleep operation occurs, re-insert pending packet into front of the queue
*/
void NotifySleep (void);
/**
* When wake up operation occurs, restart channel access
*/
void NotifyWakeUp (void);
/* Event handlers */
/**

View File

@@ -327,6 +327,16 @@ MacLow::SetupPhyMacLowListener (Ptr<WifiPhy> phy)
phy->RegisterListener (m_phyMacLowListener);
}
void
MacLow::RemovePhyMacLowListener (Ptr<WifiPhy> phy)
{
if (m_phyMacLowListener != 0 )
{
phy->UnregisterListener (m_phyMacLowListener);
delete m_phyMacLowListener;
m_phyMacLowListener = 0;
}
}
void
MacLow::DoDispose (void)
@@ -433,6 +443,19 @@ MacLow::SetPhy (Ptr<WifiPhy> phy)
m_phy->SetReceiveErrorCallback (MakeCallback (&MacLow::ReceiveError, this));
SetupPhyMacLowListener (phy);
}
Ptr<WifiPhy>
MacLow::GetPhy (void) const
{
return m_phy;
}
void
MacLow::ResetPhy (void)
{
m_phy->SetReceiveOkCallback (MakeNullCallback<void,Ptr<Packet>, double, WifiMode, enum WifiPreamble> ());
m_phy->SetReceiveErrorCallback (MakeNullCallback<void,Ptr<const Packet>, double> ());
RemovePhyMacLowListener (m_phy);
m_phy = 0;
}
void
MacLow::SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> manager)
{
@@ -663,7 +686,6 @@ void
MacLow::NotifySleepNow (void)
{
NS_LOG_DEBUG ("Device in sleep mode. Cancelling MAC pending events");
m_stationManager->Reset ();
CancelAllEvents ();
if (m_navCounterResetCtsMissed.IsRunning ())
{

View File

@@ -425,6 +425,16 @@ public:
* \param phy WifiPhy associated with this MacLow
*/
void SetPhy (Ptr<WifiPhy> phy);
/*
* \return current attached PHY device
*/
Ptr<WifiPhy> GetPhy (void) const;
/**
* Remove WifiPhy associated with this MacLow.
*
* \param phy WifiPhy associated with this MacLow
*/
void ResetPhy (void);
/**
* Set up WifiRemoteStationManager associated with this MacLow.
*
@@ -611,7 +621,7 @@ public:
* Start the transmission of the input packet and notify the listener
* of transmission events.
*/
void StartTransmission (Ptr<const Packet> packet,
virtual void StartTransmission (Ptr<const Packet> packet,
const WifiMacHeader* hdr,
MacLowTransmissionParameters parameters,
MacLowTransmissionListener *listener);
@@ -1072,6 +1082,12 @@ private:
* \param phy the WifiPhy this MacLow is connected to
*/
void SetupPhyMacLowListener (Ptr<WifiPhy> phy);
/**
* Remove current WifiPhy listener for this MacLow.
*
* \param phy the WifiPhy this MacLow is connected to
*/
void RemovePhyMacLowListener (Ptr<WifiPhy> phy);
Ptr<WifiPhy> m_phy; //!< Pointer to WifiPhy (actually send/receives frames)
Ptr<WifiRemoteStationManager> m_stationManager; //!< Pointer to WifiRemoteStationManager (rate control)

View File

@@ -208,11 +208,21 @@ RegularWifiMac::SetWifiPhy (Ptr<WifiPhy> phy)
}
Ptr<WifiPhy>
RegularWifiMac::GetWifiPhy () const
RegularWifiMac::GetWifiPhy (void) const
{
NS_LOG_FUNCTION (this);
return m_phy;
}
void
RegularWifiMac::ResetWifiPhy (void)
{
NS_LOG_FUNCTION (this);
m_low->ResetPhy ();
m_dcfManager->RemovePhyListener (m_phy);
m_phy = 0;
}
void
RegularWifiMac::SetForwardUpCallback (ForwardUpCallback upCallback)
{

View File

@@ -189,7 +189,11 @@ public:
/**
* \return the physical layer attached to this MAC.
*/
virtual Ptr<WifiPhy> GetWifiPhy () const;
virtual Ptr<WifiPhy> GetWifiPhy (void) const;
/**
* removes attached WifiPhy device from this MAC.
*/
virtual void ResetWifiPhy (void);
/**
* \param stationManager the station manager attached to this MAC.
*/
@@ -197,7 +201,7 @@ public:
/**
* \return the station manager attached to this MAC.
*/
virtual Ptr<WifiRemoteStationManager> GetWifiRemoteStationManager () const;
virtual Ptr<WifiRemoteStationManager> GetWifiRemoteStationManager (void) const;
/**
* This type defines the callback of a higher layer that a

View File

@@ -189,10 +189,23 @@ public:
* \param phy the physical layer attached to this MAC.
*/
virtual void SetWifiPhy (Ptr<WifiPhy> phy) = 0;
/**
* return current attached WifiPhy device
*/
virtual Ptr<WifiPhy> GetWifiPhy (void) const = 0;
/**
* remove current attached WifiPhy device from this MAC.
*/
virtual void ResetWifiPhy (void) = 0;
/**
* \param stationManager the station manager attached to this MAC.
*/
virtual void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stationManager) = 0;
/**
* \return the station manager attached to this MAC.
*/
virtual Ptr<WifiRemoteStationManager> GetWifiRemoteStationManager (void) const = 0;
/**
* \param upCallback the callback to invoke when a packet must be forwarded up the stack.
*/

View File

@@ -21,6 +21,7 @@
#include "ns3/log.h"
#include "ns3/simulator.h"
#include "ns3/trace-source-accessor.h"
#include <algorithm>
namespace ns3 {
@@ -85,6 +86,15 @@ WifiPhyStateHelper::RegisterListener (WifiPhyListener *listener)
{
m_listeners.push_back (listener);
}
void
WifiPhyStateHelper::UnregisterListener (WifiPhyListener *listener)
{
ListenersI i = find (m_listeners.begin(), m_listeners.end(), listener);
if (i != m_listeners.end())
{
m_listeners.erase(i);
}
}
bool
WifiPhyStateHelper::IsStateIdle (void)

View File

@@ -57,6 +57,12 @@ public:
* \param listener
*/
void RegisterListener (WifiPhyListener *listener);
/**
* Remove WifiPhyListener from this WifiPhyStateHelper.
*
* \param listener
*/
void UnregisterListener (WifiPhyListener *listener);
/**
* Return the current state of WifiPhy.
*
@@ -232,6 +238,7 @@ private:
* typedef for a list of WifiPhyListeners
*/
typedef std::vector<WifiPhyListener *> Listeners;
typedef std::vector<WifiPhyListener *>::iterator ListenersI;
/**
* Log the ideal and CCA states.

View File

@@ -219,6 +219,13 @@ public:
* PHY-level events.
*/
virtual void RegisterListener (WifiPhyListener *listener) = 0;
/**
* \param listener the listener to be unregistered
*
* Remove the input listener from the list of objects to be notified of
* PHY-level events.
*/
virtual void UnregisterListener (WifiPhyListener *listener) = 0;
/**
* Put in sleep mode.
@@ -494,7 +501,11 @@ public:
*
* \return the current channel number
*/
virtual uint16_t GetChannelNumber () const = 0;
virtual uint16_t GetChannelNumber (void) const = 0;
/**
* \return the required time for channel switch operation of this WifiPhy
*/
virtual Time GetChannelSwitchDelay (void) const = 0;
/**
* Configure the PHY-level parameters for different Wi-Fi standard.

View File

@@ -447,6 +447,18 @@ WifiRemoteStationManager::AddSupportedMode (Mac48Address address, WifiMode mode)
}
state->m_operationalRateSet.push_back (mode);
}
void
WifiRemoteStationManager::AddAllSupportedModes (Mac48Address address)
{
NS_ASSERT (!address.IsGroup ());
WifiRemoteStationState *state = LookupState (address);
state->m_operationalRateSet.clear ();
for (uint32_t i = 0; i < m_wifiPhy->GetNModes (); i++)
{
state->m_operationalRateSet.push_back ( m_wifiPhy->GetMode (i));
}
}
/*void
WifiRemoteStationManager::AddBssMembershipParameters(Mac48Address address, uint32_t selector)
{

View File

@@ -276,6 +276,14 @@ public:
* \param mode the WifiMode supports by the station
*/
void AddSupportedMode (Mac48Address address, WifiMode mode);
/**
* Invoked in a STA or AP to store all of the modes supported
* by a destination which is also supported locally.
* The set of supported modes includes the BSSBasicRateSet.
*
* \param address the address of the station being recorded
*/
void AddAllSupportedModes (Mac48Address address);
//void AddBssMembershipParameters(Mac48Address address, uint32_t selector);
/**

View File

@@ -423,11 +423,17 @@ switchChannel:
}
uint16_t
YansWifiPhy::GetChannelNumber () const
YansWifiPhy::GetChannelNumber (void) const
{
return m_channelNumber;
}
Time
YansWifiPhy::GetChannelSwitchDelay (void) const
{
return m_channelSwitchDelay;
}
double
YansWifiPhy::GetChannelFrequencyMhz () const
{
@@ -792,6 +798,12 @@ YansWifiPhy::RegisterListener (WifiPhyListener *listener)
m_state->RegisterListener (listener);
}
void
YansWifiPhy::UnregisterListener (WifiPhyListener *listener)
{
m_state->UnregisterListener (listener);
}
bool
YansWifiPhy::IsStateCcaBusy (void)
{

View File

@@ -87,7 +87,11 @@ public:
*
* \return the current channel number
*/
uint16_t GetChannelNumber () const;
uint16_t GetChannelNumber (void) const;
/**
* \return the required time for channel switch operation of this WifiPhy
*/
Time GetChannelSwitchDelay (void) const;
/**
* Return current center channel frequency in MHz.
*
@@ -249,6 +253,7 @@ public:
virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
virtual void SendPacket (Ptr<const Packet> packet, WifiTxVector txvector, enum WifiPreamble preamble);
virtual void RegisterListener (WifiPhyListener *listener);
virtual void UnregisterListener (WifiPhyListener *listener);
virtual void SetSleepMode (void);
virtual void ResumeFromSleep (void);
virtual bool IsStateCcaBusy (void);

View File

@@ -37,6 +37,8 @@ private:
virtual void DoNotifyInternalCollision (void);
virtual void DoNotifyCollision (void);
virtual void DoNotifyChannelSwitching (void);
virtual void DoNotifySleep (void);
virtual void DoNotifyWakeUp (void);
typedef std::pair<uint64_t,uint64_t> ExpectedGrant;
typedef std::list<ExpectedGrant> ExpectedGrants;
@@ -136,7 +138,16 @@ DcfStateTest::DoNotifyChannelSwitching (void)
{
m_test->NotifyChannelSwitching (m_i);
}
void
DcfStateTest::DoNotifySleep (void)
{
}
void
DcfStateTest::DoNotifyWakeUp (void)
{
}
DcfManagerTest::DcfManagerTest ()
: TestCase ("DcfManager")