A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
37
NS_OBJECT_ENSURE_REGISTERED
(WimaxPhy);
38
39
TypeId
WimaxPhy::GetTypeId
(
void
)
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)),
52
MakeTimeAccessor (&
WimaxPhy::SetFrameDuration
, &
WimaxPhy::GetFrameDurationSec
),
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),
64
MakeUintegerAccessor (&
WimaxPhy::SetChannelBandwidth
, &
WimaxPhy::GetChannelBandwidth
),
65
MakeUintegerChecker<uint32_t> (5000000, 30000000))
66
67
;
68
return
tid;
69
}
70
71
WimaxPhy::WimaxPhy
(
void
)
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
90
WimaxPhy::~WimaxPhy
(
void
)
91
{
92
}
93
94
void
95
WimaxPhy::DoDispose
(
void
)
96
{
97
m_device
= 0;
98
m_channel
= 0;
99
}
100
101
void
102
WimaxPhy::Attach
(
Ptr<WimaxChannel>
channel)
103
{
104
m_channel
= channel;
105
DoAttach
(channel);
106
}
107
108
Ptr<WimaxChannel>
109
WimaxPhy::GetChannel
(
void
)
const
110
{
111
return
m_channel
;
112
}
113
114
void
115
WimaxPhy::SetDevice
(
Ptr<WimaxNetDevice>
device)
116
{
117
m_device
= device;
118
}
119
120
Ptr<NetDevice>
121
WimaxPhy::GetDevice
(
void
)
const
122
{
123
return
m_device
;
124
}
125
126
void
127
WimaxPhy::StartScanning
(uint64_t frequency,
Time
timeout
,
Callback<void, bool, uint64_t>
callback)
128
{
129
NS_ASSERT_MSG
(
m_state
==
PHY_STATE_IDLE
||
m_state
==
PHY_STATE_SCANNING
,
130
"Error while scanning: The PHY state should be PHY_STATE_SCANNING or PHY_STATE_IDLE"
);
131
132
m_state
=
PHY_STATE_SCANNING
;
133
m_scanningFrequency
= frequency;
134
m_dlChnlSrchTimeoutEvent
=
Simulator::Schedule
(timeout, &
WimaxPhy::EndScanning
,
this
);
135
m_scanningCallback
= callback;
136
}
137
138
void
139
WimaxPhy::EndScanning
(
void
)
140
{
141
m_scanningCallback
(
false
,
m_scanningFrequency
);
142
}
143
144
void
145
WimaxPhy::SetReceiveCallback
(
Callback
<
void
,
Ptr<const PacketBurst>
> callback)
146
{
147
m_rxCallback
= callback;
148
}
149
150
Callback<void, Ptr<const PacketBurst>
>
151
WimaxPhy::GetReceiveCallback
(
void
)
const
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
171
WimaxPhy::GetRxFrequency
(
void
)
const
172
{
173
return
m_rxFrequency
;
174
}
175
176
uint64_t
177
WimaxPhy::GetTxFrequency
(
void
)
const
178
{
179
return
m_txFrequency
;
180
}
181
182
uint64_t
183
WimaxPhy::GetScanningFrequency
(
void
)
const
184
{
185
return
m_scanningFrequency
;
186
}
187
188
void
189
WimaxPhy::SetState
(
PhyState
state)
190
{
191
m_state
= state;
192
}
193
194
WimaxPhy::PhyState
WimaxPhy::GetState
(
void
)
const
195
{
196
return
m_state
;
197
}
198
199
bool
200
WimaxPhy::IsDuplex
(
void
)
const
201
{
202
return
m_duplex
;
203
}
204
205
EventId
206
WimaxPhy::GetChnlSrchTimeoutEvent
(
void
)
const
207
{
208
return
m_dlChnlSrchTimeoutEvent
;
209
}
210
211
void
212
WimaxPhy::SetScanningCallback
(
void
)
const
213
{
214
m_scanningCallback
(
true
,
GetScanningFrequency
());
215
}
216
217
void
218
WimaxPhy::SetDataRates
(
void
)
219
{
220
DoSetDataRates
();
221
}
222
223
uint32_t
224
WimaxPhy::GetDataRate
(
WimaxPhy::ModulationType
modulationType)
const
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
260
WimaxPhy::GetFrameDurationCode
(
void
)
const
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
274
WimaxPhy::SetPhyParameters
(
void
)
275
{
276
DoSetPhyParameters
();
277
}
278
279
void
280
WimaxPhy::SetNrCarriers
(uint8_t nrCarriers)
281
{
282
m_nrCarriers
= nrCarriers;
283
}
284
285
uint8_t
286
WimaxPhy::GetNrCarriers
(
void
)
const
287
{
288
return
m_nrCarriers
;
289
}
290
291
void
292
WimaxPhy::SetFrameDuration
(
Time
frameDuration)
293
{
294
m_frameDuration
= frameDuration;
295
}
296
297
Time
298
WimaxPhy::GetFrameDuration
(
void
)
const
299
{
300
return
GetFrameDurationSec
();
301
}
302
303
Time
304
WimaxPhy::GetFrameDurationSec
(
void
)
const
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
316
WimaxPhy::GetFrequency
(
void
)
const
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
328
WimaxPhy::GetChannelBandwidth
(
void
)
const
329
{
330
return
m_channelBandwidth
;
331
}
332
333
uint16_t
334
WimaxPhy::GetNfft
(
void
)
const
335
{
336
return
DoGetNfft
();
337
}
338
339
double
340
WimaxPhy::GetSamplingFactor
(
void
)
const
341
{
342
return
DoGetSamplingFactor
();
343
}
344
345
double
346
WimaxPhy::GetSamplingFrequency
(
void
)
const
347
{
348
return
DoGetSamplingFrequency
();
349
}
350
351
void
352
WimaxPhy::SetPsDuration
(
Time
psDuration)
353
{
354
m_psDuration
= psDuration;
355
}
356
357
Time
358
WimaxPhy::GetPsDuration
(
void
)
const
359
{
360
return
m_psDuration
;
361
}
362
363
void
364
WimaxPhy::SetSymbolDuration
(
Time
symbolDuration)
365
{
366
m_symbolDuration
= symbolDuration;
367
}
368
369
Time
370
WimaxPhy::GetSymbolDuration
(
void
)
const
371
{
372
return
m_symbolDuration
;
373
}
374
375
double
376
WimaxPhy::GetGValue
(
void
)
const
377
{
378
return
DoGetGValue
();
379
}
380
381
void
382
WimaxPhy::SetPsPerSymbol
(uint16_t psPerSymbol)
383
{
384
m_psPerSymbol
= psPerSymbol;
385
}
386
387
uint16_t
388
WimaxPhy::GetPsPerSymbol
(
void
)
const
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
400
WimaxPhy::GetPsPerFrame
(
void
)
const
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
412
WimaxPhy::GetSymbolsPerFrame
(
void
)
const
413
{
414
return
m_symbolsPerFrame
;
415
}
416
Ptr<Object>
417
WimaxPhy::GetMobility
(
void
)
418
{
419
return
m_mobility
;
420
}
421
422
void
423
WimaxPhy::SetMobility
(
Ptr<Object>
mobility)
424
{
425
m_mobility
= mobility;
426
427
}
428
429
}
// namespace ns3
src
wimax
model
wimax-phy.cc
Generated on Tue Oct 9 2012 16:45:50 for ns-3 by
1.8.1.2