A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("WimaxPhy");
34 
35 namespace ns3 {
36 
38 
40 {
41  static TypeId tid = TypeId ("ns3::WimaxPhy").SetParent<Object> ()
42 
43  .AddAttribute ("Channel",
44  "Wimax channel",
45  PointerValue (),
46  MakePointerAccessor (&WimaxPhy::GetChannel, &WimaxPhy::Attach),
47  MakePointerChecker<WimaxChannel> ())
48 
49  .AddAttribute ("FrameDuration",
50  "The frame duration in seconds.",
51  TimeValue (Seconds (0.01)),
53  MakeTimeChecker ())
54 
55  .AddAttribute ("Frequency",
56  "The central frequency in KHz.",
57  UintegerValue (5000000),
58  MakeUintegerAccessor (&WimaxPhy::SetFrequency, &WimaxPhy::GetFrequency),
59  MakeUintegerChecker<uint32_t> (1000000, 11000000))
60 
61  .AddAttribute ("Bandwidth",
62  "The channel bandwidth in Hz.",
63  UintegerValue (10000000),
65  MakeUintegerChecker<uint32_t> (5000000, 30000000))
66 
67  ;
68  return tid;
69 }
70 
72  : m_state (PHY_STATE_IDLE),
73  m_nrCarriers (0),
74  m_frameDuration (Seconds (0.01)),
75  m_frequency (5000000),
76  m_channelBandwidth (10000000),
77  m_psDuration (Seconds (0)),
78  m_symbolDuration (Seconds (0)),
79  m_psPerSymbol (0),
80  m_psPerFrame (0),
81  m_symbolsPerFrame (0)
82 {
83  m_mobility = 0;
84  m_duplex = 0;
85  m_txFrequency = 0;
86  m_rxFrequency = 0;
87 
88 }
89 
91 {
92 }
93 
94 void
96 {
97  m_device = 0;
98  m_channel = 0;
99 }
100 
101 void
103 {
104  m_channel = channel;
105  DoAttach (channel);
106 }
107 
110 {
111  return m_channel;
112 }
113 
114 void
116 {
117  m_device = device;
118 }
119 
122 {
123  return m_device;
124 }
125 
126 void
128 {
130  "Error while scanning: The PHY state should be PHY_STATE_SCANNING or PHY_STATE_IDLE");
131 
133  m_scanningFrequency = frequency;
135  m_scanningCallback = callback;
136 }
137 
138 void
140 {
142 }
143 
144 void
146 {
147  m_rxCallback = callback;
148 }
149 
152 {
153  return m_rxCallback;
154 }
155 
156 void
157 WimaxPhy::SetDuplex (uint64_t rxFrequency, uint64_t txFrequency)
158 {
159  m_txFrequency = txFrequency;
160  m_rxFrequency = rxFrequency;
161 }
162 
163 void
164 WimaxPhy::SetSimplex (uint64_t frequency)
165 {
166  m_txFrequency = frequency;
167  m_rxFrequency = frequency;
168 }
169 
170 uint64_t
172 {
173  return m_rxFrequency;
174 }
175 
176 uint64_t
178 {
179  return m_txFrequency;
180 }
181 
182 uint64_t
184 {
185  return m_scanningFrequency;
186 }
187 
188 void
190 {
191  m_state = state;
192 }
193 
195 {
196  return m_state;
197 }
198 
199 bool
200 WimaxPhy::IsDuplex (void) const
201 {
202  return m_duplex;
203 }
204 
205 EventId
207 {
209 }
210 
211 void
213 {
215 }
216 
217 void
219 {
220  DoSetDataRates ();
221 }
222 
223 uint32_t
225 {
226  return DoGetDataRate (modulationType);
227 }
228 
229 Time
230 WimaxPhy::GetTransmissionTime (uint32_t size, WimaxPhy::ModulationType modulationType) const
231 {
232  return DoGetTransmissionTime (size, modulationType);
233 }
234 
235 uint64_t
236 WimaxPhy::GetNrSymbols (uint32_t size, WimaxPhy::ModulationType modulationType) const
237 {
238  return DoGetNrSymbols (size, modulationType);
239 }
240 
241 uint64_t
242 WimaxPhy::GetNrBytes (uint32_t symbols, WimaxPhy::ModulationType modulationType) const
243 {
244  return DoGetNrBytes (symbols, modulationType);
245 }
246 
247 uint16_t
248 WimaxPhy::GetTtg (void) const
249 {
250  return DoGetTtg ();
251 }
252 
253 uint16_t
254 WimaxPhy::GetRtg (void) const
255 {
256  return DoGetRtg ();
257 }
258 
259 uint8_t
261 {
262  return DoGetFrameDurationCode ();
263 }
264 
265 Time
266 WimaxPhy::GetFrameDuration (uint8_t frameDurationCode) const
267 {
268  return DoGetFrameDuration (frameDurationCode);
269 }
270 
271 /*---------------------PHY parameters functions-----------------------*/
272 
273 void
275 {
277 }
278 
279 void
280 WimaxPhy::SetNrCarriers (uint8_t nrCarriers)
281 {
282  m_nrCarriers = nrCarriers;
283 }
284 
285 uint8_t
287 {
288  return m_nrCarriers;
289 }
290 
291 void
293 {
294  m_frameDuration = frameDuration;
295 }
296 
297 Time
299 {
300  return GetFrameDurationSec ();
301 }
302 
303 Time
305 {
306  return m_frameDuration;
307 }
308 
309 void
310 WimaxPhy::SetFrequency (uint32_t frequency)
311 {
312  m_frequency = frequency;
313 }
314 
315 uint32_t
317 {
318  return m_frequency;
319 }
320 
321 void
322 WimaxPhy::SetChannelBandwidth (uint32_t channelBandwidth)
323 {
324  m_channelBandwidth = channelBandwidth;
325 }
326 
327 uint32_t
329 {
330  return m_channelBandwidth;
331 }
332 
333 uint16_t
334 WimaxPhy::GetNfft (void) const
335 {
336  return DoGetNfft ();
337 }
338 
339 double
341 {
342  return DoGetSamplingFactor ();
343 }
344 
345 double
347 {
348  return DoGetSamplingFrequency ();
349 }
350 
351 void
353 {
354  m_psDuration = psDuration;
355 }
356 
357 Time
359 {
360  return m_psDuration;
361 }
362 
363 void
365 {
366  m_symbolDuration = symbolDuration;
367 }
368 
369 Time
371 {
372  return m_symbolDuration;
373 }
374 
375 double
377 {
378  return DoGetGValue ();
379 }
380 
381 void
382 WimaxPhy::SetPsPerSymbol (uint16_t psPerSymbol)
383 {
384  m_psPerSymbol = psPerSymbol;
385 }
386 
387 uint16_t
389 {
390  return m_psPerSymbol;
391 }
392 
393 void
394 WimaxPhy::SetPsPerFrame (uint16_t psPerFrame)
395 {
396  m_psPerFrame = psPerFrame;
397 }
398 
399 uint16_t
401 {
402  return m_psPerFrame;
403 }
404 
405 void
406 WimaxPhy::SetSymbolsPerFrame (uint32_t symbolsPerFrame)
407 {
408  m_symbolsPerFrame = symbolsPerFrame;
409 }
410 
411 uint32_t
413 {
414  return m_symbolsPerFrame;
415 }
418 {
419  return m_mobility;
420 }
421 
422 void
424 {
425  m_mobility = mobility;
426 
427 }
428 
429 } // namespace ns3
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
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
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
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
bool IsDuplex(void) const
Definition: wimax-phy.cc:200
WimaxPhy(void)
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
Ptr< Object > m_mobility
Definition: wimax-phy.h:360
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
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
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Definition: simulator.h:825
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
hold objects of type ns3::Time
Definition: nstime.h:1008
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
Hold an unsigned integer type.
Definition: uinteger.h:46
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
hold objects of type Ptr
Definition: pointer.h:33
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 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
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:84
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
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:441
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 double DoGetSamplingFrequency(void) const =0
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
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