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
29namespace ns3 {
30
31class UanTxMode;
32class UanModesList;
33
42{
43public:
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
81class UanPhyDual : public UanPhy
82{
83public:
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 ([[maybe_unused]] bool sleep)
139 {
141 }
142 int64_t AssignStreams (int64_t stream);
143 Ptr<Packet> GetPacketRx (void) const;
144
145
147 bool IsPhy1Idle (void);
149 bool IsPhy2Idle (void);
151 bool IsPhy1Rx (void);
153 bool IsPhy2Rx (void);
155 bool IsPhy1Tx (void);
157 bool IsPhy2Tx (void);
158
159 // Attribute getters and setters
161 double GetCcaThresholdPhy1 (void) const;
163 double GetCcaThresholdPhy2 (void) const;
165 void SetCcaThresholdPhy1 (double thresh);
167 void SetCcaThresholdPhy2 (double thresh);
168
170 double GetTxPowerDbPhy1 (void) const;
172 double GetTxPowerDbPhy2 (void) const;
174 void SetTxPowerDbPhy1 (double txpwr);
176 void SetTxPowerDbPhy2 (double txpwr);
177
178
184 UanModesList GetModesPhy1 (void) const;
186 UanModesList GetModesPhy2 (void) const;
187
193 void SetModesPhy1 (UanModesList modes);
195 void SetModesPhy2 (UanModesList modes);
196
202 Ptr<UanPhyPer> GetPerModelPhy1 (void) const;
204 Ptr<UanPhyPer> GetPerModelPhy2 (void) const;
205
214
223
232
233
235 Ptr<Packet> GetPhy1PacketRx (void) const;
237 Ptr<Packet> GetPhy2PacketRx (void) const;
238
239
240private:
245
256
257
265 void RxOkFromSubPhy (Ptr<Packet> pkt, double sinr, UanTxMode mode);
272 void RxErrFromSubPhy (Ptr<Packet> pkt, double sinr);
273
274protected:
275 virtual void DoDispose ();
276
277}; // class UanPhyDual
278
279} // namespace ns3
280
281#endif /* UAN_PHY_DUAL_H */
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 model for UanPhyDual.
Definition: uan-phy-dual.h:42
UanPhyCalcSinrDual()
Constructor.
Definition: uan-phy-dual.cc:48
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-dual.cc:58
virtual ~UanPhyCalcSinrDual()
Destructor.
Definition: uan-phy-dual.cc:52
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
Class used for calculating SINR of packet in UanPhy.
Definition: uan-phy.h:45
Two channel Phy.
Definition: uan-phy-dual.h:82
virtual void DoDispose()
Destructor implementation.
RxOkCallback m_recOkCb
Callback when packet received without errors.
Definition: uan-phy-dual.h:253
virtual void SetTxPowerDb(double txpwr)
Set the transmit power.
Ptr< UanPhy > m_phy1
First Phy layer.
Definition: uan-phy-dual.h:242
Ptr< UanPhyPer > GetPerModelPhy2(void) const
Get the error probability model.
void RxOkFromSubPhy(Ptr< Packet > pkt, double sinr, UanTxMode mode)
Handle callback and logger for packets received without error.
virtual Ptr< UanTransducer > GetTransducer(void)
Get the attached transducer.
virtual void SetEnergyModelCallback(DeviceEnergyModel::ChangeStateCallback callback)
Set the DeviceEnergyModel callback for UanPhy device.
virtual Ptr< UanChannel > GetChannel(void) const
Get the attached channel.
virtual uint32_t GetNModes(void)
Get the number of transmission modes supported by this Phy.
virtual void SetChannel(Ptr< UanChannel > channel)
Attach to a channel.
virtual void SendPacket(Ptr< Packet > pkt, uint32_t modeNum)
Send a packet using a specific transmission mode.
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxErrLogger
A packet was received unsuccessfully.
Definition: uan-phy-dual.h:249
virtual void SetReceiveErrorCallback(RxErrCallback cb)
Set the callback to be used when a packet is received with errors.
void SetPerModelPhy1(Ptr< UanPhyPer > per)
Set the error probability model.
UanModesList GetModesPhy2(void) const
Get the list of available modes.
Ptr< UanPhy > m_phy2
Second Phy layer.
Definition: uan-phy-dual.h:244
virtual void SetReceiveOkCallback(RxOkCallback cb)
Set the callback to be used when a packet is received without error.
Ptr< Packet > GetPhy2PacketRx(void) const
Get the packet currently being received.
virtual double GetCcaThresholdDb(void)
Get the CCA threshold signal strength required to detect channel busy.
virtual void EnergyDepletionHandler(void)
Handle the energy depletion event.
void SetTxPowerDbPhy1(double txpwr)
Set the transmit power.
Ptr< Packet > GetPhy1PacketRx(void) const
Get the packet currently being received.
void SetModesPhy2(UanModesList modes)
Set the available modes.
virtual void Clear(void)
Clear all pointer references.
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_txLogger
A packet was sent from this Phy.
Definition: uan-phy-dual.h:251
Ptr< UanPhyCalcSinr > GetSinrModelPhy2(void) const
Get the SINR calculator.
virtual void NotifyTransStartTx(Ptr< Packet > packet, double txPowerDb, UanTxMode txMode)
Called when a transmission is beginning on the attached transducer.
virtual void SetTransducer(Ptr< UanTransducer > trans)
Attach a transducer to this Phy.
bool IsPhy1Tx(void)
double GetCcaThresholdPhy2(void) const
Get the CCA threshold signal strength required to detect channel busy.
double GetTxPowerDbPhy2(void) const
Get the current transmit power, in dB.
double GetCcaThresholdPhy1(void) const
Get the CCA threshold signal strength required to detect channel busy.
Ptr< Packet > GetPacketRx(void) const
Get the packet currently being received.
virtual ~UanPhyDual()
Dummy destructor.
virtual void EnergyRechargeHandler(void)
Handle the energy recharge event.
Ptr< UanPhyPer > GetPerModelPhy1(void) const
Get the error probability model.
bool IsPhy1Idle(void)
virtual double GetRxThresholdDb(void)
Get the minimum received signal strength required to receive a packet without errors.
void SetPerModelPhy2(Ptr< UanPhyPer > per)
Set the error probability model.
static TypeId GetTypeId()
Register this type.
void SetSinrModelPhy2(Ptr< UanPhyCalcSinr > calcSinr)
Set the SINR calculator.
virtual bool IsStateIdle(void)
virtual void SetDevice(Ptr< UanNetDevice > device)
Set the device hosting this Phy.
virtual UanTxMode GetMode(uint32_t n)
Get a specific transmission mode.
void SetModesPhy1(UanModesList modes)
Set the available modes.
virtual void StartRxPacket(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp)
Packet arriving from channel: i.e.
virtual bool IsStateSleep(void)
UanPhyDual()
Constructor.
virtual bool IsStateCcaBusy(void)
virtual void SetMac(Ptr< UanMac > mac)
Set the MAC forwarding messages to this Phy.
UanModesList GetModesPhy1(void) const
Get the list of available modes.
virtual void RegisterListener(UanPhyListener *listener)
Register a UanPhyListener to be notified of common UanPhy events.
bool IsPhy2Idle(void)
void RxErrFromSubPhy(Ptr< Packet > pkt, double sinr)
Handle callback and logger for packets received with error.
virtual bool IsStateTx(void)
Ptr< UanPhyCalcSinr > GetSinrModelPhy1(void) const
Get the SINR calculator.
virtual void SetRxThresholdDb(double thresh)
Set the minimum SINR threshold to receive a packet without errors.
RxErrCallback m_recErrCb
Callback when packet received with errors.
Definition: uan-phy-dual.h:255
virtual void SetCcaThresholdDb(double thresh)
Set the threshold for detecting channel busy.
void SetCcaThresholdPhy1(double thresh)
Set the threshold for detecting channel busy.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxOkLogger
A packet was received successfully.
Definition: uan-phy-dual.h:247
bool IsPhy2Rx(void)
bool IsPhy2Tx(void)
void SetSinrModelPhy1(Ptr< UanPhyCalcSinr > calcSinr)
Set the SINR calculator.
void SetTxPowerDbPhy2(double txpwr)
Set the transmit power.
virtual double GetTxPowerDb(void)
Get the current transmit power, in dB.
virtual Ptr< UanNetDevice > GetDevice(void) const
Get the device hosting this Phy.
virtual void SetSleepMode(bool sleep)
Set the Phy SLEEP mode.
Definition: uan-phy-dual.h:138
double GetTxPowerDbPhy1(void) const
Get the current transmit power, in dB.
virtual bool IsStateRx(void)
virtual void NotifyIntChange(void)
Called when there has been a change in the amount of interference this node is experiencing from othe...
bool IsPhy1Rx(void)
void SetCcaThresholdPhy2(double thresh)
Set the threshold for detecting channel busy.
virtual bool IsStateBusy(void)
Base class for UAN Phy models.
Definition: uan-phy.h:179
Interface for PHY event listener.
Definition: uan-phy.h:147
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