A Discrete-Event Network Simulator
API
wimax-phy.cc
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 #include "ns3/simulator.h"
22 #include "ns3/packet.h"
23 #include "ns3/node.h"
24 #include "wimax-net-device.h"
25 #include "wimax-phy.h"
26 #include "wimax-channel.h"
27 #include "ns3/packet-burst.h"
28 #include "ns3/trace-source-accessor.h"
29 #include "ns3/pointer.h"
30 #include "ns3/uinteger.h"
31 #include "ns3/double.h"
32 
33 namespace ns3 {
34 
35 NS_LOG_COMPONENT_DEFINE ("WimaxPhy");
36 
38 
40 {
41  static TypeId tid = TypeId ("ns3::WimaxPhy")
42  .SetParent<Object> ()
43  .SetGroupName("Wimax")
44 
45  // No AddConstructor because this is an abstract class.
46 
47  .AddAttribute ("Channel",
48  "Wimax channel",
49  PointerValue (),
51  MakePointerChecker<WimaxChannel> ())
52 
53  .AddAttribute ("FrameDuration",
54  "The frame duration in seconds.",
55  TimeValue (Seconds (0.01)),
57  MakeTimeChecker ())
58 
59  .AddAttribute ("Frequency",
60  "The central frequency in KHz.",
61  UintegerValue (5000000),
63  MakeUintegerChecker<uint32_t> (1000000, 11000000))
64 
65  .AddAttribute ("Bandwidth",
66  "The channel bandwidth in Hz.",
67  UintegerValue (10000000),
69  MakeUintegerChecker<uint32_t> (5000000, 30000000))
70 
71  ;
72  return tid;
73 }
74 
76  : m_state (PHY_STATE_IDLE),
77  m_nrCarriers (0),
78  m_frameDuration (Seconds (0.01)),
79  m_frequency (5000000),
80  m_channelBandwidth (10000000),
81  m_psDuration (Seconds (0)),
82  m_symbolDuration (Seconds (0)),
83  m_psPerSymbol (0),
84  m_psPerFrame (0),
85  m_symbolsPerFrame (0)
86 {
87  m_mobility = 0;
88  m_duplex = 0;
89  m_txFrequency = 0;
90  m_rxFrequency = 0;
91 
92 }
93 
95 {
96 }
97 
98 void
100 {
101  m_device = 0;
102  m_channel = 0;
103 }
104 
105 void
107 {
108  m_channel = channel;
109  DoAttach (channel);
110 }
111 
114 {
115  return m_channel;
116 }
117 
118 void
120 {
121  m_device = device;
122 }
123 
126 {
127  return m_device;
128 }
129 
130 void
132 {
134  "Error while scanning: The PHY state should be PHY_STATE_SCANNING or PHY_STATE_IDLE");
135 
137  m_scanningFrequency = frequency;
139  m_scanningCallback = callback;
140 }
141 
142 void
144 {
146 }
147 
148 void
150 {
151  m_rxCallback = callback;
152 }
153 
156 {
157  return m_rxCallback;
158 }
159 
160 void
161 WimaxPhy::SetDuplex (uint64_t rxFrequency, uint64_t txFrequency)
162 {
163  m_txFrequency = txFrequency;
164  m_rxFrequency = rxFrequency;
165 }
166 
167 void
168 WimaxPhy::SetSimplex (uint64_t frequency)
169 {
170  m_txFrequency = frequency;
171  m_rxFrequency = frequency;
172 }
173 
174 uint64_t
176 {
177  return m_rxFrequency;
178 }
179 
180 uint64_t
182 {
183  return m_txFrequency;
184 }
185 
186 uint64_t
188 {
189  return m_scanningFrequency;
190 }
191 
192 void
194 {
195  m_state = state;
196 }
197 
199 {
200  return m_state;
201 }
202 
203 bool
204 WimaxPhy::IsDuplex (void) const
205 {
206  return m_duplex;
207 }
208 
209 EventId
211 {
213 }
214 
215 void
217 {
219 }
220 
221 void
223 {
224  DoSetDataRates ();
225 }
226 
227 uint32_t
229 {
230  return DoGetDataRate (modulationType);
231 }
232 
233 Time
234 WimaxPhy::GetTransmissionTime (uint32_t size, WimaxPhy::ModulationType modulationType) const
235 {
236  return DoGetTransmissionTime (size, modulationType);
237 }
238 
239 uint64_t
240 WimaxPhy::GetNrSymbols (uint32_t size, WimaxPhy::ModulationType modulationType) const
241 {
242  return DoGetNrSymbols (size, modulationType);
243 }
244 
245 uint64_t
246 WimaxPhy::GetNrBytes (uint32_t symbols, WimaxPhy::ModulationType modulationType) const
247 {
248  return DoGetNrBytes (symbols, modulationType);
249 }
250 
251 uint16_t
252 WimaxPhy::GetTtg (void) const
253 {
254  return DoGetTtg ();
255 }
256 
257 uint16_t
258 WimaxPhy::GetRtg (void) const
259 {
260  return DoGetRtg ();
261 }
262 
263 uint8_t
265 {
266  return DoGetFrameDurationCode ();
267 }
268 
269 Time
270 WimaxPhy::GetFrameDuration (uint8_t frameDurationCode) const
271 {
272  return DoGetFrameDuration (frameDurationCode);
273 }
274 
275 /*---------------------PHY parameters functions-----------------------*/
276 
277 void
279 {
281 }
282 
283 void
284 WimaxPhy::SetNrCarriers (uint8_t nrCarriers)
285 {
286  m_nrCarriers = nrCarriers;
287 }
288 
289 uint8_t
291 {
292  return m_nrCarriers;
293 }
294 
295 void
297 {
298  m_frameDuration = frameDuration;
299 }
300 
301 Time
303 {
304  return GetFrameDurationSec ();
305 }
306 
307 Time
309 {
310  return m_frameDuration;
311 }
312 
313 void
314 WimaxPhy::SetFrequency (uint32_t frequency)
315 {
316  m_frequency = frequency;
317 }
318 
319 uint32_t
321 {
322  return m_frequency;
323 }
324 
325 void
326 WimaxPhy::SetChannelBandwidth (uint32_t channelBandwidth)
327 {
328  m_channelBandwidth = channelBandwidth;
329 }
330 
331 uint32_t
333 {
334  return m_channelBandwidth;
335 }
336 
337 uint16_t
338 WimaxPhy::GetNfft (void) const
339 {
340  return DoGetNfft ();
341 }
342 
343 double
345 {
346  return DoGetSamplingFactor ();
347 }
348 
349 double
351 {
352  return DoGetSamplingFrequency ();
353 }
354 
355 void
357 {
358  m_psDuration = psDuration;
359 }
360 
361 Time
363 {
364  return m_psDuration;
365 }
366 
367 void
369 {
370  m_symbolDuration = symbolDuration;
371 }
372 
373 Time
375 {
376  return m_symbolDuration;
377 }
378 
379 double
381 {
382  return DoGetGValue ();
383 }
384 
385 void
386 WimaxPhy::SetPsPerSymbol (uint16_t psPerSymbol)
387 {
388  m_psPerSymbol = psPerSymbol;
389 }
390 
391 uint16_t
393 {
394  return m_psPerSymbol;
395 }
396 
397 void
398 WimaxPhy::SetPsPerFrame (uint16_t psPerFrame)
399 {
400  m_psPerFrame = psPerFrame;
401 }
402 
403 uint16_t
405 {
406  return m_psPerFrame;
407 }
408 
409 void
410 WimaxPhy::SetSymbolsPerFrame (uint32_t symbolsPerFrame)
411 {
412  m_symbolsPerFrame = symbolsPerFrame;
413 }
414 
415 uint32_t
417 {
418  return m_symbolsPerFrame;
419 }
422 {
423  return m_mobility;
424 }
425 
426 void
428 {
430 
431 }
432 
433 } // namespace ns3
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:102
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
duplex
Definition: wimax-phy.h:472
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
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
void SetFrameDuration(Time frameDuration)
Set the frame duration.
Definition: wimax-phy.cc:296
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
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.
WimaxPhy(void)
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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
Time m_frameDuration
in seconds
Definition: wimax-phy.h:479
Ptr< WimaxChannel > m_channel
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
channel
Definition: third.py:85
mobility
Definition: third.py:101
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:446
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
void EndScanning(void)
End scanning.
Definition: wimax-phy.cc:143
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
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: pointer.h:220
uint32_t m_channelBandwidth
in Hz
Definition: wimax-phy.h:481
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1381
AttributeValue implementation for Time.
Definition: nstime.h:1076
Ptr< NetDevice > GetDevice(void) const
Definition: wimax-phy.cc:125
Hold an unsigned integer type.
Definition: uinteger.h:44
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
Get NFFT.
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.
Hold objects of type Ptr<T>.
Definition: pointer.h:36
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
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: nstime.h:1077
Time m_symbolDuration
in seconds
Definition: wimax-phy.h:483
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
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
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
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1014
PhyState m_state
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 double DoGetSamplingFrequency(void) const =0
Get sampling frequency.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
a unique identifier for an interface.
Definition: type-id.h:58
PhyState
PhyState enumeration.
Definition: wimax-phy.h:61
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
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
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