A Discrete-Event Network Simulator
API
spectrum-wifi-phy.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  * Ghada Badawy <gbadawy@gmail.com>
20  * Sébastien Deronne <sebastien.deronne@gmail.com>
21  *
22  * Ported from yans-wifi-phy.h by several contributors starting
23  * with Nicola Baldo and Dean Armstrong
24  */
25 
26 #ifndef SPECTRUM_WIFI_PHY_H
27 #define SPECTRUM_WIFI_PHY_H
28 
29 #include "ns3/antenna-model.h"
30 #include "wifi-phy.h"
32 #include "ns3/spectrum-channel.h"
33 #include "ns3/spectrum-interference.h"
34 
35 namespace ns3 {
36 
49 class SpectrumWifiPhy : public WifiPhy
50 {
51 public:
52  static TypeId GetTypeId (void);
53 
54  SpectrumWifiPhy ();
55  virtual ~SpectrumWifiPhy ();
56 
69  void AddOperationalChannel (uint16_t channelNumber);
77  std::vector<uint16_t> GetOperationalChannelList (void) const;
81  void ClearOperationalChannelList (void);
82 
92  void StartReceivePacket (Ptr<Packet> packet,
93  WifiTxVector txVector,
94  WifiPreamble preamble,
95  enum mpduType mpdutype,
97 
104  void StartRx (Ptr<SpectrumSignalParameters> rxParams);
128  void SetAntenna (Ptr<AntennaModel> antenna);
134  Ptr<AntennaModel> GetRxAntenna (void) const;
153  void SetPacketReceivedCallback (RxCallback callback);
154 
163  typedef void (* SignalArrivalCallback) (bool signalType, uint32_t senderNodeId, double rxPower, Time duration);
164 
165  virtual void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
166  virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
167  virtual void SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, enum WifiPreamble preamble);
168  virtual void SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, enum WifiPreamble preamble, enum mpduType mpdutype);
169  virtual void RegisterListener (WifiPhyListener *listener);
170  virtual void UnregisterListener (WifiPhyListener *listener);
171  virtual void SetSleepMode (void);
172  virtual void ResumeFromSleep (void);
173  virtual Ptr<WifiChannel> GetChannel (void) const;
174 
175 protected:
176  // Inherited
177  virtual void DoDispose (void);
178  virtual void DoInitialize (void);
179  virtual bool DoChannelSwitch (uint16_t id);
180  virtual bool DoFrequencySwitch (uint32_t frequency);
181 
182 private:
191  void EndReceive (Ptr<Packet> packet, enum WifiPreamble preamble, enum mpduType mpdutype, Ptr<InterferenceHelper::Event> event);
192 
199  void SwitchMaybeToCcaBusy (void);
200 
210  Ptr<SpectrumValue> GetTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW) const;
211 
213  std::vector<uint16_t> m_operationalChannelList;
214 
218  RxCallback m_rxCallback;
221 
222 };
223 
224 } //namespace ns3
225 
226 #endif /* SPECTRUM_WIFI_PHY_H */
Ptr< SpectrumValue > GetTxPowerSpectralDensity(uint32_t centerFrequency, uint32_t channelWidth, double txPowerW) const
tuple channel
Definition: third.py:85
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
virtual bool DoChannelSwitch(uint16_t id)
The default implementation does nothing and returns true.
TracedCallback< bool, uint32_t, double, Time > m_signalCb
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void StartReceivePacket(Ptr< Packet > packet, WifiTxVector txVector, WifiPreamble preamble, enum mpduType mpdutype, Ptr< InterferenceHelper::Event > event)
Starting receiving the payload of a packet (i.e.
virtual void SetReceiveErrorCallback(WifiPhy::RxErrorCallback callback)
void StartRx(Ptr< SpectrumSignalParameters > rxParams)
Input method for delivering a signal from the spectrum channel and low-level Phy interface to this Sp...
void SetChannel(Ptr< SpectrumChannel > channel)
Set the SpectrumChannel this SpectrumWifiPhy is to be connected to.
802.11 PHY layer model
Definition: wifi-phy.h:162
Forward calls to a chain of Callback.
void SetAntenna(Ptr< AntennaModel > antenna)
static TypeId GetTypeId(void)
bool m_disableWifiReception
forces this Phy to fail to sync on any signal
virtual Ptr< WifiChannel > GetChannel(void) const
Return the WifiChannel this WifiPhy is connected to.
Ptr< const SpectrumModel > GetRxSpectrumModel() const
Ptr< WifiSpectrumPhyInterface > GetSpectrumPhy(void) const
virtual void UnregisterListener(WifiPhyListener *listener)
virtual void SetSleepMode(void)
Put in sleep mode.
void(* SignalArrivalCallback)(bool signalType, uint32_t senderNodeId, double rxPower, Time duration)
Callback invoked when the Phy model starts to process a signal.
virtual void DoInitialize(void)
Initialize() implementation.
Ptr< SpectrumChannel > m_channel
SpectrumChannel that this SpectrumWifiPhy is connected to.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:30
std::vector< uint16_t > GetOperationalChannelList(void) const
Return a list of channels to which it may be possible to roam By default, this method will return the...
Callback< void, bool > RxCallback
Callback invoked at the end of a frame reception, to notify whether the frame was received successful...
Ptr< AntennaModel > GetRxAntenna(void) const
Get the antenna model used for reception.
receive notifications about phy events.
Definition: wifi-phy.h:81
virtual void DoDispose(void)
Destructor implementation.
void SetPacketReceivedCallback(RxCallback callback)
Set the packet received callback (invoked at the end of a frame reception), to notify whether the fra...
802.11 PHY layer modelThis PHY implements a spectrum-aware enhancement of the 802.11 SpectrumWifiPhy model.
virtual void RegisterListener(WifiPhyListener *listener)
Ptr< const SpectrumModel > m_rxSpectrumModel
void AddOperationalChannel(uint16_t channelNumber)
Add a channel number to the list of operational channels.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void SetReceiveOkCallback(WifiPhy::RxOkCallback callback)
void EndReceive(Ptr< Packet > packet, enum WifiPreamble preamble, enum mpduType mpdutype, Ptr< InterferenceHelper::Event > event)
The last bit of the packet has arrived.
virtual void SendPacket(Ptr< const Packet > packet, WifiTxVector txVector, enum WifiPreamble preamble)
Ptr< AntennaModel > m_antenna
void ClearOperationalChannelList(void)
Clear the list of operational channels.
Ptr< WifiSpectrumPhyInterface > m_wifiSpectrumPhyInterface
std::vector< uint16_t > m_operationalChannelList
List of possible channels.
void SwitchMaybeToCcaBusy(void)
Check if Phy state should move to CCA busy state based on current state of interference tracker...
virtual void ResumeFromSleep(void)
Resume from sleep mode.
a unique identifier for an interface.
Definition: type-id.h:58
void CreateWifiSpectrumPhyInterface(Ptr< NetDevice > device)
Method to encapsulate the creation of the WifiSpectrumPhyInterface object (used to bind the WifiSpect...
mpduType
This enumeration defines the type of an MPDU.
Definition: wifi-phy.h:56
virtual bool DoFrequencySwitch(uint32_t frequency)
The default implementation does nothing and returns true.