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 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);
88  uint16_t GetChannelNumber () const;
90  double GetChannelFrequencyMhz () const;
91 
92  void StartReceivePacket (Ptr<Packet> packet,
93  double rxPowerDbm,
94  WifiMode mode,
95  WifiPreamble preamble);
96 
97  void SetRxNoiseFigure (double noiseFigureDb);
98  void SetTxPowerStart (double start);
99  void SetTxPowerEnd (double end);
100  void SetNTxPower (uint32_t n);
101  void SetTxGain (double gain);
102  void SetRxGain (double gain);
103  void SetEdThreshold (double threshold);
104  void SetCcaMode1Threshold (double threshold);
106  void SetDevice (Ptr<Object> device);
107  void SetMobility (Ptr<Object> mobility);
108  double GetRxNoiseFigure (void) const;
109  double GetTxGain (void) const;
110  double GetRxGain (void) const;
111  double GetEdThreshold (void) const;
112  double GetCcaMode1Threshold (void) const;
114  Ptr<Object> GetDevice (void) const;
115  Ptr<Object> GetMobility (void);
116 
117 
118 
119 
120  virtual double GetTxPowerStart (void) const;
121  virtual double GetTxPowerEnd (void) const;
122  virtual uint32_t GetNTxPower (void) const;
123  virtual void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
124  virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
125  virtual void SendPacket (Ptr<const Packet> packet, WifiMode mode, enum WifiPreamble preamble, uint8_t txPowerLevel);
126  virtual void RegisterListener (WifiPhyListener *listener);
127  virtual bool IsStateCcaBusy (void);
128  virtual bool IsStateIdle (void);
129  virtual bool IsStateBusy (void);
130  virtual bool IsStateRx (void);
131  virtual bool IsStateTx (void);
132  virtual bool IsStateSwitching (void);
133  virtual Time GetStateDuration (void);
134  virtual Time GetDelayUntilIdle (void);
135  virtual Time GetLastRxStartTime (void) const;
136  virtual uint32_t GetNModes (void) const;
137  virtual WifiMode GetMode (uint32_t mode) const;
138  virtual double CalculateSnr (WifiMode txMode, double ber) const;
139  virtual Ptr<WifiChannel> GetChannel (void) const;
140  virtual void ConfigureStandard (enum WifiPhyStandard standard);
141 
150  int64_t AssignStreams (int64_t stream);
151 
152 private:
153  YansWifiPhy (const YansWifiPhy &o);
154  virtual void DoDispose (void);
155  void Configure80211a (void);
156  void Configure80211b (void);
157  void Configure80211g (void);
158  void Configure80211_10Mhz (void);
159  void Configure80211_5Mhz ();
160  void ConfigureHolland (void);
161  void Configure80211p_CCH (void);
162  void Configure80211p_SCH (void);
163  double GetEdThresholdW (void) const;
164  double DbmToW (double dbm) const;
165  double DbToRatio (double db) const;
166  double WToDbm (double w) const;
167  double RatioToDb (double ratio) const;
168  double GetPowerDbm (uint8_t power) const;
170 
171 private:
174  double m_txGainDb;
175  double m_rxGainDb;
178  uint32_t m_nTxPower;
179 
181  uint16_t m_channelNumber;
184 
222 
231 
232 };
233 
234 } // namespace ns3
235 
236 
237 #endif /* YANS_WIFI_PHY_H */