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 * 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: Nicola Baldo <nbaldo@cttc.es>
18 */
19
20#ifndef HALF_DUPLEX_IDEAL_PHY_H
21#define HALF_DUPLEX_IDEAL_PHY_H
22
23#include "spectrum-channel.h"
25#include "spectrum-phy.h"
27#include "spectrum-value.h"
28
29#include <ns3/data-rate.h>
30#include <ns3/event-id.h>
31#include <ns3/generic-phy.h>
32#include <ns3/mobility-model.h>
33#include <ns3/net-device.h>
34#include <ns3/nstime.h>
35#include <ns3/packet.h>
36
37namespace ns3
38{
39
40/**
41 * \ingroup spectrum
42 *
43 * This PHY layer implementation realizes an ideal OFDM PHY which
44 * transmits half-duplex (i.e., it can either receive or transmit at a
45 * given time). The device is ideal in the sense that:
46 * 1) it uses an error model based on the Shannon capacity, which
47 * assumes ideal channel coding;
48 * 2) it uses ideal signal acquisition, i.e., preamble detection and
49 * synchronization are always successful
50 * 3) it has no PHY layer overhead
51 *
52 * Being half duplex, if a RX is ongoing but a TX is requested, the RX
53 * is aborted and the TX is started. Of course, no RX can be performed
54 * while there is an ongoing TX.
55 *
56 * The use of OFDM is modeled by means of the Spectrum framework. By
57 * calling the method SetTxPowerSpectralDensity(), the
58 * user can specify how much of the spectrum is used, how many
59 * subcarriers are used, and what power is allocated to each
60 * subcarrier.
61 *
62 * The user can also specify the PHY rate
63 * at which communications take place by using SetRate(). This is
64 * equivalent to choosing a particular modulation and coding scheme.
65 *
66 * The use of the ShannonSpectrumErrorModel allows us to account for
67 * the following aspects in determining whether a
68 * transmission is successful or not:
69 * - the PHY rate (trades off communication speed with reliability)
70 * - the power spectral density (trade-off among total power consumed,
71 * total bandwidth used (i.e., how much of the spectrum is occupied),
72 * and communication reliability)
73 * - the signal propagation
74 *
75 * This PHY model supports a single antenna model instance which is
76 * used for both transmission and reception.
77 */
79{
80 public:
82 ~HalfDuplexIdealPhy() override;
83
84 /**
85 * PHY states
86 */
87 enum State
88 {
89 IDLE, //!< Idle state
90 TX, //!< Transmitting state
91 RX //!< Receiving state
92 };
93
94 /**
95 * \brief Get the type ID.
96 * \return the object TypeId
97 */
98 static TypeId GetTypeId();
99
100 // inherited from SpectrumPhy
101 void SetChannel(Ptr<SpectrumChannel> c) override;
102 void SetMobility(Ptr<MobilityModel> m) override;
103 void SetDevice(Ptr<NetDevice> d) override;
104 Ptr<MobilityModel> GetMobility() const override;
105 Ptr<NetDevice> GetDevice() const override;
107 Ptr<Object> GetAntenna() const override;
108 void StartRx(Ptr<SpectrumSignalParameters> params) override;
109
110 /**
111 * \brief Set the Power Spectral Density of outgoing signals in power units
112 * (Watt, Pascal...) per Hz.
113 *
114 * @param txPsd Tx Power Spectral Density
115 */
117
118 /**
119 * \brief Set the Noise Power Spectral Density in power units
120 * (Watt, Pascal...) per Hz.
121 * @param noisePsd the Noise Power Spectral Density
122 */
124
125 /**
126 * Start a transmission
127 *
128 *
129 * @param p the packet to be transmitted
130 *
131 * @return true if an error occurred and the transmission was not
132 * started, false otherwise.
133 */
134 bool StartTx(Ptr<Packet> p);
135
136 /**
137 * Set the PHY rate to be used by this PHY.
138 *
139 * @param rate DataRate
140 */
141 void SetRate(DataRate rate);
142
143 /**
144 * Get the PHY rate to be used by this PHY.
145 *
146 * @return the PHY rate used by this PHY.
147 */
148 DataRate GetRate() const;
149
150 /**
151 * Set the callback for the end of a TX, as part of the
152 * interconnections between the PHY and the MAC
153 *
154 * @param c the callback
155 */
157
158 /**
159 * Set the callback for the start of RX, as part of the
160 * interconnections between the PHY and the MAC
161 *
162 * @param c the callback
163 */
165
166 /**
167 * set the callback for the end of a RX in error, as part of the
168 * interconnections between the PHY and the MAC
169 *
170 * @param c the callback
171 */
173
174 /**
175 * set the callback for the successful end of a RX, as part of the
176 * interconnections between the PHY and the MAC
177 *
178 * @param c the callback
179 */
181
182 /**
183 * set the AntennaModel to be used
184 *
185 * \param a the Antenna Model
186 */
188
189 private:
190 void DoDispose() override;
191
192 /**
193 * Change the PHY state
194 * \param newState new state
195 */
196 void ChangeState(State newState);
197 /**
198 * End the current Tx
199 */
200 void EndTx();
201 /**
202 * About current Rx
203 */
204 void AbortRx();
205 /**
206 * End current Rx
207 */
208 void EndRx();
209
210 EventId m_endRxEventId; //!< End Rx event
211
212 Ptr<MobilityModel> m_mobility; //!< Mobility model
213 Ptr<AntennaModel> m_antenna; //!< Antenna model
214 Ptr<NetDevice> m_netDevice; //!< NetDevice connected to this phy
216
217 Ptr<SpectrumValue> m_txPsd; //!< Tx power spectral density
218 Ptr<const SpectrumValue> m_rxPsd; //!< Rx power spectral density
219 Ptr<Packet> m_txPacket; //!< Tx packet
220 Ptr<Packet> m_rxPacket; //!< Rx packet
221
222 DataRate m_rate; //!< Datarate
223 State m_state; //!< PHY state
224
231
236
237 SpectrumInterference m_interference; //!< Received interference
238};
239
240} // namespace ns3
241
242#endif /* HALF_DUPLEX_IDEAL_PHY_H */
Class for representing data rates.
Definition: data-rate.h:89
An identifier for simulation events.
Definition: event-id.h:55
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.
void EndRx()
End current Rx.
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.
Definition: ptr.h:77
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.
Definition: spectrum-phy.h:46
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.