A Discrete-Event Network Simulator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
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  */
22 #ifndef YANS_WIFI_PHY_H
23 #define YANS_WIFI_PHY_H
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"
41 namespace ns3 {
43 #define HT_PHY 127
45 class YansWifiChannel;
46 class WifiPhyStateHelper;
64 class YansWifiPhy : public WifiPhy
65 {
66 public:
67  static TypeId GetTypeId (void);
69  YansWifiPhy ();
70  virtual ~YansWifiPhy ();
77  void SetChannel (Ptr<YansWifiChannel> channel);
84  void SetChannelNumber (uint16_t id);
90  uint16_t GetChannelNumber () const;
96  double GetChannelFrequencyMhz () const;
106  void StartReceivePacket (Ptr<Packet> packet,
107  double rxPowerDbm,
108  WifiTxVector txVector,
109  WifiPreamble preamble);
116  void SetRxNoiseFigure (double noiseFigureDb);
122  void SetTxPowerStart (double start);
128  void SetTxPowerEnd (double end);
136  void SetNTxPower (uint32_t n);
142  void SetTxGain (double gain);
148  void SetRxGain (double gain);
156  void SetEdThreshold (double threshold);
164  void SetCcaMode1Threshold (double threshold);
176  void SetDevice (Ptr<Object> device);
182  void SetMobility (Ptr<Object> mobility);
188  double GetRxNoiseFigure (void) const;
194  double GetTxGain (void) const;
200  double GetRxGain (void) const;
206  double GetEdThreshold (void) const;
212  double GetCcaMode1Threshold (void) const;
224  Ptr<Object> GetDevice (void) const;
230  Ptr<Object> GetMobility (void);
236  virtual double GetTxPowerStart (void) const;
241  virtual double GetTxPowerEnd (void) const;
247  virtual uint32_t GetNTxPower (void) const;
248  virtual void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
249  virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
250  virtual void SendPacket (Ptr<const Packet> packet, WifiMode mode, enum WifiPreamble preamble, WifiTxVector txvector);
251  virtual void RegisterListener (WifiPhyListener *listener);
252  virtual bool IsStateCcaBusy (void);
253  virtual bool IsStateIdle (void);
254  virtual bool IsStateBusy (void);
255  virtual bool IsStateRx (void);
256  virtual bool IsStateTx (void);
257  virtual bool IsStateSwitching (void);
258  virtual Time GetStateDuration (void);
259  virtual Time GetDelayUntilIdle (void);
260  virtual Time GetLastRxStartTime (void) const;
261  virtual uint32_t GetNModes (void) const;
262  virtual WifiMode GetMode (uint32_t mode) const;
263  virtual bool IsModeSupported (WifiMode mode) const;
264  virtual bool IsMcsSupported (WifiMode mode);
265  virtual double CalculateSnr (WifiMode txMode, double ber) const;
266  virtual Ptr<WifiChannel> GetChannel (void) const;
268  virtual void ConfigureStandard (enum WifiPhyStandard standard);
278  int64_t AssignStreams (int64_t stream);
283  virtual void SetFrequency (uint32_t freq);
287  virtual uint32_t GetFrequency (void) const;
291  virtual void SetNumberOfTransmitAntennas (uint32_t tx);
292  virtual uint32_t GetNumberOfTransmitAntennas (void) const;
296  virtual void SetNumberOfReceiveAntennas (uint32_t rx) ;
300  virtual uint32_t GetNumberOfReceiveAntennas (void) const;
306  virtual void SetGuardInterval (bool guardInterval);
312  virtual bool GetGuardInterval (void) const;
317  virtual void SetLdpc (bool ldpc);
323  virtual bool GetLdpc (void) const;
329  virtual void SetStbc (bool stbc);
335  virtual bool GetStbc (void) const;
341  virtual void SetGreenfield (bool greenfield);
347  virtual bool GetGreenfield (void) const;
353  virtual bool GetChannelBonding (void) const ;
359  virtual void SetChannelBonding (bool channelbonding) ;
361  virtual uint32_t GetNBssMembershipSelectors (void) const;
362  virtual uint32_t GetBssMembershipSelector (uint32_t selector) const;
363  virtual WifiModeList GetMembershipSelectorModes(uint32_t selector);
367  virtual uint8_t GetNMcs (void) const;
368  virtual uint8_t GetMcs (uint8_t mcs) const;
370  virtual uint32_t WifiModeToMcs (WifiMode mode);
371  virtual WifiMode McsToWifiMode (uint8_t mcs);
373 private:
374  //YansWifiPhy (const YansWifiPhy &o);
375  virtual void DoDispose (void);
380  void Configure80211a (void);
385  void Configure80211b (void);
390  void Configure80211g (void);
395  void Configure80211_10Mhz (void);
400  void Configure80211_5Mhz ();
401  void ConfigureHolland (void);
406  void Configure80211n (void);
412  double GetEdThresholdW (void) const;
419  double DbmToW (double dbm) const;
426  double DbToRatio (double db) const;
433  double WToDbm (double w) const;
440  double RatioToDb (double ratio) const;
448  double GetPowerDbm (uint8_t power) const;
457 private:
458  double m_edThresholdW;
460  double m_txGainDb;
461  double m_rxGainDb;
464  uint32_t m_nTxPower;
467  uint16_t m_channelNumber;
473  bool m_ldpc;
474  bool m_stbc;
518  std::vector<uint32_t> m_bssMembershipSelectorSet;
519  std::vector<uint8_t> m_deviceMcsSet;
528 };
530 } // namespace ns3
533 #endif /* YANS_WIFI_PHY_H */
uint16_t m_channelNumber
Operating channel number.
bool m_channelBonding
Flag if channel conding 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:79
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
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:117
handles interference calculations
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)
uint16_t GetChannelNumber() const
Return the current channel number.
void SetChannelNumber(uint16_t id)
Set the current channel number.
virtual void SendPacket(Ptr< const Packet > packet, WifiMode mode, enum WifiPreamble preamble, WifiTxVector txvector)
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:91
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)
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).
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)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
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)
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).
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.
void SetRxGain(double gain)
Sets the reception gain (dB).
std::vector< WifiMode > WifiModeList
In various parts of the code, folk are interested in maintaining a list of transmission modes...
Definition: wifi-mode.h:188
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 bool IsStateIdle(void)
void StartReceivePacket(Ptr< Packet > packet, double rxPowerDbm, WifiTxVector txVector, WifiPreamble preamble)
Starting receiving the packet (i.e.
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 SetMobility(Ptr< Object > mobility)
Sets the mobility model.
an identifier for simulation events.
Definition: event-id.h:46
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.
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:49
uint32_t m_numberOfReceivers
Number of receivers.
virtual void SetChannelBonding(bool channelbonding)
Enable or disable channel bonding support.
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.