A Discrete-Event Network Simulator
API
yans-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 
23 #ifndef YANS_WIFI_PHY_H
24 #define YANS_WIFI_PHY_H
25 
26 #include <stdint.h>
27 #include "ns3/callback.h"
28 #include "ns3/event-id.h"
29 #include "ns3/packet.h"
30 #include "ns3/object.h"
31 #include "ns3/traced-callback.h"
32 #include "ns3/nstime.h"
33 #include "ns3/ptr.h"
34 #include "ns3/random-variable-stream.h"
35 #include "ns3/mobility-model.h"
36 #include "wifi-phy.h"
37 #include "wifi-mode.h"
38 #include "wifi-preamble.h"
39 #include "wifi-phy-standard.h"
40 #include "interference-helper.h"
41 
42 namespace ns3 {
43 
44 #define VHT_PHY 126
45 #define HT_PHY 127
46 
47 class YansWifiChannel;
48 class WifiPhyStateHelper;
49 
50 
66 class YansWifiPhy : public WifiPhy
67 {
68 public:
69  static TypeId GetTypeId (void);
70 
71  YansWifiPhy ();
72  virtual ~YansWifiPhy ();
73 
85  void SetChannelNumber (uint16_t id);
91  uint16_t GetChannelNumber (void) const;
95  Time GetChannelSwitchDelay (void) const;
101  double GetChannelFrequencyMhz () const;
102 
114  double rxPowerDbm,
115  WifiTxVector txVector,
116  WifiPreamble preamble,
117  enum mpduType mpdutype,
118  Time rxDuration);
128  void StartReceivePacket (Ptr<Packet> packet,
129  WifiTxVector txVector,
130  WifiPreamble preamble,
131  enum mpduType mpdutype,
133 
139  void SetRxNoiseFigure (double noiseFigureDb);
145  void SetTxPowerStart (double start);
151  void SetTxPowerEnd (double end);
159  void SetNTxPower (uint32_t n);
165  void SetTxGain (double gain);
171  void SetRxGain (double gain);
179  void SetEdThreshold (double threshold);
187  void SetCcaMode1Threshold (double threshold);
199  void SetDevice (Ptr<NetDevice> device);
216  double GetRxNoiseFigure (void) const;
222  double GetTxGain (void) const;
228  double GetRxGain (void) const;
234  double GetEdThreshold (void) const;
240  double GetCcaMode1Threshold (void) const;
252  Ptr<NetDevice> GetDevice (void) const;
267  virtual double GetTxPowerStart (void) const;
272  virtual double GetTxPowerEnd (void) const;
278  virtual uint32_t GetNTxPower (void) const;
279 
280  virtual void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
281  virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
282  virtual void SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, enum WifiPreamble preamble);
283  virtual void SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, enum WifiPreamble preamble, enum mpduType mpdutype);
284  virtual void RegisterListener (WifiPhyListener *listener);
285  virtual void UnregisterListener (WifiPhyListener *listener);
286  virtual void SetSleepMode (void);
287  virtual void ResumeFromSleep (void);
288  virtual bool IsStateCcaBusy (void);
289  virtual bool IsStateIdle (void);
290  virtual bool IsStateBusy (void);
291  virtual bool IsStateRx (void);
292  virtual bool IsStateTx (void);
293  virtual bool IsStateSwitching (void);
294  virtual bool IsStateSleep (void);
295  virtual Time GetStateDuration (void);
296  virtual Time GetDelayUntilIdle (void);
297  virtual Time GetLastRxStartTime (void) const;
298  virtual uint32_t GetNModes (void) const;
299  virtual WifiMode GetMode (uint32_t mode) const;
300  virtual bool IsModeSupported (WifiMode mode) const;
301  virtual bool IsMcsSupported (WifiMode mcs);
302  virtual double CalculateSnr (WifiTxVector txVector, double ber) const;
303  virtual Ptr<WifiChannel> GetChannel (void) const;
304 
305  virtual void ConfigureStandard (enum WifiPhyStandard standard);
306 
315  int64_t AssignStreams (int64_t stream);
316 
320  virtual void SetFrequency (uint32_t freq);
324  virtual uint32_t GetFrequency (void) const;
328  virtual void SetNumberOfTransmitAntennas (uint32_t tx);
332  virtual uint32_t GetNumberOfTransmitAntennas (void) const;
336  virtual void SetNumberOfReceiveAntennas (uint32_t rx);
340  virtual uint32_t GetNumberOfReceiveAntennas (void) const;
346  virtual void SetGuardInterval (bool guardInterval);
352  virtual bool GetGuardInterval (void) const;
357  virtual void SetLdpc (bool ldpc);
363  virtual bool GetLdpc (void) const;
369  virtual void SetStbc (bool stbc);
375  virtual bool GetStbc (void) const;
381  virtual void SetGreenfield (bool greenfield);
387  virtual bool GetGreenfield (void) const;
393  virtual void SetShortPlcpPreambleSupported (bool preamble);
399  virtual bool GetShortPlcpPreambleSupported (void) const;
405  virtual uint32_t GetChannelWidth (void) const;
411  virtual void SetChannelWidth (uint32_t channelwidth);
412 
413  virtual uint8_t GetSupportedRxSpatialStreams (void) const;
414  virtual uint8_t GetSupportedTxSpatialStreams (void) const;
415  virtual void AddSupportedChannelWidth (uint32_t width);
416  virtual std::vector<uint32_t> GetSupportedChannelWidthSet (void) const;
417  virtual uint32_t GetNBssMembershipSelectors (void) const;
418  virtual uint32_t GetBssMembershipSelector (uint32_t selector) const;
419  virtual WifiModeList GetMembershipSelectorModes (uint32_t selector);
420 
424  virtual uint8_t GetNMcs (void) const;
425  virtual WifiMode GetMcs (uint8_t mcs) const;
426 
427 private:
428  virtual void DoInitialize (void);
429  virtual void DoDispose (void);
430 
435  void Configure80211a (void);
440  void Configure80211b (void);
445  void Configure80211g (void);
450  void Configure80211_10Mhz (void);
455  void Configure80211_5Mhz ();
456  void ConfigureHolland (void);
461  void Configure80211n (void);
466  void Configure80211ac (void);
471  void ConfigureHtDeviceMcsSet (void);
477  double GetEdThresholdW (void) const;
485  double DbmToW (double dbm) const;
493  double DbToRatio (double db) const;
501  double WToDbm (double w) const;
509  double RatioToDb (double ratio) const;
518  double GetPowerDbm (uint8_t power) const;
527  void EndReceive (Ptr<Packet> packet, enum WifiPreamble preamble, enum mpduType mpdutype, Ptr<InterferenceHelper::Event> event);
528 
530  double m_edThresholdW;
532  double m_txGainDb;
533  double m_rxGainDb;
536  uint32_t m_nTxPower;
537 
539  uint16_t m_channelNumber;
542 
545  bool m_ldpc;
546  bool m_stbc;
549  uint32_t m_channelWidth;
550  std::vector<uint32_t> m_supportedChannelWidthSet;
552 
591 
592  std::vector<uint32_t> m_bssMembershipSelectorSet;
595 
601  uint16_t m_mpdusNum;
605 };
606 
607 } //namespace ns3
608 
609 #endif /* YANS_WIFI_PHY_H */
uint16_t m_channelNumber
Operating channel number.
tuple channel
Definition: third.py:85
virtual double CalculateSnr(WifiTxVector txVector, double ber) const
virtual uint8_t GetSupportedTxSpatialStreams(void) const
virtual bool IsStateBusy(void)
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
uint16_t GetChannelNumber(void) const
Return the current channel number.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
void Configure80211b(void)
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11b standard.
virtual uint32_t GetFrequency(void) const
std::vector< uint32_t > m_supportedChannelWidthSet
Supported channel width.
virtual bool IsModeSupported(WifiMode mode) const
Check if the given WifiMode is supported by the PHY.
EventId m_endPlcpRxEvent
virtual WifiModeList GetMembershipSelectorModes(uint32_t selector)
The WifiPhy::GetMembershipSelectorModes() method is used (e.g., by a WifiRemoteStationManager) to det...
virtual std::vector< uint32_t > GetSupportedChannelWidthSet(void) const
double DbmToW(double dbm) const
Convert from dBm to Watts.
double DbToRatio(double db) const
Convert from dB to ratio.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetErrorRateModel(Ptr< ErrorRateModel > rate)
Sets the error rate model.
virtual void SendPacket(Ptr< const Packet > packet, WifiTxVector txVector, enum WifiPreamble preamble)
virtual bool IsStateSwitching(void)
virtual bool IsStateTx(void)
void Configure80211n(void)
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11n standard.
Ptr< YansWifiChannel > m_channel
YansWifiChannel that this YansWifiPhy is connected to.
void SetTxGain(double gain)
Sets the transmission gain (dB).
802.11 PHY layer model
Definition: wifi-phy.h:151
handles interference calculations
def start()
Definition: core.py:1482
virtual void SetGuardInterval(bool guardInterval)
Enable or disable short/long guard interval.
virtual void SetLdpc(bool ldpc)
Enable or disable LDPC.
virtual void RegisterListener(WifiPhyListener *listener)
double m_txPowerBaseDbm
Minimum transmission power (dBm)
void SetChannelNumber(uint16_t id)
Set the current channel number.
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
virtual bool IsStateSleep(void)
double m_edThresholdW
Energy detection threshold in watts.
void Configure80211_5Mhz()
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11a standard with 5MHz channel spacing.
virtual Time GetDelayUntilIdle(void)
uint32_t m_rxMpduReferenceNumber
A-MPDU reference number to identify all received subframes belonging to the same received A-MPDU...
void Configure80211a(void)
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11a standard.
void Configure80211ac(void)
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11ac standard.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:99
void Configure80211g(void)
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11g standard.
virtual Time GetStateDuration(void)
virtual uint32_t GetNBssMembershipSelectors(void) const
The WifiPhy::NBssMembershipSelectors() method is used (e.g., by a WifiRemoteStationManager) to determ...
double m_rxGainDb
Reception gain (dB)
double GetTxGain(void) const
Return the transmission gain (dB).
bool m_shortPreamble
Flag if short PLCP preamble is supported.
std::vector< uint32_t > m_bssMembershipSelectorSet
void SetMobility(Ptr< MobilityModel > mobility)
assign a mobility model to this device
virtual void SetChannelWidth(uint32_t channelwidth)
Set channel width.
virtual void SetReceiveErrorCallback(WifiPhy::RxErrorCallback callback)
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:30
virtual uint32_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
virtual bool IsStateRx(void)
virtual uint8_t GetNMcs(void) const
virtual double GetTxPowerStart(void) const
Return the minimum available transmission power level (dBm).
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
virtual WifiMode GetMode(uint32_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
double m_channelStartingFrequency
Standard-dependent center frequency of 0-th channel in MHz.
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.
void SetEdThreshold(double threshold)
Sets the energy detection threshold (dBm).
bool m_ldpc
Flag if LDPC is used.
tuple mobility
Definition: third.py:101
receive notifications about phy events.
Definition: wifi-phy.h:70
virtual bool GetStbc(void) const
Return whether STBC is supported.
bool m_stbc
Flag if STBC is used.
WifiModeList m_deviceRateSet
This vector holds the set of transmission modes that this WifiPhy(-derived class) can support...
double m_ccaMode1ThresholdW
Clear channel assessment (CCA) threshold in watts.
virtual void DoDispose(void)
Destructor implementation.
virtual void SetStbc(bool stbc)
Enable or disable STBC.
virtual uint32_t GetBssMembershipSelector(uint32_t selector) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
virtual WifiMode GetMcs(uint8_t mcs) const
The WifiPhy::GetMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of tr...
double GetRxGain(void) const
Return the reception gain (dB).
uint32_t m_txMpduReferenceNumber
A-MPDU reference number to identify all transmitted subframes belonging to the same received A-MPDU...
double GetChannelFrequencyMhz() const
Return current center channel frequency in MHz.
double WToDbm(double w) const
Convert from Watts to dBm.
void SetChannel(Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
void SetNTxPower(uint32_t n)
Sets the number of transmission power levels available between the minimum level and the maximum leve...
virtual void SetShortPlcpPreambleSupported(bool preamble)
Enable or disable short PLCP preamble.
virtual bool IsStateCcaBusy(void)
virtual void AddSupportedChannelWidth(uint32_t width)
virtual ~YansWifiPhy()
double m_txPowerEndDbm
Maximum transmission power (dBm)
virtual void SetReceiveOkCallback(WifiPhy::RxOkCallback callback)
virtual void UnregisterListener(WifiPhyListener *listener)
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
double GetCcaMode1Threshold(void) const
Return the CCA threshold (dBm).
Every class exported by the ns3 library is enclosed in the ns3 namespace.
802.11 PHY layer modelThis PHY implements a model of 802.11a.
Definition: yans-wifi-phy.h:66
double GetEdThreshold(void) const
Return the energy detection threshold (dBm).
static TypeId GetTypeId(void)
virtual uint32_t GetNumberOfTransmitAntennas(void) const
virtual bool GetShortPlcpPreambleSupported(void) const
Return whether short PLCP preamble is supported.
virtual uint32_t GetNumberOfReceiveAntennas(void) const
uint32_t m_nTxPower
Number of available transmission power levels.
void SetRxGain(double gain)
Sets the reception gain (dB).
WifiModeList m_deviceMcsSet
virtual void SetSleepMode(void)
Put in sleep mode.
std::vector< WifiMode > WifiModeList
In various parts of the code, folk are interested in maintaining a list of transmission modes...
Definition: wifi-mode.h:225
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
double RatioToDb(double ratio) const
Convert from ratio to dB.
virtual void SetNumberOfTransmitAntennas(uint32_t tx)
virtual void DoInitialize(void)
Initialize() implementation.
Time GetChannelSwitchDelay(void) const
virtual bool IsStateIdle(void)
virtual Time GetLastRxStartTime(void) const
Return the start time of the last received packet.
virtual bool GetGreenfield(void) const
Return whether Greenfield is supported.
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
Ptr< NetDevice > m_device
Pointer to the device.
void StartReceivePreambleAndHeader(Ptr< Packet > packet, double rxPowerDbm, WifiTxVector txVector, WifiPreamble preamble, enum mpduType mpdutype, Time rxDuration)
Starting receiving the plcp of a packet (i.e.
InterferenceHelper m_interference
Pointer to InterferenceHelper.
virtual bool GetGuardInterval(void) const
Return whether guard interval is being used.
An identifier for simulation events.
Definition: event-id.h:53
Time m_channelSwitchDelay
Time required to switch between channel.
virtual void ConfigureStandard(enum WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
uint32_t m_channelWidth
Channel width.
void ConfigureHtDeviceMcsSet(void)
Configure the device Mcs set with the appropriate HtMcs modes for the number of available transmit sp...
virtual bool GetLdpc(void) const
Return if LDPC is supported.
uint16_t m_mpdusNum
carries the number of expected mpdus that are part of an A-MPDU
double m_txGainDb
Transmission gain (dB)
bool m_greenfield
Flag if GreenField format is supported.
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
bool m_guardInterval
Flag if short guard interval is used.
virtual uint32_t GetChannelWidth(void) const
Return channel width.
virtual void SetNumberOfReceiveAntennas(uint32_t rx)
void SetDevice(Ptr< NetDevice > device)
Sets the device this PHY is associated with.
uint32_t m_numberOfTransmitters
Number of transmitters.
virtual bool IsMcsSupported(WifiMode mcs)
double GetEdThresholdW(void) const
Return the energy detection threshold.
virtual Ptr< WifiChannel > GetChannel(void) const
Return the WifiChannel this WifiPhy is connected to.
void SetCcaMode1Threshold(double threshold)
Sets the CCA threshold (dBm).
void ConfigureHolland(void)
Ptr< NetDevice > GetDevice(void) const
Return the device this PHY is associated with.
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
virtual uint8_t GetSupportedRxSpatialStreams(void) const
double GetRxNoiseFigure(void) const
Return the RX noise figure (dBm).
virtual double GetTxPowerEnd(void) const
Return the maximum available transmission power level (dBm).
void EndReceive(Ptr< Packet > packet, enum WifiPreamble preamble, enum mpduType mpdutype, Ptr< InterferenceHelper::Event > event)
The last bit of the packet has arrived.
a unique identifier for an interface.
Definition: type-id.h:58
uint32_t m_numberOfReceivers
Number of receivers.
virtual void ResumeFromSleep(void)
Resume from sleep mode.
bool m_plcpSuccess
Flag if the PLCP of the packet or the first MPDU in an A-MPDU has been received.
bool m_initialized
Flag for runtime initialization.
virtual void SetFrequency(uint32_t freq)
void Configure80211_10Mhz(void)
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11a standard with 10MHz channel spacing.
virtual uint32_t GetNTxPower(void) const
Return the number of available transmission power levels.
mpduType
This enumeration defines the type of an MPDU.
Definition: wifi-phy.h:45
void SetRxNoiseFigure(double noiseFigureDb)
Sets the RX loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.
Ptr< ErrorRateModel > GetErrorRateModel(void) const
Return the error rate model this PHY is using.
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
Ptr< MobilityModel > GetMobility(void)
Return the mobility model this PHY is associated with.
virtual void SetGreenfield(bool greenfield)
Enable or disable Greenfield support.