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