A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
uan-phy-gen.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_GEN_H
22#define UAN_PHY_GEN_H
23
24#include "uan-phy.h"
25
26#include "ns3/device-energy-model.h"
27#include "ns3/event-id.h"
28#include "ns3/nstime.h"
29#include "ns3/random-variable-stream.h"
30#include "ns3/traced-callback.h"
31
32#include <list>
33
34namespace ns3
35{
36
46{
47 public:
51 ~UanPhyPerGenDefault() override;
52
57 static TypeId GetTypeId();
58
59 double CalcPer(Ptr<Packet> pkt, double sinrDb, UanTxMode mode) override;
60
61 private:
62 double m_thresh;
63
64}; // class UanPhyPerGenDefault
65
76{
77 public:
81 ~UanPhyPerUmodem() override;
82
87 static TypeId GetTypeId();
88
104 double CalcPer(Ptr<Packet> pkt, double sinrDb, UanTxMode mode) override;
105
106 private:
114 double NChooseK(uint32_t n, uint32_t k);
115
116}; // class UanPhyPerUmodem
117
127{
128 public:
132 ~UanPhyPerCommonModes() override;
133
138 static TypeId GetTypeId();
139
152 double CalcPer(Ptr<Packet> pkt, double sinrDb, UanTxMode mode) override;
153
154}; // class UanPhyPerCommonModes
155
166{
167 public:
171 ~UanPhyCalcSinrDefault() override;
172
177 static TypeId GetTypeId();
178
194 double CalcSinrDb(Ptr<Packet> pkt,
195 Time arrTime,
196 double rxPowerDb,
197 double ambNoiseDb,
198 UanTxMode mode,
199 UanPdp pdp,
200 const UanTransducer::ArrivalList& arrivalList) const override;
201
202}; // class UanPhyCalcSinrDefault
203
224{
225 public:
229 ~UanPhyCalcSinrFhFsk() override;
230
235 static TypeId GetTypeId();
236
237 double CalcSinrDb(Ptr<Packet> pkt,
238 Time arrTime,
239 double rxPowerDb,
240 double ambNoiseDb,
241 UanTxMode mode,
242 UanPdp pdp,
243 const UanTransducer::ArrivalList& arrivalList) const override;
244
245 private:
247
248}; // class UanPhyCalcSinrFhFsk
249
260class UanPhyGen : public UanPhy
261{
262 public:
264 UanPhyGen();
266 ~UanPhyGen() override;
273
278 static TypeId GetTypeId();
279
280 // Inherited methods
282 void EnergyDepletionHandler() override;
283 void EnergyRechargeHandler() override;
284 void SendPacket(Ptr<Packet> pkt, uint32_t modeNum) override;
285 void RegisterListener(UanPhyListener* listener) override;
286 void StartRxPacket(Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp) override;
287 void SetReceiveOkCallback(RxOkCallback cb) override;
288 void SetReceiveErrorCallback(RxErrCallback cb) override;
289 bool IsStateSleep() override;
290 bool IsStateIdle() override;
291 bool IsStateBusy() override;
292 bool IsStateRx() override;
293 bool IsStateTx() override;
294 bool IsStateCcaBusy() override;
295 void SetTxPowerDb(double txpwr) override;
296 void SetRxThresholdDb(double thresh) override;
297 void SetCcaThresholdDb(double thresh) override;
298 double GetTxPowerDb() override;
299 double GetRxThresholdDb() override;
300 double GetCcaThresholdDb() override;
301 Ptr<UanChannel> GetChannel() const override;
302 Ptr<UanNetDevice> GetDevice() const override;
304 void SetChannel(Ptr<UanChannel> channel) override;
305 void SetDevice(Ptr<UanNetDevice> device) override;
306 void SetMac(Ptr<UanMac> mac) override;
307 void SetTransducer(Ptr<UanTransducer> trans) override;
308 void NotifyTransStartTx(Ptr<Packet> packet, double txPowerDb, UanTxMode txMode) override;
309 void NotifyIntChange() override;
310 uint32_t GetNModes() override;
311 UanTxMode GetMode(uint32_t n) override;
312 Ptr<Packet> GetPacketRx() const override;
313 void Clear() override;
314 void SetSleepMode(bool sleep) override;
315 int64_t AssignStreams(int64_t stream) override;
316
317 private:
319 typedef std::list<UanPhyListener*> ListenerList;
320
322
333
334 double m_txPwrDb;
337
345
347
350
353
362
373 double CalculateSinrDb(Ptr<Packet> pkt,
374 Time arrTime,
375 double rxPowerDb,
376 UanTxMode mode,
377 UanPdp pdp);
378
389 double GetInterferenceDb(Ptr<Packet> pkt);
398 double DbToKp(double db);
407 double KpToDb(double kp);
415 void RxEndEvent(Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode);
417 void TxEndEvent();
423 void UpdatePowerConsumption(const State state);
424
440 void NotifyListenersTxStart(Time duration);
445
446 protected:
447 void DoDispose() override;
448
449}; // class UanPhyGen
450
451} // namespace ns3
452
453#endif /* UAN_PHY_GEN_H */
An identifier for simulation events.
Definition: event-id.h:55
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
Container for UanTxModes.
Definition: uan-tx-mode.h:259
The power delay profile returned by propagation models.
Default SINR calculator for UanPhyGen.
Definition: uan-phy-gen.h:166
double CalcSinrDb(Ptr< Packet > pkt, Time arrTime, double rxPowerDb, double ambNoiseDb, UanTxMode mode, UanPdp pdp, const UanTransducer::ArrivalList &arrivalList) const override
Calculate the SINR value for a packet.
Definition: uan-phy-gen.cc:72
UanPhyCalcSinrDefault()
Constructor.
Definition: uan-phy-gen.cc:53
static TypeId GetTypeId()
Register this type.
Definition: uan-phy-gen.cc:62
~UanPhyCalcSinrDefault() override
Destructor.
Definition: uan-phy-gen.cc:57
WHOI Micromodem like FH-FSK model.
Definition: uan-phy-gen.h:224
UanPhyCalcSinrFhFsk()
Constructor.
Definition: uan-phy-gen.cc:102
double CalcSinrDb(Ptr< Packet > pkt, Time arrTime, double rxPowerDb, double ambNoiseDb, UanTxMode mode, UanPdp pdp, const UanTransducer::ArrivalList &arrivalList) const override
Calculate the SINR value for a packet.
Definition: uan-phy-gen.cc:126
static TypeId GetTypeId()
Register this type.
Definition: uan-phy-gen.cc:111
~UanPhyCalcSinrFhFsk() override
Destructor.
Definition: uan-phy-gen.cc:106
uint32_t m_hops
Number of hops.
Definition: uan-phy-gen.h:246
Class used for calculating SINR of packet in UanPhy.
Definition: uan-phy.h:44
Generic PHY model.
Definition: uan-phy-gen.h:261
std::list< UanPhyListener * > ListenerList
List of Phy Listeners.
Definition: uan-phy-gen.h:319
Ptr< UanChannel > GetChannel() const override
Get the attached channel.
Definition: uan-phy-gen.cc:970
bool IsStateSleep() override
Definition: uan-phy-gen.cc:898
void SetTxPowerDb(double txpwr) override
Set the transmit power.
Definition: uan-phy-gen.cc:934
double KpToDb(double kp)
Convert kilopascals to dB.
void NotifyTransStartTx(Ptr< Packet > packet, double txPowerDb, UanTxMode txMode) override
Called when a transmission is beginning on the attached transducer.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< UanPhyPer > m_per
Error model.
Definition: uan-phy-gen.h:331
UanPhyGen()
Constructor.
Definition: uan-phy-gen.cc:493
void SetRxThresholdDb(double thresh) override
Set the minimum SINR threshold to receive a packet without errors.
Definition: uan-phy-gen.cc:940
void EnergyDepletionHandler() override
Handle the energy depletion event.
Definition: uan-phy-gen.cc:652
void NotifyListenersTxStart(Time duration)
Call UanListener::NotifyTxStart on all listeners.
Time m_pktRxArrTime
Packet arrival time.
Definition: uan-phy-gen.h:342
UanTxMode GetMode(uint32_t n) override
Get a specific transmission mode.
void UpdatePowerConsumption(const State state)
Update energy source with new state.
Definition: uan-phy-gen.cc:641
double GetRxThresholdDb() override
Get the minimum received signal strength required to receive a packet without errors.
Definition: uan-phy-gen.cc:958
ListenerList m_listeners
List of listeners.
Definition: uan-phy-gen.h:324
void NotifyListenersCcaStart()
Call UanListener::NotifyCcaStart on all listeners.
void SetSleepMode(bool sleep) override
Set the Phy SLEEP mode.
~UanPhyGen() override
Dummy destructor, see DoDispose.
Definition: uan-phy-gen.cc:512
double m_rxRecvPwrDb
Receiver power.
Definition: uan-phy-gen.h:341
bool IsStateBusy() override
Definition: uan-phy-gen.cc:910
void NotifyListenersRxGood()
Call UanListener::NotifyRxEndOk on all listeners.
uint32_t GetNModes() override
Get the number of transmission modes supported by this Phy.
Ptr< UanPhyCalcSinr > m_sinr
SINR calculator.
Definition: uan-phy-gen.h:332
void NotifyListenersRxBad()
Call UanListener::NotifyRxEndError on all listeners.
double GetCcaThresholdDb() override
Get the CCA threshold signal strength required to detect channel busy.
Definition: uan-phy-gen.cc:964
Ptr< Packet > m_pktRx
Received packet.
Definition: uan-phy-gen.h:338
void SetReceiveErrorCallback(RxErrCallback cb) override
Set the callback to be used when a packet is received with errors.
Definition: uan-phy-gen.cc:892
Ptr< UanTransducer > GetTransducer() override
Get the attached transducer.
Definition: uan-phy-gen.cc:982
DeviceEnergyModel::ChangeStateCallback m_energyCallback
Energy model callback.
Definition: uan-phy-gen.h:355
Ptr< UanTransducer > m_transducer
Associated transducer.
Definition: uan-phy-gen.h:328
double m_rxThreshDb
Receive SINR threshold.
Definition: uan-phy-gen.h:335
EventId m_rxEndEvent
Rx event.
Definition: uan-phy-gen.h:349
void DoDispose() override
Destructor implementation.
Definition: uan-phy-gen.cc:559
double m_ccaThreshDb
CCA busy threshold.
Definition: uan-phy-gen.h:336
void SetTransducer(Ptr< UanTransducer > trans) override
Attach a transducer to this Phy.
RxOkCallback m_recOkCb
Callback for packets received without error.
Definition: uan-phy-gen.h:325
State m_state
Phy state.
Definition: uan-phy-gen.h:323
void NotifyListenersTxEnd()
Call UanListener::NotifyTxEnd on all listeners.
Ptr< UanMac > m_mac
MAC layer.
Definition: uan-phy-gen.h:330
Ptr< UanNetDevice > GetDevice() const override
Get the device hosting this Phy.
Definition: uan-phy-gen.cc:976
double GetInterferenceDb(Ptr< Packet > pkt)
Calculate interference power from overlapping packet arrivals, in dB.
double m_txPwrDb
Transmit power.
Definition: uan-phy-gen.h:334
double CalculateSinrDb(Ptr< Packet > pkt, Time arrTime, double rxPowerDb, UanTxMode mode, UanPdp pdp)
Calculate the SINR value for a packet.
void SetReceiveOkCallback(RxOkCallback cb) override
Set the callback to be used when a packet is received without error.
Definition: uan-phy-gen.cc:886
static UanModesList GetDefaultModes()
Get the default transmission modes.
Definition: uan-phy-gen.cc:567
bool IsStateTx() override
Definition: uan-phy-gen.cc:922
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxOkLogger
A packet destined for this Phy was received without error.
Definition: uan-phy-gen.h:357
Ptr< UniformRandomVariable > m_pg
Provides uniform random variables.
Definition: uan-phy-gen.h:352
EventId m_txEndEvent
Tx event.
Definition: uan-phy-gen.h:348
void SendPacket(Ptr< Packet > pkt, uint32_t modeNum) override
Send a packet using a specific transmission mode.
Definition: uan-phy-gen.cc:684
void RegisterListener(UanPhyListener *listener) override
Register a UanPhyListener to be notified of common UanPhy events.
Definition: uan-phy-gen.cc:748
bool m_cleared
Flag when we've been cleared.
Definition: uan-phy-gen.h:346
bool IsStateRx() override
Definition: uan-phy-gen.cc:916
void SetMac(Ptr< UanMac > mac) override
Set the MAC forwarding messages to this Phy.
double m_minRxSinrDb
Minimum receive SINR during packet reception.
Definition: uan-phy-gen.h:340
static TypeId GetTypeId()
Register this type.
Definition: uan-phy-gen.cc:581
void SetCcaThresholdDb(double thresh) override
Set the threshold for detecting channel busy.
Definition: uan-phy-gen.cc:946
Ptr< UanChannel > m_channel
Attached channel.
Definition: uan-phy-gen.h:327
bool IsStateCcaBusy() override
Definition: uan-phy-gen.cc:928
void SetEnergyModelCallback(DeviceEnergyModel::ChangeStateCallback cb) override
Set the DeviceEnergyModel callback for UanPhy device.
Definition: uan-phy-gen.cc:634
void SetDevice(Ptr< UanNetDevice > device) override
Set the device hosting this Phy.
Definition: uan-phy-gen.cc:994
double DbToKp(double db)
Convert dB to kilopascals.
UanTxMode m_pktRxMode
Packet transmission mode at receiver.
Definition: uan-phy-gen.h:344
void TxEndEvent()
Event to process end of packet transmission.
Definition: uan-phy-gen.cc:724
void Clear() override
Clear all pointer references.
Definition: uan-phy-gen.cc:517
Ptr< Packet > GetPacketRx() const override
Get the packet currently being received.
RxErrCallback m_recErrCb
Callback for packets received with errors.
Definition: uan-phy-gen.h:326
void RxEndEvent(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode)
Event to process end of packet reception.
Definition: uan-phy-gen.cc:836
Ptr< UanNetDevice > m_device
Device hosting this Phy.
Definition: uan-phy-gen.h:329
void StartRxPacket(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp) override
Packet arriving from channel: i.e.
Definition: uan-phy-gen.cc:754
Ptr< Packet > m_pktTx
Sent packet.
Definition: uan-phy-gen.h:339
void SetChannel(Ptr< UanChannel > channel) override
Attach to a channel.
Definition: uan-phy-gen.cc:988
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_txLogger
A packet was sent from this Phy.
Definition: uan-phy-gen.h:361
void NotifyIntChange() override
Called when there has been a change in the amount of interference this node is experiencing from othe...
double GetTxPowerDb() override
Get the current transmit power, in dB.
Definition: uan-phy-gen.cc:952
bool IsStateIdle() override
Definition: uan-phy-gen.cc:904
UanPdp m_pktRxPdp
Power delay profile of packet.
Definition: uan-phy-gen.h:343
void NotifyListenersCcaEnd()
Call UanListener::NotifyCcaEnd on all listeners.
void EnergyRechargeHandler() override
Handle the energy recharge event.
Definition: uan-phy-gen.cc:674
void NotifyListenersRxStart()
Call UanListener::NotifyRxStart on all listeners.
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxErrLogger
A packet destined for this Phy was received with error.
Definition: uan-phy-gen.h:359
UanModesList m_modes
List of modes supported by this PHY.
Definition: uan-phy-gen.h:321
Base class for UAN Phy models.
Definition: uan-phy.h:178
State
Enum defining possible Phy states.
Definition: uan-phy.h:182
Interface for PHY event listener.
Definition: uan-phy.h:145
Packet error rate calculation for common tx modes based on UanPhyPerUmodem.
Definition: uan-phy-gen.h:127
~UanPhyPerCommonModes() override
Destructor.
Definition: uan-phy-gen.cc:263
double CalcPer(Ptr< Packet > pkt, double sinrDb, UanTxMode mode) override
Calculate the Packet ERror probability based on SINR at the receiver and a tx mode.
Definition: uan-phy-gen.cc:279
UanPhyPerCommonModes()
Constructor.
Definition: uan-phy-gen.cc:258
static TypeId GetTypeId()
Register this type.
Definition: uan-phy-gen.cc:268
Default Packet Error Rate calculator for UanPhyGen.
Definition: uan-phy-gen.h:46
UanPhyPerGenDefault()
Constructor.
Definition: uan-phy-gen.cc:219
~UanPhyPerGenDefault() override
Destructor.
Definition: uan-phy-gen.cc:223
double CalcPer(Ptr< Packet > pkt, double sinrDb, UanTxMode mode) override
Calculate the packet error probability based on SINR at the receiver and a tx mode.
Definition: uan-phy-gen.cc:245
static TypeId GetTypeId()
Register this type.
Definition: uan-phy-gen.cc:228
double m_thresh
SINR threshold.
Definition: uan-phy-gen.h:62
Calculate packet error probability, based on received SINR and modulation (mode).
Definition: uan-phy.h:110
Packet error rate calculation assuming WHOI Micromodem-like PHY (FH-FSK)
Definition: uan-phy-gen.h:76
double CalcPer(Ptr< Packet > pkt, double sinrDb, UanTxMode mode) override
Calculate the packet error probability based on SINR at the receiver and a tx mode.
Definition: uan-phy-gen.cc:432
static TypeId GetTypeId()
Register this type.
Definition: uan-phy-gen.cc:402
double NChooseK(uint32_t n, uint32_t k)
Binomial coefficient.
Definition: uan-phy-gen.cc:412
UanPhyPerUmodem()
Constructor.
Definition: uan-phy-gen.cc:393
~UanPhyPerUmodem() override
Destructor.
Definition: uan-phy-gen.cc:397
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.