A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
72  void SetChannel (Ptr<YansWifiChannel> channel);
73 
89  void SetChannelNumber (uint16_t id);
91  uint16_t GetChannelNumber () const;
93  double GetChannelFrequencyMhz () const;
94 
95  void StartReceivePacket (Ptr<Packet> packet,
96  double rxPowerDbm,
97  WifiTxVector txVector,
98  WifiPreamble preamble);
99 
100  void SetRxNoiseFigure (double noiseFigureDb);
101  void SetTxPowerStart (double start);
102  void SetTxPowerEnd (double end);
103  void SetNTxPower (uint32_t n);
104  void SetTxGain (double gain);
105  void SetRxGain (double gain);
106  void SetEdThreshold (double threshold);
107  void SetCcaMode1Threshold (double threshold);
109  void SetDevice (Ptr<Object> device);
110  void SetMobility (Ptr<Object> mobility);
111  double GetRxNoiseFigure (void) const;
112  double GetTxGain (void) const;
113  double GetRxGain (void) const;
114  double GetEdThreshold (void) const;
115  double GetCcaMode1Threshold (void) const;
117  Ptr<Object> GetDevice (void) const;
118  Ptr<Object> GetMobility (void);
119 
120 
121 
122 
123  virtual double GetTxPowerStart (void) const;
124  virtual double GetTxPowerEnd (void) const;
125  virtual uint32_t GetNTxPower (void) const;
126  virtual void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
127  virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
128  virtual void SendPacket (Ptr<const Packet> packet, WifiMode mode, enum WifiPreamble preamble, WifiTxVector txvector);
129  virtual void RegisterListener (WifiPhyListener *listener);
130  virtual bool IsStateCcaBusy (void);
131  virtual bool IsStateIdle (void);
132  virtual bool IsStateBusy (void);
133  virtual bool IsStateRx (void);
134  virtual bool IsStateTx (void);
135  virtual bool IsStateSwitching (void);
136  virtual Time GetStateDuration (void);
137  virtual Time GetDelayUntilIdle (void);
138  virtual Time GetLastRxStartTime (void) const;
139  virtual uint32_t GetNModes (void) const;
140  virtual WifiMode GetMode (uint32_t mode) const;
141  virtual double CalculateSnr (WifiMode txMode, double ber) const;
142  virtual Ptr<WifiChannel> GetChannel (void) const;
143  virtual void ConfigureStandard (enum WifiPhyStandard standard);
144 
153  int64_t AssignStreams (int64_t stream);
154 
158  virtual void SetFrequency (uint32_t freq);
162  virtual uint32_t GetFrequency (void) const;
166  virtual void SetNumberOfTransmitAntennas (uint32_t tx);
167  virtual uint32_t GetNumberOfTransmitAntennas (void) const;
171  virtual void SetNumberOfReceiveAntennas (uint32_t rx) ;
175  virtual uint32_t GetNumberOfReceiveAntennas (void) const;
179  virtual void SetGuardInterval (bool GuardInterval);
180  virtual bool GetGuardInterval (void) const;
184  virtual void SetLdpc (bool Ldpc);
188  virtual bool GetLdpc (void) const;
192  virtual void SetStbc (bool stbc);
196  virtual bool GetStbc (void) const;
200  virtual void SetGreenfield (bool greenfield);
204  virtual bool GetGreenfield (void) const;
208  virtual bool GetChannelBonding (void) const ;
212  virtual void SetChannelBonding (bool channelbonding) ;
213 
214  virtual uint32_t GetNBssMembershipSelectors (void) const;
215  virtual uint32_t GetBssMembershipSelector (uint32_t selector) const;
216  virtual WifiModeList GetMembershipSelectorModes(uint32_t selector);
220  virtual uint8_t GetNMcs (void) const;
221  virtual uint8_t GetMcs (uint8_t mcs) const;
229  virtual uint32_t WifiModeToMcs (WifiMode mode);
237  virtual WifiMode McsToWifiMode (uint8_t mcs);
238 
239 private:
240  YansWifiPhy (const YansWifiPhy &o);
241  virtual void DoDispose (void);
242  void Configure80211a (void);
243  void Configure80211b (void);
244  void Configure80211g (void);
245  void Configure80211_10Mhz (void);
246  void Configure80211_5Mhz ();
247  void ConfigureHolland (void);
248  void Configure80211p_CCH (void);
249  void Configure80211p_SCH (void);
250  void Configure80211n (void);
251  double GetEdThresholdW (void) const;
252  double DbmToW (double dbm) const;
253  double DbToRatio (double db) const;
254  double WToDbm (double w) const;
255  double RatioToDb (double ratio) const;
256  double GetPowerDbm (uint8_t power) const;
258 
259 private:
262  double m_txGainDb;
263  double m_rxGainDb;
266  uint32_t m_nTxPower;
267 
269  uint16_t m_channelNumber;
272 
273  // number of transmitters
275  // number of recievers
277  //if true use LDPC
278  bool m_ldpc;
279  // True if STBC is used
280  bool m_stbc;
281  //True if GreenField format is supported
283  //True is short guard interval is used
285  //True if channel bonding is used
287 
288 
326 
327  std::vector<uint32_t> m_bssMembershipSelectorSet;
328  std::vector<uint8_t> m_deviceMcsSet;
337 
338 };
339 
340 } // namespace ns3
341 
342 
343 #endif /* YANS_WIFI_PHY_H */