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 // end of class UanPhyCalcSinrDual
51};
52
53/**
54 * @ingroup uan
55 *
56 * Two channel Phy.
57 *
58 * A class that wraps two generic UAN Phy layers (UanPhyGen) into a single PHY.
59 * This is used to simulate two receivers (and transmitters) that use
60 * the same front end hardware. When attached to a UanTransducerHd,
61 * this results in a net device able to transmit on one or two channels
62 * simultaneously or receive on one or two channels simultaneously but
63 * that cannot transmit and receive simultaneously.
64 *
65 * Many of the standard PHY functions here become ambiguous. In most cases
66 * information for "Phy1" are returned.
67 */
68class UanPhyDual : public UanPhy
69{
70 public:
71 /** Constructor */
72 UanPhyDual();
73 /** Dummy destructor \see DoDispose */
74 ~UanPhyDual() override;
75
76 /**
77 * Register this type.
78 * @return The TypeId.
79 */
80 static TypeId GetTypeId();
81
82 // Inherited methods:
84 void EnergyDepletionHandler() override;
85 void EnergyRechargeHandler() override;
86 void SendPacket(Ptr<Packet> pkt, uint32_t modeNum) override;
87
88 /**
89 * Register a UanPhyListener to be notified of common UanPhy events.
90 *
91 * @param listener New listener to register.
92 *
93 * @note You may receive duplicate
94 * messages as underneath there are two generic phys here.
95 * Each will notify of state changes independently.
96 */
97 void RegisterListener(UanPhyListener* listener) override;
98 void StartRxPacket(Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp) override;
99 void SetReceiveOkCallback(RxOkCallback cb) override;
100 void SetReceiveErrorCallback(RxErrCallback cb) override;
101 void SetTxPowerDb(double txpwr) override;
102 void SetRxThresholdDb(double thresh) override;
103 void SetCcaThresholdDb(double thresh) override;
104 double GetTxPowerDb() override;
105 double GetRxThresholdDb() override;
106 double GetCcaThresholdDb() override;
107 bool IsStateSleep() override;
108 bool IsStateIdle() override;
109 bool IsStateBusy() override;
110 bool IsStateRx() override;
111 bool IsStateTx() override;
112 bool IsStateCcaBusy() override;
113 Ptr<UanChannel> GetChannel() const override;
114 Ptr<UanNetDevice> GetDevice() const override;
115 void SetChannel(Ptr<UanChannel> channel) override;
116 void SetDevice(Ptr<UanNetDevice> device) override;
117 void SetMac(Ptr<UanMac> mac) override;
118 void NotifyTransStartTx(Ptr<Packet> packet, double txPowerDb, UanTxMode txMode) override;
119 void NotifyIntChange() override;
120 void SetTransducer(Ptr<UanTransducer> trans) override;
122 uint32_t GetNModes() override;
123 UanTxMode GetMode(uint32_t n) override;
124 void Clear() override;
125
126 void SetSleepMode(bool /* sleep */) override
127 {
128 /// @todo This method has to be implemented
129 }
130
131 int64_t AssignStreams(int64_t stream) override;
132 Ptr<Packet> GetPacketRx() const override;
133
134 /** @copydoc UanPhy::IsStateIdle */
135 bool IsPhy1Idle();
136 /** @copydoc UanPhy::IsStateIdle */
137 bool IsPhy2Idle();
138 /** @copydoc UanPhy::IsStateRx */
139 bool IsPhy1Rx();
140 /** @copydoc UanPhy::IsStateRx */
141 bool IsPhy2Rx();
142 /** @copydoc UanPhy::IsStateTx */
143 bool IsPhy1Tx();
144 /** @copydoc UanPhy::IsStateTx */
145 bool IsPhy2Tx();
146
147 // Attribute getters and setters
148 /** @copydoc ns3::UanPhy::GetCcaThresholdDb() */
149 double GetCcaThresholdPhy1() const;
150 /** @copydoc UanPhy::GetCcaThresholdDb() */
151 double GetCcaThresholdPhy2() const;
152 /** @copydoc UanPhy::SetCcaThresholdDb */
153 void SetCcaThresholdPhy1(double thresh);
154 /** @copydoc UanPhy::SetCcaThresholdDb */
155 void SetCcaThresholdPhy2(double thresh);
156
157 /** @copydoc UanPhy::GetTxPowerDb */
158 double GetTxPowerDbPhy1() const;
159 /** @copydoc UanPhy::GetTxPowerDb */
160 double GetTxPowerDbPhy2() const;
161 /** @copydoc UanPhy::SetTxPowerDb */
162 void SetTxPowerDbPhy1(double txpwr);
163 /** @copydoc UanPhy::SetTxPowerDb */
164 void SetTxPowerDbPhy2(double txpwr);
165
166 /**
167 * Get the list of available modes.
168 *
169 * @return The mode list.
170 */
172 /** @copydoc GetModesPhy1 */
174
175 /**
176 * Set the available modes.
177 *
178 * @param modes List of modes.
179 */
180 void SetModesPhy1(UanModesList modes);
181 /** @copydoc SetModesPhy1 */
182 void SetModesPhy2(UanModesList modes);
183
184 /**
185 * Get the error probability model.
186 *
187 * @return The error model.
188 */
190 /** @copydoc GetPerModelPhy1() */
192
193 /**
194 * Set the error probability model.
195 *
196 * @param per The error model.
197 */
199 /** @copydoc SetPerModelPhy1 */
201
202 /**
203 * Get the SINR calculator.
204 *
205 * @return The SINR calculator.
206 */
208 /** @copydoc GetSinrModelPhy1 */
210
211 /**
212 * Set the SINR calculator.
213 *
214 * @param calcSinr The SINR calculator.
215 */
217 /** @copydoc SetSinrModelPhy1 */
219
220 /** @copydoc UanPhy::GetPacketRx */
222 /** @copydoc UanPhy::GetPacketRx */
224
225 private:
226 /** First Phy layer. */
228 /** Second Phy layer. */
230
231 /** A packet was received successfully. */
233 /** A packet was received unsuccessfuly. */
235 /** A packet was sent from this Phy. */
237 /** Callback when packet received without errors. */
239 /** Callback when packet received with errors. */
241
242 /**
243 * Handle callback and logger for packets received without error.
244 *
245 * @param pkt The packet.
246 * @param sinr The SINR.
247 * @param mode The channel mode.
248 */
249 void RxOkFromSubPhy(Ptr<Packet> pkt, double sinr, UanTxMode mode);
250 /**
251 * Handle callback and logger for packets received with error.
252 *
253 * @param pkt The packet.
254 * @param sinr The SINR.
255 */
256 void RxErrFromSubPhy(Ptr<Packet> pkt, double sinr);
257
258 protected:
259 void DoDispose() override;
260
261 // end of class UanPhyDual
262};
263
264} // namespace ns3
265
266#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:49
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:171
Interface for PHY event listener.
Definition uan-phy.h:136
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.