A Discrete-Event Network Simulator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
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  */
22 #ifndef UAN_PHY_GEN_H
23 #define UAN_PHY_GEN_H
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>
33 namespace ns3 {
44 {
45 public:
49  virtual ~UanPhyPerGenDefault ();
55  static TypeId GetTypeId (void);
57  virtual double CalcPer (Ptr<Packet> pkt, double sinrDb, UanTxMode mode);
58 private:
60  double m_thresh;
62 }; // class UanPhyPerGenDefault
74 class UanPhyPerUmodem : public UanPhyPer
75 {
76 public:
78  UanPhyPerUmodem ();
80  virtual ~UanPhyPerUmodem ();
86  static TypeId GetTypeId (void);
103  virtual double CalcPer (Ptr<Packet> pkt, double sinrDb, UanTxMode mode);
105 private:
113  double NChooseK (uint32_t n, uint32_t k);
115 }; // class UanPhyPerUmodem
128 {
130 public:
134  virtual ~UanPhyCalcSinrDefault ();
140  static TypeId GetTypeId (void);
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;
166 }; // class UanPhyCalcSinrDefault
181 {
183 public:
187  virtual ~UanPhyCalcSinrFhFsk ();
193  static TypeId GetTypeId (void);
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;
206 }; // class UanPhyCalcSinrFhFsk
219 class UanPhyGen : public UanPhy
220 {
221 public:
223  UanPhyGen ();
225  virtual ~UanPhyGen ();
231  static UanModesList GetDefaultModes (void);
238  static TypeId GetTypeId (void);
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);
278 private:
280  typedef std::list<UanPhyListener *> ListenerList;
295  double m_rxGainDb;
296  double m_txPwrDb;
297  double m_rxThreshDb;
298  double m_ccaThreshDb;
301  double m_minRxSinrDb;
302  double m_rxRecvPwrDb;
307  bool m_cleared;
308  bool m_disabled;
332  double CalculateSinrDb (Ptr<Packet> pkt, Time arrTime, double rxPowerDb,
333  UanTxMode mode, UanPdp pdp);
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);
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);
399 protected:
400  virtual void DoDispose ();
402 }; // class UanPhyGen
404 } // namespace ns3
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:877
virtual bool IsStateBusy(void)
Definition: uan-phy-gen.cc:731
virtual Ptr< UanTransducer > GetTransducer(void)
Get the attached transducer.
Definition: uan-phy-gen.cc:809
virtual double GetRxThresholdDb(void)
Get the minimum received signal strength required to receive a packet without errors.
Definition: uan-phy-gen.cc:786
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
virtual bool IsStateRx(void)
Definition: uan-phy-gen.cc:736
double KpToDb(double kp)
Convert kilopascals to dB.
Definition: uan-phy-gen.cc:930
virtual void SetEnergyModelCallback(DeviceEnergyModel::ChangeStateCallback cb)
Set the DeviceEnergyModel callback for UanPhy device.
Definition: uan-phy-gen.cc:484
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:716
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:896
virtual void EnergyDepletionHandler(void)
Handle the energy depletion event.
Definition: uan-phy-gen.cc:502
virtual void SetTransducer(Ptr< UanTransducer > trans)
Attach a transducer to this Phy.
Definition: uan-phy-gen.cc:832
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:364
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:839
virtual void StartRxPacket(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp)
Packet arriving from channel: i.e.
Definition: uan-phy-gen.cc:580
virtual uint32_t GetNModes(void)
Get the number of transmission modes supported by this Phy.
Definition: uan-phy-gen.cc:993
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:780
virtual double GetCcaThresholdDb(void)
Get the CCA threshold signal strength required to detect channel busy.
Definition: uan-phy-gen.cc:791
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:412
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:252
double NChooseK(uint32_t n, uint32_t k)
Binomial coefficient.
Definition: uan-phy-gen.cc:262
WHOI Micromodem like FH-FSK model.
Definition: uan-phy-gen.h:180
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:428
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:71
virtual bool IsStateTx(void)
Definition: uan-phy-gen.cc:741
virtual void SetDevice(Ptr< UanNetDevice > device)
Set the device hosting this Phy.
Definition: uan-phy-gen.cc:820
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:869
double m_rxGainDb
Receive gain.
Definition: uan-phy-gen.h:295
virtual ~UanPhyPerUmodem()
Definition: uan-phy-gen.cc:247
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:946
void NotifyListenersCcaEnd(void)
Call UanListener::NotifyCcaEnd on all listeners.
Definition: uan-phy-gen.cc:973
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
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:770
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:886
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:122
virtual Ptr< UanChannel > GetChannel(void) const
Get the attached channel.
Definition: uan-phy-gen.cc:797
Ptr< UanPhyCalcSinr > m_sinr
SINR calculator.
Definition: uan-phy-gen.h:293
virtual UanTxMode GetMode(uint32_t n)
Get a specific transmission mode.
Definition: uan-phy-gen.cc:999
virtual void SetRxThresholdDb(double thresh)
Set the minimum SINR threshold to receive a packet without errors.
Definition: uan-phy-gen.cc:765
void TxEndEvent()
Event to process end of packet transmission.
Definition: uan-phy-gen.cc:551
double DbToKp(double db)
Convert dB to kilopascals.
Definition: uan-phy-gen.cc:925
virtual void SetRxGainDb(double gain)
Set the receiver gain.
Definition: uan-phy-gen.cc:754
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:214
void UpdatePowerConsumption(const State state)
Update energy source with new state.
Definition: uan-phy-gen.cc:491
void NotifyListenersRxStart(void)
Call UanListener::NotifyRxStart on all listeners.
Definition: uan-phy-gen.cc:936
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:282
State m_state
Phy state.
Definition: uan-phy-gen.h:284
virtual ~UanPhyCalcSinrFhFsk()
Definition: uan-phy-gen.cc:102
void RxEndEvent(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode)
Event to process end of packet reception.
Definition: uan-phy-gen.cc:659
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:814
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()
Definition: uan-phy-gen.cc:209
Definition: uan-phy-gen.cc:98
bool m_disabled
Energy depleted.
Definition: uan-phy-gen.h:308
virtual bool IsStateIdle(void)
Definition: uan-phy-gen.cc:726
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:61
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:964
double GetInterferenceDb(Ptr< Packet > pkt)
Calculate interference power from overlapping packet arrivals, in dB.
Definition: uan-phy-gen.cc:903
void NotifyListenersRxBad(void)
Call UanListener::NotifyRxEndError on all listeners.
Definition: uan-phy-gen.cc:955
Ptr< UanTransducer > m_transducer
Associated transducer.
Definition: uan-phy-gen.h:289
Definition: uan-phy-gen.cc:243
Definition: uan-phy-gen.cc:204
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:108
Definition: uan-phy-gen.cc:344
virtual ~UanPhyCalcSinrDefault()
Definition: uan-phy-gen.cc:55
virtual void SendPacket(Ptr< Packet > pkt, uint32_t modeNum)
Send a packet using a specific transmission mode.
Definition: uan-phy-gen.cc:512
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:747
virtual void RegisterListener(UanPhyListener *listener)
Register a UanPhyListener to be notified of common UanPhy events.
Definition: uan-phy-gen.cc:573
virtual double GetRxGainDb(void)
Get the receiver gain added to signal at receiver in dB.
Definition: uan-phy-gen.cc:775
double m_minRxSinrDb
Minimum receive SINR during packet reception.
Definition: uan-phy-gen.h:301
virtual bool IsStateSleep(void)
Definition: uan-phy-gen.cc:721
virtual void SetMac(Ptr< UanMac > mac)
Set the MAC forwarding messages to this Phy.
Definition: uan-phy-gen.cc:826
virtual void SetReceiveOkCallback(RxOkCallback cb)
Set the callback to be used when a packet is received without error.
Definition: uan-phy-gen.cc:710
static UanModesList GetDefaultModes(void)
Get the default transmission modes.
Definition: uan-phy-gen.cc:420
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:230
virtual Ptr< UanNetDevice > GetDevice(void)
Get the device hosting this Phy.
Definition: uan-phy-gen.cc:803
virtual void Clear(void)
Clear all pointer references.
Definition: uan-phy-gen.cc:370
Definition: uan-phy-gen.cc:51
void NotifyListenersTxStart(Time duration)
Call UanListener::NotifyTxStart on all listeners.
Definition: uan-phy-gen.cc:983
virtual void SetTxPowerDb(double txpwr)
Set the transmit power.
Definition: uan-phy-gen.cc:760