A Discrete-Event Network Simulator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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;
47 {
48 public:
50  {
53  };
55  static TypeId GetTypeId (void);
56  SimpleOfdmWimaxPhy (void);
57  SimpleOfdmWimaxPhy (char * tracesPath);
58  ~SimpleOfdmWimaxPhy (void);
63  void ActivateLoss (bool loss);
69  void SetSNRToBlockErrorRateTracesPath (char * tracesPath);
74  void DoAttach (Ptr<WimaxChannel> channel);
85  void Send (Ptr<PacketBurst> burst, WimaxPhy::ModulationType modulationType, uint8_t direction);
90  void Send (SendParams *params);
95  WimaxPhy::PhyType GetPhyType (void) const;
107  void StartReceive (uint32_t burstSize,
108  bool isFirstBlock,
109  uint64_t frequency,
110  WimaxPhy::ModulationType modulationType,
111  uint8_t direction,
112  double rxPower,
113  Ptr<PacketBurst> burst);
118  uint32_t GetBandwidth (void) const;
123  void SetBandwidth (uint32_t BW);
127  double GetTxPower (void) const;
132  void SetTxPower (double txPower);
136  double GetNoiseFigure (void) const;
141  void SetNoiseFigure (double nf);
147  void NotifyTxBegin (Ptr<PacketBurst> burst);
153  void NotifyTxEnd (Ptr<PacketBurst> burst);
159  void NotifyTxDrop (Ptr<PacketBurst> burst);
165  void NotifyRxBegin (Ptr<PacketBurst> burst);
171  void NotifyRxEnd (Ptr<PacketBurst> burst);
177  void NotifyRxDrop (Ptr<PacketBurst> burst);
187  int64_t AssignStreams (int64_t stream);
189 private:
190  Time DoGetTransmissionTime (uint32_t size, WimaxPhy::ModulationType modulationType) const;
191  uint64_t DoGetNrSymbols (uint32_t size, WimaxPhy::ModulationType modulationType) const;
192  uint64_t DoGetNrBytes (uint32_t symbols, WimaxPhy::ModulationType modulationType) const;
195  void CreateFecBlocks (const bvec &buffer, WimaxPhy::ModulationType modulationType);
196  bvec RecreateBuffer ();
197  uint32_t GetFecBlockSize (WimaxPhy::ModulationType type) const;
198  uint32_t GetCodedFecBlockSize (WimaxPhy::ModulationType modulationType) const;
199  void SetBlockParameters (uint32_t burstSize, WimaxPhy::ModulationType modulationType);
200  uint16_t GetNrBlocks (uint32_t burstSize, WimaxPhy::ModulationType modulationType) const;
201  void DoDispose (void);
202  void EndSend (void);
203  void EndSendFecBlock (WimaxPhy::ModulationType modulationType, uint8_t direction);
204  void EndReceive (Ptr<const PacketBurst> burst);
205  void EndReceiveFecBlock (uint32_t burstSize,
206  WimaxPhy::ModulationType modulationType,
207  uint8_t direction,
208  uint8_t drop,
209  Ptr<PacketBurst> burst);
210  void StartSendDummyFecBlock (bool isFirstBlock,
211  WimaxPhy::ModulationType modulationType,
212  uint8_t direction);
214  void DoSetDataRates (void);
215  void InitSimpleOfdmWimaxPhy (void);
217  void GetModulationFecParams (WimaxPhy::ModulationType modulationType, uint8_t &bitsPerSymbol, double &fecCode) const;
218  uint32_t CalculateDataRate (WimaxPhy::ModulationType modulationType) const;
219  uint32_t DoGetDataRate (WimaxPhy::ModulationType modulationType) const;
220  uint16_t DoGetTtg (void) const;
221  uint16_t DoGetRtg (void) const;
222  uint8_t DoGetFrameDurationCode (void) const;
223  Time DoGetFrameDuration (uint8_t frameDurationCode) const;
224  void DoSetPhyParameters (void);
225  uint16_t DoGetNfft (void) const;
226  void DoSetNfft (uint16_t);
227  double DoGetSamplingFactor (void) const;
228  double DoGetSamplingFrequency (void) const;
229  double DoGetGValue (void) const;
230  void DoSetGValue (double);
232  double GetRxGain (void) const;
233  void SetRxGain (double rxgain);
235  double GetTxGain (void) const;
236  void SetTxGain (double txgain);
238  std::string GetTraceFilePath (void) const;
239  void SetTraceFilePath (std::string path);
241  uint16_t m_fecBlockSize; // in bits, size of FEC block transmitted after PHY operations
244  std::list<bvec> *m_receivedFecBlocks; // a list of received FEC blocks until they are combined to recreate the full burst buffer
245  uint32_t m_nrFecBlocksSent; // counting the number of FEC blocks sent (within a burst)
246  std::list<bvec> *m_fecBlocks;
252  // data rates for this Phy
256  // parameters to store for a per burst life-time
257  uint16_t m_nrBlocks;
260  uint16_t m_blockSize;
261  uint32_t m_paddingBits;
264  uint16_t m_nfft;
265  double m_g;
266  double m_bandWidth;
267  double m_txPower;
269  double m_txGain;
270  double m_rxGain;
323 };
325 } // namespace ns3
327 #endif /* OFDM_WIMAX_PHY_H */
void SetNoiseFigure(double nf)
set the noise figure of the device
uint32_t GetCodedFecBlockSize(WimaxPhy::ModulationType modulationType) const
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:79
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
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.
Callback template class.
Definition: callback.h:924
void EndReceiveFecBlock(uint32_t burstSize, WimaxPhy::ModulationType modulationType, uint8_t direction, uint8_t drop, Ptr< PacketBurst > burst)
void Send(Ptr< PacketBurst > burst, WimaxPhy::ModulationType modulationType, uint8_t direction)
Sends a burst on the channel.
double DoGetSamplingFrequency(void) const
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
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
std::list< bvec > * m_receivedFecBlocks
SNRToBlockErrorRateManager * m_snrToBlockErrorRateManager
void NotifyTxDrop(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxDrop trace.
Time DoGetTransmissionTime(uint32_t size, WimaxPhy::ModulationType modulationType) const
uint8_t DoGetFrameDurationCode(void) const
void NotifyTxBegin(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxBegin trace.
uint32_t DoGetDataRate(WimaxPhy::ModulationType modulationType) const
void SetTraceFilePath(std::string path)
double DoGetSamplingFactor(void) const
TracedCallback< Ptr< PacketBurst > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet as it tries to transmit it.
void SetBandwidth(uint32_t BW)
Set the bandwidth.
void CreateFecBlocks(const bvec &buffer, WimaxPhy::ModulationType modulationType)
void EndSendFecBlock(WimaxPhy::ModulationType modulationType, uint8_t direction)
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.
bvec ConvertBurstToBits(Ptr< const PacketBurst > burst)
uint16_t DoGetTtg(void) const
The SendParams class defines the parameters with which Send() function of a particular PHY is called...
Definition: send-params.h:43
Time GetBlockTransmissionTime(WimaxPhy::ModulationType modulationType) const
Time DoGetFrameDuration(uint8_t frameDurationCode) const
void EndReceive(Ptr< const PacketBurst > burst)
uint16_t DoGetNfft(void) const
Ptr< PacketBurst > m_currentBurst
void NotifyRxEnd(Ptr< PacketBurst > burst)
Public method used to fire a PhyRxEnd trace.
void StartSendDummyFecBlock(bool isFirstBlock, WimaxPhy::ModulationType modulationType, uint8_t direction)
static TypeId GetTypeId(void)
double GetTxPower(void) const
void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
double GetNoiseFigure(void) const
uint16_t DoGetRtg(void) const
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
uint64_t DoGetNrBytes(uint32_t symbols, WimaxPhy::ModulationType modulationType) const
uint64_t DoGetNrSymbols(uint32_t size, WimaxPhy::ModulationType modulationType) const
void NotifyTxEnd(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxEnd trace.
uint32_t CalculateDataRate(WimaxPhy::ModulationType modulationType) const
TracedCallback< Ptr< PacketBurst > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
std::string GetTraceFilePath(void) const
void SetTxPower(double txPower)
set the transmission power
TracedCallback< Ptr< PacketBurst > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium. ...
uint16_t GetNrBlocks(uint32_t burstSize, WimaxPhy::ModulationType modulationType) const
uint32_t GetBandwidth(void) const
std::vector< bool > bvec
Definition: bvec.h:28
Ptr< PacketBurst > ConvertBitsToBurst(bvec buffer)
void SetBlockParameters(uint32_t burstSize, WimaxPhy::ModulationType modulationType)
WimaxPhy::PhyType GetPhyType(void) const
returns the type this physical layer
void GetModulationFecParams(WimaxPhy::ModulationType modulationType, uint8_t &bitsPerSymbol, double &fecCode) const
uint32_t GetFecBlockSize(WimaxPhy::ModulationType type) const
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.
a unique identifier for an interface.
Definition: type-id.h:49
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
std::list< bvec > * m_fecBlocks