A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
uan-phy.h
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 
23 #ifndef UAN_PHY_H
24 #define UAN_PHY_H
25 
26 #include "ns3/object.h"
27 #include "ns3/uan-mac.h"
28 #include "ns3/uan-tx-mode.h"
29 #include "ns3/uan-prop-model.h"
30 #include "ns3/uan-transducer.h"
31 #include "ns3/device-energy-model.h"
32 
33 namespace ns3 {
34 
35 
43 class UanPhyCalcSinr : public Object
44 {
45 
46 public:
47  static TypeId GetTypeId (void);
48 
58  virtual double CalcSinrDb (Ptr<Packet> pkt,
59  Time arrTime,
60  double rxPowerDb,
61  double ambNoiseDb,
62  UanTxMode mode,
63  UanPdp pdp,
64  const UanTransducer::ArrivalList &arrivalList
65  ) const = 0;
69  virtual void Clear (void);
70 
71  virtual void DoDispose (void);
72 
78  inline double DbToKp (double db) const
79  {
80  return std::pow (10, db / 10.0);
81  }
87  inline double KpToDb (double kp) const
88  {
89  return 10 * std::log10 (kp);
90  }
91 };
92 
98 class UanPhyPer : public Object
99 {
100 public:
101  static TypeId GetTypeId (void);
102 
111  virtual double CalcPer (Ptr<Packet> pkt, double sinrDb, UanTxMode mode) = 0;
115  virtual void Clear (void);
116 
117  virtual void DoDispose (void);
118 };
119 
120 
129 {
130 public:
131  virtual ~UanPhyListener ()
132  {
133  }
137  virtual void NotifyRxStart (void) = 0;
141  virtual void NotifyRxEndOk (void) = 0;
145  virtual void NotifyRxEndError (void) = 0;
149  virtual void NotifyCcaStart (void) = 0;
153  virtual void NotifyCcaEnd (void) = 0;
158  virtual void NotifyTxStart (Time duration) = 0;
159 };
160 
166 class UanPhy : public Object
167 {
168 public:
169  static TypeId GetTypeId (void);
170 
172  enum State
173  {
174  IDLE, CCABUSY, RX, TX, SLEEP
175  };
176 
183 
189 
201  virtual void EnergyDepletionHandler (void) = 0;
206  virtual void SendPacket (Ptr<Packet> pkt, uint32_t modeNum) = 0;
207 
213  virtual void RegisterListener (UanPhyListener *listener) = 0;
214 
222  virtual void StartRxPacket (Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp) = 0;
223 
227  virtual void SetReceiveOkCallback (RxOkCallback cb) = 0;
228 
232  virtual void SetReceiveErrorCallback (RxErrCallback cb) = 0;
233 
238  virtual void SetRxGainDb (double gain) = 0;
239 
243  virtual void SetTxPowerDb (double txpwr) = 0;
244 
248  virtual void SetRxThresholdDb (double thresh) = 0;
249 
254  virtual void SetCcaThresholdDb (double thresh) = 0;
255 
259  virtual double GetRxGainDb (void) = 0;
260 
264  virtual double GetTxPowerDb (void) = 0;
265 
269  virtual double GetRxThresholdDb (void) = 0;
270 
274  virtual double GetCcaThresholdDb (void) = 0;
279  virtual bool IsStateSleep (void) = 0;
284  virtual bool IsStateIdle (void) = 0;
289  virtual bool IsStateBusy (void) = 0;
294  virtual bool IsStateRx (void) = 0;
299  virtual bool IsStateTx (void) = 0;
304  virtual bool IsStateCcaBusy (void) = 0;
305 
309  virtual Ptr<UanChannel> GetChannel (void) const = 0;
310 
314  virtual Ptr<UanNetDevice> GetDevice (void) = 0;
315 
319  virtual void SetChannel (Ptr<UanChannel> channel) = 0;
320 
324  virtual void SetDevice (Ptr<UanNetDevice> device) = 0;
325 
329  virtual void SetMac (Ptr<UanMac> mac) = 0;
330 
340  virtual void NotifyTransStartTx (Ptr<Packet> packet, double txPowerDb, UanTxMode txMode) = 0;
341 
348  virtual void NotifyIntChange (void) = 0;
349 
354  virtual void SetTransducer (Ptr<UanTransducer> trans) = 0;
355 
359  virtual Ptr<UanTransducer> GetTransducer (void) = 0;
360 
364  virtual uint32_t GetNModes (void) = 0;
365 
370  virtual UanTxMode GetMode (uint32_t n) = 0;
371 
376  virtual Ptr<Packet> GetPacketRx (void) const = 0;
377 
381  virtual void Clear (void) = 0;
382 
383  virtual void SetSleepMode (bool sleep) = 0;
384 
385 
390  void NotifyTxBegin (Ptr<const Packet> packet);
391 
396  void NotifyTxEnd (Ptr<const Packet> packet);
397 
402  void NotifyTxDrop (Ptr<const Packet> packet);
403 
408  void NotifyRxBegin (Ptr<const Packet> packet);
409 
414  void NotifyRxEnd (Ptr<const Packet> packet);
415 
420  void NotifyRxDrop (Ptr<const Packet> packet);
421 
430  virtual int64_t AssignStreams (int64_t stream) = 0;
431 
432 private:
440 
448 
456 
464 
472 
479 };
480 
481 }
482 
483 #endif /* UAN_PHY_H */
virtual Ptr< UanNetDevice > GetDevice(void)=0
keep track of time unit.
Definition: nstime.h:149
virtual bool IsStateBusy(void)=0
TracedCallback< Ptr< const Packet > > m_phyTxBeginTrace
Definition: uan-phy.h:439
virtual bool IsStateSleep(void)=0
virtual void NotifyTransStartTx(Ptr< Packet > packet, double txPowerDb, UanTxMode txMode)=0
Callback template class.
Definition: callback.h:369
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: uan-phy.cc:127
virtual void SetCcaThresholdDb(double thresh)=0
virtual double GetRxThresholdDb(void)=0
virtual Ptr< UanChannel > GetChannel(void) const =0
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
virtual void SetRxThresholdDb(double thresh)=0
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
Definition: uan-phy.h:478
virtual void SetDevice(Ptr< UanNetDevice > device)=0
virtual void Clear(void)=0
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
Definition: uan-phy.h:455
virtual void SetReceiveErrorCallback(RxErrCallback cb)=0
virtual void NotifyIntChange(void)=0
virtual void DoDispose(void)
Definition: uan-phy.cc:40
virtual uint32_t GetNModes(void)=0
virtual bool IsStateTx(void)=0
virtual double GetCcaThresholdDb(void)=0
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: uan-phy.cc:109
void NotifyRxEnd(Ptr< const Packet > packet)
Definition: uan-phy.cc:121
virtual void RegisterListener(UanPhyListener *listener)=0
virtual void NotifyRxStart(void)=0
Function called when Phy object begins receiving packet.
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
Definition: uan-phy.h:471
virtual bool IsStateCcaBusy(void)=0
virtual void Clear(void)
Definition: uan-phy.cc:35
double KpToDb(double kp) const
Converts kilopascals to dB re 1 uPa.
Definition: uan-phy.h:87
virtual void NotifyTxStart(Time duration)=0
Function called when transmission starts from Phy object.
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:36
std::list< UanPacketArrival > ArrivalList
Arrival list is a standard template library list of UanPacketArrivals objects.
State
Enum defining possible Phy states.
Definition: uan-phy.h:172
void NotifyTxBegin(Ptr< const Packet > packet)
Definition: uan-phy.cc:97
virtual void NotifyRxEndError(void)=0
Function called when Phy object finishes receiving packet in error.
void NotifyRxBegin(Ptr< const Packet > packet)
Definition: uan-phy.cc:115
virtual void NotifyRxEndOk(void)=0
Function called when Phy object finishes receiving packet without error.
virtual void SetTxPowerDb(double txpwr)=0
Interface for PHY event listener A class which implements this interface may register with Phy object...
Definition: uan-phy.h:128
virtual void DoDispose(void)
Definition: uan-phy.cc:61
double DbToKp(double db) const
Converts dB re 1 uPa to kilopascals.
Definition: uan-phy.h:78
virtual int64_t AssignStreams(int64_t stream)=0
virtual double CalcPer(Ptr< Packet > pkt, double sinrDb, UanTxMode mode)=0
Base class for UAN Phy models.
Definition: uan-phy.h:166
virtual void EnergyDepletionHandler(void)=0
virtual double GetTxPowerDb(void)=0
virtual void NotifyCcaStart(void)=0
Function called when Phy object begins sensing channel is busy.
virtual void SetEnergyModelCallback(DeviceEnergyModel::ChangeStateCallback callback)=0
virtual void SetRxGainDb(double gain)=0
Callback< void, Ptr< Packet >, double, UanTxMode > RxOkCallback
Definition: uan-phy.h:182
virtual void NotifyCcaEnd(void)=0
Function called when Phy object stops sensing channel is busy.
virtual UanTxMode GetMode(uint32_t n)=0
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
Definition: uan-phy.h:447
virtual double GetRxGainDb(void)=0
virtual void Clear(void)
Definition: uan-phy.cc:56
virtual void StartRxPacket(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp)=0
Packet arriving from channel: i.e. leading bit of packet has arrived.
virtual double CalcSinrDb(Ptr< Packet > pkt, Time arrTime, double rxPowerDb, double ambNoiseDb, UanTxMode mode, UanPdp pdp, const UanTransducer::ArrivalList &arrivalList) const =0
virtual Ptr< UanTransducer > GetTransducer(void)=0
a base class which provides memory management and object aggregation
Definition: object.h:63
virtual void SetMac(Ptr< UanMac > mac)=0
virtual bool IsStateIdle(void)=0
virtual Ptr< Packet > GetPacketRx(void) const =0
virtual void SetChannel(Ptr< UanChannel > channel)=0
Callback< void, Ptr< Packet >, double > RxErrCallback
Definition: uan-phy.h:188
virtual void SendPacket(Ptr< Packet > pkt, uint32_t modeNum)=0
virtual void SetTransducer(Ptr< UanTransducer > trans)=0
a unique identifier for an interface.
Definition: type-id.h:44
void NotifyTxEnd(Ptr< const Packet > packet)
Definition: uan-phy.cc:103
virtual bool IsStateRx(void)=0
TracedCallback< Ptr< const Packet > > m_phyRxBeginTrace
Definition: uan-phy.h:463
virtual void SetReceiveOkCallback(RxOkCallback cb)=0