A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
simple-ofdm-wimax-phy.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008, 2009 INRIA, UDcast
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
7 * <amine.ismail@udcast.com>
8 */
9
10#ifndef SIMPLE_OFDM_WIMAX_PHY_H
11#define SIMPLE_OFDM_WIMAX_PHY_H
12
13#include "bvec.h"
15#include "wimax-connection.h"
16#include "wimax-phy.h"
17
18#include "ns3/callback.h"
19#include "ns3/event-id.h"
20#include "ns3/nstime.h"
21#include "ns3/random-variable-stream.h"
22
23#include <list>
24#include <stdint.h>
25
26namespace ns3
27{
28
29class WimaxChannel;
30class WimaxNetDevice;
31class NetDevice;
32class Packet;
33class SimpleOfdmWimaxChannel;
34
35/**
36 * \ingroup wimax
37 * \brief SimpleOfdmWimaxPhy class
38 */
40{
41 public:
42 /// Frame duration code enumeration
53
54 /**
55 * \brief Get the type ID.
56 * \return the object TypeId
57 */
58 static TypeId GetTypeId();
60 /**
61 * Constructor
62 *
63 * \param tracesPath trace path
64 */
65 SimpleOfdmWimaxPhy(char* tracesPath);
66 ~SimpleOfdmWimaxPhy() override;
67 /**
68 * \brief if called with true it will enable the loss model
69 * \param loss set to true to enable the loss model
70 */
71 void ActivateLoss(bool loss);
72 /**
73 * \brief Set the path of the repository containing the traces
74 * \param tracesPath the path to the repository.
75 * see snr-to-block-error-rate-manager.h for more details.
76 */
77 void SetSNRToBlockErrorRateTracesPath(char* tracesPath);
78 /**
79 * Attach the physical layer to a channel.
80 * \param channel the channel to which the physical layer will be attached
81 */
82 void DoAttach(Ptr<WimaxChannel> channel) override;
83 /**
84 * \brief set the callback function to call when a burst is received
85 * \param callback the receive callback function
86 */
88 /**
89 * \brief Sends a burst on the channel
90 * \param burst the burst to send
91 * \param modulationType the modulation that will be used to send this burst
92 * \param direction set to uplink or downlink
93 */
94 void Send(Ptr<PacketBurst> burst, WimaxPhy::ModulationType modulationType, uint8_t direction);
95 /**
96 * \brief Sends a burst on the channel
97 * \param params parameters
98 * \see SendParams
99 */
100 void Send(SendParams* params) override;
101 /**
102 * \brief returns the type this physical layer
103 * \return always WimaxPhy::simpleOfdmWimaxPhy;
104 */
105 WimaxPhy::PhyType GetPhyType() const override;
106 /**
107 * \brief start the reception of a fec block
108 * \param burstSize the burst size
109 * \param isFirstBlock true if this block is the first one, false otherwise
110 * \param frequency the frequency in which the fec block is being received
111 * \param modulationType the modulation used to transmit this fec Block
112 * \param direction set to uplink and downlink
113 * \param rxPower the received power.
114 * \param burst the burst to be sent
115 */
116
117 void StartReceive(uint32_t burstSize,
118 bool isFirstBlock,
119 uint64_t frequency,
120 WimaxPhy::ModulationType modulationType,
121 uint8_t direction,
122 double rxPower,
123 Ptr<PacketBurst> burst);
124
125 /**
126 * \return the bandwidth
127 */
128 uint32_t GetBandwidth() const;
129 /**
130 * \brief Set the bandwidth
131 * \param BW the bandwidth
132 */
134 /**
135 * \return the transmission power
136 */
137 double GetTxPower() const;
138 /**
139 * \brief set the transmission power
140 * \param txPower the transmission power
141 */
142 void SetTxPower(double txPower);
143 /**
144 * \return the noise figure
145 */
146 double GetNoiseFigure() const;
147 /**
148 * \brief set the noise figure of the device
149 * \param nf the noise figure
150 */
151 void SetNoiseFigure(double nf);
152
153 /**
154 * Public method used to fire a PhyTxBegin trace. Implemented for encapsulation
155 * purposes.
156 * \param burst the packet burst
157 */
159
160 /**
161 * Public method used to fire a PhyTxEnd trace. Implemented for encapsulation
162 * purposes.
163 * \param burst the packet burst
164 */
165 void NotifyTxEnd(Ptr<PacketBurst> burst);
166
167 /**
168 * Public method used to fire a PhyTxDrop trace. Implemented for encapsulation
169 * purposes.
170 * \param burst the packet burst
171 */
172 void NotifyTxDrop(Ptr<PacketBurst> burst);
173
174 /**
175 * Public method used to fire a PhyRxBegin trace. Implemented for encapsulation
176 * purposes.
177 * \param burst the packet burst
178 */
180
181 /**
182 * Public method used to fire a PhyRxEnd trace. Implemented for encapsulation
183 * purposes.
184 * \param burst the packet burst
185 */
186 void NotifyRxEnd(Ptr<PacketBurst> burst);
187
188 /**
189 * Public method used to fire a PhyRxDrop trace. Implemented for encapsulation
190 * purposes.
191 * \param burst the packet burst
192 */
193 void NotifyRxDrop(Ptr<PacketBurst> burst);
194
195 /**
196 * Assign a fixed random variable stream number to the random variables
197 * used by this model. Return the number of streams (possibly zero) that
198 * have been assigned.
199 *
200 * \param stream first stream index to use
201 * \return the number of stream indices assigned by this model
202 */
203 int64_t AssignStreams(int64_t stream) override;
204
205 private:
206 /**
207 * Get transmission time
208 * \param size the size
209 * \param modulationType the modulation type
210 * \returns the transmission time
211 */
213 WimaxPhy::ModulationType modulationType) const override;
214 /**
215 * Get number of symbols
216 * \param size the size
217 * \param modulationType the modulation type
218 * \returns the number of symbols
219 */
220 uint64_t DoGetNrSymbols(uint32_t size, WimaxPhy::ModulationType modulationType) const override;
221 /**
222 * Get number of bytes
223 * \param symbols the symbols
224 * \param modulationType the modulation type
225 * \returns the number of bytes
226 */
227 uint64_t DoGetNrBytes(uint32_t symbols, WimaxPhy::ModulationType modulationType) const override;
228 /**
229 * Convert burst to bits
230 * \param burst the packet burst
231 * \returns the BVEC
232 */
234 /**
235 * Convert bits to burst
236 * \param buffer the BVEC
237 * \returns the packet burst
238 */
240 /**
241 * Create FEC blocks
242 * \param buffer the BVEC
243 * \param modulationType the modulation type
244 */
245 void CreateFecBlocks(const Bvec& buffer, WimaxPhy::ModulationType modulationType);
246 /**
247 * Recreate buffer
248 * \returns BVEC
249 */
251 /**
252 * Get FEC block size
253 * \param type the modulation type
254 * \returns the FEC block size
255 */
257 /**
258 * Get coded FEC block size
259 * \param modulationType the modulation type
260 * \returns the coded FEC block size
261 */
263 /**
264 * Set block parameters
265 * \param burstSize the burst size
266 * \param modulationType the modulation type
267 */
268 void SetBlockParameters(uint32_t burstSize, WimaxPhy::ModulationType modulationType);
269 /**
270 * Get number of blocks
271 * \param burstSize the burst size
272 * \param modulationType the modulation type
273 * \returns the number of blocks
274 */
275 uint16_t GetNrBlocks(uint32_t burstSize, WimaxPhy::ModulationType modulationType) const;
276 void DoDispose() override;
277 /// End send
278 void EndSend();
279 /**
280 * End send FEC block
281 * \param modulationType the modulation type
282 * \param direction the direction
283 */
284 void EndSendFecBlock(WimaxPhy::ModulationType modulationType, uint8_t direction);
285 /**
286 * End receive
287 * \param burst
288 */
290 /**
291 * End receive FEC block
292 * \param burstSize the burst size
293 * \param modulationType the modulation type
294 * \param direction the direction
295 * \param drop whether to drop
296 * \param burst the burst
297 */
298 void EndReceiveFecBlock(uint32_t burstSize,
299 WimaxPhy::ModulationType modulationType,
300 uint8_t direction,
301 bool drop,
302 Ptr<PacketBurst> burst);
303 /**
304 * Start end dummy FEC block
305 * \param isFirstBlock is the first block?
306 * \param modulationType the modulation type
307 * \param direction the direction
308 */
309 void StartSendDummyFecBlock(bool isFirstBlock,
310 WimaxPhy::ModulationType modulationType,
311 uint8_t direction);
312 /**
313 * Get block transmission time
314 * \param modulationType the modulation type
315 * \returns the block transmission time
316 */
318 /// Set data rates
319 void DoSetDataRates() override;
320 /// Initialize simple OFDM WIMAX Phy
322
323 /**
324 * Get moduleation FEC parameters
325 * \param modulationType the modulation type
326 * \param bitsPerSymbol the number of bits per symbol
327 * \param fecCode the FEC code
328 */
330 uint8_t& bitsPerSymbol,
331 double& fecCode) const;
332 /**
333 * Calculate data rate
334 * \param modulationType the modulation type
335 * \returns the data rate
336 */
338 /**
339 * Get data rate
340 * \param modulationType the modulation type
341 * \returns the data rate
342 */
343 uint32_t DoGetDataRate(WimaxPhy::ModulationType modulationType) const override;
344 /**
345 * Get TTG
346 * \returns the TTG
347 */
348 uint16_t DoGetTtg() const override;
349 /**
350 * Get RTG
351 * \returns the RTG
352 */
353 uint16_t DoGetRtg() const override;
354 /**
355 * Get frame duration code
356 * \returns the frame duration code
357 */
358 uint8_t DoGetFrameDurationCode() const override;
359 /**
360 * Get frame duration
361 * \param frameDurationCode the frame duration code
362 * \returns the frame duration
363 */
364 Time DoGetFrameDuration(uint8_t frameDurationCode) const override;
365 /// Set Phy parameters
366 void DoSetPhyParameters() override;
367 /**
368 * Get NFFT
369 * \returns the NFFT
370 */
371 uint16_t DoGetNfft() const override;
372 /**
373 * Set NFFT
374 * \param nfft the NFFT
375 */
376 void DoSetNfft(uint16_t nfft);
377 /**
378 * Get sampling factor
379 * \returns the sampling factor
380 */
381 double DoGetSamplingFactor() const override;
382 /**
383 * Get sampling frequency
384 * \returns the sampling frequency
385 */
386 double DoGetSamplingFrequency() const override;
387 /**
388 * Get G value
389 * \returns the G value
390 */
391 double DoGetGValue() const override;
392 /**
393 * Set G value
394 * \param g the G value
395 */
396 void DoSetGValue(double g);
397
398 /**
399 * Get receive gain
400 * \returns the receive gain
401 */
402 double GetRxGain() const;
403 /**
404 * Set receive gsain
405 * \param rxgain the receive gain
406 */
407 void SetRxGain(double rxgain);
408
409 /**
410 * Get transmit gain
411 * \returns the transmit gain
412 */
413 double GetTxGain() const;
414 /**
415 * Set transmit gain
416 * \param txgain the transmit gain
417 */
418 void SetTxGain(double txgain);
419
420 /**
421 * Get trace file path
422 * \returns the trace file path name
423 */
424 std::string GetTraceFilePath() const;
425 /**
426 * Set trace file path
427 * \param path the trace file path
428 */
429 void SetTraceFilePath(std::string path);
430
431 uint16_t m_fecBlockSize; ///< in bits, size of FEC block transmitted after PHY operations
432 uint32_t m_currentBurstSize; ///< current burst size
433
434 std::list<Bvec>* m_receivedFecBlocks; ///< a list of received FEC blocks until they are combined
435 ///< to recreate the full burst buffer
436 uint32_t m_nrFecBlocksSent; ///< counting the number of FEC blocks sent (within a burst)
437 std::list<Bvec>* m_fecBlocks; ///< the FEC blocks
438 Time m_blockTime; ///< block time
439
442
443 // data rates for this Phy
451
452 // parameters to store for a per burst life-time
453 uint16_t m_nrBlocks; ///< number of blocks
454 uint16_t m_nrRemainingBlocksToSend; ///< number of remaining blocks to send
456 uint16_t m_blockSize; ///< block size
457 uint32_t m_paddingBits; ///< padding bits
458 uint16_t m_nbErroneousBlock; ///< erroneous blocks
459 uint16_t m_nrReceivedFecBlocks; ///< number received FEC blocks
460 uint16_t m_nfft; ///< NFFT
461 double m_g; ///< G value
462 double m_bandWidth; ///< bandwidth
463 double m_txPower; ///< transmit power
464 double m_noiseFigure; ///< noise figure
465 double m_txGain; ///< transmit gain
466 double m_rxGain; ///< receive gain
467 /**
468 * The trace source fired when a packet begins the transmission process on
469 * the medium.
470 *
471 * \see class CallBackTraceSource
472 * \deprecated The non-const \c Ptr<PacketBurst> argument is deprecated
473 * and will be changed to \c Ptrc<PacketBurst> in a future release.
474 */
475 // NS_DEPRECATED() - tag for future removal
477
478 /**
479 * The trace source fired when a packet ends the transmission process on
480 * the medium.
481 *
482 * \see class CallBackTraceSource
483 * \deprecated The non-const \c Ptr<PacketBurst> argument is deprecated
484 * and will be changed to \c Ptrc<PacketBurst> in a future release.
485 */
486 // NS_DEPRECATED() - tag for future removal
488
489 /**
490 * The trace source fired when the phy layer drops a packet as it tries
491 * to transmit it.
492 *
493 * \see class CallBackTraceSource
494 * \deprecated The non-const \c Ptr<PacketBurst> argument is deprecated
495 * and will be changed to \c Ptrc<PacketBurst> in a future release.
496 */
497 // NS_DEPRECATED() - tag for future removal
499
500 /**
501 * The trace source fired when a packet begins the reception process from
502 * the medium.
503 *
504 * \see class CallBackTraceSource
505 * \deprecated The non-const \c Ptr<PacketBurst> argument is deprecated
506 * and will be changed to \c Ptrc<PacketBurst> in a future release.
507 */
508 // NS_DEPRECATED() - tag for future removal
510
511 /**
512 * The trace source fired when a packet ends the reception process from
513 * the medium.
514 *
515 * \see class CallBackTraceSource
516 * \deprecated The non-const \c Ptr<PacketBurst> argument is deprecated
517 * and will be changed to \c Ptrc<PacketBurst> in a future release.
518 */
519 // NS_DEPRECATED() - tag for future removal
521
522 /**
523 * The trace source fired when the phy layer drops a packet it has received.
524 *
525 * \see class CallBackTraceSource
526 * \deprecated The non-const \c Ptr<PacketBurst> argument is deprecated
527 * and will be changed to \c Ptrc<PacketBurst> in a future release.
528 */
529 // NS_DEPRECATED() - tag for future removal
531
532 SNRToBlockErrorRateManager* m_snrToBlockErrorRateManager; ///< SNR to block error rate manager
533
534 /// Provides uniform random variables.
536};
537
538} // namespace ns3
539
540#endif /* OFDM_WIMAX_PHY_H */
Callback template class.
Definition callback.h:422
Smart pointer class similar to boost::intrusive_ptr.
This class handles the SNR to BlcER traces.
The SendParams class defines the parameters with which Send() function of a particular PHY is called.
Definition send-params.h:31
SimpleOfdmWimaxPhy class.
std::string GetTraceFilePath() const
Get trace file path.
void GetModulationFecParams(WimaxPhy::ModulationType modulationType, uint8_t &bitsPerSymbol, double &fecCode) const
Get moduleation FEC parameters.
void NotifyRxBegin(Ptr< PacketBurst > burst)
Public method used to fire a PhyRxBegin trace.
double GetTxGain() const
Get transmit gain.
double DoGetSamplingFrequency() const override
Get sampling frequency.
void CreateFecBlocks(const Bvec &buffer, WimaxPhy::ModulationType modulationType)
Create FEC blocks.
static TypeId GetTypeId()
Get the type ID.
void NotifyRxEnd(Ptr< PacketBurst > burst)
Public method used to fire a PhyRxEnd trace.
TracedCallback< Ptr< PacketBurst > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
double m_txPower
transmit power
void EndReceiveFecBlock(uint32_t burstSize, WimaxPhy::ModulationType modulationType, uint8_t direction, bool drop, Ptr< PacketBurst > burst)
End receive FEC block.
void EndReceive(Ptr< const PacketBurst > burst)
End receive.
double DoGetGValue() const override
Get G value.
void DoSetGValue(double g)
Set G value.
uint32_t CalculateDataRate(WimaxPhy::ModulationType modulationType) const
Calculate data rate.
void StartSendDummyFecBlock(bool isFirstBlock, WimaxPhy::ModulationType modulationType, uint8_t direction)
Start end dummy FEC block.
void DoAttach(Ptr< WimaxChannel > channel) override
Attach the physical layer to a channel.
uint16_t DoGetTtg() const override
Get TTG.
uint8_t DoGetFrameDurationCode() const override
Get frame duration code.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
void ActivateLoss(bool loss)
if called with true it will enable the loss model
uint32_t m_dataRateQam16_34
data rate
uint16_t m_nbErroneousBlock
erroneous blocks
uint16_t m_nrBlocks
number of blocks
WimaxPhy::PhyType GetPhyType() const override
returns the type this physical layer
void SetTraceFilePath(std::string path)
Set trace file path.
void SetNoiseFigure(double nf)
set the noise figure of the device
uint16_t m_nrReceivedFecBlocks
number received FEC blocks
void SetRxGain(double rxgain)
Set receive gsain.
Ptr< PacketBurst > ConvertBitsToBurst(Bvec buffer)
Convert bits to burst.
void EndSendFecBlock(WimaxPhy::ModulationType modulationType, uint8_t direction)
End send FEC block.
Ptr< PacketBurst > m_currentBurst
current burst
Ptr< UniformRandomVariable > m_URNG
Provides uniform random variables.
void DoSetNfft(uint16_t nfft)
Set NFFT.
void NotifyRxDrop(Ptr< PacketBurst > burst)
Public method used to fire a PhyRxDrop trace.
uint16_t GetNrBlocks(uint32_t burstSize, WimaxPhy::ModulationType modulationType) const
Get number of blocks.
Bvec RecreateBuffer()
Recreate buffer.
TracedCallback< Ptr< PacketBurst > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
TracedCallback< Ptr< PacketBurst > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
void NotifyTxEnd(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxEnd trace.
void SetBlockParameters(uint32_t burstSize, WimaxPhy::ModulationType modulationType)
Set block parameters.
uint32_t m_dataRateQam64_34
data rate
double DoGetSamplingFactor() const override
Get sampling factor.
void SetTxPower(double txPower)
set the transmission power
FrameDurationCode
Frame duration code enumeration.
uint64_t DoGetNrBytes(uint32_t symbols, WimaxPhy::ModulationType modulationType) const override
Get number of bytes.
SNRToBlockErrorRateManager * m_snrToBlockErrorRateManager
SNR to block error rate manager.
TracedCallback< Ptr< const PacketBurst > > m_traceTx
trace transmit callback
void DoSetDataRates() override
Set data rates.
uint16_t DoGetNfft() const override
Get NFFT.
void DoSetPhyParameters() override
Set Phy parameters.
uint32_t m_dataRateQam16_12
data rate
uint16_t DoGetRtg() const override
Get RTG.
uint32_t GetCodedFecBlockSize(WimaxPhy::ModulationType modulationType) const
Get coded FEC block size.
std::list< Bvec > * m_receivedFecBlocks
a list of received FEC blocks until they are combined to recreate the full burst buffer
uint32_t GetFecBlockSize(WimaxPhy::ModulationType type) const
Get FEC block size.
void SetTxGain(double txgain)
Set transmit gain.
uint16_t m_nrRemainingBlocksToSend
number of remaining blocks to send
void SetBandwidth(uint32_t BW)
Set the bandwidth.
TracedCallback< Ptr< PacketBurst > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium.
Time GetBlockTransmissionTime(WimaxPhy::ModulationType modulationType) const
Get block transmission time.
void Send(Ptr< PacketBurst > burst, WimaxPhy::ModulationType modulationType, uint8_t direction)
Sends a burst on the channel.
Time DoGetTransmissionTime(uint32_t size, WimaxPhy::ModulationType modulationType) const override
Get transmission time.
TracedCallback< Ptr< PacketBurst > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
Time DoGetFrameDuration(uint8_t frameDurationCode) const override
Get frame duration.
void SetSNRToBlockErrorRateTracesPath(char *tracesPath)
Set the path of the repository containing the traces.
uint32_t m_currentBurstSize
current burst size
uint32_t DoGetDataRate(WimaxPhy::ModulationType modulationType) const override
Get data rate.
void NotifyTxDrop(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxDrop trace.
uint64_t DoGetNrSymbols(uint32_t size, WimaxPhy::ModulationType modulationType) const override
Get number of symbols.
void SetReceiveCallback(Callback< void, Ptr< PacketBurst >, Ptr< WimaxConnection > > callback)
set the callback function to call when a burst is received
void InitSimpleOfdmWimaxPhy()
Initialize simple OFDM WIMAX Phy.
void NotifyTxBegin(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxBegin trace.
TracedCallback< Ptr< PacketBurst > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet as it tries to transmit it.
uint32_t m_paddingBits
padding bits
std::list< Bvec > * m_fecBlocks
the FEC blocks
double GetRxGain() const
Get receive gain.
uint16_t m_fecBlockSize
in bits, size of FEC block transmitted after PHY operations
TracedCallback< Ptr< const PacketBurst > > m_traceRx
trace receive callback
Bvec ConvertBurstToBits(Ptr< const PacketBurst > burst)
Convert burst to bits.
uint32_t m_dataRateQam64_23
data rate
void DoDispose() override
Destructor implementation.
void StartReceive(uint32_t burstSize, bool isFirstBlock, uint64_t frequency, WimaxPhy::ModulationType modulationType, uint8_t direction, double rxPower, Ptr< PacketBurst > burst)
start the reception of a fec block
uint32_t m_nrFecBlocksSent
counting the number of FEC blocks sent (within a burst)
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
WiMAX PHY entity.
Definition wimax-phy.h:39
ModulationType
ModulationType enumeration.
Definition wimax-phy.h:43
PhyType
PhyType enumeration.
Definition wimax-phy.h:64
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::vector< bool > Bvec
boolean vector typedef
Definition bvec.h:18
constexpr double BW