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 INRIA
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: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
19  */
21 #ifndef WIMAX_PHY_H
22 #define WIMAX_PHY_H
24 #include <stdint.h>
25 #include <list>
26 #include "ns3/callback.h"
27 #include "ns3/nstime.h"
28 #include "ns3/event-id.h"
29 #include "bvec.h"
30 #include "send-params.h"
31 #include "ns3/log.h"
32 #include "ns3/object.h"
33 #include "ns3/traced-callback.h"
35 namespace ns3 {
37 class WimaxChannel;
38 class WimaxNetDevice;
39 class NetDevice;
40 class Packet;
45 class WimaxPhy : public Object
46 {
47 public:
49  enum ModulationType // Table 356 and 362
50  {
58  };
61  enum PhyState
62  {
67  };
70  enum PhyType
71  {
74  };
80  static TypeId GetTypeId (void);
81  WimaxPhy (void);
82  virtual ~WimaxPhy (void);
91  Ptr<WimaxChannel> GetChannel (void) const;
96  void SetDevice (Ptr<WimaxNetDevice> device);
100  Ptr<NetDevice> GetDevice (void) const;
105  void SetReceiveCallback (Callback<void, Ptr<const PacketBurst> > callback);
114  virtual void Send (SendParams *params) = 0;
119  virtual PhyType GetPhyType (void) const = 0;
125  void SetDuplex (uint64_t rxFrequency, uint64_t txFrequency);
130  void SetSimplex (uint64_t frequency);
135  uint64_t GetRxFrequency (void) const;
140  uint64_t GetTxFrequency (void) const;
145  uint64_t GetScanningFrequency (void) const;
151  void SetNrCarriers (uint8_t nrCarriers);
156  uint8_t GetNrCarriers (void) const;
161  void SetFrameDuration (Time frameDuration);
167  Time GetFrameDurationSec (void) const;
172  Time GetFrameDuration (void) const;
177  void SetFrequency (uint32_t frequency);
182  uint32_t GetFrequency (void) const;
187  void SetChannelBandwidth (uint32_t channelBandwidth);
192  uint32_t GetChannelBandwidth (void) const;
197  uint16_t GetNfft (void) const;
202  double GetSamplingFactor (void) const;
207  double GetSamplingFrequency (void) const;
212  void SetPsDuration (Time psDuration);
217  Time GetPsDuration (void) const;
222  void SetSymbolDuration (Time symbolDuration);
227  Time GetSymbolDuration (void) const;
232  double GetGValue (void) const;
237  void SetPsPerSymbol (uint16_t psPerSymbol);
242  uint16_t GetPsPerSymbol (void) const;
248  void SetPsPerFrame (uint16_t psPerFrame);
253  uint16_t GetPsPerFrame (void) const;
258  void SetSymbolsPerFrame (uint32_t symbolsPerFrame);
263  uint32_t GetSymbolsPerFrame (void) const;
268  bool IsDuplex (void) const;
273  void SetState (PhyState state);
278  PhyState GetState (void) const;
285  void StartScanning (uint64_t frequency, Time timeout, Callback<void, bool, uint64_t> callback);
290  void SetScanningCallback (void) const;
295  EventId GetChnlSrchTimeoutEvent (void) const;
299  void SetDataRates (void);
305  uint32_t GetDataRate (ModulationType modulationType) const;
312  Time GetTransmissionTime (uint32_t size, ModulationType modulationType) const;
319  uint64_t GetNrSymbols (uint32_t size, ModulationType modulationType) const;
326  uint64_t GetNrBytes (uint32_t symbols, ModulationType modulationType) const;
331  uint16_t GetTtg (void) const;
336  uint16_t GetRtg (void) const;
341  uint8_t GetFrameDurationCode (void) const;
347  Time GetFrameDuration (uint8_t frameDurationCode) const;
351  void SetPhyParameters (void);
352  virtual void DoDispose (void);
357  virtual Ptr<Object> GetMobility (void);
362  virtual void SetMobility (Ptr<Object> mobility);
372  virtual int64_t AssignStreams (int64_t stream) = 0;
374 private:
381  void GetModulationFecParams (ModulationType modulationType, uint8_t &bitsPerSymbol, double &fecCode) const;
383  void EndScanning (void);
390  virtual Time DoGetTransmissionTime (uint32_t size, ModulationType modulationType) const = 0;
395  virtual void DoAttach (Ptr<WimaxChannel> channel) = 0;
397  virtual void DoSetDataRates (void) = 0;
403  virtual uint32_t DoGetDataRate (ModulationType modulationType) const = 0;
410  virtual uint64_t DoGetNrSymbols (uint32_t size, ModulationType modulationType) const = 0;
417  virtual uint64_t DoGetNrBytes (uint32_t symbols, ModulationType modulationType) const = 0;
422  virtual uint16_t DoGetTtg (void) const = 0;
427  virtual uint16_t DoGetRtg (void) const = 0;
433  virtual uint8_t DoGetFrameDurationCode (void) const = 0;
439  virtual Time DoGetFrameDuration (uint8_t frameDurationCode) const = 0;
443  virtual void DoSetPhyParameters (void) = 0;
448  virtual double DoGetSamplingFactor (void) const = 0;
453  virtual uint16_t DoGetNfft (void) const = 0;
458  virtual double DoGetSamplingFrequency (void) const = 0;
463  virtual double DoGetGValue (void) const = 0;
468  uint64_t m_txFrequency;
469  uint64_t m_rxFrequency;
472  bool m_duplex;
478  uint8_t m_nrCarriers;
480  uint32_t m_frequency;
484  uint16_t m_psPerSymbol;
485  uint16_t m_psPerFrame;
486  uint32_t m_symbolsPerFrame;
488 };
490 } // namespace ns3
492 #endif /* WIMAX_PHY_H */
uint64_t m_rxFrequency
receive frequency
Definition: wimax-phy.h:469
virtual uint16_t DoGetTtg(void) const =0
Get TTG.
uint64_t m_txFrequency
transmit frequency
Definition: wimax-phy.h:468
uint8_t GetFrameDurationCode(void) const
Get the frame duration code.
Definition: wimax-phy.cc:264
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
Callback< void, Ptr< const PacketBurst > > GetReceiveCallback(void) const
Definition: wimax-phy.cc:155
bool m_duplex
Definition: wimax-phy.h:472
Callback template class.
Definition: callback.h:1278
virtual double DoGetSamplingFactor(void) const =0
Get sampling factor.
void SetFrequency(uint32_t frequency)
set the frequency on which the device should lock
Definition: wimax-phy.cc:314
void SetFrameDuration(Time frameDuration)
Set the frame duration.
Definition: wimax-phy.cc:296
uint32_t GetSymbolsPerFrame(void) const
Get the number of symbols per frame.
Definition: wimax-phy.cc:416
virtual void DoAttach(Ptr< WimaxChannel > channel)=0
Attach channel.
virtual void DoDispose(void)
Destructor implementation.
Definition: wimax-phy.cc:99
virtual uint8_t DoGetFrameDurationCode(void) const =0
Get frame duration code.
virtual int64_t AssignStreams(int64_t stream)=0
Assign a fixed random variable stream number to the random variables used by this model...
Definition: wimax-phy.cc:75
EventId GetChnlSrchTimeoutEvent(void) const
Get channel search timeout event.
Definition: wimax-phy.cc:210
Ptr< Object > m_mobility
modility model
Definition: wimax-phy.h:487
Time m_frameDuration
in seconds
Definition: wimax-phy.h:479
Ptr< WimaxChannel > m_channel
Definition: wimax-phy.h:466
void SetSimplex(uint64_t frequency)
configure the physical layer in simplex mode
Definition: wimax-phy.cc:168
virtual Time DoGetTransmissionTime(uint32_t size, ModulationType modulationType) const =0
Get transmission time.
ns3::Time timeout
void SetScanningCallback(void) const
calls the scanning call back function
Definition: wimax-phy.cc:216
void SetSymbolsPerFrame(uint32_t symbolsPerFrame)
set the number of symbols per frame
Definition: wimax-phy.cc:410
void SetPsDuration(Time psDuration)
set the physical slot duration
Definition: wimax-phy.cc:356
uint32_t m_frequency
in KHz
Definition: wimax-phy.h:480
double GetSamplingFactor(void) const
Get the sampling factor.
Definition: wimax-phy.cc:344
uint16_t GetRtg(void) const
Get the receive/transmit transition gap.
Definition: wimax-phy.cc:258
void SetReceiveCallback(Callback< void, Ptr< const PacketBurst > > callback)
set the callback function to call when a burst is received
Definition: wimax-phy.cc:149
uint64_t GetTxFrequency(void) const
Get the transmission frequency.
Definition: wimax-phy.cc:181
Definition: third.py:92
Definition: third.py:108
void EndScanning(void)
End scanning.
Definition: wimax-phy.cc:143
uint64_t GetNrBytes(uint32_t symbols, ModulationType modulationType) const
Get the maximum number of bytes that could be carried by symbols symbols using the modulation modulat...
Definition: wimax-phy.cc:246
virtual uint16_t DoGetRtg(void) const =0
Get RTG.
virtual uint32_t DoGetDataRate(ModulationType modulationType) const =0
Get data rate.
uint32_t GetFrequency(void) const
Get the frequency on which the device is locked.
Definition: wimax-phy.cc:320
Time GetPsDuration(void) const
Get the physical slot duration.
Definition: wimax-phy.cc:362
uint16_t m_psPerFrame
ps per framce
Definition: wimax-phy.h:485
uint16_t GetNfft(void) const
Get the size of the FFT.
Definition: wimax-phy.cc:338
uint16_t m_psPerSymbol
ps per sumbol
Definition: wimax-phy.h:484
uint32_t m_channelBandwidth
in Hz
Definition: wimax-phy.h:481
The SendParams class defines the parameters with which Send() function of a particular PHY is called...
Definition: send-params.h:43
Ptr< NetDevice > GetDevice(void) const
Definition: wimax-phy.cc:125
void SetPsPerSymbol(uint16_t psPerSymbol)
set the number of physical slots per symbol
Definition: wimax-phy.cc:386
uint16_t GetTtg(void) const
Get the transmit/receive transition gap.
Definition: wimax-phy.cc:252
bool IsDuplex(void) const
Check if configured in duplex mode.
Definition: wimax-phy.cc:204
Ptr< WimaxChannel > GetChannel(void) const
Definition: wimax-phy.cc:113
static TypeId GetTypeId(void)
Get the type ID.
Definition: wimax-phy.cc:39
Time GetTransmissionTime(uint32_t size, ModulationType modulationType) const
Get transmission time needed to send bytes at a given modulation.
Definition: wimax-phy.cc:234
virtual uint16_t DoGetNfft(void) const =0
virtual uint64_t DoGetNrBytes(uint32_t symbols, ModulationType modulationType) const =0
Get number of bytes.
Callback< void, bool, uint64_t > m_scanningCallback
scanning callback function
Definition: wimax-phy.h:476
uint16_t GetPsPerFrame(void) const
Get the number of physical slots per frame.
Definition: wimax-phy.cc:404
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t m_nrCarriers
number of carriers
Definition: wimax-phy.h:478
uint64_t GetScanningFrequency(void) const
Get the scanning frequency.
Definition: wimax-phy.cc:187
void SetChannelBandwidth(uint32_t channelBandwidth)
Set the channel bandwidth.
Definition: wimax-phy.cc:326
uint32_t m_symbolsPerFrame
symbols per frame
Definition: wimax-phy.h:486
Time GetFrameDuration(void) const
Get the frame duration.
Definition: wimax-phy.cc:302
Time GetSymbolDuration(void) const
Get the OFDM symbol duration.
Definition: wimax-phy.cc:374
Time m_symbolDuration
in seconds
Definition: wimax-phy.h:483
virtual PhyType GetPhyType(void) const =0
Get the type of the physical layer.
virtual uint64_t DoGetNrSymbols(uint32_t size, ModulationType modulationType) const =0
Get number of symbols.
void StartScanning(uint64_t frequency, Time timeout, Callback< void, bool, uint64_t > callback)
scan a frequency for maximum timeout seconds and call the callback if the frequency can be used ...
Definition: wimax-phy.cc:131
virtual ~WimaxPhy(void)
Definition: wimax-phy.cc:94
uint64_t GetNrSymbols(uint32_t size, ModulationType modulationType) const
Get the number of symbols needed to transmit size bytes using the modulation modulationType.
Definition: wimax-phy.cc:240
Callback< void, Ptr< const PacketBurst > > m_rxCallback
receive callback function
Definition: wimax-phy.h:475
ModulationType enumeration.
Definition: wimax-phy.h:49
Time m_psDuration
in seconds
Definition: wimax-phy.h:482
void Attach(Ptr< WimaxChannel > channel)
Attach the physical layer to a channel.
Definition: wimax-phy.cc:106
uint32_t GetChannelBandwidth(void) const
Get the channel bandwidth.
Definition: wimax-phy.cc:332
void SetSymbolDuration(Time symbolDuration)
set the OFDM symbol duration
Definition: wimax-phy.cc:368
uint16_t GetPsPerSymbol(void) const
Get the number of physical slots per symbol.
Definition: wimax-phy.cc:392
An identifier for simulation events.
Definition: event-id.h:53
virtual Ptr< Object > GetMobility(void)
Get the mobility model of the device.
Definition: wimax-phy.cc:421
PhyType enumeration.
Definition: wimax-phy.h:70
double GetGValue(void) const
Get the guard interval factor (the ratio TG/Td)
Definition: wimax-phy.cc:380
void SetDuplex(uint64_t rxFrequency, uint64_t txFrequency)
configure the physical layer in duplex mode
Definition: wimax-phy.cc:161
PhyState m_state
Definition: wimax-phy.h:473
void SetDevice(Ptr< WimaxNetDevice > device)
Set the device in which this physical layer is installed.
Definition: wimax-phy.cc:119
void SetState(PhyState state)
set the state of the device
Definition: wimax-phy.cc:193
void SetDataRates(void)
calculates the data rate of each modulation and save them for future use
Definition: wimax-phy.cc:222
Time GetFrameDurationSec(void) const
Get the frame duration This method is redundant with GetFrameDuration ()
Definition: wimax-phy.cc:308
uint64_t GetRxFrequency(void) const
Get the reception frequency.
Definition: wimax-phy.cc:175
void SetNrCarriers(uint8_t nrCarriers)
Set the number of carriers in the physical frame.
Definition: wimax-phy.cc:284
Ptr< WimaxNetDevice > m_device
the device
Definition: wimax-phy.h:465
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual void DoSetDataRates(void)=0
Set data rates.
void SetPsPerFrame(uint16_t psPerFrame)
set the number of physical slots per frame
Definition: wimax-phy.cc:398
PhyState GetState(void) const
Get the state of the device.
Definition: wimax-phy.cc:198
double GetSamplingFrequency(void) const
Get the sampling frequency.
Definition: wimax-phy.cc:350
virtual double DoGetGValue(void) const =0
Get G value.
void SetPhyParameters(void)
computes the Physical parameters and store them
Definition: wimax-phy.cc:278
virtual void Send(SendParams *params)=0
send a packet on the channel
virtual double DoGetSamplingFrequency(void) const =0
Get sampling frequency.
a unique identifier for an interface.
Definition: type-id.h:58
PhyState enumeration.
Definition: wimax-phy.h:61
EventId m_dlChnlSrchTimeoutEvent
DL channel search timeout event.
Definition: wimax-phy.h:471
uint8_t GetNrCarriers(void) const
Get the number of carriers in the physical frame.
Definition: wimax-phy.cc:290
void GetModulationFecParams(ModulationType modulationType, uint8_t &bitsPerSymbol, double &fecCode) const
Get modulation FEC parameters.
virtual void SetMobility(Ptr< Object > mobility)
set the mobility model of the device
Definition: wimax-phy.cc:427
virtual void DoSetPhyParameters(void)=0
Set phy parameters.
virtual Time DoGetFrameDuration(uint8_t frameDurationCode) const =0
Get frame duration.
uint32_t GetDataRate(ModulationType modulationType) const
Get the data rate corresponding to a modulation type.
Definition: wimax-phy.cc:228
uint64_t m_scanningFrequency
scanning frequency
Definition: wimax-phy.h:470