A Discrete-Event Network Simulator
API
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 
37 namespace ns3
38 {
39 
40 class WimaxChannel;
41 class WimaxNetDevice;
42 class NetDevice;
43 class Packet;
44 class SimpleOfdmWimaxChannel;
45 
51 {
52  public:
55  {
63  };
64 
69  static TypeId GetTypeId();
76  SimpleOfdmWimaxPhy(char* tracesPath);
77  ~SimpleOfdmWimaxPhy() override;
82  void ActivateLoss(bool loss);
88  void SetSNRToBlockErrorRateTracesPath(char* tracesPath);
93  void DoAttach(Ptr<WimaxChannel> channel) override;
105  void Send(Ptr<PacketBurst> burst, WimaxPhy::ModulationType modulationType, uint8_t direction);
111  void Send(SendParams* params) override;
116  WimaxPhy::PhyType GetPhyType() const override;
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 
139  uint32_t GetBandwidth() const;
144  void SetBandwidth(uint32_t BW);
148  double GetTxPower() const;
153  void SetTxPower(double txPower);
157  double GetNoiseFigure() const;
162  void SetNoiseFigure(double nf);
163 
169  void NotifyTxBegin(Ptr<PacketBurst> burst);
170 
176  void NotifyTxEnd(Ptr<PacketBurst> burst);
177 
183  void NotifyTxDrop(Ptr<PacketBurst> burst);
184 
190  void NotifyRxBegin(Ptr<PacketBurst> burst);
191 
197  void NotifyRxEnd(Ptr<PacketBurst> burst);
198 
204  void NotifyRxDrop(Ptr<PacketBurst> burst);
205 
214  int64_t AssignStreams(int64_t stream) override;
215 
216  private:
223  Time DoGetTransmissionTime(uint32_t size,
224  WimaxPhy::ModulationType modulationType) const override;
231  uint64_t DoGetNrSymbols(uint32_t size, WimaxPhy::ModulationType modulationType) const override;
238  uint64_t DoGetNrBytes(uint32_t symbols, WimaxPhy::ModulationType modulationType) const override;
256  void CreateFecBlocks(const Bvec& buffer, WimaxPhy::ModulationType modulationType);
273  uint32_t GetCodedFecBlockSize(WimaxPhy::ModulationType modulationType) const;
279  void SetBlockParameters(uint32_t burstSize, WimaxPhy::ModulationType modulationType);
286  uint16_t GetNrBlocks(uint32_t burstSize, WimaxPhy::ModulationType modulationType) const;
287  void DoDispose() override;
289  void EndSend();
295  void EndSendFecBlock(WimaxPhy::ModulationType modulationType, uint8_t direction);
309  void EndReceiveFecBlock(uint32_t burstSize,
310  WimaxPhy::ModulationType modulationType,
311  uint8_t direction,
312  bool drop,
313  Ptr<PacketBurst> burst);
320  void StartSendDummyFecBlock(bool isFirstBlock,
321  WimaxPhy::ModulationType modulationType,
322  uint8_t direction);
330  void DoSetDataRates() override;
332  void InitSimpleOfdmWimaxPhy();
333 
341  uint8_t& bitsPerSymbol,
342  double& fecCode) const;
348  uint32_t CalculateDataRate(WimaxPhy::ModulationType modulationType) const;
354  uint32_t DoGetDataRate(WimaxPhy::ModulationType modulationType) const override;
359  uint16_t DoGetTtg() const override;
364  uint16_t DoGetRtg() const override;
369  uint8_t DoGetFrameDurationCode() const override;
375  Time DoGetFrameDuration(uint8_t frameDurationCode) const override;
377  void DoSetPhyParameters() override;
382  uint16_t DoGetNfft() const override;
387  void DoSetNfft(uint16_t nfft);
392  double DoGetSamplingFactor() const override;
397  double DoGetSamplingFrequency() const override;
402  double DoGetGValue() const override;
407  void DoSetGValue(double g);
408 
413  double GetRxGain() const;
418  void SetRxGain(double rxgain);
419 
424  double GetTxGain() const;
429  void SetTxGain(double txgain);
430 
435  std::string GetTraceFilePath() const;
440  void SetTraceFilePath(std::string path);
441 
442  uint16_t m_fecBlockSize;
444 
445  std::list<Bvec>* m_receivedFecBlocks;
447  uint32_t m_nrFecBlocksSent;
448  std::list<Bvec>* m_fecBlocks;
450 
453 
454  // data rates for this Phy
455  uint32_t m_dataRateBpsk12;
456  uint32_t m_dataRateQpsk12;
457  uint32_t m_dataRateQpsk34;
462 
463  // parameters to store for a per burst life-time
464  uint16_t m_nrBlocks;
467  uint16_t m_blockSize;
468  uint32_t m_paddingBits;
471  uint16_t m_nfft;
472  double m_g;
473  double m_bandWidth;
474  double m_txPower;
475  double m_noiseFigure;
476  double m_txGain;
477  double m_rxGain;
487 
497 
507 
517 
527 
536 
538 
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 SetReceiveCallback(Callback< void, Ptr< PacketBurst >, Ptr< WimaxConnection >> callback)
set the callback function to call when a burst is received
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 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
channel
Definition: third.py:88
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
constexpr double BW