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  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  * Author: ghada Badawy <gbadawy@gmail.com>
20  */
21 
22 #ifndef YANS_WIFI_PHY_H
23 #define YANS_WIFI_PHY_H
24 
25 #include <stdint.h>
26 #include "ns3/callback.h"
27 #include "ns3/event-id.h"
28 #include "ns3/packet.h"
29 #include "ns3/object.h"
30 #include "ns3/traced-callback.h"
31 #include "ns3/nstime.h"
32 #include "ns3/ptr.h"
33 #include "ns3/random-variable-stream.h"
34 #include "wifi-phy.h"
35 #include "wifi-mode.h"
36 #include "wifi-preamble.h"
37 #include "wifi-phy-standard.h"
38 #include "interference-helper.h"
39 
40 
41 namespace ns3 {
42 
43 #define HT_PHY 127
44 
45 class YansWifiChannel;
46 class WifiPhyStateHelper;
47 
48 
64 class YansWifiPhy : public WifiPhy
65 {
66 public:
67  static TypeId GetTypeId (void);
68 
69  YansWifiPhy ();
70  virtual ~YansWifiPhy ();
71 
77  void SetChannel (Ptr<YansWifiChannel> channel);
78 
84  void SetChannelNumber (uint16_t id);
90  uint16_t GetChannelNumber (void) const;
94  Time GetChannelSwitchDelay (void) const;
100  double GetChannelFrequencyMhz () const;
101 
112  void StartReceivePacket (Ptr<Packet> packet,
113  double rxPowerDbm,
114  WifiTxVector txVector,
115  WifiPreamble preamble,
116  uint8_t packetType,
117  Time rxDuration);
118 
124  void SetRxNoiseFigure (double noiseFigureDb);
130  void SetTxPowerStart (double start);
136  void SetTxPowerEnd (double end);
144  void SetNTxPower (uint32_t n);
150  void SetTxGain (double gain);
156  void SetRxGain (double gain);
164  void SetEdThreshold (double threshold);
172  void SetCcaMode1Threshold (double threshold);
184  void SetDevice (Ptr<Object> device);
190  void SetMobility (Ptr<Object> mobility);
196  double GetRxNoiseFigure (void) const;
202  double GetTxGain (void) const;
208  double GetRxGain (void) const;
214  double GetEdThreshold (void) const;
220  double GetCcaMode1Threshold (void) const;
232  Ptr<Object> GetDevice (void) const;
238  Ptr<Object> GetMobility (void);
239 
244  virtual double GetTxPowerStart (void) const;
249  virtual double GetTxPowerEnd (void) const;
255  virtual uint32_t GetNTxPower (void) const;
256  virtual void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
257  virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
258  virtual void SendPacket (Ptr<const Packet> packet, WifiTxVector txvector, enum WifiPreamble preamble, uint8_t packetType);
259  virtual void RegisterListener (WifiPhyListener *listener);
260  virtual void UnregisterListener (WifiPhyListener *listener);
261  virtual void SetSleepMode (void);
262  virtual void ResumeFromSleep (void);
263  virtual bool IsStateCcaBusy (void);
264  virtual bool IsStateIdle (void);
265  virtual bool IsStateBusy (void);
266  virtual bool IsStateRx (void);
267  virtual bool IsStateTx (void);
268  virtual bool IsStateSwitching (void);
269  virtual bool IsStateSleep (void);
270  virtual Time GetStateDuration (void);
271  virtual Time GetDelayUntilIdle (void);
272  virtual Time GetLastRxStartTime (void) const;
273  virtual uint32_t GetNModes (void) const;
274  virtual WifiMode GetMode (uint32_t mode) const;
275  virtual bool IsModeSupported (WifiMode mode) const;
276  virtual bool IsMcsSupported (WifiMode mode);
277  virtual double CalculateSnr (WifiMode txMode, double ber) const;
278  virtual Ptr<WifiChannel> GetChannel (void) const;
279 
280  virtual void ConfigureStandard (enum WifiPhyStandard standard);
281 
290  int64_t AssignStreams (int64_t stream);
291 
295  virtual void SetFrequency (uint32_t freq);
299  virtual uint32_t GetFrequency (void) const;
303  virtual void SetNumberOfTransmitAntennas (uint32_t tx);
304  virtual uint32_t GetNumberOfTransmitAntennas (void) const;
308  virtual void SetNumberOfReceiveAntennas (uint32_t rx) ;
312  virtual uint32_t GetNumberOfReceiveAntennas (void) const;
318  virtual void SetGuardInterval (bool guardInterval);
324  virtual bool GetGuardInterval (void) const;
329  virtual void SetLdpc (bool ldpc);
335  virtual bool GetLdpc (void) const;
341  virtual void SetStbc (bool stbc);
347  virtual bool GetStbc (void) const;
353  virtual void SetGreenfield (bool greenfield);
359  virtual bool GetGreenfield (void) const;
365  virtual bool GetChannelBonding (void) const ;
371  virtual void SetChannelBonding (bool channelbonding) ;
372 
373  virtual uint32_t GetNBssMembershipSelectors (void) const;
374  virtual uint32_t GetBssMembershipSelector (uint32_t selector) const;
375  virtual WifiModeList GetMembershipSelectorModes(uint32_t selector);
379  virtual uint8_t GetNMcs (void) const;
380  virtual uint8_t GetMcs (uint8_t mcs) const;
381 
382  virtual uint32_t WifiModeToMcs (WifiMode mode);
383  virtual WifiMode McsToWifiMode (uint8_t mcs);
384 
385 private:
386  //YansWifiPhy (const YansWifiPhy &o);
387  virtual void DoDispose (void);
392  void Configure80211a (void);
397  void Configure80211b (void);
402  void Configure80211g (void);
407  void Configure80211_10Mhz (void);
412  void Configure80211_5Mhz ();
413  void ConfigureHolland (void);
418  void Configure80211n (void);
424  double GetEdThresholdW (void) const;
431  double DbmToW (double dbm) const;
438  double DbToRatio (double db) const;
445  double WToDbm (double w) const;
452  double RatioToDb (double ratio) const;
460  double GetPowerDbm (uint8_t power) const;
468 
469 private:
470  virtual void DoInitialize (void);
471 
473  double m_edThresholdW;
475  double m_txGainDb;
476  double m_rxGainDb;
479  uint32_t m_nTxPower;
480 
482  uint16_t m_channelNumber;
485 
488  bool m_ldpc;
489  bool m_stbc;
493 
494 
532 
533  std::vector<uint32_t> m_bssMembershipSelectorSet;
534  std::vector<uint8_t> m_deviceMcsSet;
536 
542  uint16_t m_mpdusNum;
543 };
544 
545 } // namespace ns3
546 
547 
548 #endif /* YANS_WIFI_PHY_H */
uint16_t m_channelNumber
Operating channel number.
bool m_channelBonding
Flag if channel bonding is used.
Ptr< Object > m_mobility
Pointer to the mobility model.
virtual bool IsStateBusy(void)
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
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
virtual bool IsModeSupported(WifiMode mode) const
Check if the given WifiMode is supported by the PHY.
virtual WifiModeList GetMembershipSelectorModes(uint32_t selector)
The WifiPhy::GetMembershipSelectorModes() method is used (e.g., by a WifiRemoteStationManager) to det...
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 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:126
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)
virtual bool IsMcsSupported(WifiMode mode)
void SetChannelNumber(uint16_t id)
Set the current channel number.
virtual bool IsStateSleep(void)
Ptr< Object > GetDevice(void) const
Return the device this PHY is associated with.
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)
void Configure80211a(void)
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11a standard.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:93
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).
virtual bool GetChannelBonding(void) const
Return whether channel bonding is supported.
std::vector< uint32_t > m_bssMembershipSelectorSet
virtual void SetReceiveErrorCallback(WifiPhy::RxErrorCallback callback)
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:29
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 SetEdThreshold(double threshold)
Sets the energy detection threshold (dBm).
bool m_ldpc
Flag if LDPC is used.
virtual uint8_t GetMcs(uint8_t mcs) const
The WifiPhy::GetMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of tr...
receive notifications about phy events.
Definition: wifi-phy.h:44
virtual bool GetStbc(void) const
Return whether STBC is supported.
bool m_stbc
Flag if STBC is used.
Ptr< Object > m_device
Pointer to the device.
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...
double GetRxGain(void) const
Return the reception gain (dB).
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 bool IsStateCcaBusy(void)
virtual ~YansWifiPhy()
void SetDevice(Ptr< Object > device)
Sets the device this PHY is associated with.
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:64
double GetEdThreshold(void) const
Return the energy detection threshold (dBm).
static TypeId GetTypeId(void)
virtual uint32_t GetNumberOfTransmitAntennas(void) const
virtual uint32_t WifiModeToMcs(WifiMode mode)
For a given WifiMode finds the corresponding MCS value and returns it as defined in the IEEE 802...
virtual uint32_t GetNumberOfReceiveAntennas(void) const
uint32_t m_nTxPower
Number of available transmission power levels.
virtual void SendPacket(Ptr< const Packet > packet, WifiTxVector txvector, enum WifiPreamble preamble, uint8_t packetType)
void SetRxGain(double gain)
Sets the reception gain (dB).
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:177
virtual WifiMode McsToWifiMode(uint8_t mcs)
For a given MCS finds the corresponding WifiMode and returns it as defined in the IEEE 802...
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 double CalculateSnr(WifiMode txMode, double ber) const
virtual bool GetGreenfield(void) const
Return whether Greenfield is supported.
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
InterferenceHelper m_interference
Pointer to InterferenceHelper.
virtual bool GetGuardInterval(void) const
Return whether guard interval is being used.
void StartReceivePacket(Ptr< Packet > packet, double rxPowerDbm, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType, Time rxDuration)
Starting receiving the packet (i.e.
void SetMobility(Ptr< Object > mobility)
Sets the mobility model.
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.
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
std::vector< uint8_t > m_deviceMcsSet
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.
void EndReceive(Ptr< Packet > packet, Ptr< InterferenceHelper::Event > event)
The last bit of the packet has arrived.
virtual void SetNumberOfReceiveAntennas(uint32_t rx)
uint32_t m_numberOfTransmitters
Number of transmitters.
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)
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
double GetRxNoiseFigure(void) const
Return the RX noise figure (dBm).
virtual double GetTxPowerEnd(void) const
Return the maximum available transmission power level (dBm).
a unique identifier for an interface.
Definition: type-id.h:51
uint32_t m_numberOfReceivers
Number of receivers.
virtual void ResumeFromSleep(void)
Resume from sleep mode.
virtual void SetChannelBonding(bool channelbonding)
Enable or disable channel bonding support.
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.
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< Object > GetMobility(void)
Return the mobility model this PHY is associated with.
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
virtual void SetGreenfield(bool greenfield)
Enable or disable Greenfield support.