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 
44 {
45 public:
49  virtual ~UanPhyPerGenDefault ();
50 
55  static TypeId GetTypeId (void);
56 
57  virtual double CalcPer (Ptr<Packet> pkt, double sinrDb, UanTxMode mode);
58 private:
59 
60  double m_thresh;
61 
62 }; // class UanPhyPerGenDefault
63 
64 
74 class UanPhyPerUmodem : public UanPhyPer
75 {
76 public:
78  UanPhyPerUmodem ();
80  virtual ~UanPhyPerUmodem ();
81 
86  static TypeId GetTypeId (void);
87 
103  virtual double CalcPer (Ptr<Packet> pkt, double sinrDb, UanTxMode mode);
104 
105 private:
113  double NChooseK (uint32_t n, uint32_t k);
114 
115 }; // class UanPhyPerUmodem
116 
117 
128 {
129 
130 public:
134  virtual ~UanPhyCalcSinrDefault ();
135 
140  static TypeId GetTypeId (void);
141 
157  virtual double CalcSinrDb (Ptr<Packet> pkt,
158  Time arrTime,
159  double rxPowerDb,
160  double ambNoiseDb,
161  UanTxMode mode,
162  UanPdp pdp,
163  const UanTransducer::ArrivalList &arrivalList
164  ) const;
165 
166 }; // class UanPhyCalcSinrDefault
167 
168 
181 {
182 
183 public:
187  virtual ~UanPhyCalcSinrFhFsk ();
188 
193  static TypeId GetTypeId (void);
194 
195  virtual double CalcSinrDb (Ptr<Packet> pkt,
196  Time arrTime,
197  double rxPowerDb,
198  double ambNoiseDb,
199  UanTxMode mode,
200  UanPdp pdp,
201  const UanTransducer::ArrivalList &arrivalList
202  ) const;
203 private:
204  uint32_t m_hops;
205 
206 }; // class UanPhyCalcSinrFhFsk
207 
208 
219 class UanPhyGen : public UanPhy
220 {
221 public:
223  UanPhyGen ();
225  virtual ~UanPhyGen ();
231  static UanModesList GetDefaultModes (void);
232 
233 
238  static TypeId GetTypeId (void);
239 
240  // Inherited methods
242  virtual void EnergyDepletionHandler (void);
243  virtual void SendPacket (Ptr<Packet> pkt, uint32_t modeNum);
244  virtual void RegisterListener (UanPhyListener *listener);
245  virtual void StartRxPacket (Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp);
246  virtual void SetReceiveOkCallback (RxOkCallback cb);
247  virtual void SetReceiveErrorCallback (RxErrCallback cb);
248  virtual bool IsStateSleep (void);
249  virtual bool IsStateIdle (void);
250  virtual bool IsStateBusy (void);
251  virtual bool IsStateRx (void);
252  virtual bool IsStateTx (void);
253  virtual bool IsStateCcaBusy (void);
254  virtual void SetRxGainDb (double gain);
255  virtual void SetTxPowerDb (double txpwr);
256  virtual void SetRxThresholdDb (double thresh);
257  virtual void SetCcaThresholdDb (double thresh);
258  virtual double GetRxGainDb (void);
259  virtual double GetTxPowerDb (void);
260  virtual double GetRxThresholdDb (void);
261  virtual double GetCcaThresholdDb (void);
262  virtual Ptr<UanChannel> GetChannel (void) const;
263  virtual Ptr<UanNetDevice> GetDevice (void);
264  virtual Ptr<UanTransducer> GetTransducer (void);
265  virtual void SetChannel (Ptr<UanChannel> channel);
266  virtual void SetDevice (Ptr<UanNetDevice> device);
267  virtual void SetMac (Ptr<UanMac> mac);
268  virtual void SetTransducer (Ptr<UanTransducer> trans);
269  virtual void NotifyTransStartTx (Ptr<Packet> packet, double txPowerDb, UanTxMode txMode);
270  virtual void NotifyIntChange (void);
271  virtual uint32_t GetNModes (void);
272  virtual UanTxMode GetMode (uint32_t n);
273  virtual Ptr<Packet> GetPacketRx (void) const;
274  virtual void Clear (void);
275  virtual void SetSleepMode (bool sleep);
276  int64_t AssignStreams (int64_t stream);
277 
278 private:
280  typedef std::list<UanPhyListener *> ListenerList;
281 
283 
294 
295  double m_rxGainDb;
296  double m_txPwrDb;
297  double m_rxThreshDb;
298  double m_ccaThreshDb;
299 
301  double m_minRxSinrDb;
302  double m_rxRecvPwrDb;
306 
307  bool m_cleared;
308  bool m_disabled;
309 
312 
321 
332  double CalculateSinrDb (Ptr<Packet> pkt, Time arrTime, double rxPowerDb,
333  UanTxMode mode, UanPdp pdp);
334 
345  double GetInterferenceDb (Ptr<Packet> pkt);
354  double DbToKp (double db);
363  double KpToDb (double kp);
371  void RxEndEvent (Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode);
373  void TxEndEvent ();
379  void UpdatePowerConsumption (const State state);
380 
381 
383  void NotifyListenersRxStart (void);
385  void NotifyListenersRxGood (void);
387  void NotifyListenersRxBad (void);
389  void NotifyListenersCcaStart (void);
391  void NotifyListenersCcaEnd (void);
397  void NotifyListenersTxStart (Time duration);
398 
399 protected:
400  virtual void DoDispose ();
401 
402 }; // class UanPhyGen
403 
404 } // namespace ns3
405 
406 #endif /* UAN_PHY_GEN_H */
virtual void NotifyTransStartTx(Ptr< Packet > packet, double txPowerDb, UanTxMode txMode)
Called when a transmission is beginning on the attched transducer.
Definition: uan-phy-gen.cc:882
virtual bool IsStateBusy(void)
Definition: uan-phy-gen.cc:736
virtual Ptr< UanTransducer > GetTransducer(void)
Get the attached transducer.
Definition: uan-phy-gen.cc:814
virtual double GetRxThresholdDb(void)
Get the minimum received signal strength required to receive a packet without errors.
Definition: uan-phy-gen.cc:791
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
virtual bool IsStateRx(void)
Definition: uan-phy-gen.cc:741
double KpToDb(double kp)
Convert kilopascals to dB.
Definition: uan-phy-gen.cc:935
virtual void SetEnergyModelCallback(DeviceEnergyModel::ChangeStateCallback cb)
Set the DeviceEnergyModel callback for UanPhy device.
Definition: uan-phy-gen.cc:489
uint32_t m_hops
Number of hops.
Definition: uan-phy-gen.h:204
virtual void SetReceiveErrorCallback(RxErrCallback cb)
Set the callback to be used when a packet is received with errors.
Definition: uan-phy-gen.cc:721
double CalculateSinrDb(Ptr< Packet > pkt, Time arrTime, double rxPowerDb, UanTxMode mode, UanPdp pdp)
Calculate the SINR value for a packet.
Definition: uan-phy-gen.cc:901
virtual void EnergyDepletionHandler(void)
Handle the energy depletion event.
Definition: uan-phy-gen.cc:507
virtual void SetTransducer(Ptr< UanTransducer > trans)
Attach a transducer to this Phy.
Definition: uan-phy-gen.cc:837
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
virtual ~UanPhyGen()
Dummy destructor, see DoDispose.
Definition: uan-phy-gen.cc:369
Ptr< UniformRandomVariable > m_pg
Provides uniform random variables.
Definition: uan-phy-gen.h:311
double m_rxRecvPwrDb
Receiver power.
Definition: uan-phy-gen.h:302
Packet error rate calculation assuming WHOI Micromodem-like PHY.
Definition: uan-phy-gen.h:74
virtual void SetSleepMode(bool sleep)
Set the Phy SLEEP mode.
Definition: uan-phy-gen.cc:844
virtual void StartRxPacket(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp)
Packet arriving from channel: i.e.
Definition: uan-phy-gen.cc:585
virtual uint32_t GetNModes(void)
Get the number of transmission modes supported by this Phy.
Definition: uan-phy-gen.cc:998
Container for UanTxModes.
Definition: uan-tx-mode.h:255
virtual double GetTxPowerDb(void)
Get the current transmit power, in dB.
Definition: uan-phy-gen.cc:785
virtual double GetCcaThresholdDb(void)
Get the CCA threshold signal strength required to detect channel busy.
Definition: uan-phy-gen.cc:796
double m_rxThreshDb
Receive SINR threshold.
Definition: uan-phy-gen.h:297
Ptr< UanPhyPer > m_per
Error model.
Definition: uan-phy-gen.h:292
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: uan-phy-gen.cc:417
Time m_pktRxArrTime
Packet arrival time.
Definition: uan-phy-gen.h:303
bool m_cleared
Flag when we've been cleared.
Definition: uan-phy-gen.h:307
TracedCallback< Ptr< const Packet >, double, UanTxMode > m_txLogger
A packet was sent from this Phy.
Definition: uan-phy-gen.h:320
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:257
double NChooseK(uint32_t n, uint32_t k)
Binomial coefficient.
Definition: uan-phy-gen.cc:267
WHOI Micromodem like FH-FSK model.
Definition: uan-phy-gen.h:180
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:433
virtual double CalcSinrDb(Ptr< Packet > pkt, Time arrTime, double rxPowerDb, double ambNoiseDb, UanTxMode mode, UanPdp pdp, const UanTransducer::ArrivalList &arrivalList) const
Calculate the SINR value for a packet.
Definition: uan-phy-gen.cc:76
virtual bool IsStateTx(void)
Definition: uan-phy-gen.cc:746
virtual void SetDevice(Ptr< UanNetDevice > device)
Set the device hosting this Phy.
Definition: uan-phy-gen.cc:825
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Definition: uan-phy-gen.cc:874
double m_rxGainDb
Receive gain.
Definition: uan-phy-gen.h:295
virtual ~UanPhyPerUmodem()
Destructor.
Definition: uan-phy-gen.cc:252
Ptr< UanNetDevice > m_device
Device hosting this Phy.
Definition: uan-phy-gen.h:290
virtual Ptr< Packet > GetPacketRx(void) const
Get the packet currently being received.
double m_txPwrDb
Transmit power.
Definition: uan-phy-gen.h:296
The power delay profile returned by propagation models.
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:41
double m_thresh
SINR threshold.
Definition: uan-phy-gen.h:60
Calculate packet error probability, based on received SINR and modulation (mode). ...
Definition: uan-phy.h:110
DeviceEnergyModel::ChangeStateCallback m_energyCallback
Energy model callback.
Definition: uan-phy-gen.h:314
double m_ccaThreshDb
CCA busy threshold.
Definition: uan-phy-gen.h:298
void NotifyListenersRxGood(void)
Call UanListener::NotifyRxEndOk on all listeners.
Definition: uan-phy-gen.cc:951
void NotifyListenersCcaEnd(void)
Call UanListener::NotifyCcaEnd on all listeners.
Definition: uan-phy-gen.cc:978
Generic PHY model.
Definition: uan-phy-gen.h:219
std::list< UanPacketArrival > ArrivalList
List of arriving packets overlapping in time.
Ptr< Packet > m_pktRx
Received packet.
Definition: uan-phy-gen.h:300
State
Enum defining possible Phy states.
Definition: uan-phy.h:179
virtual void SetCcaThresholdDb(double thresh)
Set the threshold for detecting channel busy.
Definition: uan-phy-gen.cc:775
virtual void NotifyIntChange(void)
Called when there has been a change in the ammount of interference this node is experiencing from oth...
Definition: uan-phy-gen.cc:891
UanPdp m_pktRxPdp
Power delay profile of pakket.
Definition: uan-phy-gen.h:304
virtual double CalcSinrDb(Ptr< Packet > pkt, Time arrTime, double rxPowerDb, double ambNoiseDb, UanTxMode mode, UanPdp pdp, const UanTransducer::ArrivalList &arrivalList) const
Calculate the SINR value for a packet.
Definition: uan-phy-gen.cc:127
virtual Ptr< UanChannel > GetChannel(void) const
Get the attached channel.
Definition: uan-phy-gen.cc:802
Ptr< UanPhyCalcSinr > m_sinr
SINR calculator.
Definition: uan-phy-gen.h:293
virtual UanTxMode GetMode(uint32_t n)
Get a specific transmission mode.
virtual void SetRxThresholdDb(double thresh)
Set the minimum SINR threshold to receive a packet without errors.
Definition: uan-phy-gen.cc:770
void TxEndEvent()
Event to process end of packet transmission.
Definition: uan-phy-gen.cc:556
double DbToKp(double db)
Convert dB to kilopascals.
Definition: uan-phy-gen.cc:930
virtual void SetRxGainDb(double gain)
Set the receiver gain.
Definition: uan-phy-gen.cc:759
RxOkCallback m_recOkCb
Callback for packets received without error.
Definition: uan-phy-gen.h:286
UanModesList m_modes
List of modes supported by this PHY.
Definition: uan-phy-gen.h:282
Interface for PHY event listener.
Definition: uan-phy.h:146
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:219
void UpdatePowerConsumption(const State state)
Update energy source with new state.
Definition: uan-phy-gen.cc:496
void NotifyListenersRxStart(void)
Call UanListener::NotifyRxStart on all listeners.
Definition: uan-phy-gen.cc:941
virtual double CalcPer(Ptr< Packet > pkt, double sinrDb, UanTxMode mode)
Calculate the packet error probability based on SINR at the receiver and a tx mode.
Definition: uan-phy-gen.cc:287
State m_state
Phy state.
Definition: uan-phy-gen.h:284
virtual ~UanPhyCalcSinrFhFsk()
Destructor.
Definition: uan-phy-gen.cc:107
void RxEndEvent(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode)
Event to process end of packet reception.
Definition: uan-phy-gen.cc:664
TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxOkLogger
A packet destined for this Phy was received without error.
Definition: uan-phy-gen.h:316
virtual void SetChannel(Ptr< UanChannel > channel)
Attach to a channel.
Definition: uan-phy-gen.cc:819
Default SINR calculator for UanPhyGen.
Definition: uan-phy-gen.h:127
Class used for calculating SINR of packet in UanPhy.
Definition: uan-phy.h:44
Ptr< UanMac > m_mac
MAC layer.
Definition: uan-phy-gen.h:291
Base class for UAN Phy models.
Definition: uan-phy.h:175
std::list< UanPhyListener * > ListenerList
List of Phy Listeners.
Definition: uan-phy-gen.h:280
TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxErrLogger
A packet destined for this Phy was received with error.
Definition: uan-phy-gen.h:318
virtual ~UanPhyPerGenDefault()
Destructor.
Definition: uan-phy-gen.cc:214
UanPhyCalcSinrFhFsk()
Constructor.
Definition: uan-phy-gen.cc:103
bool m_disabled
Energy depleted.
Definition: uan-phy-gen.h:308
virtual bool IsStateIdle(void)
Definition: uan-phy-gen.cc:731
RxErrCallback m_recErrCb
Callback for packets received with errors.
Definition: uan-phy-gen.h:287
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:66
Ptr< UanChannel > m_channel
Attached channel.
Definition: uan-phy-gen.h:288
void NotifyListenersCcaStart(void)
Call UanListener::NotifyCcaStart on all listeners.
Definition: uan-phy-gen.cc:969
double GetInterferenceDb(Ptr< Packet > pkt)
Calculate interference power from overlapping packet arrivals, in dB.
Definition: uan-phy-gen.cc:908
void NotifyListenersRxBad(void)
Call UanListener::NotifyRxEndError on all listeners.
Definition: uan-phy-gen.cc:960
Ptr< UanTransducer > m_transducer
Associated transducer.
Definition: uan-phy-gen.h:289
UanPhyPerUmodem()
Constructor.
Definition: uan-phy-gen.cc:248
UanPhyPerGenDefault()
Constructor.
Definition: uan-phy-gen.cc:209
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:113
UanPhyGen()
Constructor.
Definition: uan-phy-gen.cc:349
virtual ~UanPhyCalcSinrDefault()
Destructor.
Definition: uan-phy-gen.cc:60
virtual void SendPacket(Ptr< Packet > pkt, uint32_t modeNum)
Send a packet using a specific transmission mode.
Definition: uan-phy-gen.cc:517
Default Packet Error Rate calculator for UanPhyGen.
Definition: uan-phy-gen.h:43
UanTxMode m_pktRxMode
Packet transmission mode at receiver.
Definition: uan-phy-gen.h:305
ListenerList m_listeners
List of listeners.
Definition: uan-phy-gen.h:285
virtual bool IsStateCcaBusy(void)
Definition: uan-phy-gen.cc:752
virtual void RegisterListener(UanPhyListener *listener)
Register a UanPhyListener to be notified of common UanPhy events.
Definition: uan-phy-gen.cc:578
virtual double GetRxGainDb(void)
Get the receiver gain added to signal at receiver in dB.
Definition: uan-phy-gen.cc:780
double m_minRxSinrDb
Minimum receive SINR during packet reception.
Definition: uan-phy-gen.h:301
virtual bool IsStateSleep(void)
Definition: uan-phy-gen.cc:726
virtual void SetMac(Ptr< UanMac > mac)
Set the MAC forwarding messages to this Phy.
Definition: uan-phy-gen.cc:831
virtual void SetReceiveOkCallback(RxOkCallback cb)
Set the callback to be used when a packet is received without error.
Definition: uan-phy-gen.cc:715
static UanModesList GetDefaultModes(void)
Get the default transmission modes.
Definition: uan-phy-gen.cc:425
a unique identifier for an interface.
Definition: type-id.h:49
virtual double CalcPer(Ptr< Packet > pkt, double sinrDb, UanTxMode mode)
Calculate the packet error probability based on SINR at the receiver and a tx mode.
Definition: uan-phy-gen.cc:235
virtual Ptr< UanNetDevice > GetDevice(void)
Get the device hosting this Phy.
Definition: uan-phy-gen.cc:808
virtual void Clear(void)
Clear all pointer references.
Definition: uan-phy-gen.cc:375
UanPhyCalcSinrDefault()
Constructor.
Definition: uan-phy-gen.cc:56
void NotifyListenersTxStart(Time duration)
Call UanListener::NotifyTxStart on all listeners.
Definition: uan-phy-gen.cc:988
virtual void SetTxPowerDb(double txpwr)
Set the transmit power.
Definition: uan-phy-gen.cc:765