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 
34 
43 {
44 public:
48  virtual ~UanPhyCalcSinrDual ();
49 
54  static TypeId GetTypeId (void);
55 
56  virtual double CalcSinrDb (Ptr<Packet> pkt,
57  Time arrTime,
58  double rxPowerDb,
59  double ambNoiseDb,
60  UanTxMode mode,
61  UanPdp pdp,
62  const UanTransducer::ArrivalList &arrivalList
63  ) const;
64 
65 }; // class UanPhyCalcSinrDual
66 
82 class UanPhyDual : public UanPhy
83 {
84 public:
86  UanPhyDual ();
88  virtual ~UanPhyDual ();
89 
94  static TypeId GetTypeId ();
95 
96  // Inherited methods:
98  virtual void EnergyDepletionHandler (void);
99  virtual void EnergyRechargeHandler (void);
100  virtual void SendPacket (Ptr<Packet> pkt, uint32_t modeNum);
101 
111  virtual void RegisterListener (UanPhyListener *listener);
112  virtual void StartRxPacket (Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp);
113  virtual void SetReceiveOkCallback (RxOkCallback cb);
114  virtual void SetReceiveErrorCallback (RxErrCallback cb);
115  virtual void SetRxGainDb (double gain);
116  virtual void SetTxPowerDb (double txpwr);
117  NS_DEPRECATED virtual void SetRxThresholdDb (double thresh);
118  virtual void SetCcaThresholdDb (double thresh);
119  virtual double GetRxGainDb (void);
120  virtual double GetTxPowerDb (void);
121  virtual double GetRxThresholdDb (void);
122  virtual double GetCcaThresholdDb (void);
123  virtual bool IsStateSleep (void);
124  virtual bool IsStateIdle (void);
125  virtual bool IsStateBusy (void);
126  virtual bool IsStateRx (void);
127  virtual bool IsStateTx (void);
128  virtual bool IsStateCcaBusy (void);
129  virtual Ptr<UanChannel> GetChannel (void) const;
130  virtual Ptr<UanNetDevice> GetDevice (void) const;
131  virtual void SetChannel (Ptr<UanChannel> channel);
132  virtual void SetDevice (Ptr<UanNetDevice> device);
133  virtual void SetMac (Ptr<UanMac> mac);
134  virtual void NotifyTransStartTx (Ptr<Packet> packet, double txPowerDb, UanTxMode txMode);
135  virtual void NotifyIntChange (void);
136  virtual void SetTransducer (Ptr<UanTransducer> trans);
137  virtual Ptr<UanTransducer> GetTransducer (void);
138  virtual uint32_t GetNModes (void);
139  virtual UanTxMode GetMode (uint32_t n);
140  virtual void Clear (void);
141  virtual void SetSleepMode (bool sleep)
142  {
144  }
145  int64_t AssignStreams (int64_t stream);
146  Ptr<Packet> GetPacketRx (void) const;
147 
148 
150  bool IsPhy1Idle (void);
152  bool IsPhy2Idle (void);
154  bool IsPhy1Rx (void);
156  bool IsPhy2Rx (void);
158  bool IsPhy1Tx (void);
160  bool IsPhy2Tx (void);
161 
162  // Attribute getters and setters
164  double GetCcaThresholdPhy1 (void) const;
166  double GetCcaThresholdPhy2 (void) const;
168  void SetCcaThresholdPhy1 (double thresh);
170  void SetCcaThresholdPhy2 (double thresh);
171 
173  double GetTxPowerDbPhy1 (void) const;
175  double GetTxPowerDbPhy2 (void) const;
177  void SetTxPowerDbPhy1 (double txpwr);
179  void SetTxPowerDbPhy2 (double txpwr);
180 
182  double GetRxGainDbPhy1 (void) const;
184  double GetRxGainDbPhy2 (void) const;
186  void SetRxGainDbPhy1 (double gain);
188  void SetRxGainDbPhy2 (double gain);
189 
195  UanModesList GetModesPhy1 (void) const;
197  UanModesList GetModesPhy2 (void) const;
198 
204  void SetModesPhy1 (UanModesList modes);
206  void SetModesPhy2 (UanModesList modes);
207 
213  Ptr<UanPhyPer> GetPerModelPhy1 (void) const;
215  Ptr<UanPhyPer> GetPerModelPhy2 (void) const;
216 
222  void SetPerModelPhy1 (Ptr<UanPhyPer> per);
224  void SetPerModelPhy2 (Ptr<UanPhyPer> per);
225 
234 
240  void SetSinrModelPhy1 (Ptr<UanPhyCalcSinr> calcSinr);
242  void SetSinrModelPhy2 (Ptr<UanPhyCalcSinr> calcSinr);
243 
244 
246  Ptr<Packet> GetPhy1PacketRx (void) const;
248  Ptr<Packet> GetPhy2PacketRx (void) const;
249 
250 
251 private:
256 
267 
268 
276  void RxOkFromSubPhy (Ptr<Packet> pkt, double sinr, UanTxMode mode);
283  void RxErrFromSubPhy (Ptr<Packet> pkt, double sinr);
284 
285 protected:
286  virtual void DoDispose ();
287 
288 }; // class UanPhyDual
289 
290 } // namespace ns3
291 
292 #endif /* UAN_PHY_DUAL_H */
tuple channel
Definition: third.py:85
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
virtual void DoDispose()
Destructor implementation.
virtual uint32_t GetNModes(void)
Get the number of transmission modes supported by this Phy.
RxOkCallback m_recOkCb
Callback when packet received without errors.
Definition: uan-phy-dual.h:264
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-dual.cc:58
virtual Ptr< UanTransducer > GetTransducer(void)
Get the attached transducer.
Forward calls to a chain of Callback.
virtual void SetEnergyModelCallback(DeviceEnergyModel::ChangeStateCallback callback)
Set the DeviceEnergyModel callback for UanPhy device.
virtual ~UanPhyCalcSinrDual()
Destructor.
Definition: uan-phy-dual.cc:52
Ptr< UanPhy > m_phy1
First Phy layer.
Definition: uan-phy-dual.h:253
Ptr< UanPhy > m_phy2
Second Phy layer.
Definition: uan-phy-dual.h:255
Ptr< Packet > GetPacketRx(void) const
Get the packet currently being received.
virtual void SetMac(Ptr< UanMac > mac)
Set the MAC forwarding messages to this Phy.
virtual bool IsStateSleep(void)
double GetCcaThresholdPhy2(void) const
Get the CCA threshold signal strength required to detect channel busy.
Container for UanTxModes.
Definition: uan-tx-mode.h:257
virtual bool IsStateTx(void)
virtual void SetCcaThresholdDb(double thresh)
Set the threshold for detecting channel busy.
bool IsPhy1Rx(void)
bool IsPhy2Rx(void)
virtual void SetDevice(Ptr< UanNetDevice > device)
Set the device hosting this Phy.
virtual Ptr< UanChannel > GetChannel(void) const
Get the attached channel.
virtual ~UanPhyDual()
Dummy destructor.
virtual void SetTxPowerDb(double txpwr)
Set the transmit power.
virtual bool IsStateBusy(void)
virtual double GetRxThresholdDb(void)
Get the minimum received signal strength required to receive a packet without errors.
void SetCcaThresholdPhy1(double thresh)
Set the threshold for detecting channel busy.
virtual bool IsStateIdle(void)
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
double GetRxGainDbPhy1(void) const
Get the receiver gain added to signal at receiver in dB.
UanPhyDual()
Constructor.
virtual void NotifyTransStartTx(Ptr< Packet > packet, double txPowerDb, UanTxMode txMode)
Called when a transmission is beginning on the attched transducer.
virtual void SendPacket(Ptr< Packet > pkt, uint32_t modeNum)
Send a packet using a specific transmission mode.
Ptr< Packet > GetPhy1PacketRx(void) const
Get the packet currently being received.
The power delay profile returned by propagation models.
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:41
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_txLogger
A packet was sent from this Phy.
Definition: uan-phy-dual.h:262
virtual void SetSleepMode(bool sleep)
Set the Phy SLEEP mode.
Definition: uan-phy-dual.h:141
virtual void Clear(void)
Clear all pointer references.
std::list< UanPacketArrival > ArrivalList
List of arriving packets overlapping in time.
virtual void NotifyIntChange(void)
Called when there has been a change in the ammount of interference this node is experiencing from oth...
tuple mac
Definition: third.py:92
virtual void SetChannel(Ptr< UanChannel > channel)
Attach to a channel.
Ptr< UanPhyPer > GetPerModelPhy2(void) const
Get the error probability model.
UanModesList GetModesPhy1(void) const
Get the list of available modes.
void SetModesPhy1(UanModesList modes)
Set the available modes.
Ptr< UanPhyCalcSinr > GetSinrModelPhy2(void) const
Get the SINR calculator.
bool IsPhy2Idle(void)
UanModesList GetModesPhy2(void) const
Get the list of available modes.
virtual void EnergyRechargeHandler(void)
Handle the energy recharge event.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void SetRxGainDb(double gain)
Set the receiver gain.
RxErrCallback m_recErrCb
Callback when packet received with errors.
Definition: uan-phy-dual.h:266
void SetPerModelPhy1(Ptr< UanPhyPer > per)
Set the error probability model.
Interface for PHY event listener.
Definition: uan-phy.h:146
virtual void StartRxPacket(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp)
Packet arriving from channel: i.e.
void RxOkFromSubPhy(Ptr< Packet > pkt, double sinr, UanTxMode mode)
Handle callback and logger for packets received without error.
void SetTxPowerDbPhy1(double txpwr)
Set the transmit power.
virtual bool IsStateRx(void)
void SetTxPowerDbPhy2(double txpwr)
Set the transmit power.
double GetCcaThresholdPhy1(void) const
Get the CCA threshold signal strength required to detect channel busy.
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxErrLogger
A packet was received unsuccessfully.
Definition: uan-phy-dual.h:260
void RxErrFromSubPhy(Ptr< Packet > pkt, double sinr)
Handle callback and logger for packets received with error.
Class used for calculating SINR of packet in UanPhy.
Definition: uan-phy.h:44
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxOkLogger
A packet was received successfully.
Definition: uan-phy-dual.h:258
void SetModesPhy2(UanModesList modes)
Set the available modes.
Base class for UAN Phy models.
Definition: uan-phy.h:175
void SetSinrModelPhy2(Ptr< UanPhyCalcSinr > calcSinr)
Set the SINR calculator.
virtual NS_DEPRECATED void SetRxThresholdDb(double thresh)
Set the minimum SINR threshold to receive a packet without errors.
void SetSinrModelPhy1(Ptr< UanPhyCalcSinr > calcSinr)
Set the SINR calculator.
#define NS_DEPRECATED
Mark a function as deprecated.
Definition: deprecated.h:60
virtual void SetReceiveOkCallback(RxOkCallback cb)
Set the callback to be used when a packet is received without error.
bool IsPhy1Tx(void)
virtual void SetTransducer(Ptr< UanTransducer > trans)
Attach a transducer to this Phy.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
double GetTxPowerDbPhy1(void) const
Get the current transmit power, in dB.
virtual void RegisterListener(UanPhyListener *listener)
Register a UanPhyListener to be notified of common UanPhy events.
static TypeId GetTypeId()
Register this type.
Ptr< UanPhyCalcSinr > GetSinrModelPhy1(void) const
Get the SINR calculator.
virtual void SetReceiveErrorCallback(RxErrCallback cb)
Set the callback to be used when a packet is received with errors.
double GetTxPowerDbPhy2(void) const
Get the current transmit power, in dB.
Two channel Phy.
Definition: uan-phy-dual.h:82
virtual double GetRxGainDb(void)
Get the receiver gain added to signal at receiver in dB.
virtual Ptr< UanNetDevice > GetDevice(void) const
Get the device hosting this Phy.
virtual bool IsStateCcaBusy(void)
UanPhyCalcSinrDual()
Constructor.
Definition: uan-phy-dual.cc:48
bool IsPhy1Idle(void)
a unique identifier for an interface.
Definition: type-id.h:58
bool IsPhy2Tx(void)
Ptr< Packet > GetPhy2PacketRx(void) const
Get the packet currently being received.
double GetRxGainDbPhy2(void) const
Get the receiver gain added to signal at receiver in dB.
void SetPerModelPhy2(Ptr< UanPhyPer > per)
Set the error probability model.
virtual double GetCcaThresholdDb(void)
Get the CCA threshold signal strength required to detect channel busy.
void SetRxGainDbPhy2(double gain)
Set the receiver gain.
Default SINR model for UanPhyDual.
Definition: uan-phy-dual.h:42
void SetRxGainDbPhy1(double gain)
Set the receiver gain.
void SetCcaThresholdPhy2(double thresh)
Set the threshold for detecting channel busy.
Ptr< UanPhyPer > GetPerModelPhy1(void) const
Get the error probability model.
virtual UanTxMode GetMode(uint32_t n)
Get a specific transmission mode.
virtual void EnergyDepletionHandler(void)
Handle the energy depletion event.
virtual double GetTxPowerDb(void)
Get the current transmit power, in dB.