A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wimax-phy.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
18 */
19
20#include "wimax-phy.h"
21
22#include "wimax-channel.h"
23#include "wimax-net-device.h"
24
25#include "ns3/double.h"
26#include "ns3/node.h"
27#include "ns3/packet-burst.h"
28#include "ns3/packet.h"
29#include "ns3/pointer.h"
30#include "ns3/simulator.h"
31#include "ns3/trace-source-accessor.h"
32#include "ns3/uinteger.h"
33
34namespace ns3
35{
36
37NS_LOG_COMPONENT_DEFINE("WimaxPhy");
38
40
41TypeId
43{
44 static TypeId tid =
45 TypeId("ns3::WimaxPhy")
47 .SetGroupName("Wimax")
48
49 // No AddConstructor because this is an abstract class.
50
51 .AddAttribute("Channel",
52 "Wimax channel",
55 MakePointerChecker<WimaxChannel>())
56
57 .AddAttribute(
58 "FrameDuration",
59 "The frame duration in seconds.",
60 TimeValue(Seconds(0.01)),
63
64 .AddAttribute("Frequency",
65 "The central frequency in KHz.",
66 UintegerValue(5000000),
68 MakeUintegerChecker<uint32_t>(1000000, 11000000))
69
70 .AddAttribute("Bandwidth",
71 "The channel bandwidth in Hz.",
72 UintegerValue(10000000),
75 MakeUintegerChecker<uint32_t>(5000000, 30000000))
76
77 ;
78 return tid;
79}
80
82 : m_state(PHY_STATE_IDLE),
83 m_nrCarriers(0),
84 m_frameDuration(Seconds(0.01)),
85 m_frequency(5000000),
86 m_channelBandwidth(10000000),
87 m_psDuration(Seconds(0)),
88 m_symbolDuration(Seconds(0)),
89 m_psPerSymbol(0),
90 m_psPerFrame(0),
91 m_symbolsPerFrame(0)
92{
93 m_duplex = false;
94 m_txFrequency = 0;
95 m_rxFrequency = 0;
96}
97
99{
100}
101
102void
104{
105 m_device = nullptr;
106 m_channel = nullptr;
107}
108
109void
111{
112 m_channel = channel;
113 DoAttach(channel);
114}
115
118{
119 return m_channel;
120}
121
122void
124{
125 m_device = device;
126}
127
130{
131 return m_device;
132}
133
134void
136{
139 "Error while scanning: The PHY state should be PHY_STATE_SCANNING or PHY_STATE_IDLE");
140
142 m_scanningFrequency = frequency;
144 m_scanningCallback = callback;
145}
146
147void
149{
151}
152
153void
155{
156 m_rxCallback = callback;
157}
158
161{
162 return m_rxCallback;
163}
164
165void
166WimaxPhy::SetDuplex(uint64_t rxFrequency, uint64_t txFrequency)
167{
168 m_txFrequency = txFrequency;
169 m_rxFrequency = rxFrequency;
170}
171
172void
173WimaxPhy::SetSimplex(uint64_t frequency)
174{
175 m_txFrequency = frequency;
176 m_rxFrequency = frequency;
177}
178
179uint64_t
181{
182 return m_rxFrequency;
183}
184
185uint64_t
187{
188 return m_txFrequency;
189}
190
191uint64_t
193{
194 return m_scanningFrequency;
195}
196
197void
199{
200 m_state = state;
201}
202
205{
206 return m_state;
207}
208
209bool
211{
212 return m_duplex;
213}
214
217{
219}
220
221void
223{
225}
226
227void
229{
231}
232
235{
236 return DoGetDataRate(modulationType);
237}
238
239Time
241{
242 return DoGetTransmissionTime(size, modulationType);
243}
244
245uint64_t
247{
248 return DoGetNrSymbols(size, modulationType);
249}
250
251uint64_t
253{
254 return DoGetNrBytes(symbols, modulationType);
255}
256
257uint16_t
259{
260 return DoGetTtg();
261}
262
263uint16_t
265{
266 return DoGetRtg();
267}
268
269uint8_t
271{
272 return DoGetFrameDurationCode();
273}
274
275Time
276WimaxPhy::GetFrameDuration(uint8_t frameDurationCode) const
277{
278 return DoGetFrameDuration(frameDurationCode);
279}
280
281/*---------------------PHY parameters functions-----------------------*/
282
283void
285{
287}
288
289void
290WimaxPhy::SetNrCarriers(uint8_t nrCarriers)
291{
292 m_nrCarriers = nrCarriers;
293}
294
295uint8_t
297{
298 return m_nrCarriers;
299}
300
301void
303{
304 m_frameDuration = frameDuration;
305}
306
307Time
309{
310 return GetFrameDurationSec();
311}
312
313Time
315{
316 return m_frameDuration;
317}
318
319void
321{
322 m_frequency = frequency;
323}
324
327{
328 return m_frequency;
329}
330
331void
333{
334 m_channelBandwidth = channelBandwidth;
335}
336
339{
340 return m_channelBandwidth;
341}
342
343uint16_t
345{
346 return DoGetNfft();
347}
348
349double
351{
352 return DoGetSamplingFactor();
353}
354
355double
357{
358 return DoGetSamplingFrequency();
359}
360
361void
363{
364 m_psDuration = psDuration;
365}
366
367Time
369{
370 return m_psDuration;
371}
372
373void
375{
376 m_symbolDuration = symbolDuration;
377}
378
379Time
381{
382 return m_symbolDuration;
383}
384
385double
387{
388 return DoGetGValue();
389}
390
391void
392WimaxPhy::SetPsPerSymbol(uint16_t psPerSymbol)
393{
394 m_psPerSymbol = psPerSymbol;
395}
396
397uint16_t
399{
400 return m_psPerSymbol;
401}
402
403void
404WimaxPhy::SetPsPerFrame(uint16_t psPerFrame)
405{
406 m_psPerFrame = psPerFrame;
407}
408
409uint16_t
411{
412 return m_psPerFrame;
413}
414
415void
417{
418 m_symbolsPerFrame = symbolsPerFrame;
419}
420
423{
424 return m_symbolsPerFrame;
425}
426
427} // namespace ns3
Callback template class.
Definition: callback.h:438
An identifier for simulation events.
Definition: event-id.h:55
A base class which provides memory management and object aggregation.
Definition: object.h:89
AttributeValue implementation for Pointer.
Definition: pointer.h:48
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
AttributeValue implementation for Time.
Definition: nstime.h:1413
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
Hold an unsigned integer type.
Definition: uinteger.h:45
Time GetTransmissionTime(uint32_t size, ModulationType modulationType) const
Get transmission time needed to send bytes at a given modulation.
Definition: wimax-phy.cc:240
Time GetFrameDuration() const
Get the frame duration.
Definition: wimax-phy.cc:308
ModulationType
ModulationType enumeration.
Definition: wimax-phy.h:54
virtual double DoGetGValue() const =0
Get G value.
bool m_duplex
duplex
Definition: wimax-phy.h:472
void SetSymbolDuration(Time symbolDuration)
set the OFDM symbol duration
Definition: wimax-phy.cc:374
Ptr< WimaxChannel > GetChannel() const
Definition: wimax-phy.cc:117
uint32_t GetSymbolsPerFrame() const
Get the number of symbols per frame.
Definition: wimax-phy.cc:422
void SetChannelBandwidth(uint32_t channelBandwidth)
Set the channel bandwidth.
Definition: wimax-phy.cc:332
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:252
virtual uint8_t DoGetFrameDurationCode() const =0
Get frame duration code.
uint64_t m_txFrequency
transmit frequency
Definition: wimax-phy.h:468
~WimaxPhy() override
Definition: wimax-phy.cc:98
void SetDuplex(uint64_t rxFrequency, uint64_t txFrequency)
configure the physical layer in duplex mode
Definition: wimax-phy.cc:166
EventId m_dlChnlSrchTimeoutEvent
DL channel search timeout event.
Definition: wimax-phy.h:471
uint64_t GetRxFrequency() const
Get the reception frequency.
Definition: wimax-phy.cc:180
Time GetFrameDurationSec() const
Get the frame duration This method is redundant with GetFrameDuration ()
Definition: wimax-phy.cc:314
void SetDataRates()
calculates the data rate of each modulation and save them for future use
Definition: wimax-phy.cc:228
uint16_t GetPsPerFrame() const
Get the number of physical slots per frame.
Definition: wimax-phy.cc:410
Time GetSymbolDuration() const
Get the OFDM symbol duration.
Definition: wimax-phy.cc:380
uint8_t GetNrCarriers() const
Get the number of carriers in the physical frame.
Definition: wimax-phy.cc:296
uint32_t m_channelBandwidth
in Hz
Definition: wimax-phy.h:481
Time m_psDuration
in seconds
Definition: wimax-phy.h:482
PhyState GetState() const
Get the state of the device.
Definition: wimax-phy.cc:204
virtual void DoSetPhyParameters()=0
Set phy parameters.
virtual uint16_t DoGetTtg() const =0
Get TTG.
void Attach(Ptr< WimaxChannel > channel)
Attach the physical layer to a channel.
Definition: wimax-phy.cc:110
uint16_t m_psPerFrame
ps per framce
Definition: wimax-phy.h:485
virtual uint16_t DoGetNfft() const =0
Get NFFT.
void SetFrequency(uint32_t frequency)
set the frequency on which the device should lock
Definition: wimax-phy.cc:320
uint32_t m_symbolsPerFrame
symbols per frame
Definition: wimax-phy.h:486
uint8_t GetFrameDurationCode() const
Get the frame duration code.
Definition: wimax-phy.cc:270
void SetDevice(Ptr< WimaxNetDevice > device)
Set the device in which this physical layer is installed.
Definition: wimax-phy.cc:123
uint64_t m_rxFrequency
receive frequency
Definition: wimax-phy.h:469
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:135
virtual void DoSetDataRates()=0
Set data rates.
void SetReceiveCallback(Callback< void, Ptr< const PacketBurst > > callback)
set the callback function to call when a burst is received
Definition: wimax-phy.cc:154
virtual void DoAttach(Ptr< WimaxChannel > channel)=0
Attach channel.
void SetSymbolsPerFrame(uint32_t symbolsPerFrame)
set the number of symbols per frame
Definition: wimax-phy.cc:416
Ptr< WimaxNetDevice > m_device
the device
Definition: wimax-phy.h:465
void SetScanningCallback() const
calls the scanning call back function
Definition: wimax-phy.cc:222
virtual uint64_t DoGetNrSymbols(uint32_t size, ModulationType modulationType) const =0
Get number of symbols.
double GetSamplingFrequency() const
Get the sampling frequency.
Definition: wimax-phy.cc:356
virtual double DoGetSamplingFactor() const =0
Get sampling factor.
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:290
Ptr< WimaxChannel > m_channel
channel
Definition: wimax-phy.h:466
Time GetPsDuration() const
Get the physical slot duration.
Definition: wimax-phy.cc:368
static TypeId GetTypeId()
Get the type ID.
Definition: wimax-phy.cc:42
uint64_t m_scanningFrequency
scanning frequency
Definition: wimax-phy.h:470
void DoDispose() override
Destructor implementation.
Definition: wimax-phy.cc:103
uint32_t GetFrequency() const
Get the frequency on which the device is locked.
Definition: wimax-phy.cc:326
double GetGValue() const
Get the guard interval factor (the ratio TG/Td)
Definition: wimax-phy.cc:386
Ptr< NetDevice > GetDevice() const
Definition: wimax-phy.cc:129
void SetPsPerFrame(uint16_t psPerFrame)
set the number of physical slots per frame
Definition: wimax-phy.cc:404
PhyState
PhyState enumeration.
Definition: wimax-phy.h:66
@ PHY_STATE_SCANNING
Definition: wimax-phy.h:68
uint32_t GetDataRate(ModulationType modulationType) const
Get the data rate corresponding to a modulation type.
Definition: wimax-phy.cc:234
virtual Time DoGetTransmissionTime(uint32_t size, ModulationType modulationType) const =0
Get transmission time.
uint32_t m_frequency
in KHz
Definition: wimax-phy.h:480
virtual Time DoGetFrameDuration(uint8_t frameDurationCode) const =0
Get frame duration.
uint8_t m_nrCarriers
number of carriers
Definition: wimax-phy.h:478
void SetSimplex(uint64_t frequency)
configure the physical layer in simplex mode
Definition: wimax-phy.cc:173
Callback< void, Ptr< const PacketBurst > > m_rxCallback
receive callback function
Definition: wimax-phy.h:475
void SetFrameDuration(Time frameDuration)
Set the frame duration.
Definition: wimax-phy.cc:302
uint64_t GetScanningFrequency() const
Get the scanning frequency.
Definition: wimax-phy.cc:192
Time m_symbolDuration
in seconds
Definition: wimax-phy.h:483
void SetPsDuration(Time psDuration)
set the physical slot duration
Definition: wimax-phy.cc:362
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:246
void EndScanning()
End scanning.
Definition: wimax-phy.cc:148
uint16_t GetPsPerSymbol() const
Get the number of physical slots per symbol.
Definition: wimax-phy.cc:398
void SetState(PhyState state)
set the state of the device
Definition: wimax-phy.cc:198
Callback< void, bool, uint64_t > m_scanningCallback
scanning callback function
Definition: wimax-phy.h:476
virtual uint16_t DoGetRtg() const =0
Get RTG.
virtual double DoGetSamplingFrequency() const =0
Get sampling frequency.
virtual uint32_t DoGetDataRate(ModulationType modulationType) const =0
Get data rate.
uint32_t GetChannelBandwidth() const
Get the channel bandwidth.
Definition: wimax-phy.cc:338
uint16_t m_psPerSymbol
ps per sumbol
Definition: wimax-phy.h:484
EventId GetChnlSrchTimeoutEvent() const
Get channel search timeout event.
Definition: wimax-phy.cc:216
double GetSamplingFactor() const
Get the sampling factor.
Definition: wimax-phy.cc:350
void SetPhyParameters()
computes the Physical parameters and store them
Definition: wimax-phy.cc:284
Time m_frameDuration
in seconds
Definition: wimax-phy.h:479
bool IsDuplex() const
Check if configured in duplex mode.
Definition: wimax-phy.cc:210
Callback< void, Ptr< const PacketBurst > > GetReceiveCallback() const
Definition: wimax-phy.cc:160
void SetPsPerSymbol(uint16_t psPerSymbol)
set the number of physical slots per symbol
Definition: wimax-phy.cc:392
PhyState m_state
state
Definition: wimax-phy.h:473
uint64_t GetTxFrequency() const
Get the transmission frequency.
Definition: wimax-phy.cc:186
uint16_t GetRtg() const
Get the receive/transmit transition gap.
Definition: wimax-phy.cc:264
uint16_t GetTtg() const
Get the transmit/receive transition gap.
Definition: wimax-phy.cc:258
uint16_t GetNfft() const
Get the size of the FFT.
Definition: wimax-phy.cc:344
#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:86
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Definition: pointer.h:259
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition: nstime.h:1434
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1414
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Time timeout