A Discrete-Event Network Simulator
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007,2008, 2009 INRIA, UDcast
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19  * <amine.ismail@udcast.com>
20  */
25 #include <stdint.h>
26 #include <list>
27 #include "ns3/callback.h"
28 #include "ns3/nstime.h"
29 #include "ns3/event-id.h"
30 #include "ns3/random-variable-stream.h"
31 #include "wimax-phy.h"
32 #include "bvec.h"
33 #include "ns3/snr-to-block-error-rate-manager.h"
34 #include "wimax-connection.h"
35 namespace ns3 {
37 class WimaxChannel;
38 class WimaxNetDevice;
39 class NetDevice;
40 class Packet;
41 class SimpleOfdmWimaxChannel;
48 {
49 public:
52  {
60  };
66  static TypeId GetTypeId (void);
67  SimpleOfdmWimaxPhy (void);
73  SimpleOfdmWimaxPhy (char * tracesPath);
74  ~SimpleOfdmWimaxPhy (void);
79  void ActivateLoss (bool loss);
85  void SetSNRToBlockErrorRateTracesPath (char * tracesPath);
102  void Send (Ptr<PacketBurst> burst, WimaxPhy::ModulationType modulationType, uint8_t direction);
108  void Send (SendParams *params);
113  WimaxPhy::PhyType GetPhyType (void) const;
125  void StartReceive (uint32_t burstSize,
126  bool isFirstBlock,
127  uint64_t frequency,
128  WimaxPhy::ModulationType modulationType,
129  uint8_t direction,
130  double rxPower,
131  Ptr<PacketBurst> burst);
136  uint32_t GetBandwidth (void) const;
141  void SetBandwidth (uint32_t BW);
145  double GetTxPower (void) const;
150  void SetTxPower (double txPower);
154  double GetNoiseFigure (void) const;
159  void SetNoiseFigure (double nf);
166  void NotifyTxBegin (Ptr<PacketBurst> burst);
173  void NotifyTxEnd (Ptr<PacketBurst> burst);
180  void NotifyTxDrop (Ptr<PacketBurst> burst);
187  void NotifyRxBegin (Ptr<PacketBurst> burst);
194  void NotifyRxEnd (Ptr<PacketBurst> burst);
201  void NotifyRxDrop (Ptr<PacketBurst> burst);
211  int64_t AssignStreams (int64_t stream);
213 private:
220  Time DoGetTransmissionTime (uint32_t size, WimaxPhy::ModulationType modulationType) const;
227  uint64_t DoGetNrSymbols (uint32_t size, WimaxPhy::ModulationType modulationType) const;
234  uint64_t DoGetNrBytes (uint32_t symbols, WimaxPhy::ModulationType modulationType) const;
252  void CreateFecBlocks (const bvec &buffer, WimaxPhy::ModulationType modulationType);
257  bvec RecreateBuffer ();
263  uint32_t GetFecBlockSize (WimaxPhy::ModulationType type) const;
269  uint32_t GetCodedFecBlockSize (WimaxPhy::ModulationType modulationType) const;
275  void SetBlockParameters (uint32_t burstSize, WimaxPhy::ModulationType modulationType);
282  uint16_t GetNrBlocks (uint32_t burstSize, WimaxPhy::ModulationType modulationType) const;
283  void DoDispose (void);
285  void EndSend (void);
291  void EndSendFecBlock (WimaxPhy::ModulationType modulationType, uint8_t direction);
296  void EndReceive (Ptr<const PacketBurst> burst);
305  void EndReceiveFecBlock (uint32_t burstSize,
306  WimaxPhy::ModulationType modulationType,
307  uint8_t direction,
308  uint8_t drop,
309  Ptr<PacketBurst> burst);
316  void StartSendDummyFecBlock (bool isFirstBlock,
317  WimaxPhy::ModulationType modulationType,
318  uint8_t direction);
326  void DoSetDataRates (void);
328  void InitSimpleOfdmWimaxPhy (void);
336  void GetModulationFecParams (WimaxPhy::ModulationType modulationType, uint8_t &bitsPerSymbol, double &fecCode) const;
342  uint32_t CalculateDataRate (WimaxPhy::ModulationType modulationType) const;
348  uint32_t DoGetDataRate (WimaxPhy::ModulationType modulationType) const;
353  uint16_t DoGetTtg (void) const;
358  uint16_t DoGetRtg (void) const;
363  uint8_t DoGetFrameDurationCode (void) const;
369  Time DoGetFrameDuration (uint8_t frameDurationCode) const;
371  void DoSetPhyParameters (void);
376  uint16_t DoGetNfft (void) const;
381  void DoSetNfft (uint16_t nfft);
386  double DoGetSamplingFactor (void) const;
391  double DoGetSamplingFrequency (void) const;
396  double DoGetGValue (void) const;
401  void DoSetGValue (double g);
407  double GetRxGain (void) const;
412  void SetRxGain (double rxgain);
418  double GetTxGain (void) const;
423  void SetTxGain (double txgain);
429  std::string GetTraceFilePath (void) const;
434  void SetTraceFilePath (std::string path);
436  uint16_t m_fecBlockSize;
439  std::list<bvec> *m_receivedFecBlocks;
440  uint32_t m_nrFecBlocksSent;
441  std::list<bvec> *m_fecBlocks;
447  // data rates for this Phy
448  uint32_t m_dataRateBpsk12;
449  uint32_t m_dataRateQpsk12;
450  uint32_t m_dataRateQpsk34;
456  // parameters to store for a per burst life-time
457  uint16_t m_nrBlocks;
460  uint16_t m_blockSize;
461  uint32_t m_paddingBits;
464  uint16_t m_nfft;
465  double m_g;
466  double m_bandWidth;
467  double m_txPower;
468  double m_noiseFigure;
469  double m_txGain;
470  double m_rxGain;
535 };
537 } // namespace ns3
539 #endif /* OFDM_WIMAX_PHY_H */
void SetNoiseFigure(double nf)
set the noise figure of the device
double GetRxGain(void) const
Get receive gain.
WimaxPhy::PhyType GetPhyType(void) const
returns the type this physical layer
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
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
uint16_t m_blockSize
block size
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
void SetSNRToBlockErrorRateTracesPath(char *tracesPath)
Set the path of the repository containing the traces.
TracedCallback< Ptr< PacketBurst > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
uint32_t m_paddingBits
padding bits
Callback template class.
Definition: callback.h:1278
uint32_t GetFecBlockSize(WimaxPhy::ModulationType type) const
Get FEC block size.
void EndReceiveFecBlock(uint32_t burstSize, WimaxPhy::ModulationType modulationType, uint8_t direction, uint8_t drop, Ptr< PacketBurst > burst)
End receive FEC block.
void Send(Ptr< PacketBurst > burst, WimaxPhy::ModulationType modulationType, uint8_t direction)
Sends a burst on the channel.
void NotifyRxDrop(Ptr< PacketBurst > burst)
Public method used to fire a PhyRxDrop trace.
void NotifyRxBegin(Ptr< PacketBurst > burst)
Public method used to fire a PhyRxBegin trace.
TracedCallback< Ptr< const PacketBurst > > m_traceRx
trace receive callback
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
uint32_t m_dataRateQam64_23
data rate
Forward calls to a chain of Callback.
SimpleOfdmWimaxPhy class.
uint16_t GetNrBlocks(uint32_t burstSize, WimaxPhy::ModulationType modulationType) const
Get number of blocks.
void InitSimpleOfdmWimaxPhy(void)
Initialize simple OFDM WIMAX Phy.
uint16_t DoGetNfft(void) const
std::list< bvec > * m_receivedFecBlocks
a list of received FEC blocks until they are combined to recreate the full burst buffer ...
double GetTxGain(void) const
Get transmit gain.
SNRToBlockErrorRateManager * m_snrToBlockErrorRateManager
SNR to block error rate manager.
void NotifyTxDrop(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxDrop trace.
uint16_t m_fecBlockSize
in bits, size of FEC block transmitted after PHY operations
uint32_t CalculateDataRate(WimaxPhy::ModulationType modulationType) const
Calculate data rate.
void NotifyTxBegin(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxBegin trace.
void EndSend(void)
End send.
Time DoGetTransmissionTime(uint32_t size, WimaxPhy::ModulationType modulationType) const
Get transmission time.
void SetTraceFilePath(std::string path)
Set trace file path.
TracedCallback< Ptr< PacketBurst > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet as it tries to transmit it.
uint32_t GetBandwidth(void) const
void DoSetNfft(uint16_t nfft)
void SetBandwidth(uint32_t BW)
Set the bandwidth.
Definition: third.py:92
bvec RecreateBuffer()
Recreate buffer.
uint16_t DoGetRtg(void) const
Get RTG.
void CreateFecBlocks(const bvec &buffer, WimaxPhy::ModulationType modulationType)
Create FEC blocks.
void EndSendFecBlock(WimaxPhy::ModulationType modulationType, uint8_t direction)
End send FEC block.
TracedCallback< Ptr< PacketBurst > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
Ptr< UniformRandomVariable > m_URNG
Provides uniform random variables.
double m_noiseFigure
noise figure
bvec ConvertBurstToBits(Ptr< const PacketBurst > burst)
Convert burst to bits.
void DoSetDataRates(void)
Set data rates.
uint16_t m_nrRecivedFecBlocks
number received FEC blocks
uint32_t m_nrFecBlocksSent
counting the number of FEC blocks sent (within a burst)
The SendParams class defines the parameters with which Send() function of a particular PHY is called...
Definition: send-params.h:43
void GetModulationFecParams(WimaxPhy::ModulationType modulationType, uint8_t &bitsPerSymbol, double &fecCode) const
Get moduleation FEC parameters.
double GetNoiseFigure(void) const
uint32_t m_dataRateQpsk12
data rate
void EndReceive(Ptr< const PacketBurst > burst)
End receive.
void DoSetGValue(double g)
Set G value.
uint8_t DoGetFrameDurationCode(void) const
Get frame duration code.
void SetRxGain(double rxgain)
Set receive gsain.
Time DoGetFrameDuration(uint8_t frameDurationCode) const
Get frame duration.
uint32_t m_dataRateQpsk34
data rate
Ptr< PacketBurst > m_currentBurst
current burst
void NotifyRxEnd(Ptr< PacketBurst > burst)
Public method used to fire a PhyRxEnd trace.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint64_t DoGetNrBytes(uint32_t symbols, WimaxPhy::ModulationType modulationType) const
Get number of bytes.
void StartSendDummyFecBlock(bool isFirstBlock, WimaxPhy::ModulationType modulationType, uint8_t direction)
Start end dummy FEC block.
std::string GetTraceFilePath(void) const
Get trace file path.
static TypeId GetTypeId(void)
Get the type ID.
double DoGetSamplingFrequency(void) const
Get sampling frequency.
void DoDispose(void)
Destructor implementation.
uint32_t m_currentBurstSize
current burst size
uint32_t DoGetDataRate(WimaxPhy::ModulationType modulationType) const
Get data rate.
void DoAttach(Ptr< WimaxChannel > channel)
Attach the physical layer to a channel.
void ActivateLoss(bool loss)
if called with true it will enable the loss model
void SetTxGain(double txgain)
Set transmit gain.
void NotifyTxEnd(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxEnd trace.
uint32_t m_dataRateQam64_34
data rate
TracedCallback< Ptr< PacketBurst > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
void SetTxPower(double txPower)
set the transmission power
ModulationType enumeration.
Definition: wimax-phy.h:49
TracedCallback< Ptr< PacketBurst > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium. ...
Frame duration code enumeration.
double m_txPower
transmit power
uint32_t m_dataRateBpsk12
data rate
PhyType enumeration.
Definition: wimax-phy.h:70
std::vector< bool > bvec
boolean vector typedef
Definition: bvec.h:29
uint16_t m_nbErroneousBlock
erroneous blocks
Ptr< PacketBurst > ConvertBitsToBurst(bvec buffer)
Convert bits to burst.
uint16_t m_nrBlocks
number of blocks
uint32_t GetCodedFecBlockSize(WimaxPhy::ModulationType modulationType) const
Get coded FEC block size.
uint64_t DoGetNrSymbols(uint32_t size, WimaxPhy::ModulationType modulationType) const
Get number of symbols.
Time GetBlockTransmissionTime(WimaxPhy::ModulationType modulationType) const
Get block transmission time.
uint32_t m_dataRateQam16_34
data rate
void SetBlockParameters(uint32_t burstSize, WimaxPhy::ModulationType modulationType)
Set block parameters.
double DoGetGValue(void) const
Get G value.
uint16_t DoGetTtg(void) const
Get TTG.
void SetReceiveCallback(Callback< void, Ptr< PacketBurst >, Ptr< WimaxConnection > > callback)
set the callback function to call when a burst is received
This class handles the SNR to BlcER traces.
void DoSetPhyParameters(void)
Set Phy parameters.
uint32_t m_dataRateQam16_12
data rate
uint16_t m_nrRemainingBlocksToSend
number of remaining blocks to send
a unique identifier for an interface.
Definition: type-id.h:58
double m_rxGain
receive gain
double m_txGain
transmit gain
double DoGetSamplingFactor(void) const
Get sampling factor.
TracedCallback< Ptr< PacketBurst > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
TracedCallback< Ptr< const PacketBurst > > m_traceTx
trace transmit callback
std::list< bvec > * m_fecBlocks
the FEC blocks