A Discrete-Event Network Simulator
API
wimax-phy.h
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
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: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
19 */
20
21#ifndef WIMAX_PHY_H
22#define WIMAX_PHY_H
23
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"
34
35namespace ns3 {
36
37class WimaxChannel;
38class WimaxNetDevice;
39class NetDevice;
40class Packet;
41
47class WimaxPhy : public Object
48{
49public:
51 enum ModulationType // Table 356 and 362
52 {
60 };
61
64 {
69 };
70
73 {
76 };
77
82 static TypeId GetTypeId (void);
83 WimaxPhy (void);
84 virtual ~WimaxPhy (void);
93 Ptr<WimaxChannel> GetChannel (void) const;
98 void SetDevice (Ptr<WimaxNetDevice> device);
102 Ptr<NetDevice> GetDevice (void) const;
107 void SetReceiveCallback (Callback<void, Ptr<const PacketBurst> > callback);
116 virtual void Send (SendParams *params) = 0;
121 virtual PhyType GetPhyType (void) const = 0;
127 void SetDuplex (uint64_t rxFrequency, uint64_t txFrequency);
132 void SetSimplex (uint64_t frequency);
137 uint64_t GetRxFrequency (void) const;
142 uint64_t GetTxFrequency (void) const;
147 uint64_t GetScanningFrequency (void) const;
153 void SetNrCarriers (uint8_t nrCarriers);
158 uint8_t GetNrCarriers (void) const;
163 void SetFrameDuration (Time frameDuration);
169 Time GetFrameDurationSec (void) const;
174 Time GetFrameDuration (void) const;
179 void SetFrequency (uint32_t frequency);
184 uint32_t GetFrequency (void) const;
189 void SetChannelBandwidth (uint32_t channelBandwidth);
194 uint32_t GetChannelBandwidth (void) const;
199 uint16_t GetNfft (void) const;
204 double GetSamplingFactor (void) const;
209 double GetSamplingFrequency (void) const;
214 void SetPsDuration (Time psDuration);
219 Time GetPsDuration (void) const;
224 void SetSymbolDuration (Time symbolDuration);
229 Time GetSymbolDuration (void) const;
234 double GetGValue (void) const;
239 void SetPsPerSymbol (uint16_t psPerSymbol);
244 uint16_t GetPsPerSymbol (void) const;
245
250 void SetPsPerFrame (uint16_t psPerFrame);
255 uint16_t GetPsPerFrame (void) const;
260 void SetSymbolsPerFrame (uint32_t symbolsPerFrame);
265 uint32_t GetSymbolsPerFrame (void) const;
270 bool IsDuplex (void) const;
275 void SetState (PhyState state);
280 PhyState GetState (void) const;
287 void StartScanning (uint64_t frequency, Time timeout, Callback<void, bool, uint64_t> callback);
288
292 void SetScanningCallback (void) const;
297 EventId GetChnlSrchTimeoutEvent (void) const;
301 void SetDataRates (void);
307 uint32_t GetDataRate (ModulationType modulationType) const;
314 Time GetTransmissionTime (uint32_t size, ModulationType modulationType) const;
321 uint64_t GetNrSymbols (uint32_t size, ModulationType modulationType) const;
328 uint64_t GetNrBytes (uint32_t symbols, ModulationType modulationType) const;
333 uint16_t GetTtg (void) const;
338 uint16_t GetRtg (void) const;
343 uint8_t GetFrameDurationCode (void) const;
349 Time GetFrameDuration (uint8_t frameDurationCode) const;
353 void SetPhyParameters (void);
354 virtual void DoDispose (void);
359 virtual Ptr<Object> GetMobility (void);
364 virtual void SetMobility (Ptr<Object> mobility);
365
374 virtual int64_t AssignStreams (int64_t stream) = 0;
375
376private:
383 void GetModulationFecParams (ModulationType modulationType, uint8_t &bitsPerSymbol, double &fecCode) const;
385 void EndScanning (void);
392 virtual Time DoGetTransmissionTime (uint32_t size, ModulationType modulationType) const = 0;
399 virtual void DoSetDataRates (void) = 0;
405 virtual uint32_t DoGetDataRate (ModulationType modulationType) const = 0;
412 virtual uint64_t DoGetNrSymbols (uint32_t size, ModulationType modulationType) const = 0;
419 virtual uint64_t DoGetNrBytes (uint32_t symbols, ModulationType modulationType) const = 0;
424 virtual uint16_t DoGetTtg (void) const = 0;
429 virtual uint16_t DoGetRtg (void) const = 0;
430
435 virtual uint8_t DoGetFrameDurationCode (void) const = 0;
441 virtual Time DoGetFrameDuration (uint8_t frameDurationCode) const = 0;
445 virtual void DoSetPhyParameters (void) = 0;
450 virtual double DoGetSamplingFactor (void) const = 0;
455 virtual uint16_t DoGetNfft (void) const = 0;
460 virtual double DoGetSamplingFrequency (void) const = 0;
465 virtual double DoGetGValue (void) const = 0;
466
469
470 uint64_t m_txFrequency;
471 uint64_t m_rxFrequency;
474 bool m_duplex;
476
479
480 uint8_t m_nrCarriers;
486 uint16_t m_psPerSymbol;
487 uint16_t m_psPerFrame;
490};
491
492} // namespace ns3
493
494#endif /* WIMAX_PHY_H */
Callback template class.
Definition: callback.h:1279
An identifier for simulation events.
Definition: event-id.h:54
A base class which provides memory management and object aggregation.
Definition: object.h:88
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
The SendParams class defines the parameters with which Send() function of a particular PHY is called.
Definition: send-params.h:44
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
a unique identifier for an interface.
Definition: type-id.h:59
WiMAX PHY entity.
Definition: wimax-phy.h:48
Time GetTransmissionTime(uint32_t size, ModulationType modulationType) const
Get transmission time needed to send bytes at a given modulation.
Definition: wimax-phy.cc:234
uint8_t GetNrCarriers(void) const
Get the number of carriers in the physical frame.
Definition: wimax-phy.cc:290
double GetGValue(void) const
Get the guard interval factor (the ratio TG/Td)
Definition: wimax-phy.cc:380
ModulationType
ModulationType enumeration.
Definition: wimax-phy.h:52
@ MODULATION_TYPE_QPSK_12
Definition: wimax-phy.h:54
@ MODULATION_TYPE_QAM16_12
Definition: wimax-phy.h:56
@ MODULATION_TYPE_QAM64_34
Definition: wimax-phy.h:59
@ MODULATION_TYPE_QAM16_34
Definition: wimax-phy.h:57
@ MODULATION_TYPE_QAM64_23
Definition: wimax-phy.h:58
@ MODULATION_TYPE_QPSK_34
Definition: wimax-phy.h:55
@ MODULATION_TYPE_BPSK_12
Definition: wimax-phy.h:53
bool m_duplex
duplex
Definition: wimax-phy.h:474
void SetSymbolDuration(Time symbolDuration)
set the OFDM symbol duration
Definition: wimax-phy.cc:368
virtual void SetMobility(Ptr< Object > mobility)
set the mobility model of the device
Definition: wimax-phy.cc:427
void EndScanning(void)
End scanning.
Definition: wimax-phy.cc:143
void SetChannelBandwidth(uint32_t channelBandwidth)
Set the channel bandwidth.
Definition: wimax-phy.cc:326
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 int64_t AssignStreams(int64_t stream)=0
Assign a fixed random variable stream number to the random variables used by this model.
uint64_t m_txFrequency
transmit frequency
Definition: wimax-phy.h:470
Time GetSymbolDuration(void) const
Get the OFDM symbol duration.
Definition: wimax-phy.cc:374
void SetDuplex(uint64_t rxFrequency, uint64_t txFrequency)
configure the physical layer in duplex mode
Definition: wimax-phy.cc:161
EventId m_dlChnlSrchTimeoutEvent
DL channel search timeout event.
Definition: wimax-phy.h:473
Time GetPsDuration(void) const
Get the physical slot duration.
Definition: wimax-phy.cc:362
double GetSamplingFrequency(void) const
Get the sampling frequency.
Definition: wimax-phy.cc:350
Ptr< Object > m_mobility
modility model
Definition: wimax-phy.h:489
PhyType
PhyType enumeration.
Definition: wimax-phy.h:73
@ simpleOfdmWimaxPhy
Definition: wimax-phy.h:75
uint32_t m_channelBandwidth
in Hz
Definition: wimax-phy.h:483
Time m_psDuration
in seconds
Definition: wimax-phy.h:484
void Attach(Ptr< WimaxChannel > channel)
Attach the physical layer to a channel.
Definition: wimax-phy.cc:106
uint16_t m_psPerFrame
ps per framce
Definition: wimax-phy.h:487
Time GetFrameDurationSec(void) const
Get the frame duration This method is redundant with GetFrameDuration ()
Definition: wimax-phy.cc:308
virtual uint16_t DoGetTtg(void) const =0
Get TTG.
void SetFrequency(uint32_t frequency)
set the frequency on which the device should lock
Definition: wimax-phy.cc:314
uint32_t m_symbolsPerFrame
symbols per frame
Definition: wimax-phy.h:488
virtual Ptr< Object > GetMobility(void)
Get the mobility model of the device.
Definition: wimax-phy.cc:421
void SetDevice(Ptr< WimaxNetDevice > device)
Set the device in which this physical layer is installed.
Definition: wimax-phy.cc:119
uint32_t GetFrequency(void) const
Get the frequency on which the device is locked.
Definition: wimax-phy.cc:320
static TypeId GetTypeId(void)
Get the type ID.
Definition: wimax-phy.cc:39
uint64_t m_rxFrequency
receive frequency
Definition: wimax-phy.h:471
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
void SetReceiveCallback(Callback< void, Ptr< const PacketBurst > > callback)
set the callback function to call when a burst is received
Definition: wimax-phy.cc:149
virtual void DoAttach(Ptr< WimaxChannel > channel)=0
Attach channel.
virtual void Send(SendParams *params)=0
send a packet on the channel
virtual ~WimaxPhy(void)
Definition: wimax-phy.cc:94
virtual void DoDispose(void)
Destructor implementation.
Definition: wimax-phy.cc:99
void SetSymbolsPerFrame(uint32_t symbolsPerFrame)
set the number of symbols per frame
Definition: wimax-phy.cc:410
Ptr< WimaxNetDevice > m_device
the device
Definition: wimax-phy.h:467
Time GetFrameDuration(void) const
Get the frame duration.
Definition: wimax-phy.cc:302
virtual uint64_t DoGetNrSymbols(uint32_t size, ModulationType modulationType) const =0
Get number of symbols.
virtual uint64_t DoGetNrBytes(uint32_t symbols, ModulationType modulationType) const =0
Get number of bytes.
void SetNrCarriers(uint8_t nrCarriers)
Set the number of carriers in the physical frame.
Definition: wimax-phy.cc:284
uint16_t GetNfft(void) const
Get the size of the FFT.
Definition: wimax-phy.cc:338
Ptr< WimaxChannel > m_channel
channel
Definition: wimax-phy.h:468
virtual void DoSetDataRates(void)=0
Set data rates.
uint16_t GetPsPerFrame(void) const
Get the number of physical slots per frame.
Definition: wimax-phy.cc:404
Ptr< WimaxChannel > GetChannel(void) const
Definition: wimax-phy.cc:113
uint64_t m_scanningFrequency
scanning frequency
Definition: wimax-phy.h:472
void SetDataRates(void)
calculates the data rate of each modulation and save them for future use
Definition: wimax-phy.cc:222
virtual uint16_t DoGetRtg(void) const =0
Get RTG.
virtual double DoGetSamplingFactor(void) const =0
Get sampling factor.
void SetPhyParameters(void)
computes the Physical parameters and store them
Definition: wimax-phy.cc:278
uint32_t GetChannelBandwidth(void) const
Get the channel bandwidth.
Definition: wimax-phy.cc:332
void SetPsPerFrame(uint16_t psPerFrame)
set the number of physical slots per frame
Definition: wimax-phy.cc:398
PhyState
PhyState enumeration.
Definition: wimax-phy.h:64
@ PHY_STATE_SCANNING
Definition: wimax-phy.h:66
virtual double DoGetSamplingFrequency(void) const =0
Get sampling frequency.
uint64_t GetTxFrequency(void) const
Get the transmission frequency.
Definition: wimax-phy.cc:181
uint32_t GetDataRate(ModulationType modulationType) const
Get the data rate corresponding to a modulation type.
Definition: wimax-phy.cc:228
virtual Time DoGetTransmissionTime(uint32_t size, ModulationType modulationType) const =0
Get transmission time.
uint32_t m_frequency
in KHz
Definition: wimax-phy.h:482
Callback< void, Ptr< const PacketBurst > > GetReceiveCallback(void) const
Definition: wimax-phy.cc:155
virtual Time DoGetFrameDuration(uint8_t frameDurationCode) const =0
Get frame duration.
uint8_t m_nrCarriers
number of carriers
Definition: wimax-phy.h:480
uint16_t GetRtg(void) const
Get the receive/transmit transition gap.
Definition: wimax-phy.cc:258
virtual void DoSetPhyParameters(void)=0
Set phy parameters.
bool IsDuplex(void) const
Check if configured in duplex mode.
Definition: wimax-phy.cc:204
void SetSimplex(uint64_t frequency)
configure the physical layer in simplex mode
Definition: wimax-phy.cc:168
Callback< void, Ptr< const PacketBurst > > m_rxCallback
receive callback function
Definition: wimax-phy.h:477
void SetFrameDuration(Time frameDuration)
Set the frame duration.
Definition: wimax-phy.cc:296
Time m_symbolDuration
in seconds
Definition: wimax-phy.h:485
EventId GetChnlSrchTimeoutEvent(void) const
Get channel search timeout event.
Definition: wimax-phy.cc:210
uint64_t GetScanningFrequency(void) const
Get the scanning frequency.
Definition: wimax-phy.cc:187
void SetPsDuration(Time psDuration)
set the physical slot duration
Definition: wimax-phy.cc:356
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
uint32_t GetSymbolsPerFrame(void) const
Get the number of symbols per frame.
Definition: wimax-phy.cc:416
void SetState(PhyState state)
set the state of the device
Definition: wimax-phy.cc:193
Callback< void, bool, uint64_t > m_scanningCallback
scanning callback function
Definition: wimax-phy.h:478
virtual uint32_t DoGetDataRate(ModulationType modulationType) const =0
Get data rate.
void GetModulationFecParams(ModulationType modulationType, uint8_t &bitsPerSymbol, double &fecCode) const
Get modulation FEC parameters.
virtual uint8_t DoGetFrameDurationCode(void) const =0
Get frame duration code.
virtual uint16_t DoGetNfft(void) const =0
Get NFFT.
uint16_t m_psPerSymbol
ps per sumbol
Definition: wimax-phy.h:486
uint64_t GetRxFrequency(void) const
Get the reception frequency.
Definition: wimax-phy.cc:175
Time m_frameDuration
in seconds
Definition: wimax-phy.h:481
Ptr< NetDevice > GetDevice(void) const
Definition: wimax-phy.cc:125
uint8_t GetFrameDurationCode(void) const
Get the frame duration code.
Definition: wimax-phy.cc:264
PhyState GetState(void) const
Get the state of the device.
Definition: wimax-phy.cc:198
void SetPsPerSymbol(uint16_t psPerSymbol)
set the number of physical slots per symbol
Definition: wimax-phy.cc:386
PhyState m_state
state
Definition: wimax-phy.h:475
uint16_t GetTtg(void) const
Get the transmit/receive transition gap.
Definition: wimax-phy.cc:252
void SetScanningCallback(void) const
calls the scanning call back function
Definition: wimax-phy.cc:216
virtual PhyType GetPhyType(void) const =0
Get the type of the physical layer.
double GetSamplingFactor(void) const
Get the sampling factor.
Definition: wimax-phy.cc:344
virtual double DoGetGValue(void) const =0
Get G value.
uint16_t GetPsPerSymbol(void) const
Get the number of physical slots per symbol.
Definition: wimax-phy.cc:392
WimaxPhy(void)
Definition: wimax-phy.cc:75
Every class exported by the ns3 library is enclosed in the ns3 namespace.
channel
Definition: third.py:83
mobility
Definition: third.py:98
ns3::Time timeout