A Discrete-Event Network Simulator
API
uan-phy-gen.h
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
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#ifndef UAN_PHY_GEN_H
23#define UAN_PHY_GEN_H
24
25
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 "ns3/event-id.h"
32#include <list>
33
34namespace ns3 {
35
45{
46public:
50 virtual ~UanPhyPerGenDefault ();
51
56 static TypeId GetTypeId (void);
57
58 virtual double CalcPer (Ptr<Packet> pkt, double sinrDb, UanTxMode mode);
59private:
60 double m_thresh;
61
62}; // class UanPhyPerGenDefault
63
64
75{
76public:
80 virtual ~UanPhyPerUmodem ();
81
86 static TypeId GetTypeId (void);
87
103 virtual double CalcPer (Ptr<Packet> pkt, double sinrDb, UanTxMode mode);
104
105private:
113 double NChooseK (uint32_t n, uint32_t k);
114
115}; // class UanPhyPerUmodem
116
117
127{
128public:
132 virtual ~UanPhyPerCommonModes ();
133
138 static TypeId GetTypeId (void);
139
152 virtual double CalcPer (Ptr<Packet> pkt, double sinrDb, UanTxMode mode);
153
154}; // class UanPhyPerCommonModes
155
156
167{
168
169public:
173 virtual ~UanPhyCalcSinrDefault ();
174
179 static TypeId GetTypeId (void);
180
196 virtual double CalcSinrDb (Ptr<Packet> pkt,
197 Time arrTime,
198 double rxPowerDb,
199 double ambNoiseDb,
200 UanTxMode mode,
201 UanPdp pdp,
202 const UanTransducer::ArrivalList &arrivalList
203 ) const;
204
205}; // class UanPhyCalcSinrDefault
206
207
228{
229
230public:
234 virtual ~UanPhyCalcSinrFhFsk ();
235
240 static TypeId GetTypeId (void);
241
242 virtual double CalcSinrDb (Ptr<Packet> pkt,
243 Time arrTime,
244 double rxPowerDb,
245 double ambNoiseDb,
246 UanTxMode mode,
247 UanPdp pdp,
248 const UanTransducer::ArrivalList &arrivalList
249 ) const;
250private:
252
253}; // class UanPhyCalcSinrFhFsk
254
255
266class UanPhyGen : public UanPhy
267{
268public:
270 UanPhyGen ();
272 virtual ~UanPhyGen ();
278 static UanModesList GetDefaultModes (void);
279
284 static TypeId GetTypeId (void);
285
286 // Inherited methods
288 virtual void EnergyDepletionHandler (void);
289 virtual void EnergyRechargeHandler (void);
290 virtual void SendPacket (Ptr<Packet> pkt, uint32_t modeNum);
291 virtual void RegisterListener (UanPhyListener *listener);
292 virtual void StartRxPacket (Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp);
293 virtual void SetReceiveOkCallback (RxOkCallback cb);
294 virtual void SetReceiveErrorCallback (RxErrCallback cb);
295 virtual bool IsStateSleep (void);
296 virtual bool IsStateIdle (void);
297 virtual bool IsStateBusy (void);
298 virtual bool IsStateRx (void);
299 virtual bool IsStateTx (void);
300 virtual bool IsStateCcaBusy (void);
301 virtual void SetTxPowerDb (double txpwr);
302 virtual void SetRxThresholdDb (double thresh);
303 virtual void SetCcaThresholdDb (double thresh);
304 virtual double GetTxPowerDb (void);
305 virtual double GetRxThresholdDb (void);
306 virtual double GetCcaThresholdDb (void);
307 virtual Ptr<UanChannel> GetChannel (void) const;
308 virtual Ptr<UanNetDevice> GetDevice (void) const;
309 virtual Ptr<UanTransducer> GetTransducer (void);
310 virtual void SetChannel (Ptr<UanChannel> channel);
311 virtual void SetDevice (Ptr<UanNetDevice> device);
312 virtual void SetMac (Ptr<UanMac> mac);
313 virtual void SetTransducer (Ptr<UanTransducer> trans);
314 virtual void NotifyTransStartTx (Ptr<Packet> packet, double txPowerDb, UanTxMode txMode);
315 virtual void NotifyIntChange (void);
316 virtual uint32_t GetNModes (void);
317 virtual UanTxMode GetMode (uint32_t n);
318 virtual Ptr<Packet> GetPacketRx (void) const;
319 virtual void Clear (void);
320 virtual void SetSleepMode (bool sleep);
321 int64_t AssignStreams (int64_t stream);
322
323private:
325 typedef std::list<UanPhyListener *> ListenerList;
326
328
339
340 double m_txPwrDb;
343
351
353
356
359
368
379 double CalculateSinrDb (Ptr<Packet> pkt, Time arrTime, double rxPowerDb,
380 UanTxMode mode, UanPdp pdp);
381
392 double GetInterferenceDb (Ptr<Packet> pkt);
401 double DbToKp (double db);
410 double KpToDb (double kp);
418 void RxEndEvent (Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode);
420 void TxEndEvent ();
426 void UpdatePowerConsumption (const State state);
427
428
430 void NotifyListenersRxStart (void);
432 void NotifyListenersRxGood (void);
434 void NotifyListenersRxBad (void);
436 void NotifyListenersCcaStart (void);
438 void NotifyListenersCcaEnd (void);
444 void NotifyListenersTxStart (Time duration);
448 void NotifyListenersTxEnd (void);
449
450protected:
451 virtual void DoDispose ();
452
453}; // class UanPhyGen
454
455} // namespace ns3
456
457#endif /* UAN_PHY_GEN_H */
An identifier for simulation events.
Definition: event-id.h:54
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
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:258
The power delay profile returned by propagation models.
Default SINR calculator for UanPhyGen.
Definition: uan-phy-gen.h:167
UanPhyCalcSinrDefault()
Constructor.
Definition: uan-phy-gen.cc:53
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:74
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:63
virtual ~UanPhyCalcSinrDefault()
Destructor.
Definition: uan-phy-gen.cc:57
WHOI Micromodem like FH-FSK model.
Definition: uan-phy-gen.h:228
UanPhyCalcSinrFhFsk()
Constructor.
Definition: uan-phy-gen.cc:101
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:126
virtual ~UanPhyCalcSinrFhFsk()
Destructor.
Definition: uan-phy-gen.cc:105
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:111
uint32_t m_hops
Number of hops.
Definition: uan-phy-gen.h:251
Class used for calculating SINR of packet in UanPhy.
Definition: uan-phy.h:45
Generic PHY model.
Definition: uan-phy-gen.h:267
virtual Ptr< UanNetDevice > GetDevice(void) const
Get the device hosting this Phy.
Definition: uan-phy-gen.cc:969
void NotifyListenersRxStart(void)
Call UanListener::NotifyRxStart on all listeners.
double KpToDb(double kp)
Convert kilopascals to dB.
virtual Ptr< UanTransducer > GetTransducer(void)
Get the attached transducer.
Definition: uan-phy-gen.cc:975
Ptr< UanPhyPer > m_per
Error model.
Definition: uan-phy-gen.h:337
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxOkLogger
A packet destined for this Phy was received without error.
Definition: uan-phy-gen.h:363
virtual uint32_t GetNModes(void)
Get the number of transmission modes supported by this Phy.
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_txLogger
A packet was sent from this Phy.
Definition: uan-phy-gen.h:367
UanPhyGen()
Constructor.
Definition: uan-phy-gen.cc:494
virtual void SetRxThresholdDb(double thresh)
Set the minimum SINR threshold to receive a packet without errors.
Definition: uan-phy-gen.cc:934
virtual void EnergyRechargeHandler(void)
Handle the energy recharge event.
Definition: uan-phy-gen.cc:675
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxErrLogger
A packet destined for this Phy was received with error.
Definition: uan-phy-gen.h:365
void NotifyListenersTxStart(Time duration)
Call UanListener::NotifyTxStart on all listeners.
virtual bool IsStateRx(void)
Definition: uan-phy-gen.cc:911
Time m_pktRxArrTime
Packet arrival time.
Definition: uan-phy-gen.h:348
virtual void StartRxPacket(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp)
Packet arriving from channel: i.e.
Definition: uan-phy-gen.cc:756
virtual void SetSleepMode(bool sleep)
Set the Phy SLEEP mode.
void UpdatePowerConsumption(const State state)
Update energy source with new state.
Definition: uan-phy-gen.cc:642
void NotifyListenersTxEnd(void)
Call UanListener::NotifyTxEnd on all listeners.
ListenerList m_listeners
List of listeners.
Definition: uan-phy-gen.h:330
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
double m_rxRecvPwrDb
Receiver power.
Definition: uan-phy-gen.h:347
virtual void SetChannel(Ptr< UanChannel > channel)
Attach to a channel.
Definition: uan-phy-gen.cc:980
virtual Ptr< UanChannel > GetChannel(void) const
Get the attached channel.
Definition: uan-phy-gen.cc:963
Ptr< UanPhyCalcSinr > m_sinr
SINR calculator.
Definition: uan-phy-gen.h:338
Ptr< Packet > m_pktRx
Received packet.
Definition: uan-phy-gen.h:344
static UanModesList GetDefaultModes(void)
Get the default transmission modes.
Definition: uan-phy-gen.cc:569
virtual ~UanPhyGen()
Dummy destructor, see DoDispose.
Definition: uan-phy-gen.cc:513
DeviceEnergyModel::ChangeStateCallback m_energyCallback
Energy model callback.
Definition: uan-phy-gen.h:361
Ptr< UanTransducer > m_transducer
Associated transducer.
Definition: uan-phy-gen.h:334
double m_rxThreshDb
Receive SINR threshold.
Definition: uan-phy-gen.h:341
EventId m_rxEndEvent
Rx event.
Definition: uan-phy-gen.h:355
std::list< UanPhyListener * > ListenerList
List of Phy Listeners.
Definition: uan-phy-gen.h:325
double m_ccaThreshDb
CCA busy threshold.
Definition: uan-phy-gen.h:342
virtual bool IsStateSleep(void)
Definition: uan-phy-gen.cc:896
virtual void RegisterListener(UanPhyListener *listener)
Register a UanPhyListener to be notified of common UanPhy events.
Definition: uan-phy-gen.cc:749
RxOkCallback m_recOkCb
Callback for packets received without error.
Definition: uan-phy-gen.h:331
virtual void SendPacket(Ptr< Packet > pkt, uint32_t modeNum)
Send a packet using a specific transmission mode.
Definition: uan-phy-gen.cc:685
State m_state
Phy state.
Definition: uan-phy-gen.h:329
virtual void SetDevice(Ptr< UanNetDevice > device)
Set the device hosting this Phy.
Definition: uan-phy-gen.cc:986
Ptr< UanMac > m_mac
MAC layer.
Definition: uan-phy-gen.h:336
virtual void SetTransducer(Ptr< UanTransducer > trans)
Attach a transducer to this Phy.
Definition: uan-phy-gen.cc:998
double GetInterferenceDb(Ptr< Packet > pkt)
Calculate interference power from overlapping packet arrivals, in dB.
double m_txPwrDb
Transmit power.
Definition: uan-phy-gen.h:340
double CalculateSinrDb(Ptr< Packet > pkt, Time arrTime, double rxPowerDb, UanTxMode mode, UanPdp pdp)
Calculate the SINR value for a packet.
void NotifyListenersCcaStart(void)
Call UanListener::NotifyCcaStart on all listeners.
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:580
Ptr< UniformRandomVariable > m_pg
Provides uniform random variables.
Definition: uan-phy-gen.h:358
virtual void DoDispose()
Destructor implementation.
Definition: uan-phy-gen.cc:561
virtual void SetTxPowerDb(double txpwr)
Set the transmit power.
Definition: uan-phy-gen.cc:929
EventId m_txEndEvent
Tx event.
Definition: uan-phy-gen.h:354
virtual void NotifyTransStartTx(Ptr< Packet > packet, double txPowerDb, UanTxMode txMode)
Called when a transmission is beginning on the attached transducer.
virtual void SetReceiveOkCallback(RxOkCallback cb)
Set the callback to be used when a packet is received without error.
Definition: uan-phy-gen.cc:885
bool m_cleared
Flag when we've been cleared.
Definition: uan-phy-gen.h:352
virtual bool IsStateCcaBusy(void)
Definition: uan-phy-gen.cc:922
virtual void EnergyDepletionHandler(void)
Handle the energy depletion event.
Definition: uan-phy-gen.cc:653
virtual void SetMac(Ptr< UanMac > mac)
Set the MAC forwarding messages to this Phy.
Definition: uan-phy-gen.cc:992
virtual double GetTxPowerDb(void)
Get the current transmit power, in dB.
Definition: uan-phy-gen.cc:945
double m_minRxSinrDb
Minimum receive SINR during packet reception.
Definition: uan-phy-gen.h:346
void NotifyListenersRxBad(void)
Call UanListener::NotifyRxEndError on all listeners.
Ptr< UanChannel > m_channel
Attached channel.
Definition: uan-phy-gen.h:333
virtual Ptr< Packet > GetPacketRx(void) const
Get the packet currently being received.
double DbToKp(double db)
Convert dB to kilopascals.
UanTxMode m_pktRxMode
Packet transmission mode at receiver.
Definition: uan-phy-gen.h:350
void TxEndEvent()
Event to process end of packet transmission.
Definition: uan-phy-gen.cc:725
virtual bool IsStateTx(void)
Definition: uan-phy-gen.cc:916
virtual UanTxMode GetMode(uint32_t n)
Get a specific transmission mode.
virtual void SetCcaThresholdDb(double thresh)
Set the threshold for detecting channel busy.
Definition: uan-phy-gen.cc:939
RxErrCallback m_recErrCb
Callback for packets received with errors.
Definition: uan-phy-gen.h:332
virtual bool IsStateIdle(void)
Definition: uan-phy-gen.cc:901
void RxEndEvent(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode)
Event to process end of packet reception.
Definition: uan-phy-gen.cc:834
virtual double GetCcaThresholdDb(void)
Get the CCA threshold signal strength required to detect channel busy.
Definition: uan-phy-gen.cc:957
Ptr< UanNetDevice > m_device
Device hosting this Phy.
Definition: uan-phy-gen.h:335
virtual void Clear(void)
Clear all pointer references.
Definition: uan-phy-gen.cc:519
virtual void SetReceiveErrorCallback(RxErrCallback cb)
Set the callback to be used when a packet is received with errors.
Definition: uan-phy-gen.cc:891
Ptr< Packet > m_pktTx
Sent packet.
Definition: uan-phy-gen.h:345
virtual void SetEnergyModelCallback(DeviceEnergyModel::ChangeStateCallback cb)
Set the DeviceEnergyModel callback for UanPhy device.
Definition: uan-phy-gen.cc:635
void NotifyListenersRxGood(void)
Call UanListener::NotifyRxEndOk on all listeners.
UanPdp m_pktRxPdp
Power delay profile of packet.
Definition: uan-phy-gen.h:349
virtual double GetRxThresholdDb(void)
Get the minimum received signal strength required to receive a packet without errors.
Definition: uan-phy-gen.cc:952
UanModesList m_modes
List of modes supported by this PHY.
Definition: uan-phy-gen.h:327
virtual bool IsStateBusy(void)
Definition: uan-phy-gen.cc:906
virtual void NotifyIntChange(void)
Called when there has been a change in the amount of interference this node is experiencing from othe...
void NotifyListenersCcaEnd(void)
Call UanListener::NotifyCcaEnd on all listeners.
Base class for UAN Phy models.
Definition: uan-phy.h:179
State
Enum defining possible Phy states.
Definition: uan-phy.h:183
Interface for PHY event listener.
Definition: uan-phy.h:147
Packet error rate calculation for common tx modes based on UanPhyPerUmodem.
Definition: uan-phy-gen.h:127
virtual ~UanPhyPerCommonModes()
Destructor.
Definition: uan-phy-gen.cc:257
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:274
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:263
UanPhyPerCommonModes()
Constructor.
Definition: uan-phy-gen.cc:251
Default Packet Error Rate calculator for UanPhyGen.
Definition: uan-phy-gen.h:45
UanPhyPerGenDefault()
Constructor.
Definition: uan-phy-gen.cc:211
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:221
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:238
virtual ~UanPhyPerGenDefault()
Destructor.
Definition: uan-phy-gen.cc:216
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:111
Packet error rate calculation assuming WHOI Micromodem-like PHY (FH-FSK)
Definition: uan-phy-gen.h:75
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:397
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:428
double NChooseK(uint32_t n, uint32_t k)
Binomial coefficient.
Definition: uan-phy-gen.cc:408
UanPhyPerUmodem()
Constructor.
Definition: uan-phy-gen.cc:388
virtual ~UanPhyPerUmodem()
Destructor.
Definition: uan-phy-gen.cc:392
std::list< UanPacketArrival > ArrivalList
List of arriving packets overlapping in time.
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:42
Every class exported by the ns3 library is enclosed in the ns3 namespace.
channel
Definition: third.py:92
mac
Definition: third.py:96