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 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:
48  enum ModulationType // Table 356 and 362
49  {
52  };
54  enum PhyState
55  {
57  };
59  enum PhyType
60  {
62  };
64  static TypeId GetTypeId (void);
65  WimaxPhy (void);
66  virtual ~WimaxPhy (void);
71  void Attach (Ptr<WimaxChannel> channel);
75  Ptr<WimaxChannel> GetChannel (void) const;
80  void SetDevice (Ptr<WimaxNetDevice> device);
84  Ptr<NetDevice> GetDevice (void) const;
89  void SetReceiveCallback (Callback<void, Ptr<const PacketBurst> > callback);
98  virtual void Send (SendParams *params) = 0;
102  virtual PhyType GetPhyType (void) const = 0;
108  void SetDuplex (uint64_t rxFrequency, uint64_t txFrequency);
113  void SetSimplex (uint64_t frequency);
117  uint64_t GetRxFrequency (void) const;
121  uint64_t GetTxFrequency (void) const;
125  uint64_t GetScanningFrequency (void) const;
131  void SetNrCarriers (uint8_t nrCarriers);
135  uint8_t GetNrCarriers (void) const;
140  void SetFrameDuration (Time frameDuration);
144  Time GetFrameDurationSec (void) const;
148  Time GetFrameDuration (void) const;
153  void SetFrequency (uint32_t frequency);
157  uint32_t GetFrequency (void) const;
162  void SetChannelBandwidth (uint32_t channelBandwidth);
166  uint32_t GetChannelBandwidth (void) const;
170  uint16_t GetNfft (void) const;
174  double GetSamplingFactor (void) const;
178  double GetSamplingFrequency (void) const;
183  void SetPsDuration (Time psDuration);
187  Time GetPsDuration (void) const;
192  void SetSymbolDuration (Time symbolDuration);
196  Time GetSymbolDuration (void) const;
200  double GetGValue (void) const;
205  void SetPsPerSymbol (uint16_t psPerSymbol);
209  uint16_t GetPsPerSymbol (void) const;
215  void SetPsPerFrame (uint16_t psPerFrame);
219  uint16_t GetPsPerFrame (void) const;
224  void SetSymbolsPerFrame (uint32_t symbolsPerFrame);
228  uint32_t GetSymbolsPerFrame (void) const;
232  bool IsDuplex (void) const;
237  void SetState (PhyState state);
241  PhyState GetState (void) const;
248  void StartScanning (uint64_t frequency, Time timeout, Callback<void, bool, uint64_t> callback);
253  void SetScanningCallback (void) const;
254  EventId GetChnlSrchTimeoutEvent (void) const;
259  void SetDataRates (void);
264  uint32_t GetDataRate (ModulationType modulationType) const;
270  Time GetTransmissionTime (uint32_t size, ModulationType modulationType) const;
276  uint64_t GetNrSymbols (uint32_t size, ModulationType modulationType) const;
282  uint64_t GetNrBytes (uint32_t symbols, ModulationType modulationType) const;
286  uint16_t GetTtg (void) const;
290  uint16_t GetRtg (void) const;
291  uint8_t GetFrameDurationCode (void) const;
292  Time GetFrameDuration (uint8_t frameDurationCode) const;
296  void SetPhyParameters (void);
297  virtual void DoDispose (void);
301  virtual Ptr<Object> GetMobility (void);
306  virtual void SetMobility (Ptr<Object> mobility);
316  virtual int64_t AssignStreams (int64_t stream) = 0;
318 private:
319  void GetModulationFecParams (ModulationType modulationType, uint8_t &bitsPerSymbol, double &fecCode) const;
320  void EndScanning (void);
321  virtual Time DoGetTransmissionTime (uint32_t size, ModulationType modulationType) const = 0;
322  virtual void DoAttach (Ptr<WimaxChannel> channel) = 0;
323  virtual void DoSetDataRates (void) = 0;
324  virtual uint32_t DoGetDataRate (ModulationType modulationType) const = 0;
325  virtual uint64_t DoGetNrSymbols (uint32_t size, ModulationType modulationType) const = 0;
326  virtual uint64_t DoGetNrBytes (uint32_t symbols, ModulationType modulationType) const = 0;
327  virtual uint16_t DoGetTtg (void) const = 0;
328  virtual uint16_t DoGetRtg (void) const = 0;
330  virtual uint8_t DoGetFrameDurationCode (void) const = 0;
331  virtual Time DoGetFrameDuration (uint8_t frameDurationCode) const = 0;
332  virtual void DoSetPhyParameters (void) = 0;
333  virtual double DoGetSamplingFactor (void) const = 0;
334  virtual uint16_t DoGetNfft (void) const = 0;
335  virtual double DoGetSamplingFrequency (void) const = 0;
336  virtual double DoGetGValue (void) const = 0;
341  uint64_t m_txFrequency;
342  uint64_t m_rxFrequency;
345  bool m_duplex;
351  uint8_t m_nrCarriers;
352  Time m_frameDuration; // in seconds
353  uint32_t m_frequency; // in KHz
354  uint32_t m_channelBandwidth; // in Hz
355  Time m_psDuration; // in seconds
356  Time m_symbolDuration; // in seconds
357  uint16_t m_psPerSymbol;
358  uint16_t m_psPerFrame;
361 };
363 } // namespace ns3
365 #endif /* WIMAX_PHY_H */
Time GetPsDuration(void) const
Definition: wimax-phy.cc:358
uint64_t m_rxFrequency
Definition: wimax-phy.h:342
virtual uint16_t DoGetTtg(void) const =0
uint64_t m_txFrequency
Definition: wimax-phy.h:341
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
Callback< void, Ptr< const PacketBurst > > GetReceiveCallback(void) const
Definition: wimax-phy.cc:151
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
Callback template class.
Definition: callback.h:924
virtual double DoGetSamplingFactor(void) const =0
void SetFrequency(uint32_t frequency)
set the frequency on which the device should lock
Definition: wimax-phy.cc:310
void SetFrameDuration(Time frameDuration)
Set the frame duration.
Definition: wimax-phy.cc:292
virtual void DoAttach(Ptr< WimaxChannel > channel)=0
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: wimax-phy.cc:95
virtual uint8_t DoGetFrameDurationCode(void) const =0
virtual int64_t AssignStreams(int64_t stream)=0
Assign a fixed random variable stream number to the random variables used by this model...
bool IsDuplex(void) const
Definition: wimax-phy.cc:200
Definition: wimax-phy.cc:71
uint32_t GetChannelBandwidth(void) const
Definition: wimax-phy.cc:328
uint32_t GetSymbolsPerFrame(void) const
Definition: wimax-phy.cc:412
void GetModulationFecParams(ModulationType modulationType, uint8_t &bitsPerSymbol, double &fecCode) const
Ptr< Object > m_mobility
Definition: wimax-phy.h:360
Time m_frameDuration
Definition: wimax-phy.h:352
Ptr< WimaxChannel > m_channel
Definition: wimax-phy.h:339
void SetSimplex(uint64_t frequency)
configure the physical layer in simplex mode
Definition: wimax-phy.cc:164
uint64_t GetRxFrequency(void) const
Definition: wimax-phy.cc:171
double GetSamplingFactor(void) const
Definition: wimax-phy.cc:340
Time GetSymbolDuration(void) const
Definition: wimax-phy.cc:370
virtual Time DoGetTransmissionTime(uint32_t size, ModulationType modulationType) const =0
ns3::Time timeout
void SetSymbolsPerFrame(uint32_t symbolsPerFrame)
set the number of symbols per frame
Definition: wimax-phy.cc:406
void SetPsDuration(Time psDuration)
set the physical slot duration in seconds
Definition: wimax-phy.cc:352
uint32_t m_frequency
Definition: wimax-phy.h:353
Time GetFrameDuration(void) const
Definition: wimax-phy.cc:298
void SetReceiveCallback(Callback< void, Ptr< const PacketBurst > > callback)
set the callback function to call when a burst is received
Definition: wimax-phy.cc:145
Time GetTransmissionTime(uint32_t size, ModulationType modulationType) const
Definition: wimax-phy.cc:230
void EndScanning(void)
Definition: wimax-phy.cc:139
virtual uint16_t DoGetRtg(void) const =0
virtual uint32_t DoGetDataRate(ModulationType modulationType) const =0
uint16_t m_psPerFrame
Definition: wimax-phy.h:358
uint16_t GetTtg(void) const
Definition: wimax-phy.cc:248
uint16_t m_psPerSymbol
Definition: wimax-phy.h:357
uint32_t m_channelBandwidth
Definition: wimax-phy.h:354
The SendParams class defines the parameters with which Send() function of a particular PHY is called...
Definition: send-params.h:43
void SetScanningCallback(void) const
calls the scanning call back function
Definition: wimax-phy.cc:212
uint16_t GetNfft(void) const
Definition: wimax-phy.cc:334
void SetPsPerSymbol(uint16_t psPerSymbol)
set the number of physical slots per symbol
Definition: wimax-phy.cc:382
uint64_t GetNrSymbols(uint32_t size, ModulationType modulationType) const
Definition: wimax-phy.cc:236
static TypeId GetTypeId(void)
Definition: wimax-phy.cc:39
Ptr< WimaxChannel > GetChannel(void) const
Definition: wimax-phy.cc:109
virtual uint16_t DoGetNfft(void) const =0
virtual uint64_t DoGetNrBytes(uint32_t symbols, ModulationType modulationType) const =0
Time GetFrameDurationSec(void) const
Definition: wimax-phy.cc:304
uint8_t GetNrCarriers(void) const
Definition: wimax-phy.cc:286
Callback< void, bool, uint64_t > m_scanningCallback
Definition: wimax-phy.h:349
double GetGValue(void) const
Definition: wimax-phy.cc:376
uint8_t m_nrCarriers
Definition: wimax-phy.h:351
void SetChannelBandwidth(uint32_t channelBandwidth)
Set the channel bandwidth.
Definition: wimax-phy.cc:322
uint32_t m_symbolsPerFrame
Definition: wimax-phy.h:359
uint64_t GetNrBytes(uint32_t symbols, ModulationType modulationType) const
Definition: wimax-phy.cc:242
uint16_t GetPsPerSymbol(void) const
Definition: wimax-phy.cc:388
Time m_symbolDuration
Definition: wimax-phy.h:356
virtual PhyType GetPhyType(void) const =0
Get the type of the physical layer.
virtual uint64_t DoGetNrSymbols(uint32_t size, ModulationType modulationType) const =0
void StartScanning(uint64_t frequency, Time timeout, Callback< void, bool, uint64_t > callback)
scan the frequency frequency for maximum timeout seconds and calls callback if the frequency could be...
Definition: wimax-phy.cc:127
virtual ~WimaxPhy(void)
Definition: wimax-phy.cc:90
Ptr< NetDevice > GetDevice(void) const
Definition: wimax-phy.cc:121
Callback< void, Ptr< const PacketBurst > > m_rxCallback
Definition: wimax-phy.h:348
Time m_psDuration
Definition: wimax-phy.h:355
void Attach(Ptr< WimaxChannel > channel)
Attach the physical layer to a channel.
Definition: wimax-phy.cc:102
void SetSymbolDuration(Time symbolDuration)
set the OFMD symbol duration in second
Definition: wimax-phy.cc:364
uint16_t GetPsPerFrame(void) const
Definition: wimax-phy.cc:400
uint8_t GetFrameDurationCode(void) const
Definition: wimax-phy.cc:260
an identifier for simulation events.
Definition: event-id.h:46
virtual Ptr< Object > GetMobility(void)
Definition: wimax-phy.cc:417
void SetDuplex(uint64_t rxFrequency, uint64_t txFrequency)
configure the physical layer in duplex mode
Definition: wimax-phy.cc:157
PhyState m_state
Definition: wimax-phy.h:346
void SetDevice(Ptr< WimaxNetDevice > device)
Set the device in which this physical layer is installed.
Definition: wimax-phy.cc:115
void SetState(PhyState state)
set the state of the device
Definition: wimax-phy.cc:189
uint16_t GetRtg(void) const
Definition: wimax-phy.cc:254
void SetDataRates(void)
calculates the data rate of each modulation and save them for future use
Definition: wimax-phy.cc:218
uint32_t GetDataRate(ModulationType modulationType) const
Definition: wimax-phy.cc:224
void SetNrCarriers(uint8_t nrCarriers)
Set the number of carriers in the physical frame.
Definition: wimax-phy.cc:280
Ptr< WimaxNetDevice > m_device
Definition: wimax-phy.h:338
double GetSamplingFrequency(void) const
Definition: wimax-phy.cc:346
uint64_t GetTxFrequency(void) const
Definition: wimax-phy.cc:177
a base class which provides memory management and object aggregation
Definition: object.h:64
virtual void DoSetDataRates(void)=0
EventId GetChnlSrchTimeoutEvent(void) const
Definition: wimax-phy.cc:206
void SetPsPerFrame(uint16_t psPerFrame)
set the number of physical slot per frame
Definition: wimax-phy.cc:394
uint32_t GetFrequency(void) const
Definition: wimax-phy.cc:316
virtual double DoGetGValue(void) const =0
void SetPhyParameters(void)
computes the Physical parameters and store them
Definition: wimax-phy.cc:274
virtual void Send(SendParams *params)=0
send a packet on the channel
virtual double DoGetSamplingFrequency(void) const =0
a unique identifier for an interface.
Definition: type-id.h:49
EventId m_dlChnlSrchTimeoutEvent
Definition: wimax-phy.h:344
virtual void SetMobility(Ptr< Object > mobility)
set the mobility model of the device
Definition: wimax-phy.cc:423
PhyState GetState(void) const
Definition: wimax-phy.cc:194
uint64_t GetScanningFrequency(void) const
Definition: wimax-phy.cc:183
virtual void DoSetPhyParameters(void)=0
virtual Time DoGetFrameDuration(uint8_t frameDurationCode) const =0
uint64_t m_scanningFrequency
Definition: wimax-phy.h:343