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  */
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 RandomUniform;
43 class RxEvent;
44 class YansWifiChannel;
45 class WifiPhyStateHelper;
46 
47 
63 class YansWifiPhy : public WifiPhy
64 {
65 public:
66  static TypeId GetTypeId (void);
67 
68  YansWifiPhy ();
69  virtual ~YansWifiPhy ();
70 
71  void SetChannel (Ptr<YansWifiChannel> channel);
72 
88  void SetChannelNumber (uint16_t id);
90  uint16_t GetChannelNumber () const;
92  double GetChannelFrequencyMhz () const;
93 
94  void StartReceivePacket (Ptr<Packet> packet,
95  double rxPowerDbm,
96  WifiMode mode,
97  WifiPreamble preamble);
98 
99  void SetRxNoiseFigure (double noiseFigureDb);
100  void SetTxPowerStart (double start);
101  void SetTxPowerEnd (double end);
102  void SetNTxPower (uint32_t n);
103  void SetTxGain (double gain);
104  void SetRxGain (double gain);
105  void SetEdThreshold (double threshold);
106  void SetCcaMode1Threshold (double threshold);
108  void SetDevice (Ptr<Object> device);
109  void SetMobility (Ptr<Object> mobility);
110  double GetRxNoiseFigure (void) const;
111  double GetTxGain (void) const;
112  double GetRxGain (void) const;
113  double GetEdThreshold (void) const;
114  double GetCcaMode1Threshold (void) const;
116  Ptr<Object> GetDevice (void) const;
117  Ptr<Object> GetMobility (void);
118 
119 
120 
121 
122  virtual double GetTxPowerStart (void) const;
123  virtual double GetTxPowerEnd (void) const;
124  virtual uint32_t GetNTxPower (void) const;
125  virtual void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
126  virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
127  virtual void SendPacket (Ptr<const Packet> packet, WifiMode mode, enum WifiPreamble preamble, uint8_t txPowerLevel);
128  virtual void RegisterListener (WifiPhyListener *listener);
129  virtual bool IsStateCcaBusy (void);
130  virtual bool IsStateIdle (void);
131  virtual bool IsStateBusy (void);
132  virtual bool IsStateRx (void);
133  virtual bool IsStateTx (void);
134  virtual bool IsStateSwitching (void);
135  virtual Time GetStateDuration (void);
136  virtual Time GetDelayUntilIdle (void);
137  virtual Time GetLastRxStartTime (void) const;
138  virtual uint32_t GetNModes (void) const;
139  virtual WifiMode GetMode (uint32_t mode) const;
140  virtual double CalculateSnr (WifiMode txMode, double ber) const;
141  virtual Ptr<WifiChannel> GetChannel (void) const;
142  virtual void ConfigureStandard (enum WifiPhyStandard standard);
143 
152  int64_t AssignStreams (int64_t stream);
153 
154 private:
155  YansWifiPhy (const YansWifiPhy &o);
156  virtual void DoDispose (void);
157  void Configure80211a (void);
158  void Configure80211b (void);
159  void Configure80211g (void);
160  void Configure80211_10Mhz (void);
161  void Configure80211_5Mhz ();
162  void ConfigureHolland (void);
163  void Configure80211p_CCH (void);
164  void Configure80211p_SCH (void);
165  double GetEdThresholdW (void) const;
166  double DbmToW (double dbm) const;
167  double DbToRatio (double db) const;
168  double WToDbm (double w) const;
169  double RatioToDb (double ratio) const;
170  double GetPowerDbm (uint8_t power) const;
172 
173 private:
176  double m_txGainDb;
177  double m_rxGainDb;
180  uint32_t m_nTxPower;
181 
183  uint16_t m_channelNumber;
186 
224 
233 
234 };
235 
236 } // namespace ns3
237 
238 
239 #endif /* YANS_WIFI_PHY_H */