A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
yans-wifi-phy.h
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  */
20 
21 #ifndef YANS_WIFI_PHY_H
22 #define YANS_WIFI_PHY_H
23 
24 #include <stdint.h>
25 #include "ns3/callback.h"
26 #include "ns3/event-id.h"
27 #include "ns3/packet.h"
28 #include "ns3/object.h"
29 #include "ns3/traced-callback.h"
30 #include "ns3/nstime.h"
31 #include "ns3/ptr.h"
32 #include "ns3/random-variable-stream.h"
33 #include "wifi-phy.h"
34 #include "wifi-mode.h"
35 #include "wifi-preamble.h"
36 #include "wifi-phy-standard.h"
37 #include "interference-helper.h"
38 
39 
40 namespace ns3 {
41 
42 class YansWifiChannel;
43 class WifiPhyStateHelper;
44 
45 
61 class YansWifiPhy : public WifiPhy
62 {
63 public:
64  static TypeId GetTypeId (void);
65 
66  YansWifiPhy ();
67  virtual ~YansWifiPhy ();
68 
69  void SetChannel (Ptr<YansWifiChannel> channel);
70 
86  void SetChannelNumber (uint16_t id);
87 
94  void StartSensing (Time duration);
95 
97  uint16_t GetChannelNumber () const;
99  double GetChannelFrequencyMhz () const;
100 
101  void StartReceivePacket (Ptr<Packet> packet,
102  double rxPowerDbm,
103  WifiMode mode,
104  WifiPreamble preamble);
105 
106  void SetRxNoiseFigure (double noiseFigureDb);
107  void SetTxPowerStart (double start);
108  void SetTxPowerEnd (double end);
109  void SetNTxPower (uint32_t n);
110  void SetTxGain (double gain);
111  void SetRxGain (double gain);
112  void SetEdThreshold (double threshold);
113  void SetCcaMode1Threshold (double threshold);
114  void SetErrorRateModel (Ptr<ErrorRateModel> rate);
115  void SetDevice (Ptr<Object> device);
116  void SetMobility (Ptr<Object> mobility);
117  double GetRxNoiseFigure (void) const;
118  double GetTxGain (void) const;
119  double GetRxGain (void) const;
120  double GetEdThreshold (void) const;
121  double GetCcaMode1Threshold (void) const;
122  Ptr<ErrorRateModel> GetErrorRateModel (void) const;
123  Ptr<Object> GetDevice (void) const;
124  Ptr<Object> GetMobility (void);
125  Time GetSwitchingDelay(void);
126 
127 
128 
129 
130  virtual double GetTxPowerStart (void) const;
131  virtual double GetTxPowerEnd (void) const;
132  virtual uint32_t GetNTxPower (void) const;
133  virtual void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
134  virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
135  virtual void SetSenseEndedCallback(WifiPhy::SnsEndedCallback callback);
137  virtual void SendPacket (Ptr<const Packet> packet, WifiMode mode, enum WifiPreamble preamble, uint8_t txPowerLevel);
138  virtual void RegisterListener (WifiPhyListener *listener);
139  virtual bool IsStateCcaBusy (void);
140  virtual bool IsStateIdle (void);
141  virtual bool IsStateBusy (void);
142  virtual bool IsStateRx (void);
143  virtual bool IsStateTx (void);
144  virtual bool IsStateSwitching (void);
145  virtual bool IsStateSensing (void);
146  virtual Time GetStateDuration (void);
147  virtual Time GetDelayUntilIdle (void);
148  virtual Time GetLastRxStartTime (void) const;
149  virtual uint32_t GetNModes (void) const;
150  virtual WifiMode GetMode (uint32_t mode) const;
151  virtual double CalculateSnr (WifiMode txMode, double ber) const;
152  virtual Ptr<WifiChannel> GetChannel (void) const;
153  virtual void ConfigureStandard (enum WifiPhyStandard standard);
154 
163  int64_t AssignStreams (int64_t stream);
164 
165 private:
166  YansWifiPhy (const YansWifiPhy &o);
167  virtual void DoDispose (void);
168  void Configure80211a (void);
169  void Configure80211b (void);
170  void Configure80211g (void);
171  void Configure80211_10Mhz (void);
172  void Configure80211_5Mhz ();
173  void ConfigureHolland (void);
174  void Configure80211p_CCH (void);
175  void Configure80211p_SCH (void);
176  double GetEdThresholdW (void) const;
177  double DbmToW (double dbm) const;
178  double DbToRatio (double db) const;
179  double WToDbm (double w) const;
180  double RatioToDb (double ratio) const;
181  double GetPowerDbm (uint8_t power) const;
182  void EndReceive (Ptr<Packet> packet, Ptr<InterferenceHelper::Event> event);
183 
184 private:
185  double m_edThresholdW;
186  double m_ccaMode1ThresholdW;
187  double m_txGainDb;
188  double m_rxGainDb;
189  double m_txPowerBaseDbm;
190  double m_txPowerEndDbm;
191  uint32_t m_nTxPower;
192 
193  Ptr<YansWifiChannel> m_channel;
194  uint16_t m_channelNumber;
195  Ptr<Object> m_device;
196  Ptr<Object> m_mobility;
197 
235 
236  EventId m_endRxEvent;
241  Ptr<WifiPhyStateHelper> m_state;
242  InterferenceHelper m_interference;
243  Time m_channelSwitchDelay;
244 
245  //sensing ended callback
246  SnsEndedCallback m_senseEndedCallback;
247  //handoff ended callback
248  HandoffEndedCallback m_handoffEndedCallback;
249 
250 
251 };
252 
253 } // namespace ns3
254 
255 
256 #endif /* YANS_WIFI_PHY_H */
void StartSensing(Time duration)
Start sensing on current channel.
virtual bool IsStateBusy(void)
keep track of time unit.
Definition: nstime.h:149
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
virtual bool IsStateSwitching(void)
virtual bool IsStateTx(void)
802.11 PHY layer model
Definition: wifi-phy.h:121
handles interference calculations
virtual void RegisterListener(WifiPhyListener *listener)
uint16_t GetChannelNumber() const
Return current channel number, see SetChannelNumber()
void SetChannelNumber(uint16_t id)
Set channel number.
virtual Time GetDelayUntilIdle(void)
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:88
virtual Time GetStateDuration(void)
virtual void SendPacket(Ptr< const Packet > packet, WifiMode mode, enum WifiPreamble preamble, uint8_t txPowerLevel)
virtual bool IsStateSensing(void)
virtual void SetHandoffEndedCallback(WifiPhy::HandoffEndedCallback callback)
virtual void SetReceiveErrorCallback(WifiPhy::RxErrorCallback callback)
WifiPreamble
Definition: wifi-preamble.h:29
virtual uint32_t GetNModes(void) const
virtual bool IsStateRx(void)
virtual WifiMode GetMode(uint32_t mode) const
double m_channelStartingFrequency
Standard-dependent center frequency of 0-th channel, MHz.
receive notifications about phy events.
Definition: wifi-phy.h:44
WifiModeList m_deviceRateSet
virtual void DoDispose(void)
double GetChannelFrequencyMhz() const
Return current center channel frequency in MHz, see SetChannelNumber()
virtual bool IsStateCcaBusy(void)
virtual void SetReceiveOkCallback(WifiPhy::RxOkCallback callback)
int64_t AssignStreams(int64_t stream)
802.11 PHY layer modelThis PHY implements a model of 802.11a. The model implemented here is based on ...
Definition: yans-wifi-phy.h:61
virtual void SetSenseEndedCallback(WifiPhy::SnsEndedCallback callback)
std::vector< WifiMode > WifiModeList
Definition: wifi-mode.h:174
virtual bool IsStateIdle(void)
virtual double CalculateSnr(WifiMode txMode, double ber) const
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
an identifier for simulation events.
Definition: event-id.h:46
a unique identifier for an interface.
Definition: type-id.h:44
virtual uint32_t GetNTxPower(void) const