A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
uan-phy-gen.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 University of Washington
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: Leonard Tracy <lentracy@gmail.com>
19  * Andrea Sacco <andrea.sacco85@gmail.com>
20  */
21 
22 #ifndef UAN_PHY_GEN_H
23 #define UAN_PHY_GEN_H
24 
25 
26 #include "uan-phy.h"
27 #include "ns3/traced-callback.h"
28 #include "ns3/nstime.h"
29 #include "ns3/device-energy-model.h"
30 #include "ns3/random-variable-stream.h"
31 #include <list>
32 
33 namespace ns3 {
34 
42 {
43 public:
45  virtual ~UanPhyPerGenDefault ();
46 
47  static TypeId GetTypeId (void);
48  virtual double CalcPer (Ptr<Packet> pkt, double sinrDb, UanTxMode mode);
49 private:
50  double m_thresh;
51 
52 };
53 
60 class UanPhyPerUmodem : public UanPhyPer
61 {
62 public:
63  UanPhyPerUmodem ();
64  virtual ~UanPhyPerUmodem ();
65 
66  static TypeId GetTypeId (void);
67 
81  virtual double CalcPer (Ptr<Packet> pkt, double sinrDb, UanTxMode mode);
82 private:
83  double NChooseK (uint32_t n, uint32_t k);
84 
85 };
94 {
95 
96 public:
98  virtual ~UanPhyCalcSinrDefault ();
99  static TypeId GetTypeId (void);
113  virtual double CalcSinrDb (Ptr<Packet> pkt,
114  Time arrTime,
115  double rxPowerDb,
116  double ambNoiseDb,
117  UanTxMode mode,
118  UanPdp pdp,
119  const UanTransducer::ArrivalList &arrivalList
120  ) const;
121 };
122 
134 {
135 
136 public:
138  virtual ~UanPhyCalcSinrFhFsk ();
139  static TypeId GetTypeId (void);
140  virtual double CalcSinrDb (Ptr<Packet> pkt,
141  Time arrTime,
142  double rxPowerDb,
143  double ambNoiseDb,
144  UanTxMode mode,
145  UanPdp pdp,
146  const UanTransducer::ArrivalList &arrivalList
147  ) const;
148 private:
149  uint32_t m_hops;
150 };
151 
161 class UanPhyGen : public UanPhy
162 {
163 public:
164  UanPhyGen ();
165  virtual ~UanPhyGen ();
169  static UanModesList GetDefaultModes (void);
170 
171  static TypeId GetTypeId (void);
173  virtual void EnergyDepletionHandler (void);
174  virtual void SendPacket (Ptr<Packet> pkt, uint32_t modeNum);
175  virtual void RegisterListener (UanPhyListener *listener);
176  virtual void StartRxPacket (Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp);
177  virtual void SetReceiveOkCallback (RxOkCallback cb);
178  virtual void SetReceiveErrorCallback (RxErrCallback cb);
179  virtual bool IsStateSleep (void);
180  virtual bool IsStateIdle (void);
181  virtual bool IsStateBusy (void);
182  virtual bool IsStateRx (void);
183  virtual bool IsStateTx (void);
184  virtual bool IsStateCcaBusy (void);
185  virtual void SetRxGainDb (double gain);
186  virtual void SetTxPowerDb (double txpwr);
187  virtual void SetRxThresholdDb (double thresh);
188  virtual void SetCcaThresholdDb (double thresh);
189  virtual double GetRxGainDb (void);
190  virtual double GetTxPowerDb (void);
191  virtual double GetRxThresholdDb (void);
192  virtual double GetCcaThresholdDb (void);
193  virtual Ptr<UanChannel> GetChannel (void) const;
194  virtual Ptr<UanNetDevice> GetDevice (void);
195  virtual Ptr<UanTransducer> GetTransducer (void);
196  virtual void SetChannel (Ptr<UanChannel> channel);
197  virtual void SetDevice (Ptr<UanNetDevice> device);
198  virtual void SetMac (Ptr<UanMac> mac);
199  virtual void SetTransducer (Ptr<UanTransducer> trans);
200  virtual void NotifyTransStartTx (Ptr<Packet> packet, double txPowerDb, UanTxMode txMode);
201  virtual void NotifyIntChange (void);
202  virtual uint32_t GetNModes (void);
203  virtual UanTxMode GetMode (uint32_t n);
204  virtual Ptr<Packet> GetPacketRx (void) const;
205  virtual void Clear (void);
206 
207  virtual void SetSleepMode (bool sleep);
208 
217  int64_t AssignStreams (int64_t stream);
218 
219 private:
220  typedef std::list<UanPhyListener *> ListenerList;
221 
223 
234 
235  double m_rxGainDb;
236  double m_txPwrDb;
237  double m_rxThreshDb;
239 
246 
247  bool m_cleared;
249 
252 
257 
258  double CalculateSinrDb (Ptr<Packet> pkt, Time arrTime, double rxPowerDb, UanTxMode mode, UanPdp pdp);
259  double GetInterferenceDb (Ptr<Packet> pkt);
260  double DbToKp (double db);
261  double KpToDb (double kp);
262  void RxEndEvent (Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode);
263  void TxEndEvent ();
264  void UpdatePowerConsumption (const State state);
265 
266  void NotifyListenersRxStart (void);
267  void NotifyListenersRxGood (void);
268  void NotifyListenersRxBad (void);
269  void NotifyListenersCcaStart (void);
270  void NotifyListenersCcaEnd (void);
271  void NotifyListenersTxStart (Time duration);
272 protected:
273  virtual void DoDispose ();
274 
275 };
276 
277 } // namespace ns3
278 
279 #endif /* UAN_PHY_GEN_H */