A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
simple-ofdm-wimax-phy.h
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
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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  */
21 
22 #ifndef SIMPLE_OFDM_WIMAX_PHY_H
23 #define SIMPLE_OFDM_WIMAX_PHY_H
24 
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 {
36 
37 class WimaxChannel;
38 class WimaxNetDevice;
39 class NetDevice;
40 class Packet;
41 class SimpleOfdmWimaxChannel;
42 
47 {
48 public:
49  enum FrameDurationCode
50  {
51  FRAME_DURATION_2_POINT_5_MS, FRAME_DURATION_4_MS, FRAME_DURATION_5_MS, FRAME_DURATION_8_MS, FRAME_DURATION_10_MS,
52  FRAME_DURATION_12_POINT_5_MS, FRAME_DURATION_20_MS
53  };
54 
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);
114 
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);
142 
147  void NotifyTxBegin (Ptr<PacketBurst> burst);
148 
153  void NotifyTxEnd (Ptr<PacketBurst> burst);
154 
159  void NotifyTxDrop (Ptr<PacketBurst> burst);
160 
165  void NotifyRxBegin (Ptr<PacketBurst> burst);
166 
171  void NotifyRxEnd (Ptr<PacketBurst> burst);
172 
177  void NotifyRxDrop (Ptr<PacketBurst> burst);
178 
187  int64_t AssignStreams (int64_t stream);
188 
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;
193  bvec ConvertBurstToBits (Ptr<const PacketBurst> burst);
194  Ptr<PacketBurst> ConvertBitsToBurst (bvec buffer);
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);
213  Time GetBlockTransmissionTime (WimaxPhy::ModulationType modulationType) const;
214  void DoSetDataRates (void);
215  void InitSimpleOfdmWimaxPhy (void);
216 
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);
231 
232  double GetRxGain (void) const;
233  void SetRxGain (double rxgain);
234 
235  double GetTxGain (void) const;
236  void SetTxGain (double txgain);
237 
238  std::string GetTraceFilePath (void) const;
239  void SetTraceFilePath (std::string path);
240 
241  uint16_t m_fecBlockSize; // in bits, size of FEC block transmitted after PHY operations
242  uint32_t m_currentBurstSize;
243 
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;
247  Time m_blockTime;
248 
251 
252  // data rates for this Phy
253  uint32_t m_dataRateBpsk12, m_dataRateQpsk12, m_dataRateQpsk34, m_dataRateQam16_12, m_dataRateQam16_34,
254  m_dataRateQam64_23, m_dataRateQam64_34;
255 
256  // parameters to store for a per burst life-time
257  uint16_t m_nrBlocks;
258  uint16_t m_nrRemainingBlocksToSend;
259  Ptr<PacketBurst> m_currentBurst;
260  uint16_t m_blockSize;
261  uint32_t m_paddingBits;
262  uint16_t m_nbErroneousBlock;
263  uint16_t m_nrRecivedFecBlocks;
264  uint16_t m_nfft;
265  double m_g;
266  double m_bandWidth;
267  double m_txPower;
268  double m_noiseFigure;
269  double m_txGain;
270  double m_rxGain;
278 
286 
294 
302 
310 
317 
318  SNRToBlockErrorRateManager * m_snrToBlockErrorRateManager;
319 
322 
323 };
324 
325 } // namespace ns3
326 
327 #endif /* OFDM_WIMAX_PHY_H */
void SetNoiseFigure(double nf)
set the noise figure of the device
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
keep track of time unit.
Definition: nstime.h:149
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
void SetSNRToBlockErrorRateTracesPath(char *tracesPath)
Set the path of the repository containing the traces.
TracedCallback< Ptr< PacketBurst > > m_phyRxEndTrace
Callback template class.
Definition: callback.h:369
void Send(Ptr< PacketBurst > burst, WimaxPhy::ModulationType modulationType, uint8_t direction)
Sends a burst on the channel.
void NotifyRxDrop(Ptr< PacketBurst > burst)
void NotifyRxBegin(Ptr< PacketBurst > burst)
int64_t AssignStreams(int64_t stream)
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
void NotifyTxDrop(Ptr< PacketBurst > burst)
void NotifyTxBegin(Ptr< PacketBurst > burst)
TracedCallback< Ptr< PacketBurst > > m_phyTxDropTrace
void SetBandwidth(uint32_t BW)
Set the bandwidth.
TracedCallback< Ptr< PacketBurst > > m_phyTxBeginTrace
Ptr< UniformRandomVariable > m_URNG
Provides uniform random variables.
The SendParams class defines the parameters with which Send() function of a particular PHY is called...
Definition: send-params.h:43
void NotifyRxEnd(Ptr< PacketBurst > burst)
double GetTxPower(void) const
double GetNoiseFigure(void) const
void DoAttach(Ptr< WimaxChannel > channel)
void ActivateLoss(bool loss)
if called with true it will enable the loss model
void NotifyTxEnd(Ptr< PacketBurst > burst)
TracedCallback< Ptr< PacketBurst > > m_phyRxBeginTrace
void SetTxPower(double txPower)
set the transmission power
TracedCallback< Ptr< PacketBurst > > m_phyTxEndTrace
uint32_t GetBandwidth(void) const
WimaxPhy::PhyType GetPhyType(void) const
returns the type this physical layer
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 path to a repository containing trace files should be p...
a unique identifier for an interface.
Definition: type-id.h:44
TracedCallback< Ptr< PacketBurst > > m_phyRxDropTrace