A Discrete-Event Network Simulator
API
uan-phy-dual.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_DUAL_H
23 #define UAN_PHY_DUAL_H
24 
25 #include "ns3/uan-phy.h"
26 
27 
28 
29 namespace ns3 {
30 
31 class UanTxMode;
32 class UanModesList;
33 
42 {
43 public:
47  virtual ~UanPhyCalcSinrDual ();
48 
53  static TypeId GetTypeId (void);
54 
55  virtual double CalcSinrDb (Ptr<Packet> pkt,
56  Time arrTime,
57  double rxPowerDb,
58  double ambNoiseDb,
59  UanTxMode mode,
60  UanPdp pdp,
61  const UanTransducer::ArrivalList &arrivalList
62  ) const;
63 
64 }; // class UanPhyCalcSinrDual
65 
81 class UanPhyDual : public UanPhy
82 {
83 public:
85  UanPhyDual ();
87  virtual ~UanPhyDual ();
88 
93  static TypeId GetTypeId ();
94 
95  // Inherited methods:
97  virtual void EnergyDepletionHandler (void);
98  virtual void EnergyRechargeHandler (void);
99  virtual void SendPacket (Ptr<Packet> pkt, uint32_t modeNum);
100 
110  virtual void RegisterListener (UanPhyListener *listener);
111  virtual void StartRxPacket (Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp);
112  virtual void SetReceiveOkCallback (RxOkCallback cb);
113  virtual void SetReceiveErrorCallback (RxErrCallback cb);
114  virtual void SetTxPowerDb (double txpwr);
115  virtual void SetRxThresholdDb (double thresh);
116  virtual void SetCcaThresholdDb (double thresh);
117  virtual double GetTxPowerDb (void);
118  virtual double GetRxThresholdDb (void);
119  virtual double GetCcaThresholdDb (void);
120  virtual bool IsStateSleep (void);
121  virtual bool IsStateIdle (void);
122  virtual bool IsStateBusy (void);
123  virtual bool IsStateRx (void);
124  virtual bool IsStateTx (void);
125  virtual bool IsStateCcaBusy (void);
126  virtual Ptr<UanChannel> GetChannel (void) const;
127  virtual Ptr<UanNetDevice> GetDevice (void) const;
128  virtual void SetChannel (Ptr<UanChannel> channel);
129  virtual void SetDevice (Ptr<UanNetDevice> device);
130  virtual void SetMac (Ptr<UanMac> mac);
131  virtual void NotifyTransStartTx (Ptr<Packet> packet, double txPowerDb, UanTxMode txMode);
132  virtual void NotifyIntChange (void);
133  virtual void SetTransducer (Ptr<UanTransducer> trans);
134  virtual Ptr<UanTransducer> GetTransducer (void);
135  virtual uint32_t GetNModes (void);
136  virtual UanTxMode GetMode (uint32_t n);
137  virtual void Clear (void);
138  virtual void SetSleepMode (bool sleep)
139  {
140  NS_UNUSED (sleep);
142  }
143  int64_t AssignStreams (int64_t stream);
144  Ptr<Packet> GetPacketRx (void) const;
145 
146 
148  bool IsPhy1Idle (void);
150  bool IsPhy2Idle (void);
152  bool IsPhy1Rx (void);
154  bool IsPhy2Rx (void);
156  bool IsPhy1Tx (void);
158  bool IsPhy2Tx (void);
159 
160  // Attribute getters and setters
162  double GetCcaThresholdPhy1 (void) const;
164  double GetCcaThresholdPhy2 (void) const;
166  void SetCcaThresholdPhy1 (double thresh);
168  void SetCcaThresholdPhy2 (double thresh);
169 
171  double GetTxPowerDbPhy1 (void) const;
173  double GetTxPowerDbPhy2 (void) const;
175  void SetTxPowerDbPhy1 (double txpwr);
177  void SetTxPowerDbPhy2 (double txpwr);
178 
179 
185  UanModesList GetModesPhy1 (void) const;
187  UanModesList GetModesPhy2 (void) const;
188 
194  void SetModesPhy1 (UanModesList modes);
196  void SetModesPhy2 (UanModesList modes);
197 
203  Ptr<UanPhyPer> GetPerModelPhy1 (void) const;
205  Ptr<UanPhyPer> GetPerModelPhy2 (void) const;
206 
212  void SetPerModelPhy1 (Ptr<UanPhyPer> per);
214  void SetPerModelPhy2 (Ptr<UanPhyPer> per);
215 
224 
230  void SetSinrModelPhy1 (Ptr<UanPhyCalcSinr> calcSinr);
232  void SetSinrModelPhy2 (Ptr<UanPhyCalcSinr> calcSinr);
233 
234 
236  Ptr<Packet> GetPhy1PacketRx (void) const;
238  Ptr<Packet> GetPhy2PacketRx (void) const;
239 
240 
241 private:
246 
257 
258 
266  void RxOkFromSubPhy (Ptr<Packet> pkt, double sinr, UanTxMode mode);
273  void RxErrFromSubPhy (Ptr<Packet> pkt, double sinr);
274 
275 protected:
276  virtual void DoDispose ();
277 
278 }; // class UanPhyDual
279 
280 } // namespace ns3
281 
282 #endif /* UAN_PHY_DUAL_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::UanPhyDual::GetSinrModelPhy2
Ptr< UanPhyCalcSinr > GetSinrModelPhy2(void) const
Get the SINR calculator.
Definition: uan-phy-dual.cc:594
ns3::UanPhyDual::GetCcaThresholdPhy1
double GetCcaThresholdPhy1(void) const
Get the CCA threshold signal strength required to detect channel busy.
Definition: uan-phy-dual.cc:372
ns3::UanPhyDual::GetTxPowerDbPhy2
double GetTxPowerDbPhy2(void) const
Get the current transmit power, in dB.
Definition: uan-phy-dual.cc:354
ns3::UanPhyDual::SetSleepMode
virtual void SetSleepMode(bool sleep)
Set the Phy SLEEP mode.
Definition: uan-phy-dual.h:138
ns3::UanPdp
The power delay profile returned by propagation models.
Definition: uan-prop-model.h:92
ns3::UanPhyDual::DoDispose
virtual void DoDispose()
Destructor implementation.
Definition: uan-phy-dual.cc:152
ns3::UanPhyDual::SetModesPhy1
void SetModesPhy1(UanModesList modes)
Set the available modes.
Definition: uan-phy-dual.cc:546
ns3::UanPhyDual::SetTxPowerDbPhy1
void SetTxPowerDbPhy1(double txpwr)
Set the transmit power.
Definition: uan-phy-dual.cc:305
ns3::Callback< void, int >
ns3::UanPhyDual::SetMac
virtual void SetMac(Ptr< UanMac > mac)
Set the MAC forwarding messages to this Phy.
Definition: uan-phy-dual.cc:481
ns3::UanPhyDual::NotifyTransStartTx
virtual void NotifyTransStartTx(Ptr< Packet > packet, double txPowerDb, UanTxMode txMode)
Called when a transmission is beginning on the attached transducer.
Definition: uan-phy-dual.cc:487
ns3::UanPhyDual::m_rxErrLogger
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxErrLogger
A packet was received unsuccessfully.
Definition: uan-phy-dual.h:250
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::UanPhyDual::GetCcaThresholdDb
virtual double GetCcaThresholdDb(void)
Get the CCA threshold signal strength required to detect channel busy.
Definition: uan-phy-dual.cc:366
ns3::UanPhyDual::GetMode
virtual UanTxMode GetMode(uint32_t n)
Get a specific transmission mode.
Definition: uan-phy-dual.cc:516
ns3::UanPhyDual::GetNModes
virtual uint32_t GetNModes(void)
Get the number of transmission modes supported by this Phy.
Definition: uan-phy-dual.cc:511
ns3::UanPhyDual::SetTxPowerDbPhy2
void SetTxPowerDbPhy2(double txpwr)
Set the transmit power.
Definition: uan-phy-dual.cc:310
ns3::UanPhyDual::RxErrFromSubPhy
void RxErrFromSubPhy(Ptr< Packet > pkt, double sinr)
Handle callback and logger for packets received with error.
Definition: uan-phy-dual.cc:622
ns3::UanPhyDual::StartRxPacket
virtual void StartRxPacket(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp)
Packet arriving from channel: i.e.
Definition: uan-phy-dual.cc:276
third.channel
channel
Definition: third.py:92
ns3::UanPhyDual::IsStateCcaBusy
virtual bool IsStateCcaBusy(void)
Definition: uan-phy-dual.cc:454
ns3::UanPhyDual::SetEnergyModelCallback
virtual void SetEnergyModelCallback(DeviceEnergyModel::ChangeStateCallback callback)
Set the DeviceEnergyModel callback for UanPhy device.
Definition: uan-phy-dual.cc:234
ns3::UanPhyCalcSinrDual::CalcSinrDb
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-dual.cc:69
ns3::UanPhyDual
Two channel Phy.
Definition: uan-phy-dual.h:82
ns3::UanPhyCalcSinrDual::UanPhyCalcSinrDual
UanPhyCalcSinrDual()
Constructor.
Definition: uan-phy-dual.cc:48
ns3::UanPhyDual::SetDevice
virtual void SetDevice(Ptr< UanNetDevice > device)
Set the device hosting this Phy.
Definition: uan-phy-dual.cc:475
third.mac
mac
Definition: third.py:99
ns3::UanPhyDual::SetPerModelPhy1
void SetPerModelPhy1(Ptr< UanPhyPer > per)
Set the error probability model.
Definition: uan-phy-dual.cc:574
ns3::UanPhyDual::IsStateTx
virtual bool IsStateTx(void)
Definition: uan-phy-dual.cc:449
ns3::UanModesList
Container for UanTxModes.
Definition: uan-tx-mode.h:258
ns3::UanPhyDual::SetCcaThresholdPhy1
void SetCcaThresholdPhy1(double thresh)
Set the threshold for detecting channel busy.
Definition: uan-phy-dual.cc:329
ns3::UanPhyDual::SetChannel
virtual void SetChannel(Ptr< UanChannel > channel)
Attach to a channel.
Definition: uan-phy-dual.cc:469
ns3::UanPhy
Base class for UAN Phy models.
Definition: uan-phy.h:179
ns3::UanPhyDual::AssignStreams
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: uan-phy-dual.cc:636
ns3::Ptr< Packet >
ns3::UanPhyDual::SetCcaThresholdPhy2
void SetCcaThresholdPhy2(double thresh)
Set the threshold for detecting channel busy.
Definition: uan-phy-dual.cc:334
ns3::UanPhyDual::m_rxOkLogger
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxOkLogger
A packet was received successfully.
Definition: uan-phy-dual.h:248
ns3::UanPhyDual::GetPhy2PacketRx
Ptr< Packet > GetPhy2PacketRx(void) const
Get the packet currently being received.
Definition: uan-phy-dual.cc:418
ns3::UanPhyDual::GetRxThresholdDb
virtual double GetRxThresholdDb(void)
Get the minimum received signal strength required to receive a packet without errors.
Definition: uan-phy-dual.cc:360
ns3::UanPhyDual::GetModesPhy1
UanModesList GetModesPhy1(void) const
Get the list of available modes.
Definition: uan-phy-dual.cc:529
ns3::UanPhyDual::SendPacket
virtual void SendPacket(Ptr< Packet > pkt, uint32_t modeNum)
Send a packet using a specific transmission mode.
Definition: uan-phy-dual.cc:252
ns3::UanPhyDual::SetRxThresholdDb
virtual void SetRxThresholdDb(double thresh)
Set the minimum SINR threshold to receive a packet without errors.
Definition: uan-phy-dual.cc:316
ns3::UanPhyDual::Clear
virtual void Clear(void)
Clear all pointer references.
Definition: uan-phy-dual.cc:138
ns3::UanPhyDual::GetCcaThresholdPhy2
double GetCcaThresholdPhy2(void) const
Get the CCA threshold signal strength required to detect channel busy.
Definition: uan-phy-dual.cc:377
ns3::UanPhyDual::GetSinrModelPhy1
Ptr< UanPhyCalcSinr > GetSinrModelPhy1(void) const
Get the SINR calculator.
Definition: uan-phy-dual.cc:586
ns3::UanPhyDual::GetPerModelPhy2
Ptr< UanPhyPer > GetPerModelPhy2(void) const
Get the error probability model.
Definition: uan-phy-dual.cc:566
ns3::UanPhyDual::SetSinrModelPhy1
void SetSinrModelPhy1(Ptr< UanPhyCalcSinr > calcSinr)
Set the SINR calculator.
Definition: uan-phy-dual.cc:602
ns3::UanPhyDual::UanPhyDual
UanPhyDual()
Constructor.
Definition: uan-phy-dual.cc:118
ns3::UanPhyDual::~UanPhyDual
virtual ~UanPhyDual()
Dummy destructor.
Definition: uan-phy-dual.cc:133
ns3::UanPhyDual::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition: uan-phy-dual.cc:159
ns3::UanPhyDual::SetPerModelPhy2
void SetPerModelPhy2(Ptr< UanPhyPer > per)
Set the error probability model.
Definition: uan-phy-dual.cc:580
ns3::UanPhyDual::RegisterListener
virtual void RegisterListener(UanPhyListener *listener)
Register a UanPhyListener to be notified of common UanPhy events.
Definition: uan-phy-dual.cc:269
ns3::UanPhyDual::GetPhy1PacketRx
Ptr< Packet > GetPhy1PacketRx(void) const
Get the packet currently being received.
Definition: uan-phy-dual.cc:412
NS_UNUSED
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
ns3::UanPhyCalcSinrDual::~UanPhyCalcSinrDual
virtual ~UanPhyCalcSinrDual()
Destructor.
Definition: uan-phy-dual.cc:52
ns3::UanPhyDual::GetDevice
virtual Ptr< UanNetDevice > GetDevice(void) const
Get the device hosting this Phy.
Definition: uan-phy-dual.cc:464
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::UanPhyDual::SetReceiveOkCallback
virtual void SetReceiveOkCallback(RxOkCallback cb)
Set the callback to be used when a packet is received without error.
Definition: uan-phy-dual.cc:283
ns3::UanTxMode
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:42
ns3::UanPhyDual::IsStateBusy
virtual bool IsStateBusy(void)
Definition: uan-phy-dual.cc:439
ns3::UanPhyDual::EnergyDepletionHandler
virtual void EnergyDepletionHandler(void)
Handle the energy depletion event.
Definition: uan-phy-dual.cc:240
ns3::UanPhyDual::m_txLogger
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_txLogger
A packet was sent from this Phy.
Definition: uan-phy-dual.h:252
ns3::UanPhyCalcSinrDual::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-dual.cc:58
ns3::UanPhyDual::m_recErrCb
RxErrCallback m_recErrCb
Callback when packet received with errors.
Definition: uan-phy-dual.h:256
ns3::UanPhyDual::SetTxPowerDb
virtual void SetTxPowerDb(double txpwr)
Set the transmit power.
Definition: uan-phy-dual.cc:298
ns3::UanPhyDual::NotifyIntChange
virtual void NotifyIntChange(void)
Called when there has been a change in the amount of interference this node is experiencing from othe...
Definition: uan-phy-dual.cc:492
ns3::UanPhyDual::GetPerModelPhy1
Ptr< UanPhyPer > GetPerModelPhy1(void) const
Get the error probability model.
Definition: uan-phy-dual.cc:558
ns3::UanPhyDual::GetTxPowerDb
virtual double GetTxPowerDb(void)
Get the current transmit power, in dB.
Definition: uan-phy-dual.cc:341
ns3::UanPhyDual::GetTxPowerDbPhy1
double GetTxPowerDbPhy1(void) const
Get the current transmit power, in dB.
Definition: uan-phy-dual.cc:348
ns3::UanPhyListener
Interface for PHY event listener.
Definition: uan-phy.h:147
ns3::UanPhyDual::SetModesPhy2
void SetModesPhy2(UanModesList modes)
Set the available modes.
Definition: uan-phy-dual.cc:552
ns3::UanPhyDual::RxOkFromSubPhy
void RxOkFromSubPhy(Ptr< Packet > pkt, double sinr, UanTxMode mode)
Handle callback and logger for packets received without error.
Definition: uan-phy-dual.cc:614
ns3::UanPhyDual::GetChannel
virtual Ptr< UanChannel > GetChannel(void) const
Get the attached channel.
Definition: uan-phy-dual.cc:459
ns3::UanPhyDual::IsPhy2Idle
bool IsPhy2Idle(void)
Definition: uan-phy-dual.cc:388
ns3::UanPhyDual::IsStateRx
virtual bool IsStateRx(void)
Definition: uan-phy-dual.cc:444
ns3::UanTransducer::ArrivalList
std::list< UanPacketArrival > ArrivalList
List of arriving packets overlapping in time.
Definition: uan-transducer.h:154
ns3::UanPhyDual::m_recOkCb
RxOkCallback m_recOkCb
Callback when packet received without errors.
Definition: uan-phy-dual.h:254
ns3::UanPhyDual::GetTransducer
virtual Ptr< UanTransducer > GetTransducer(void)
Get the attached transducer.
Definition: uan-phy-dual.cc:505
ns3::UanPhyDual::IsStateSleep
virtual bool IsStateSleep(void)
Definition: uan-phy-dual.cc:429
ns3::UanPhyDual::IsPhy1Tx
bool IsPhy1Tx(void)
Definition: uan-phy-dual.cc:406
ns3::UanPhyCalcSinr
Class used for calculating SINR of packet in UanPhy.
Definition: uan-phy.h:45
ns3::UanPhyDual::m_phy2
Ptr< UanPhy > m_phy2
Second Phy layer.
Definition: uan-phy-dual.h:245
ns3::UanPhyDual::IsPhy1Rx
bool IsPhy1Rx(void)
Definition: uan-phy-dual.cc:394
ns3::UanPhyDual::SetSinrModelPhy2
void SetSinrModelPhy2(Ptr< UanPhyCalcSinr > calcSinr)
Set the SINR calculator.
Definition: uan-phy-dual.cc:608
ns3::UanPhyDual::IsPhy1Idle
bool IsPhy1Idle(void)
Definition: uan-phy-dual.cc:383
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition: traced-callback.h:53
ns3::UanPhyDual::IsPhy2Tx
bool IsPhy2Tx(void)
Definition: uan-phy-dual.cc:424
ns3::UanPhyDual::IsPhy2Rx
bool IsPhy2Rx(void)
Definition: uan-phy-dual.cc:400
ns3::UanPhyDual::m_phy1
Ptr< UanPhy > m_phy1
First Phy layer.
Definition: uan-phy-dual.h:243
ns3::UanPhyDual::SetCcaThresholdDb
virtual void SetCcaThresholdDb(double thresh)
Set the threshold for detecting channel busy.
Definition: uan-phy-dual.cc:322
ns3::UanPhyDual::IsStateIdle
virtual bool IsStateIdle(void)
Definition: uan-phy-dual.cc:434
sample-rng-plot.n
n
Definition: sample-rng-plot.py:37
ns3::UanPhyDual::SetReceiveErrorCallback
virtual void SetReceiveErrorCallback(RxErrCallback cb)
Set the callback to be used when a packet is received with errors.
Definition: uan-phy-dual.cc:290
ns3::UanPhyDual::GetPacketRx
Ptr< Packet > GetPacketRx(void) const
Get the packet currently being received.
Definition: uan-phy-dual.cc:629
ns3::UanPhyDual::SetTransducer
virtual void SetTransducer(Ptr< UanTransducer > trans)
Attach a transducer to this Phy.
Definition: uan-phy-dual.cc:499
ns3::UanPhyDual::EnergyRechargeHandler
virtual void EnergyRechargeHandler(void)
Handle the energy recharge event.
Definition: uan-phy-dual.cc:246
ns3::UanPhyCalcSinrDual
Default SINR model for UanPhyDual.
Definition: uan-phy-dual.h:42
ns3::UanPhyDual::GetModesPhy2
UanModesList GetModesPhy2(void) const
Get the list of available modes.
Definition: uan-phy-dual.cc:538