A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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 "uan-mac.h"
25#include "uan-prop-model.h"
26#include "uan-transducer.h"
27#include "uan-tx-mode.h"
28
29#include "ns3/device-energy-model.h"
30#include "ns3/object.h"
31
32namespace ns3
33{
34
43class UanPhyCalcSinr : public Object
44{
45 public:
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) const = 0;
69 static TypeId GetTypeId();
70
72 virtual void Clear();
73
80 inline double DbToKp(double db) const
81 {
82 return std::pow(10, db / 10.0);
83 }
84
91 inline double KpToDb(double kp) const
92 {
93 return 10 * std::log10(kp);
94 }
95
96 protected:
97 void DoDispose() override;
98
99}; // class UanPhyCalcSinr
100
109class UanPhyPer : public Object
110{
111 public:
121 virtual double CalcPer(Ptr<Packet> pkt, double sinrDb, UanTxMode mode) = 0;
122
127 static TypeId GetTypeId();
129 virtual void Clear();
130
131 protected:
132 void DoDispose() override;
133
134}; // class UanPhyPer
135
145{
146 public:
149 {
150 }
151
153 virtual void NotifyRxStart() = 0;
155 virtual void NotifyRxEndOk() = 0;
157 virtual void NotifyRxEndError() = 0;
159 virtual void NotifyCcaStart() = 0;
161 virtual void NotifyCcaEnd() = 0;
167 virtual void NotifyTxStart(Time duration) = 0;
169 virtual void NotifyTxEnd() = 0;
170}; // class UanPhyListener
171
177class UanPhy : public Object
178{
179 public:
181 enum State
182 {
188 DISABLED
189 };
190
199
207
215 typedef void (*TracedCallback)(Ptr<const Packet> pkt, double sinr, UanTxMode mode);
216
226 virtual void EnergyDepletionHandler() = 0;
230 virtual void EnergyRechargeHandler() = 0;
237 virtual void SendPacket(Ptr<Packet> pkt, uint32_t modeNum) = 0;
238
244 virtual void RegisterListener(UanPhyListener* listener) = 0;
245
254 virtual void StartRxPacket(Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp) = 0;
255
261 virtual void SetReceiveOkCallback(RxOkCallback cb) = 0;
262
269
275 virtual void SetTxPowerDb(double txpwr) = 0;
276
284 virtual void SetRxThresholdDb(double thresh) = 0;
285
291 virtual void SetCcaThresholdDb(double thresh) = 0;
292
298 virtual double GetTxPowerDb() = 0;
299
306 virtual double GetRxThresholdDb() = 0;
307
313 virtual double GetCcaThresholdDb() = 0;
315 virtual bool IsStateSleep() = 0;
317 virtual bool IsStateIdle() = 0;
319 virtual bool IsStateBusy() = 0;
321 virtual bool IsStateRx() = 0;
323 virtual bool IsStateTx() = 0;
325 virtual bool IsStateCcaBusy() = 0;
326
332 virtual Ptr<UanChannel> GetChannel() const = 0;
333
339 virtual Ptr<UanNetDevice> GetDevice() const = 0;
340
346 virtual void SetChannel(Ptr<UanChannel> channel) = 0;
347
353 virtual void SetDevice(Ptr<UanNetDevice> device) = 0;
354
360 virtual void SetMac(Ptr<UanMac> mac) = 0;
361
370 virtual void NotifyTransStartTx(Ptr<Packet> packet, double txPowerDb, UanTxMode txMode) = 0;
371
377 virtual void NotifyIntChange() = 0;
378
384 virtual void SetTransducer(Ptr<UanTransducer> trans) = 0;
385
392
398 virtual uint32_t GetNModes() = 0;
399
406 virtual UanTxMode GetMode(uint32_t n) = 0;
407
414 virtual Ptr<Packet> GetPacketRx() const = 0;
415
417 virtual void Clear() = 0;
418
424 virtual void SetSleepMode(bool sleep) = 0;
425
434 void NotifyTxBegin(Ptr<const Packet> packet);
435
444 void NotifyTxEnd(Ptr<const Packet> packet);
445
455 void NotifyTxDrop(Ptr<const Packet> packet);
456
465 void NotifyRxBegin(Ptr<const Packet> packet);
466
475 void NotifyRxEnd(Ptr<const Packet> packet);
476
485 void NotifyRxDrop(Ptr<const Packet> packet);
486
495 virtual int64_t AssignStreams(int64_t stream) = 0;
496
501 static TypeId GetTypeId();
502
503 private:
511
519
527
535
543
551
552}; // class UanPhy
553
554} // namespace ns3
555
556#endif /* UAN_PHY_H */
Callback template class.
Definition: callback.h:438
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
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:44
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:80
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:91
Base class for UAN Phy models.
Definition: uan-phy.h:178
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:198
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:534
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:526
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:550
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:542
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:518
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:510
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:206
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:182
@ RX
Receiving.
Definition: uan-phy.h:185
@ SLEEP
Sleeping.
Definition: uan-phy.h:187
@ IDLE
Idle state.
Definition: uan-phy.h:183
@ DISABLED
Disabled.
Definition: uan-phy.h:188
@ TX
Transmitting.
Definition: uan-phy.h:186
@ CCABUSY
Channel busy.
Definition: uan-phy.h:184
virtual void SetSleepMode(bool sleep)=0
Set the Phy SLEEP mode.
Interface for PHY event listener.
Definition: uan-phy.h:145
virtual ~UanPhyListener()
Default destructor.
Definition: uan-phy.h:148
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:110
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.