A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
half-duplex-ideal-phy.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 CTTC
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 */
8
9#ifndef HALF_DUPLEX_IDEAL_PHY_H
10#define HALF_DUPLEX_IDEAL_PHY_H
11
12#include "spectrum-channel.h"
14#include "spectrum-phy.h"
16#include "spectrum-value.h"
17
18#include <ns3/data-rate.h>
19#include <ns3/event-id.h>
20#include <ns3/generic-phy.h>
21#include <ns3/mobility-model.h>
22#include <ns3/net-device.h>
23#include <ns3/nstime.h>
24#include <ns3/packet.h>
25
26namespace ns3
27{
28
29/**
30 * \ingroup spectrum
31 *
32 * This PHY layer implementation realizes an ideal OFDM PHY which
33 * transmits half-duplex (i.e., it can either receive or transmit at a
34 * given time). The device is ideal in the sense that:
35 * 1) it uses an error model based on the Shannon capacity, which
36 * assumes ideal channel coding;
37 * 2) it uses ideal signal acquisition, i.e., preamble detection and
38 * synchronization are always successful
39 * 3) it has no PHY layer overhead
40 *
41 * Being half duplex, if a RX is ongoing but a TX is requested, the RX
42 * is aborted and the TX is started. Of course, no RX can be performed
43 * while there is an ongoing TX.
44 *
45 * The use of OFDM is modeled by means of the Spectrum framework. By
46 * calling the method SetTxPowerSpectralDensity(), the
47 * user can specify how much of the spectrum is used, how many
48 * subcarriers are used, and what power is allocated to each
49 * subcarrier.
50 *
51 * The user can also specify the PHY rate
52 * at which communications take place by using SetRate(). This is
53 * equivalent to choosing a particular modulation and coding scheme.
54 *
55 * The use of the ShannonSpectrumErrorModel allows us to account for
56 * the following aspects in determining whether a
57 * transmission is successful or not:
58 * - the PHY rate (trades off communication speed with reliability)
59 * - the power spectral density (trade-off among total power consumed,
60 * total bandwidth used (i.e., how much of the spectrum is occupied),
61 * and communication reliability)
62 * - the signal propagation
63 *
64 * This PHY model supports a single antenna model instance which is
65 * used for both transmission and reception.
66 */
68{
69 public:
71 ~HalfDuplexIdealPhy() override;
72
73 /**
74 * PHY states
75 */
76 enum State
77 {
78 IDLE, //!< Idle state
79 TX, //!< Transmitting state
80 RX //!< Receiving state
81 };
82
83 /**
84 * \brief Get the type ID.
85 * \return the object TypeId
86 */
87 static TypeId GetTypeId();
88
89 // inherited from SpectrumPhy
90 void SetChannel(Ptr<SpectrumChannel> c) override;
91 void SetMobility(Ptr<MobilityModel> m) override;
92 void SetDevice(Ptr<NetDevice> d) override;
93 Ptr<MobilityModel> GetMobility() const override;
94 Ptr<NetDevice> GetDevice() const override;
96 Ptr<Object> GetAntenna() const override;
97 void StartRx(Ptr<SpectrumSignalParameters> params) override;
98
99 /**
100 * \brief Set the Power Spectral Density of outgoing signals in power units
101 * (Watt, Pascal...) per Hz.
102 *
103 * @param txPsd Tx Power Spectral Density
104 */
106
107 /**
108 * \brief Set the Noise Power Spectral Density in power units
109 * (Watt, Pascal...) per Hz.
110 * @param noisePsd the Noise Power Spectral Density
111 */
113
114 /**
115 * Start a transmission
116 *
117 *
118 * @param p the packet to be transmitted
119 *
120 * @return true if an error occurred and the transmission was not
121 * started, false otherwise.
122 */
123 bool StartTx(Ptr<Packet> p);
124
125 /**
126 * Set the PHY rate to be used by this PHY.
127 *
128 * @param rate DataRate
129 */
130 void SetRate(DataRate rate);
131
132 /**
133 * Get the PHY rate to be used by this PHY.
134 *
135 * @return the PHY rate used by this PHY.
136 */
137 DataRate GetRate() const;
138
139 /**
140 * Set the callback for the end of a TX, as part of the
141 * interconnections between the PHY and the MAC
142 *
143 * @param c the callback
144 */
146
147 /**
148 * Set the callback for the start of RX, as part of the
149 * interconnections between the PHY and the MAC
150 *
151 * @param c the callback
152 */
154
155 /**
156 * set the callback for the end of a RX in error, as part of the
157 * interconnections between the PHY and the MAC
158 *
159 * @param c the callback
160 */
162
163 /**
164 * set the callback for the successful end of a RX, as part of the
165 * interconnections between the PHY and the MAC
166 *
167 * @param c the callback
168 */
170
171 /**
172 * set the AntennaModel to be used
173 *
174 * \param a the Antenna Model
175 */
177
178 private:
179 void DoDispose() override;
180
181 /**
182 * Change the PHY state
183 * \param newState new state
184 */
185 void ChangeState(State newState);
186 /**
187 * End the current Tx
188 */
189 void EndTx();
190 /**
191 * About current Rx
192 */
193 void AbortRx();
194 /**
195 * End current Rx
196 */
197 void EndRx();
198
199 EventId m_endRxEventId; //!< End Rx event
200
201 Ptr<MobilityModel> m_mobility; //!< Mobility model
202 Ptr<AntennaModel> m_antenna; //!< Antenna model
203 Ptr<NetDevice> m_netDevice; //!< NetDevice connected to this phy
205
206 Ptr<SpectrumValue> m_txPsd; //!< Tx power spectral density
207 Ptr<const SpectrumValue> m_rxPsd; //!< Rx power spectral density
208 Ptr<Packet> m_txPacket; //!< Tx packet
209 Ptr<Packet> m_rxPacket; //!< Rx packet
210
211 DataRate m_rate; //!< Datarate
212 State m_state; //!< PHY state
213
220
225
226 SpectrumInterference m_interference; //!< Received interference
227};
228
229} // namespace ns3
230
231#endif /* HALF_DUPLEX_IDEAL_PHY_H */
Class for representing data rates.
Definition data-rate.h:78
An identifier for simulation events.
Definition event-id.h:45
This PHY layer implementation realizes an ideal OFDM PHY which transmits half-duplex (i....
TracedCallback< Ptr< const Packet > > m_phyRxEndOkTrace
Trace - Tx end (ok)
void SetGenericPhyTxEndCallback(GenericPhyTxEndCallback c)
Set the callback for the end of a TX, as part of the interconnections between the PHY and the MAC.
Ptr< const SpectrumValue > m_rxPsd
Rx power spectral density.
GenericPhyTxEndCallback m_phyMacTxEndCallback
Callback - Tx end.
void SetGenericPhyRxEndErrorCallback(GenericPhyRxEndErrorCallback c)
set the callback for the end of a RX in error, as part of the interconnections between the PHY and th...
void SetRate(DataRate rate)
Set the PHY rate to be used by this PHY.
SpectrumInterference m_interference
Received interference.
DataRate GetRate() const
Get the PHY rate to be used by this PHY.
Ptr< MobilityModel > m_mobility
Mobility model.
void SetChannel(Ptr< SpectrumChannel > c) override
Set the channel attached to this device.
TracedCallback< Ptr< const Packet > > m_phyRxStartTrace
Trace - Rx start.
Ptr< AntennaModel > m_antenna
Antenna model.
TracedCallback< Ptr< const Packet > > m_phyRxAbortTrace
Trace - Rx abort.
Ptr< const SpectrumModel > GetRxSpectrumModel() const override
void SetAntenna(Ptr< AntennaModel > a)
set the AntennaModel to be used
TracedCallback< Ptr< const Packet > > m_phyTxStartTrace
Trace - Tx start.
Ptr< Object > GetAntenna() const override
Get the AntennaModel used by this SpectrumPhy instance for transmission and/or reception.
void SetGenericPhyRxEndOkCallback(GenericPhyRxEndOkCallback c)
set the callback for the successful end of a RX, as part of the interconnections between the PHY and ...
GenericPhyRxStartCallback m_phyMacRxStartCallback
Callback - Rx start.
void StartRx(Ptr< SpectrumSignalParameters > params) override
Notify the SpectrumPhy instance of an incoming signal.
void DoDispose() override
Destructor implementation.
static TypeId GetTypeId()
Get the type ID.
Ptr< SpectrumChannel > m_channel
Channel.
EventId m_endRxEventId
End Rx event.
void ChangeState(State newState)
Change the PHY state.
Ptr< Packet > m_rxPacket
Rx packet.
void SetNoisePowerSpectralDensity(Ptr< const SpectrumValue > noisePsd)
Set the Noise Power Spectral Density in power units (Watt, Pascal...) per Hz.
GenericPhyRxEndErrorCallback m_phyMacRxEndErrorCallback
Callback - Rx error.
Ptr< NetDevice > m_netDevice
NetDevice connected to this phy.
Ptr< NetDevice > GetDevice() const override
Get the associated NetDevice instance.
Ptr< Packet > m_txPacket
Tx packet.
void EndTx()
End the current Tx.
TracedCallback< Ptr< const Packet > > m_phyRxEndErrorTrace
Trace - Rx end (error)
void SetDevice(Ptr< NetDevice > d) override
Set the associated NetDevice instance.
Ptr< MobilityModel > GetMobility() const override
Get the associated MobilityModel instance.
void AbortRx()
About current Rx.
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
Set the Power Spectral Density of outgoing signals in power units (Watt, Pascal......
bool StartTx(Ptr< Packet > p)
Start a transmission.
void SetMobility(Ptr< MobilityModel > m) override
Set the mobility model associated with this device.
Ptr< SpectrumValue > m_txPsd
Tx power spectral density.
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
Trace - Tx end.
void SetGenericPhyRxStartCallback(GenericPhyRxStartCallback c)
Set the callback for the start of RX, as part of the interconnections between the PHY and the MAC.
GenericPhyRxEndOkCallback m_phyMacRxEndOkCallback
Callback - Rx end.
Smart pointer class similar to boost::intrusive_ptr.
This class implements a gaussian interference model, i.e., all incoming signals are added to the tota...
Abstract base class for Spectrum-aware PHY layers.
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.