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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Leonard Tracy <lentracy@gmail.com>
7 * Andrea Sacco <andrea.sacco85@gmail.com>
8 */
9
10#ifndef UAN_PHY_DUAL_H
11#define UAN_PHY_DUAL_H
12
13#include "uan-phy.h"
14
15namespace ns3
16{
17
18class UanTxMode;
19class UanModesList;
20
21/**
22 * Default SINR model for UanPhyDual
23 *
24 * Considers interfering packet power as additional ambient noise only
25 * if there is overlap in frequency band as found from supplied UanTxMode.
26 * If there is no overlap, then the packets are considered not to interfere.
27 */
29{
30 public:
31 /** Constructor */
33 /** Destructor */
34 ~UanPhyCalcSinrDual() override;
35
36 /**
37 * Register this type.
38 * \return The TypeId.
39 */
40 static TypeId GetTypeId();
41
42 double CalcSinrDb(Ptr<Packet> pkt,
43 Time arrTime,
44 double rxPowerDb,
45 double ambNoiseDb,
46 UanTxMode mode,
47 UanPdp pdp,
48 const UanTransducer::ArrivalList& arrivalList) const override;
49
50}; // class UanPhyCalcSinrDual
51
52/**
53 * \ingroup uan
54 *
55 * Two channel Phy.
56 *
57 * A class that wraps two generic UAN Phy layers (UanPhyGen) into a single PHY.
58 * This is used to simulate two receivers (and transmitters) that use
59 * the same front end hardware. When attached to a UanTransducerHd,
60 * this results in a net device able to transmit on one or two channels
61 * simultaneously or receive on one or two channels simultaneously but
62 * that cannot transmit and receive simultaneously.
63 *
64 * Many of the standard PHY functions here become ambiguous. In most cases
65 * information for "Phy1" are returned.
66 */
67class UanPhyDual : public UanPhy
68{
69 public:
70 /** Constructor */
71 UanPhyDual();
72 /** Dummy destructor \see DoDispose */
73 ~UanPhyDual() override;
74
75 /**
76 * Register this type.
77 * \return The TypeId.
78 */
79 static TypeId GetTypeId();
80
81 // Inherited methods:
83 void EnergyDepletionHandler() override;
84 void EnergyRechargeHandler() override;
85 void SendPacket(Ptr<Packet> pkt, uint32_t modeNum) override;
86
87 /**
88 * Register a UanPhyListener to be notified of common UanPhy events.
89 *
90 * \param listener New listener to register.
91 *
92 * \note You may receive duplicate
93 * messages as underneath there are two generic phys here.
94 * Each will notify of state changes independently.
95 */
96 void RegisterListener(UanPhyListener* listener) override;
97 void StartRxPacket(Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp) override;
98 void SetReceiveOkCallback(RxOkCallback cb) override;
99 void SetReceiveErrorCallback(RxErrCallback cb) override;
100 void SetTxPowerDb(double txpwr) override;
101 void SetRxThresholdDb(double thresh) override;
102 void SetCcaThresholdDb(double thresh) override;
103 double GetTxPowerDb() override;
104 double GetRxThresholdDb() override;
105 double GetCcaThresholdDb() override;
106 bool IsStateSleep() override;
107 bool IsStateIdle() override;
108 bool IsStateBusy() override;
109 bool IsStateRx() override;
110 bool IsStateTx() override;
111 bool IsStateCcaBusy() override;
112 Ptr<UanChannel> GetChannel() const override;
113 Ptr<UanNetDevice> GetDevice() const override;
114 void SetChannel(Ptr<UanChannel> channel) override;
115 void SetDevice(Ptr<UanNetDevice> device) override;
116 void SetMac(Ptr<UanMac> mac) override;
117 void NotifyTransStartTx(Ptr<Packet> packet, double txPowerDb, UanTxMode txMode) override;
118 void NotifyIntChange() override;
119 void SetTransducer(Ptr<UanTransducer> trans) override;
121 uint32_t GetNModes() override;
122 UanTxMode GetMode(uint32_t n) override;
123 void Clear() override;
124
125 void SetSleepMode(bool /* sleep */) override
126 {
127 /// \todo This method has to be implemented
128 }
129
130 int64_t AssignStreams(int64_t stream) override;
131 Ptr<Packet> GetPacketRx() const override;
132
133 /** \copydoc UanPhy::IsStateIdle */
134 bool IsPhy1Idle();
135 /** \copydoc UanPhy::IsStateIdle */
136 bool IsPhy2Idle();
137 /** \copydoc UanPhy::IsStateRx */
138 bool IsPhy1Rx();
139 /** \copydoc UanPhy::IsStateRx */
140 bool IsPhy2Rx();
141 /** \copydoc UanPhy::IsStateTx */
142 bool IsPhy1Tx();
143 /** \copydoc UanPhy::IsStateTx */
144 bool IsPhy2Tx();
145
146 // Attribute getters and setters
147 /** \copydoc ns3::UanPhy::GetCcaThresholdDb() */
148 double GetCcaThresholdPhy1() const;
149 /** \copydoc UanPhy::GetCcaThresholdDb() */
150 double GetCcaThresholdPhy2() const;
151 /** \copydoc UanPhy::SetCcaThresholdDb */
152 void SetCcaThresholdPhy1(double thresh);
153 /** \copydoc UanPhy::SetCcaThresholdDb */
154 void SetCcaThresholdPhy2(double thresh);
155
156 /** \copydoc UanPhy::GetTxPowerDb */
157 double GetTxPowerDbPhy1() const;
158 /** \copydoc UanPhy::GetTxPowerDb */
159 double GetTxPowerDbPhy2() const;
160 /** \copydoc UanPhy::SetTxPowerDb */
161 void SetTxPowerDbPhy1(double txpwr);
162 /** \copydoc UanPhy::SetTxPowerDb */
163 void SetTxPowerDbPhy2(double txpwr);
164
165 /**
166 * Get the list of available modes.
167 *
168 * \return The mode list.
169 */
171 /** \copydoc GetModesPhy1 */
173
174 /**
175 * Set the available modes.
176 *
177 * \param modes List of modes.
178 */
179 void SetModesPhy1(UanModesList modes);
180 /** \copydoc SetModesPhy1 */
181 void SetModesPhy2(UanModesList modes);
182
183 /**
184 * Get the error probability model.
185 *
186 * \return The error model.
187 */
189 /** \copydoc GetPerModelPhy1() */
191
192 /**
193 * Set the error probability model.
194 *
195 * \param per The error model.
196 */
198 /** \copydoc SetPerModelPhy1 */
200
201 /**
202 * Get the SINR calculator.
203 *
204 * \return The SINR calculator.
205 */
207 /** \copydoc GetSinrModelPhy1 */
209
210 /**
211 * Set the SINR calculator.
212 *
213 * \param calcSinr The SINR calculator.
214 */
216 /** \copydoc SetSinrModelPhy1 */
218
219 /** \copydoc UanPhy::GetPacketRx */
221 /** \copydoc UanPhy::GetPacketRx */
223
224 private:
225 /** First Phy layer. */
227 /** Second Phy layer. */
229
230 /** A packet was received successfully. */
232 /** A packet was received unsuccessfuly. */
234 /** A packet was sent from this Phy. */
236 /** Callback when packet received without errors. */
238 /** Callback when packet received with errors. */
240
241 /**
242 * Handle callback and logger for packets received without error.
243 *
244 * \param pkt The packet.
245 * \param sinr The SINR.
246 * \param mode The channel mode.
247 */
248 void RxOkFromSubPhy(Ptr<Packet> pkt, double sinr, UanTxMode mode);
249 /**
250 * Handle callback and logger for packets received with error.
251 *
252 * \param pkt The packet.
253 * \param sinr The SINR.
254 */
255 void RxErrFromSubPhy(Ptr<Packet> pkt, double sinr);
256
257 protected:
258 void DoDispose() override;
259
260}; // class UanPhyDual
261
262} // namespace ns3
263
264#endif /* UAN_PHY_DUAL_H */
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:48
Container for UanTxModes.
The power delay profile returned by propagation models.
Default SINR model for UanPhyDual.
UanPhyCalcSinrDual()
Constructor.
~UanPhyCalcSinrDual() override
Destructor.
static TypeId GetTypeId()
Register this type.
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.
Class used for calculating SINR of packet in UanPhy.
Definition uan-phy.h:33
Two channel Phy.
RxOkCallback m_recOkCb
Callback when packet received without errors.
Ptr< UanPhy > m_phy1
First Phy layer.
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.
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.
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.
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.
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 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.
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.
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 SetEnergyModelCallback(energy::DeviceEnergyModel::ChangeStateCallback callback) override
Set the DeviceEnergyModel callback for UanPhy device.
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:167
Interface for PHY event listener.
Definition uan-phy.h:134
std::list< UanPacketArrival > ArrivalList
List of arriving packets overlapping in time.
Abstraction of packet modulation information.
Definition uan-tx-mode.h:32
Every class exported by the ns3 library is enclosed in the ns3 namespace.