A Discrete-Event Network Simulator
API
uan-phy.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 University of Washington
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Leonard Tracy <lentracy@gmail.com>
18 * Andrea Sacco <andrea.sacco85@gmail.com>
19 */
20
21#ifndef UAN_PHY_H
22#define UAN_PHY_H
23
24#include "ns3/device-energy-model.h"
25#include "ns3/object.h"
26#include "ns3/uan-mac.h"
27#include "ns3/uan-prop-model.h"
28#include "ns3/uan-transducer.h"
29#include "ns3/uan-tx-mode.h"
30
31namespace ns3
32{
33
42class UanPhyCalcSinr : public Object
43{
44 public:
57 virtual double CalcSinrDb(Ptr<Packet> pkt,
58 Time arrTime,
59 double rxPowerDb,
60 double ambNoiseDb,
61 UanTxMode mode,
62 UanPdp pdp,
63 const UanTransducer::ArrivalList& arrivalList) const = 0;
68 static TypeId GetTypeId();
69
71 virtual void Clear();
72
79 inline double DbToKp(double db) const
80 {
81 return std::pow(10, db / 10.0);
82 }
83
90 inline double KpToDb(double kp) const
91 {
92 return 10 * std::log10(kp);
93 }
94
95 protected:
96 void DoDispose() override;
97
98}; // class UanPhyCalcSinr
99
108class UanPhyPer : public Object
109{
110 public:
120 virtual double CalcPer(Ptr<Packet> pkt, double sinrDb, UanTxMode mode) = 0;
121
126 static TypeId GetTypeId();
128 virtual void Clear();
129
130 protected:
131 void DoDispose() override;
132
133}; // class UanPhyPer
134
144{
145 public:
148 {
149 }
150
152 virtual void NotifyRxStart() = 0;
154 virtual void NotifyRxEndOk() = 0;
156 virtual void NotifyRxEndError() = 0;
158 virtual void NotifyCcaStart() = 0;
160 virtual void NotifyCcaEnd() = 0;
166 virtual void NotifyTxStart(Time duration) = 0;
168 virtual void NotifyTxEnd() = 0;
169}; // class UanPhyListener
170
176class UanPhy : public Object
177{
178 public:
180 enum State
181 {
187 DISABLED
188 };
189
198
206
214 typedef void (*TracedCallback)(Ptr<const Packet> pkt, double sinr, UanTxMode mode);
215
225 virtual void EnergyDepletionHandler() = 0;
229 virtual void EnergyRechargeHandler() = 0;
236 virtual void SendPacket(Ptr<Packet> pkt, uint32_t modeNum) = 0;
237
243 virtual void RegisterListener(UanPhyListener* listener) = 0;
244
253 virtual void StartRxPacket(Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp) = 0;
254
260 virtual void SetReceiveOkCallback(RxOkCallback cb) = 0;
261
268
274 virtual void SetTxPowerDb(double txpwr) = 0;
275
283 virtual void SetRxThresholdDb(double thresh) = 0;
284
290 virtual void SetCcaThresholdDb(double thresh) = 0;
291
297 virtual double GetTxPowerDb() = 0;
298
305 virtual double GetRxThresholdDb() = 0;
306
312 virtual double GetCcaThresholdDb() = 0;
314 virtual bool IsStateSleep() = 0;
316 virtual bool IsStateIdle() = 0;
318 virtual bool IsStateBusy() = 0;
320 virtual bool IsStateRx() = 0;
322 virtual bool IsStateTx() = 0;
324 virtual bool IsStateCcaBusy() = 0;
325
331 virtual Ptr<UanChannel> GetChannel() const = 0;
332
338 virtual Ptr<UanNetDevice> GetDevice() const = 0;
339
346
352 virtual void SetDevice(Ptr<UanNetDevice> device) = 0;
353
359 virtual void SetMac(Ptr<UanMac> mac) = 0;
360
369 virtual void NotifyTransStartTx(Ptr<Packet> packet, double txPowerDb, UanTxMode txMode) = 0;
370
376 virtual void NotifyIntChange() = 0;
377
383 virtual void SetTransducer(Ptr<UanTransducer> trans) = 0;
384
391
397 virtual uint32_t GetNModes() = 0;
398
405 virtual UanTxMode GetMode(uint32_t n) = 0;
406
413 virtual Ptr<Packet> GetPacketRx() const = 0;
414
416 virtual void Clear() = 0;
417
423 virtual void SetSleepMode(bool sleep) = 0;
424
433 void NotifyTxBegin(Ptr<const Packet> packet);
434
443 void NotifyTxEnd(Ptr<const Packet> packet);
444
454 void NotifyTxDrop(Ptr<const Packet> packet);
455
464 void NotifyRxBegin(Ptr<const Packet> packet);
465
474 void NotifyRxEnd(Ptr<const Packet> packet);
475
484 void NotifyRxDrop(Ptr<const Packet> packet);
485
494 virtual int64_t AssignStreams(int64_t stream) = 0;
495
500 static TypeId GetTypeId();
501
502 private:
510
518
526
534
542
550
551}; // class UanPhy
552
553} // namespace ns3
554
555#endif /* UAN_PHY_H */
Callback template class.
Definition: callback.h:443
A base class which provides memory management and object aggregation.
Definition: object.h:89
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
The power delay profile returned by propagation models.
Class used for calculating SINR of packet in UanPhy.
Definition: uan-phy.h:43
static TypeId GetTypeId()
Register this type.
Definition: uan-phy.cc:28
double DbToKp(double db) const
Convert dB re 1 uPa to kilopascals.
Definition: uan-phy.h:79
virtual void Clear()
Clear all pointer references.
Definition: uan-phy.cc:35
void DoDispose() override
Destructor implementation.
Definition: uan-phy.cc:40
virtual double CalcSinrDb(Ptr< Packet > pkt, Time arrTime, double rxPowerDb, double ambNoiseDb, UanTxMode mode, UanPdp pdp, const UanTransducer::ArrivalList &arrivalList) const =0
Calculate the SINR value for a packet.
double KpToDb(double kp) const
Convert kilopascals to dB re 1 uPa.
Definition: uan-phy.h:90
Base class for UAN Phy models.
Definition: uan-phy.h:177
virtual void SetEnergyModelCallback(DeviceEnergyModel::ChangeStateCallback callback)=0
Set the DeviceEnergyModel callback for UanPhy device.
virtual bool IsStateRx()=0
Callback< void, Ptr< Packet >, double, UanTxMode > RxOkCallback
Packet received successfully callback function type.
Definition: uan-phy.h:197
virtual void SetTxPowerDb(double txpwr)=0
Set the transmit power.
virtual double GetTxPowerDb()=0
Get the current transmit power, in dB.
static TypeId GetTypeId()
Register this type.
Definition: uan-phy.cc:70
virtual Ptr< Packet > GetPacketRx() const =0
Get the packet currently being received.
virtual uint32_t GetNModes()=0
Get the number of transmission modes supported by this Phy.
virtual void SetChannel(Ptr< UanChannel > channel)=0
Attach to a channel.
virtual bool IsStateTx()=0
void NotifyTxDrop(Ptr< const Packet > packet)
Called when the transducer attempts to transmit a new packet while already transmitting a prior packe...
Definition: uan-phy.cc:122
ns3::TracedCallback< Ptr< const Packet > > m_phyRxBeginTrace
Trace source indicating a packet has begun being received from the channel medium by the device.
Definition: uan-phy.h:533
virtual void SetTransducer(Ptr< UanTransducer > trans)=0
Attach a transducer to this Phy.
virtual void SetCcaThresholdDb(double thresh)=0
Set the threshold for detecting channel busy.
void NotifyTxEnd(Ptr< const Packet > packet)
Called when the transducer finishes transmitting a packet.
Definition: uan-phy.cc:116
void NotifyRxDrop(Ptr< const Packet > packet)
Called when the Phy drops a packet.
Definition: uan-phy.cc:140
virtual void StartRxPacket(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp)=0
Packet arriving from channel: i.e.
virtual void SetDevice(Ptr< UanNetDevice > device)=0
Set the device hosting this Phy.
ns3::TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
Trace source indicating a packet has been dropped by the device during transmission.
Definition: uan-phy.h:525
virtual double GetRxThresholdDb()=0
Get the minimum received signal strength required to receive a packet without errors.
ns3::TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
Trace source indicating a packet has been dropped by the device during reception.
Definition: uan-phy.h:549
ns3::TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
Trace source indicating a packet has been completely received from the channel medium by the device.
Definition: uan-phy.h:541
virtual void NotifyIntChange()=0
Called when there has been a change in the amount of interference this node is experiencing from othe...
virtual void NotifyTransStartTx(Ptr< Packet > packet, double txPowerDb, UanTxMode txMode)=0
Called when a transmission is beginning on the attached transducer.
virtual UanTxMode GetMode(uint32_t n)=0
Get a specific transmission mode.
virtual bool IsStateSleep()=0
virtual void EnergyRechargeHandler()=0
Handle the energy recharge event.
virtual void RegisterListener(UanPhyListener *listener)=0
Register a UanPhyListener to be notified of common UanPhy events.
virtual void EnergyDepletionHandler()=0
Handle the energy depletion event.
ns3::TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
Trace source indicating a packet has been completely transmitted over the channel.
Definition: uan-phy.h:517
virtual bool IsStateIdle()=0
virtual Ptr< UanChannel > GetChannel() const =0
Get the attached channel.
virtual Ptr< UanNetDevice > GetDevice() const =0
Get the device hosting this Phy.
virtual void SetReceiveErrorCallback(RxErrCallback cb)=0
Set the callback to be used when a packet is received with errors.
virtual bool IsStateBusy()=0
virtual bool IsStateCcaBusy()=0
virtual void SetRxThresholdDb(double thresh)=0
Set the minimum SINR threshold to receive a packet without errors.
ns3::TracedCallback< Ptr< const Packet > > m_phyTxBeginTrace
Trace source indicating a packet has begun transmitting over the channel medium.
Definition: uan-phy.h:509
virtual void SetMac(Ptr< UanMac > mac)=0
Set the MAC forwarding messages to this Phy.
virtual void SendPacket(Ptr< Packet > pkt, uint32_t modeNum)=0
Send a packet using a specific transmission mode.
virtual void SetReceiveOkCallback(RxOkCallback cb)=0
Set the callback to be used when a packet is received without error.
void NotifyRxBegin(Ptr< const Packet > packet)
Called when the Phy begins to receive a packet.
Definition: uan-phy.cc:128
virtual int64_t AssignStreams(int64_t stream)=0
Assign a fixed random variable stream number to the random variables used by this model.
void NotifyRxEnd(Ptr< const Packet > packet)
Called when a packet is received without error.
Definition: uan-phy.cc:134
virtual Ptr< UanTransducer > GetTransducer()=0
Get the attached transducer.
Callback< void, Ptr< Packet >, double > RxErrCallback
Packet receive error callback function type.
Definition: uan-phy.h:205
virtual double GetCcaThresholdDb()=0
Get the CCA threshold signal strength required to detect channel busy.
void NotifyTxBegin(Ptr< const Packet > packet)
Called when the transducer begins transmitting a packet.
Definition: uan-phy.cc:110
virtual void Clear()=0
Clear all pointer references.
State
Enum defining possible Phy states.
Definition: uan-phy.h:181
@ RX
Receiving.
Definition: uan-phy.h:184
@ SLEEP
Sleeping.
Definition: uan-phy.h:186
@ IDLE
Idle state.
Definition: uan-phy.h:182
@ DISABLED
Disabled.
Definition: uan-phy.h:187
@ TX
Transmitting.
Definition: uan-phy.h:185
@ CCABUSY
Channel busy.
Definition: uan-phy.h:183
virtual void SetSleepMode(bool sleep)=0
Set the Phy SLEEP mode.
Interface for PHY event listener.
Definition: uan-phy.h:144
virtual ~UanPhyListener()
Default destructor.
Definition: uan-phy.h:147
virtual void NotifyRxStart()=0
Called when UanPhy begins receiving packet.
virtual void NotifyTxStart(Time duration)=0
Called when transmission starts from Phy object.
virtual void NotifyRxEndError()=0
Called when UanPhy finishes receiving packet in error.
virtual void NotifyTxEnd()=0
Function called when Phy object finishes transmitting packet.
virtual void NotifyCcaStart()=0
Called when UanPhy begins sensing channel is busy.
virtual void NotifyCcaEnd()=0
Called when UanPhy stops sensing channel is busy.
virtual void NotifyRxEndOk()=0
Called when UanPhy finishes receiving packet without error.
Calculate packet error probability, based on received SINR and modulation (mode).
Definition: uan-phy.h:109
virtual void Clear()
Clear all pointer references.
Definition: uan-phy.cc:56
static TypeId GetTypeId()
Register this type.
Definition: uan-phy.cc:49
virtual double CalcPer(Ptr< Packet > pkt, double sinrDb, UanTxMode mode)=0
Calculate the packet error probability based on SINR at the receiver and a tx mode.
void DoDispose() override
Destructor implementation.
Definition: uan-phy.cc:61
std::list< UanPacketArrival > ArrivalList
List of arriving packets overlapping in time.
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:43
Every class exported by the ns3 library is enclosed in the ns3 namespace.
channel
Definition: third.py:81
mac
Definition: third.py:85