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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
7 */
8
9#include "wimax-phy.h"
10
11#include "wimax-channel.h"
12#include "wimax-net-device.h"
13
14#include "ns3/double.h"
15#include "ns3/node.h"
16#include "ns3/packet-burst.h"
17#include "ns3/packet.h"
18#include "ns3/pointer.h"
19#include "ns3/simulator.h"
20#include "ns3/trace-source-accessor.h"
21#include "ns3/uinteger.h"
22
23namespace ns3
24{
25
26NS_LOG_COMPONENT_DEFINE("WimaxPhy");
27
29
30TypeId
32{
33 static TypeId tid =
34 TypeId("ns3::WimaxPhy")
36 .SetGroupName("Wimax")
37
38 // No AddConstructor because this is an abstract class.
39
40 .AddAttribute("Channel",
41 "Wimax channel",
45
46 .AddAttribute(
47 "FrameDuration",
48 "The frame duration in seconds.",
49 TimeValue(Seconds(0.01)),
52
53 .AddAttribute("Frequency",
54 "The central frequency in KHz.",
55 UintegerValue(5000000),
57 MakeUintegerChecker<uint32_t>(1000000, 11000000))
58
59 .AddAttribute("Bandwidth",
60 "The channel bandwidth in Hz.",
61 UintegerValue(10000000),
64 MakeUintegerChecker<uint32_t>(5000000, 30000000))
65
66 ;
67 return tid;
68}
69
71 : m_state(PHY_STATE_IDLE),
72 m_nrCarriers(0),
73 m_frameDuration(Seconds(0.01)),
74 m_frequency(5000000),
75 m_channelBandwidth(10000000),
76 m_psDuration(Seconds(0)),
77 m_symbolDuration(Seconds(0)),
78 m_psPerSymbol(0),
79 m_psPerFrame(0),
80 m_symbolsPerFrame(0)
81{
82 m_duplex = false;
83 m_txFrequency = 0;
84 m_rxFrequency = 0;
85}
86
90
91void
93{
94 m_device = nullptr;
95 m_channel = nullptr;
96}
97
98void
100{
101 m_channel = channel;
102 DoAttach(channel);
103}
104
107{
108 return m_channel;
109}
110
111void
113{
114 m_device = device;
115}
116
119{
120 return m_device;
121}
122
123void
125{
128 "Error while scanning: The PHY state should be PHY_STATE_SCANNING or PHY_STATE_IDLE");
129
131 m_scanningFrequency = frequency;
133 m_scanningCallback = callback;
134}
135
136void
141
142void
147
150{
151 return m_rxCallback;
152}
153
154void
155WimaxPhy::SetDuplex(uint64_t rxFrequency, uint64_t txFrequency)
156{
157 m_txFrequency = txFrequency;
158 m_rxFrequency = rxFrequency;
159}
160
161void
162WimaxPhy::SetSimplex(uint64_t frequency)
163{
164 m_txFrequency = frequency;
165 m_rxFrequency = frequency;
166}
167
168uint64_t
170{
171 return m_rxFrequency;
172}
173
174uint64_t
176{
177 return m_txFrequency;
178}
179
180uint64_t
185
186void
188{
189 m_state = state;
190}
191
194{
195 return m_state;
196}
197
198bool
200{
201 return m_duplex;
202}
203
209
210void
215
216void
221
224{
225 return DoGetDataRate(modulationType);
226}
227
228Time
230{
231 return DoGetTransmissionTime(size, modulationType);
232}
233
234uint64_t
236{
237 return DoGetNrSymbols(size, modulationType);
238}
239
240uint64_t
242{
243 return DoGetNrBytes(symbols, modulationType);
244}
245
246uint16_t
248{
249 return DoGetTtg();
250}
251
252uint16_t
254{
255 return DoGetRtg();
256}
257
258uint8_t
263
264Time
265WimaxPhy::GetFrameDuration(uint8_t frameDurationCode) const
266{
267 return DoGetFrameDuration(frameDurationCode);
268}
269
270/*---------------------PHY parameters functions-----------------------*/
271
272void
277
278void
279WimaxPhy::SetNrCarriers(uint8_t nrCarriers)
280{
281 m_nrCarriers = nrCarriers;
282}
283
284uint8_t
286{
287 return m_nrCarriers;
288}
289
290void
292{
293 m_frameDuration = frameDuration;
294}
295
296Time
298{
299 return GetFrameDurationSec();
300}
301
302Time
304{
305 return m_frameDuration;
306}
307
308void
310{
311 m_frequency = frequency;
312}
313
316{
317 return m_frequency;
318}
319
320void
322{
323 m_channelBandwidth = channelBandwidth;
324}
325
331
332uint16_t
334{
335 return DoGetNfft();
336}
337
338double
340{
341 return DoGetSamplingFactor();
342}
343
344double
349
350void
352{
353 m_psDuration = psDuration;
354}
355
356Time
358{
359 return m_psDuration;
360}
361
362void
364{
365 m_symbolDuration = symbolDuration;
366}
367
368Time
370{
371 return m_symbolDuration;
372}
373
374double
376{
377 return DoGetGValue();
378}
379
380void
381WimaxPhy::SetPsPerSymbol(uint16_t psPerSymbol)
382{
383 m_psPerSymbol = psPerSymbol;
384}
385
386uint16_t
388{
389 return m_psPerSymbol;
390}
391
392void
393WimaxPhy::SetPsPerFrame(uint16_t psPerFrame)
394{
395 m_psPerFrame = psPerFrame;
396}
397
398uint16_t
400{
401 return m_psPerFrame;
402}
403
404void
406{
407 m_symbolsPerFrame = symbolsPerFrame;
408}
409
415
416} // namespace ns3
Callback template class.
Definition callback.h:422
An identifier for simulation events.
Definition event-id.h:45
A base class which provides memory management and object aggregation.
Definition object.h:78
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold an unsigned integer type.
Definition uinteger.h:34
Time GetTransmissionTime(uint32_t size, ModulationType modulationType) const
Get transmission time needed to send bytes at a given modulation.
Definition wimax-phy.cc:229
Time GetFrameDuration() const
Get the frame duration.
Definition wimax-phy.cc:297
ModulationType
ModulationType enumeration.
Definition wimax-phy.h:43
virtual double DoGetGValue() const =0
Get G value.
bool m_duplex
duplex
Definition wimax-phy.h:461
void SetSymbolDuration(Time symbolDuration)
set the OFDM symbol duration
Definition wimax-phy.cc:363
Ptr< WimaxChannel > GetChannel() const
Definition wimax-phy.cc:106
uint32_t GetSymbolsPerFrame() const
Get the number of symbols per frame.
Definition wimax-phy.cc:411
void SetChannelBandwidth(uint32_t channelBandwidth)
Set the channel bandwidth.
Definition wimax-phy.cc:321
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:241
virtual uint8_t DoGetFrameDurationCode() const =0
Get frame duration code.
uint64_t m_txFrequency
transmit frequency
Definition wimax-phy.h:457
~WimaxPhy() override
Definition wimax-phy.cc:87
void SetDuplex(uint64_t rxFrequency, uint64_t txFrequency)
configure the physical layer in duplex mode
Definition wimax-phy.cc:155
EventId m_dlChnlSrchTimeoutEvent
DL channel search timeout event.
Definition wimax-phy.h:460
uint64_t GetRxFrequency() const
Get the reception frequency.
Definition wimax-phy.cc:169
Time GetFrameDurationSec() const
Get the frame duration This method is redundant with GetFrameDuration ()
Definition wimax-phy.cc:303
void SetDataRates()
calculates the data rate of each modulation and save them for future use
Definition wimax-phy.cc:217
uint16_t GetPsPerFrame() const
Get the number of physical slots per frame.
Definition wimax-phy.cc:399
Time GetSymbolDuration() const
Get the OFDM symbol duration.
Definition wimax-phy.cc:369
uint8_t GetNrCarriers() const
Get the number of carriers in the physical frame.
Definition wimax-phy.cc:285
uint32_t m_channelBandwidth
in Hz
Definition wimax-phy.h:470
Time m_psDuration
in seconds
Definition wimax-phy.h:471
PhyState GetState() const
Get the state of the device.
Definition wimax-phy.cc:193
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:99
uint16_t m_psPerFrame
ps per framce
Definition wimax-phy.h:474
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:309
uint32_t m_symbolsPerFrame
symbols per frame
Definition wimax-phy.h:475
uint8_t GetFrameDurationCode() const
Get the frame duration code.
Definition wimax-phy.cc:259
void SetDevice(Ptr< WimaxNetDevice > device)
Set the device in which this physical layer is installed.
Definition wimax-phy.cc:112
uint64_t m_rxFrequency
receive frequency
Definition wimax-phy.h:458
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:124
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:143
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:405
Ptr< WimaxNetDevice > m_device
the device
Definition wimax-phy.h:454
void SetScanningCallback() const
calls the scanning call back function
Definition wimax-phy.cc:211
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:345
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:279
Ptr< WimaxChannel > m_channel
channel
Definition wimax-phy.h:455
Time GetPsDuration() const
Get the physical slot duration.
Definition wimax-phy.cc:357
static TypeId GetTypeId()
Get the type ID.
Definition wimax-phy.cc:31
uint64_t m_scanningFrequency
scanning frequency
Definition wimax-phy.h:459
void DoDispose() override
Destructor implementation.
Definition wimax-phy.cc:92
uint32_t GetFrequency() const
Get the frequency on which the device is locked.
Definition wimax-phy.cc:315
double GetGValue() const
Get the guard interval factor (the ratio TG/Td)
Definition wimax-phy.cc:375
Ptr< NetDevice > GetDevice() const
Definition wimax-phy.cc:118
void SetPsPerFrame(uint16_t psPerFrame)
set the number of physical slots per frame
Definition wimax-phy.cc:393
PhyState
PhyState enumeration.
Definition wimax-phy.h:55
uint32_t GetDataRate(ModulationType modulationType) const
Get the data rate corresponding to a modulation type.
Definition wimax-phy.cc:223
virtual Time DoGetTransmissionTime(uint32_t size, ModulationType modulationType) const =0
Get transmission time.
uint32_t m_frequency
in KHz
Definition wimax-phy.h:469
virtual Time DoGetFrameDuration(uint8_t frameDurationCode) const =0
Get frame duration.
uint8_t m_nrCarriers
number of carriers
Definition wimax-phy.h:467
void SetSimplex(uint64_t frequency)
configure the physical layer in simplex mode
Definition wimax-phy.cc:162
Callback< void, Ptr< const PacketBurst > > m_rxCallback
receive callback function
Definition wimax-phy.h:464
void SetFrameDuration(Time frameDuration)
Set the frame duration.
Definition wimax-phy.cc:291
uint64_t GetScanningFrequency() const
Get the scanning frequency.
Definition wimax-phy.cc:181
Time m_symbolDuration
in seconds
Definition wimax-phy.h:472
void SetPsDuration(Time psDuration)
set the physical slot duration
Definition wimax-phy.cc:351
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:235
void EndScanning()
End scanning.
Definition wimax-phy.cc:137
uint16_t GetPsPerSymbol() const
Get the number of physical slots per symbol.
Definition wimax-phy.cc:387
void SetState(PhyState state)
set the state of the device
Definition wimax-phy.cc:187
Callback< void, bool, uint64_t > m_scanningCallback
scanning callback function
Definition wimax-phy.h:465
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:327
uint16_t m_psPerSymbol
ps per sumbol
Definition wimax-phy.h:473
EventId GetChnlSrchTimeoutEvent() const
Get channel search timeout event.
Definition wimax-phy.cc:205
double GetSamplingFactor() const
Get the sampling factor.
Definition wimax-phy.cc:339
void SetPhyParameters()
computes the Physical parameters and store them
Definition wimax-phy.cc:273
Time m_frameDuration
in seconds
Definition wimax-phy.h:468
bool IsDuplex() const
Check if configured in duplex mode.
Definition wimax-phy.cc:199
Callback< void, Ptr< const PacketBurst > > GetReceiveCallback() const
Definition wimax-phy.cc:149
void SetPsPerSymbol(uint16_t psPerSymbol)
set the number of physical slots per symbol
Definition wimax-phy.cc:381
PhyState m_state
state
Definition wimax-phy.h:462
uint64_t GetTxFrequency() const
Get the transmission frequency.
Definition wimax-phy.cc:175
uint16_t GetRtg() const
Get the receive/transmit transition gap.
Definition wimax-phy.cc:253
uint16_t GetTtg() const
Get the transmit/receive transition gap.
Definition wimax-phy.cc:247
uint16_t GetNfft() const
Get the size of the FFT.
Definition wimax-phy.cc:333
#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:75
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:248
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Definition pointer.h:269
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition nstime.h:1396
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition uinteger.h:35
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1416
ns3::Time timeout