A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
uan-phy-dual.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_DUAL_H
22#define UAN_PHY_DUAL_H
23
24#include "uan-phy.h"
25
26namespace ns3
27{
28
29class UanTxMode;
30class UanModesList;
31
32/**
33 * Default SINR model for UanPhyDual
34 *
35 * Considers interfering packet power as additional ambient noise only
36 * if there is overlap in frequency band as found from supplied UanTxMode.
37 * If there is no overlap, then the packets are considered not to interfere.
38 */
40{
41 public:
42 /** Constructor */
44 /** Destructor */
45 ~UanPhyCalcSinrDual() override;
46
47 /**
48 * Register this type.
49 * \return The TypeId.
50 */
51 static TypeId GetTypeId();
52
53 double CalcSinrDb(Ptr<Packet> pkt,
54 Time arrTime,
55 double rxPowerDb,
56 double ambNoiseDb,
57 UanTxMode mode,
58 UanPdp pdp,
59 const UanTransducer::ArrivalList& arrivalList) const override;
60
61}; // class UanPhyCalcSinrDual
62
63/**
64 * \ingroup uan
65 *
66 * Two channel Phy.
67 *
68 * A class that wraps two generic UAN Phy layers (UanPhyGen) into a single PHY.
69 * This is used to simulate two receivers (and transmitters) that use
70 * the same front end hardware. When attached to a UanTransducerHd,
71 * this results in a net device able to transmit on one or two channels
72 * simultaneously or receive on one or two channels simultaneously but
73 * that cannot transmit and receive simultaneously.
74 *
75 * Many of the standard PHY functions here become ambiguous. In most cases
76 * information for "Phy1" are returned.
77 */
78class UanPhyDual : public UanPhy
79{
80 public:
81 /** Constructor */
82 UanPhyDual();
83 /** Dummy destructor \see DoDispose */
84 ~UanPhyDual() override;
85
86 /**
87 * Register this type.
88 * \return The TypeId.
89 */
90 static TypeId GetTypeId();
91
92 // Inherited methods:
94 void EnergyDepletionHandler() override;
95 void EnergyRechargeHandler() override;
96 void SendPacket(Ptr<Packet> pkt, uint32_t modeNum) override;
97
98 /**
99 * Register a UanPhyListener to be notified of common UanPhy events.
100 *
101 * \param listener New listener to register.
102 *
103 * \note You may receive duplicate
104 * messages as underneath there are two generic phys here.
105 * Each will notify of state changes independently.
106 */
107 void RegisterListener(UanPhyListener* listener) override;
108 void StartRxPacket(Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp) override;
109 void SetReceiveOkCallback(RxOkCallback cb) override;
110 void SetReceiveErrorCallback(RxErrCallback cb) override;
111 void SetTxPowerDb(double txpwr) override;
112 void SetRxThresholdDb(double thresh) override;
113 void SetCcaThresholdDb(double thresh) override;
114 double GetTxPowerDb() override;
115 double GetRxThresholdDb() override;
116 double GetCcaThresholdDb() override;
117 bool IsStateSleep() override;
118 bool IsStateIdle() override;
119 bool IsStateBusy() override;
120 bool IsStateRx() override;
121 bool IsStateTx() override;
122 bool IsStateCcaBusy() override;
123 Ptr<UanChannel> GetChannel() const override;
124 Ptr<UanNetDevice> GetDevice() const override;
125 void SetChannel(Ptr<UanChannel> channel) override;
126 void SetDevice(Ptr<UanNetDevice> device) override;
127 void SetMac(Ptr<UanMac> mac) override;
128 void NotifyTransStartTx(Ptr<Packet> packet, double txPowerDb, UanTxMode txMode) override;
129 void NotifyIntChange() override;
130 void SetTransducer(Ptr<UanTransducer> trans) override;
132 uint32_t GetNModes() override;
133 UanTxMode GetMode(uint32_t n) override;
134 void Clear() override;
135
136 void SetSleepMode(bool /* sleep */) override
137 {
138 /// \todo This method has to be implemented
139 }
140
141 int64_t AssignStreams(int64_t stream) override;
142 Ptr<Packet> GetPacketRx() const override;
143
144 /** \copydoc UanPhy::IsStateIdle */
145 bool IsPhy1Idle();
146 /** \copydoc UanPhy::IsStateIdle */
147 bool IsPhy2Idle();
148 /** \copydoc UanPhy::IsStateRx */
149 bool IsPhy1Rx();
150 /** \copydoc UanPhy::IsStateRx */
151 bool IsPhy2Rx();
152 /** \copydoc UanPhy::IsStateTx */
153 bool IsPhy1Tx();
154 /** \copydoc UanPhy::IsStateTx */
155 bool IsPhy2Tx();
156
157 // Attribute getters and setters
158 /** \copydoc ns3::UanPhy::GetCcaThresholdDb() */
159 double GetCcaThresholdPhy1() const;
160 /** \copydoc UanPhy::GetCcaThresholdDb() */
161 double GetCcaThresholdPhy2() const;
162 /** \copydoc UanPhy::SetCcaThresholdDb */
163 void SetCcaThresholdPhy1(double thresh);
164 /** \copydoc UanPhy::SetCcaThresholdDb */
165 void SetCcaThresholdPhy2(double thresh);
166
167 /** \copydoc UanPhy::GetTxPowerDb */
168 double GetTxPowerDbPhy1() const;
169 /** \copydoc UanPhy::GetTxPowerDb */
170 double GetTxPowerDbPhy2() const;
171 /** \copydoc UanPhy::SetTxPowerDb */
172 void SetTxPowerDbPhy1(double txpwr);
173 /** \copydoc UanPhy::SetTxPowerDb */
174 void SetTxPowerDbPhy2(double txpwr);
175
176 /**
177 * Get the list of available modes.
178 *
179 * \return The mode list.
180 */
182 /** \copydoc GetModesPhy1 */
184
185 /**
186 * Set the available modes.
187 *
188 * \param modes List of modes.
189 */
190 void SetModesPhy1(UanModesList modes);
191 /** \copydoc SetModesPhy1 */
192 void SetModesPhy2(UanModesList modes);
193
194 /**
195 * Get the error probability model.
196 *
197 * \return The error model.
198 */
200 /** \copydoc GetPerModelPhy1() */
202
203 /**
204 * Set the error probability model.
205 *
206 * \param per The error model.
207 */
209 /** \copydoc SetPerModelPhy1 */
211
212 /**
213 * Get the SINR calculator.
214 *
215 * \return The SINR calculator.
216 */
218 /** \copydoc GetSinrModelPhy1 */
220
221 /**
222 * Set the SINR calculator.
223 *
224 * \param calcSinr The SINR calculator.
225 */
227 /** \copydoc SetSinrModelPhy1 */
229
230 /** \copydoc UanPhy::GetPacketRx */
232 /** \copydoc UanPhy::GetPacketRx */
234
235 private:
236 /** First Phy layer. */
238 /** Second Phy layer. */
240
241 /** A packet was received successfully. */
243 /** A packet was received unsuccessfuly. */
245 /** A packet was sent from this Phy. */
247 /** Callback when packet received without errors. */
249 /** Callback when packet received with errors. */
251
252 /**
253 * Handle callback and logger for packets received without error.
254 *
255 * \param pkt The packet.
256 * \param sinr The SINR.
257 * \param mode The channel mode.
258 */
259 void RxOkFromSubPhy(Ptr<Packet> pkt, double sinr, UanTxMode mode);
260 /**
261 * Handle callback and logger for packets received with error.
262 *
263 * \param pkt The packet.
264 * \param sinr The SINR.
265 */
266 void RxErrFromSubPhy(Ptr<Packet> pkt, double sinr);
267
268 protected:
269 void DoDispose() override;
270
271}; // class UanPhyDual
272
273} // namespace ns3
274
275#endif /* UAN_PHY_DUAL_H */
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 model for UanPhyDual.
Definition: uan-phy-dual.h:40
UanPhyCalcSinrDual()
Constructor.
Definition: uan-phy-dual.cc:49
~UanPhyCalcSinrDual() override
Destructor.
Definition: uan-phy-dual.cc:53
static TypeId GetTypeId()
Register this type.
Definition: uan-phy-dual.cc:58
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-dual.cc:68
Class used for calculating SINR of packet in UanPhy.
Definition: uan-phy.h:44
Two channel Phy.
Definition: uan-phy-dual.h:79
RxOkCallback m_recOkCb
Callback when packet received without errors.
Definition: uan-phy-dual.h:248
Ptr< UanPhy > m_phy1
First Phy layer.
Definition: uan-phy-dual.h:237
UanModesList GetModesPhy2() const
Get the list of available modes.
double GetCcaThresholdPhy1() const
Get the CCA threshold signal strength required to detect channel busy.
void RxOkFromSubPhy(Ptr< Packet > pkt, double sinr, UanTxMode mode)
Handle callback and logger for packets received without error.
bool IsStateRx() override
void SetSleepMode(bool) override
Set the Phy SLEEP mode.
Definition: uan-phy-dual.h:136
Ptr< UanChannel > GetChannel() const override
Get the attached channel.
~UanPhyDual() override
Dummy destructor.
void EnergyDepletionHandler() override
Handle the energy depletion event.
Ptr< Packet > GetPhy2PacketRx() const
Get the packet currently being received.
void NotifyIntChange() override
Called when there has been a change in the amount of interference this node is experiencing from othe...
Ptr< UanPhyCalcSinr > GetSinrModelPhy2() const
Get the SINR calculator.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
void SetPerModelPhy1(Ptr< UanPhyPer > per)
Set the error probability model.
Ptr< UanPhy > m_phy2
Second Phy layer.
Definition: uan-phy-dual.h:239
void SetTxPowerDbPhy1(double txpwr)
Set the transmit power.
void SetModesPhy2(UanModesList modes)
Set the available modes.
bool IsStateCcaBusy() override
UanModesList GetModesPhy1() const
Get the list of available modes.
bool IsStateBusy() override
Ptr< Packet > GetPacketRx() const override
Get the packet currently being received.
void Clear() override
Clear all pointer references.
void SetCcaThresholdDb(double thresh) override
Set the threshold for detecting channel busy.
bool IsStateIdle() override
uint32_t GetNModes() override
Get the number of transmission modes supported by this Phy.
UanTxMode GetMode(uint32_t n) override
Get a specific transmission mode.
double GetCcaThresholdDb() override
Get the CCA threshold signal strength required to detect channel busy.
void SetTransducer(Ptr< UanTransducer > trans) override
Attach a transducer to this Phy.
bool IsStateTx() override
double GetCcaThresholdPhy2() const
Get the CCA threshold signal strength required to detect channel busy.
void SetRxThresholdDb(double thresh) override
Set the minimum SINR threshold to receive a packet without errors.
void SetPerModelPhy2(Ptr< UanPhyPer > per)
Set the error probability model.
void SetChannel(Ptr< UanChannel > channel) override
Attach to a channel.
static TypeId GetTypeId()
Register this type.
void RegisterListener(UanPhyListener *listener) override
Register a UanPhyListener to be notified of common UanPhy events.
double GetRxThresholdDb() override
Get the minimum received signal strength required to receive a packet without errors.
bool IsStateSleep() override
void SetSinrModelPhy2(Ptr< UanPhyCalcSinr > calcSinr)
Set the SINR calculator.
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxErrLogger
A packet was received unsuccessfuly.
Definition: uan-phy-dual.h:244
void SetModesPhy1(UanModesList modes)
Set the available modes.
Ptr< UanPhyPer > GetPerModelPhy2() const
Get the error probability model.
double GetTxPowerDb() override
Get the current transmit power, in dB.
UanPhyDual()
Constructor.
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxOkLogger
A packet was received successfully.
Definition: uan-phy-dual.h:242
void NotifyTransStartTx(Ptr< Packet > packet, double txPowerDb, UanTxMode txMode) override
Called when a transmission is beginning on the attached transducer.
Ptr< UanPhyPer > GetPerModelPhy1() const
Get the error probability model.
void SendPacket(Ptr< Packet > pkt, uint32_t modeNum) override
Send a packet using a specific transmission mode.
void SetMac(Ptr< UanMac > mac) override
Set the MAC forwarding messages to this Phy.
void SetDevice(Ptr< UanNetDevice > device) override
Set the device hosting this Phy.
double GetTxPowerDbPhy2() const
Get the current transmit power, in dB.
void SetEnergyModelCallback(DeviceEnergyModel::ChangeStateCallback callback) override
Set the DeviceEnergyModel callback for UanPhy device.
void DoDispose() override
Destructor implementation.
void RxErrFromSubPhy(Ptr< Packet > pkt, double sinr)
Handle callback and logger for packets received with error.
void SetTxPowerDb(double txpwr) override
Set the transmit power.
void EnergyRechargeHandler() override
Handle the energy recharge event.
RxErrCallback m_recErrCb
Callback when packet received with errors.
Definition: uan-phy-dual.h:250
double GetTxPowerDbPhy1() const
Get the current transmit power, in dB.
void SetCcaThresholdPhy1(double thresh)
Set the threshold for detecting channel busy.
Ptr< UanTransducer > GetTransducer() override
Get the attached transducer.
void SetReceiveErrorCallback(RxErrCallback cb) override
Set the callback to be used when a packet is received with errors.
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_txLogger
A packet was sent from this Phy.
Definition: uan-phy-dual.h:246
void SetSinrModelPhy1(Ptr< UanPhyCalcSinr > calcSinr)
Set the SINR calculator.
void SetTxPowerDbPhy2(double txpwr)
Set the transmit power.
Ptr< Packet > GetPhy1PacketRx() const
Get the packet currently being received.
Ptr< UanNetDevice > GetDevice() const override
Get the device hosting this Phy.
void SetCcaThresholdPhy2(double thresh)
Set the threshold for detecting channel busy.
void SetReceiveOkCallback(RxOkCallback cb) override
Set the callback to be used when a packet is received without error.
void StartRxPacket(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp) override
Packet arriving from channel: i.e.
Ptr< UanPhyCalcSinr > GetSinrModelPhy1() const
Get the SINR calculator.
Base class for UAN Phy models.
Definition: uan-phy.h:178
Interface for PHY event listener.
Definition: uan-phy.h:145
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.