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
40{
41 public:
45 ~UanPhyCalcSinrDual() override;
46
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
78class UanPhyDual : public UanPhy
79{
80 public:
82 UanPhyDual();
84 ~UanPhyDual() override;
85
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
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 {
139 }
140
141 int64_t AssignStreams(int64_t stream) override;
142 Ptr<Packet> GetPacketRx() const override;
143
145 bool IsPhy1Idle();
147 bool IsPhy2Idle();
149 bool IsPhy1Rx();
151 bool IsPhy2Rx();
153 bool IsPhy1Tx();
155 bool IsPhy2Tx();
156
157 // Attribute getters and setters
159 double GetCcaThresholdPhy1() const;
161 double GetCcaThresholdPhy2() const;
163 void SetCcaThresholdPhy1(double thresh);
165 void SetCcaThresholdPhy2(double thresh);
166
168 double GetTxPowerDbPhy1() const;
170 double GetTxPowerDbPhy2() const;
172 void SetTxPowerDbPhy1(double txpwr);
174 void SetTxPowerDbPhy2(double txpwr);
175
184
190 void SetModesPhy1(UanModesList modes);
192 void SetModesPhy2(UanModesList modes);
193
202
211
220
229
234
235 private:
240
251
259 void RxOkFromSubPhy(Ptr<Packet> pkt, double sinr, UanTxMode mode);
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.