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  ;
39 
41 {
42  static TypeId tid = TypeId ("ns3::WimaxPhy").SetParent<Object> ()
43 
44  .AddAttribute ("Channel",
45  "Wimax channel",
46  PointerValue (),
47  MakePointerAccessor (&WimaxPhy::GetChannel, &WimaxPhy::Attach),
48  MakePointerChecker<WimaxChannel> ())
49 
50  .AddAttribute ("FrameDuration",
51  "The frame duration in seconds.",
52  TimeValue (Seconds (0.01)),
54  MakeTimeChecker ())
55 
56  .AddAttribute ("Frequency",
57  "The central frequency in KHz.",
58  UintegerValue (5000000),
59  MakeUintegerAccessor (&WimaxPhy::SetFrequency, &WimaxPhy::GetFrequency),
60  MakeUintegerChecker<uint32_t> (1000000, 11000000))
61 
62  .AddAttribute ("Bandwidth",
63  "The channel bandwidth in Hz.",
64  UintegerValue (10000000),
66  MakeUintegerChecker<uint32_t> (5000000, 30000000))
67 
68  ;
69  return tid;
70 }
71 
73  : m_state (PHY_STATE_IDLE),
74  m_nrCarriers (0),
75  m_frameDuration (Seconds (0.01)),
76  m_frequency (5000000),
77  m_channelBandwidth (10000000),
78  m_psDuration (Seconds (0)),
79  m_symbolDuration (Seconds (0)),
80  m_psPerSymbol (0),
81  m_psPerFrame (0),
82  m_symbolsPerFrame (0)
83 {
84  m_mobility = 0;
85  m_duplex = 0;
86  m_txFrequency = 0;
87  m_rxFrequency = 0;
88 
89 }
90 
92 {
93 }
94 
95 void
97 {
98  m_device = 0;
99  m_channel = 0;
100 }
101 
102 void
104 {
105  m_channel = channel;
106  DoAttach (channel);
107 }
108 
111 {
112  return m_channel;
113 }
114 
115 void
117 {
118  m_device = device;
119 }
120 
123 {
124  return m_device;
125 }
126 
127 void
129 {
131  "Error while scanning: The PHY state should be PHY_STATE_SCANNING or PHY_STATE_IDLE");
132 
134  m_scanningFrequency = frequency;
136  m_scanningCallback = callback;
137 }
138 
139 void
141 {
143 }
144 
145 void
147 {
148  m_rxCallback = callback;
149 }
150 
153 {
154  return m_rxCallback;
155 }
156 
157 void
158 WimaxPhy::SetDuplex (uint64_t rxFrequency, uint64_t txFrequency)
159 {
160  m_txFrequency = txFrequency;
161  m_rxFrequency = rxFrequency;
162 }
163 
164 void
165 WimaxPhy::SetSimplex (uint64_t frequency)
166 {
167  m_txFrequency = frequency;
168  m_rxFrequency = frequency;
169 }
170 
171 uint64_t
173 {
174  return m_rxFrequency;
175 }
176 
177 uint64_t
179 {
180  return m_txFrequency;
181 }
182 
183 uint64_t
185 {
186  return m_scanningFrequency;
187 }
188 
189 void
191 {
192  m_state = state;
193 }
194 
196 {
197  return m_state;
198 }
199 
200 bool
201 WimaxPhy::IsDuplex (void) const
202 {
203  return m_duplex;
204 }
205 
206 EventId
208 {
210 }
211 
212 void
214 {
216 }
217 
218 void
220 {
221  DoSetDataRates ();
222 }
223 
224 uint32_t
226 {
227  return DoGetDataRate (modulationType);
228 }
229 
230 Time
231 WimaxPhy::GetTransmissionTime (uint32_t size, WimaxPhy::ModulationType modulationType) const
232 {
233  return DoGetTransmissionTime (size, modulationType);
234 }
235 
236 uint64_t
237 WimaxPhy::GetNrSymbols (uint32_t size, WimaxPhy::ModulationType modulationType) const
238 {
239  return DoGetNrSymbols (size, modulationType);
240 }
241 
242 uint64_t
243 WimaxPhy::GetNrBytes (uint32_t symbols, WimaxPhy::ModulationType modulationType) const
244 {
245  return DoGetNrBytes (symbols, modulationType);
246 }
247 
248 uint16_t
249 WimaxPhy::GetTtg (void) const
250 {
251  return DoGetTtg ();
252 }
253 
254 uint16_t
255 WimaxPhy::GetRtg (void) const
256 {
257  return DoGetRtg ();
258 }
259 
260 uint8_t
262 {
263  return DoGetFrameDurationCode ();
264 }
265 
266 Time
267 WimaxPhy::GetFrameDuration (uint8_t frameDurationCode) const
268 {
269  return DoGetFrameDuration (frameDurationCode);
270 }
271 
272 /*---------------------PHY parameters functions-----------------------*/
273 
274 void
276 {
278 }
279 
280 void
281 WimaxPhy::SetNrCarriers (uint8_t nrCarriers)
282 {
283  m_nrCarriers = nrCarriers;
284 }
285 
286 uint8_t
288 {
289  return m_nrCarriers;
290 }
291 
292 void
294 {
295  m_frameDuration = frameDuration;
296 }
297 
298 Time
300 {
301  return GetFrameDurationSec ();
302 }
303 
304 Time
306 {
307  return m_frameDuration;
308 }
309 
310 void
311 WimaxPhy::SetFrequency (uint32_t frequency)
312 {
313  m_frequency = frequency;
314 }
315 
316 uint32_t
318 {
319  return m_frequency;
320 }
321 
322 void
323 WimaxPhy::SetChannelBandwidth (uint32_t channelBandwidth)
324 {
325  m_channelBandwidth = channelBandwidth;
326 }
327 
328 uint32_t
330 {
331  return m_channelBandwidth;
332 }
333 
334 uint16_t
335 WimaxPhy::GetNfft (void) const
336 {
337  return DoGetNfft ();
338 }
339 
340 double
342 {
343  return DoGetSamplingFactor ();
344 }
345 
346 double
348 {
349  return DoGetSamplingFrequency ();
350 }
351 
352 void
354 {
355  m_psDuration = psDuration;
356 }
357 
358 Time
360 {
361  return m_psDuration;
362 }
363 
364 void
366 {
367  m_symbolDuration = symbolDuration;
368 }
369 
370 Time
372 {
373  return m_symbolDuration;
374 }
375 
376 double
378 {
379  return DoGetGValue ();
380 }
381 
382 void
383 WimaxPhy::SetPsPerSymbol (uint16_t psPerSymbol)
384 {
385  m_psPerSymbol = psPerSymbol;
386 }
387 
388 uint16_t
390 {
391  return m_psPerSymbol;
392 }
393 
394 void
395 WimaxPhy::SetPsPerFrame (uint16_t psPerFrame)
396 {
397  m_psPerFrame = psPerFrame;
398 }
399 
400 uint16_t
402 {
403  return m_psPerFrame;
404 }
405 
406 void
407 WimaxPhy::SetSymbolsPerFrame (uint32_t symbolsPerFrame)
408 {
409  m_symbolsPerFrame = symbolsPerFrame;
410 }
411 
412 uint32_t
414 {
415  return m_symbolsPerFrame;
416 }
419 {
420  return m_mobility;
421 }
422 
423 void
425 {
426  m_mobility = mobility;
427 
428 }
429 
430 } // namespace ns3
Time GetPsDuration(void) const
Definition: wimax-phy.cc:359
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
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
Callback< void, Ptr< const PacketBurst > > GetReceiveCallback(void) const
Definition: wimax-phy.cc:152
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
virtual double DoGetSamplingFactor(void) const =0
void SetFrequency(uint32_t frequency)
set the frequency on which the device should lock
Definition: wimax-phy.cc:311
void SetFrameDuration(Time frameDuration)
Set the frame duration.
Definition: wimax-phy.cc:293
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:96
virtual uint8_t DoGetFrameDurationCode(void) const =0
bool IsDuplex(void) const
Definition: wimax-phy.cc:201
WimaxPhy(void)
Definition: wimax-phy.cc:72
uint32_t GetChannelBandwidth(void) const
Definition: wimax-phy.cc:329
uint32_t GetSymbolsPerFrame(void) const
Definition: wimax-phy.cc:413
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
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:165
uint64_t GetRxFrequency(void) const
Definition: wimax-phy.cc:172
double GetSamplingFactor(void) const
Definition: wimax-phy.cc:341
Time GetSymbolDuration(void) const
Definition: wimax-phy.cc:371
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:824
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:407
void SetPsDuration(Time psDuration)
set the physical slot duration in seconds
Definition: wimax-phy.cc:353
uint32_t m_frequency
Definition: wimax-phy.h:353
Time GetFrameDuration(void) const
Definition: wimax-phy.cc:299
void SetReceiveCallback(Callback< void, Ptr< const PacketBurst > > callback)
set the callback function to call when a burst is received
Definition: wimax-phy.cc:146
Time GetTransmissionTime(uint32_t size, ModulationType modulationType) const
Definition: wimax-phy.cc:231
void EndScanning(void)
Definition: wimax-phy.cc:140
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:249
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:961
void SetScanningCallback(void) const
calls the scanning call back function
Definition: wimax-phy.cc:213
uint16_t GetNfft(void) const
Definition: wimax-phy.cc:335
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:383
uint64_t GetNrSymbols(uint32_t size, ModulationType modulationType) const
Definition: wimax-phy.cc:237
static TypeId GetTypeId(void)
Definition: wimax-phy.cc:40
Ptr< WimaxChannel > GetChannel(void) const
Definition: wimax-phy.cc:110
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:305
uint8_t GetNrCarriers(void) const
Definition: wimax-phy.cc:287
Callback< void, bool, uint64_t > m_scanningCallback
Definition: wimax-phy.h:349
double GetGValue(void) const
Definition: wimax-phy.cc:377
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:323
uint32_t m_symbolsPerFrame
Definition: wimax-phy.h:359
uint64_t GetNrBytes(uint32_t symbols, ModulationType modulationType) const
Definition: wimax-phy.cc:243
uint16_t GetPsPerSymbol(void) const
Definition: wimax-phy.cc:389
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:128
virtual ~WimaxPhy(void)
Definition: wimax-phy.cc:91
Ptr< NetDevice > GetDevice(void) const
Definition: wimax-phy.cc:122
Callback< void, Ptr< const PacketBurst > > m_rxCallback
Definition: wimax-phy.h:348
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
Time m_psDuration
Definition: wimax-phy.h:355
void Attach(Ptr< WimaxChannel > channel)
Attach the physical layer to a channel.
Definition: wimax-phy.cc:103
void SetSymbolDuration(Time symbolDuration)
set the OFMD symbol duration in second
Definition: wimax-phy.cc:365
uint16_t GetPsPerFrame(void) const
Definition: wimax-phy.cc:401
uint8_t GetFrameDurationCode(void) const
Definition: wimax-phy.cc:261
an identifier for simulation events.
Definition: event-id.h:46
virtual Ptr< Object > GetMobility(void)
Definition: wimax-phy.cc:418
void SetDuplex(uint64_t rxFrequency, uint64_t txFrequency)
configure the physical layer in duplex mode
Definition: wimax-phy.cc:158
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:116
void SetState(PhyState state)
set the state of the device
Definition: wimax-phy.cc:190
uint16_t GetRtg(void) const
Definition: wimax-phy.cc:255
void SetDataRates(void)
calculates the data rate of each modulation and save them for future use
Definition: wimax-phy.cc:219
uint32_t GetDataRate(ModulationType modulationType) const
Definition: wimax-phy.cc:225
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:452
void SetNrCarriers(uint8_t nrCarriers)
Set the number of carriers in the physical frame.
Definition: wimax-phy.cc:281
Ptr< WimaxNetDevice > m_device
Definition: wimax-phy.h:338
double GetSamplingFrequency(void) const
Definition: wimax-phy.cc:347
uint64_t GetTxFrequency(void) const
Definition: wimax-phy.cc:178
a base class which provides memory management and object aggregation
Definition: object.h:63
virtual void DoSetDataRates(void)=0
EventId GetChnlSrchTimeoutEvent(void) const
Definition: wimax-phy.cc:207
void SetPsPerFrame(uint16_t psPerFrame)
set the number of physical slot per frame
Definition: wimax-phy.cc:395
uint32_t GetFrequency(void) const
Definition: wimax-phy.cc:317
virtual double DoGetGValue(void) const =0
void SetPhyParameters(void)
computes the Physical parameters and store them
Definition: wimax-phy.cc:275
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:611
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:424
PhyState GetState(void) const
Definition: wimax-phy.cc:195
uint64_t GetScanningFrequency(void) const
Definition: wimax-phy.cc:184
NS_LOG_COMPONENT_DEFINE("WimaxPhy")
virtual void DoSetPhyParameters(void)=0
virtual Time DoGetFrameDuration(uint8_t frameDurationCode) const =0
uint64_t m_scanningFrequency
Definition: wimax-phy.h:343