A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wimax-phy.h
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#ifndef WIMAX_PHY_H
10#define WIMAX_PHY_H
11
12#include "bvec.h"
13#include "send-params.h"
14
15#include "ns3/callback.h"
16#include "ns3/event-id.h"
17#include "ns3/log.h"
18#include "ns3/nstime.h"
19#include "ns3/object.h"
20#include "ns3/traced-callback.h"
21
22#include <list>
23#include <stdint.h>
24
25namespace ns3
26{
27
28class WimaxChannel;
29class WimaxNetDevice;
30class NetDevice;
31class Packet;
32
33/**
34 * \ingroup wimax
35 *
36 * WiMAX PHY entity
37 */
38class WimaxPhy : public Object
39{
40 public:
41 /// ModulationType enumeration
52
53 /// PhyState enumeration
61
62 /// PhyType enumeration
68
69 /**
70 * \brief Get the type ID.
71 * \return the object TypeId
72 */
73 static TypeId GetTypeId();
74 WimaxPhy();
75 ~WimaxPhy() override;
76 /**
77 * Attach the physical layer to a channel.
78 * \param channel the channel to which the physical layer will be attached
79 */
80 void Attach(Ptr<WimaxChannel> channel);
81 /**
82 * \return the channel to which this physical layer is attached
83 */
85 /**
86 * \brief Set the device in which this physical layer is installed
87 * \param device the device in which this physical layer is installed
88 */
89 void SetDevice(Ptr<WimaxNetDevice> device);
90 /**
91 * \return the the device in which this physical layer is installed
92 */
94 /**
95 * \brief set the callback function to call when a burst is received
96 * \param callback the callback function to call when a burst is received
97 */
99 /**
100 * \return the receive callback
101 */
103 /**
104 * \brief send a packet on the channel
105 * \param params the parameters used to send the packet
106 */
107 virtual void Send(SendParams* params) = 0;
108 /**
109 * \brief Get the type of the physical layer
110 * \returns the phy type
111 */
112 virtual PhyType GetPhyType() const = 0;
113 /**
114 * \brief configure the physical layer in duplex mode
115 * \param rxFrequency the reception frequency
116 * \param txFrequency the transmission frequency
117 */
118 void SetDuplex(uint64_t rxFrequency, uint64_t txFrequency);
119 /**
120 * \brief configure the physical layer in simplex mode
121 * \param frequency the frequency to be used for reception and transmission process
122 */
123 void SetSimplex(uint64_t frequency);
124 /**
125 * Get the reception frequency
126 * \return the reception frequency
127 */
128 uint64_t GetRxFrequency() const;
129 /**
130 * Get the transmission frequency
131 * \return the transmission frequency
132 */
133 uint64_t GetTxFrequency() const;
134 /**
135 * Get the scanning frequency
136 * \return the scanning frequency
137 */
138 uint64_t GetScanningFrequency() const;
139 /**
140 * Set the number of carriers in the physical frame
141 * \brief Set the number of carriers in the physical frame
142 * \param nrCarriers the number of carriers in the frame
143 */
144 void SetNrCarriers(uint8_t nrCarriers);
145 /**
146 * Get the number of carriers in the physical frame
147 * \return the number of carriers in the physical frame
148 */
149 uint8_t GetNrCarriers() const;
150 /**
151 * \brief Set the frame duration
152 * \param frameDuration the frame duration
153 */
154 void SetFrameDuration(Time frameDuration);
155 /**
156 * \brief Get the frame duration
157 * This method is redundant with GetFrameDuration ()
158 * \return the frame duration
159 */
161 /**
162 * \brief Get the frame duration
163 * \return the frame duration
164 */
165 Time GetFrameDuration() const;
166 /**
167 * \brief set the frequency on which the device should lock
168 * \param frequency the frequency to configure
169 */
170 void SetFrequency(uint32_t frequency);
171 /**
172 * Get the frequency on which the device is locked
173 * \return the frequency on which the device is locked
174 */
175 uint32_t GetFrequency() const;
176 /**
177 * \brief Set the channel bandwidth
178 * \param channelBandwidth The channel bandwidth
179 */
180 void SetChannelBandwidth(uint32_t channelBandwidth);
181 /**
182 * Get the channel bandwidth
183 * \return the channel bandwidth
184 */
186 /**
187 * Get the size of the FFT
188 * \return the size of the FFT
189 */
190 uint16_t GetNfft() const;
191 /**
192 * Get the sampling factor
193 * \return the sampling factor
194 */
195 double GetSamplingFactor() const;
196 /**
197 * Get the sampling frequency
198 * \return the sampling frequency
199 */
200 double GetSamplingFrequency() const;
201 /**
202 * \brief set the physical slot duration
203 * \param psDuration the physical slot duration
204 */
205 void SetPsDuration(Time psDuration);
206 /**
207 * Get the physical slot duration
208 * \return the physical slot duration
209 */
210 Time GetPsDuration() const;
211 /**
212 * \brief set the OFDM symbol duration
213 * \param symbolDuration the symbol duration
214 */
215 void SetSymbolDuration(Time symbolDuration);
216 /**
217 * Get the OFDM symbol duration
218 * \return the symbol duration in second
219 */
220 Time GetSymbolDuration() const;
221 /**
222 * Get the guard interval factor (the ratio TG/Td)
223 * \return the guard interval factor
224 */
225 double GetGValue() const;
226 /**
227 * \brief set the number of physical slots per symbol
228 * \param psPerSymbol the number of physical slots per symbol
229 */
230 void SetPsPerSymbol(uint16_t psPerSymbol);
231 /**
232 * Get the number of physical slots per symbol
233 * \return the number of physical slots per symbol
234 */
235 uint16_t GetPsPerSymbol() const;
236
237 /**
238 * \brief set the number of physical slots per frame
239 * \param psPerFrame the number of physical slots per frame
240 */
241 void SetPsPerFrame(uint16_t psPerFrame);
242 /**
243 * Get the number of physical slots per frame
244 * \return the number of physical slot per frame
245 */
246 uint16_t GetPsPerFrame() const;
247 /**
248 * \brief set the number of symbols per frame
249 * \param symbolsPerFrame the number of symbols per frame
250 */
251 void SetSymbolsPerFrame(uint32_t symbolsPerFrame);
252 /**
253 * Get the number of symbols per frame
254 * \return the number of symbols per frame
255 */
257 /**
258 * Check if configured in duplex mode
259 * \return true if the device is configured in duplex mode
260 */
261 bool IsDuplex() const;
262 /**
263 * \brief set the state of the device
264 * \param state the state to be set (PHY_STATE_IDLE, PHY_STATE_SCANNING, PHY_STATE_TX,
265 * PHY_STATE_RX)
266 */
267 void SetState(PhyState state);
268 /**
269 * Get the state of the device
270 * \return the state of the device (PHY_STATE_IDLE, PHY_STATE_SCANNING, PHY_STATE_TX,
271 * PHY_STATE_RX)
272 */
273 PhyState GetState() const;
274 /**
275 * \brief scan a frequency for maximum timeout seconds and call the callback if the frequency
276 * can be used
277 * \param frequency the frequency to scan
278 * \param timeout the timeout before considering the channel as unusable
279 * \param callback the function to call if the channel could be used
280 */
281 void StartScanning(uint64_t frequency, Time timeout, Callback<void, bool, uint64_t> callback);
282
283 /**
284 * \brief calls the scanning call back function
285 */
286 void SetScanningCallback() const;
287 /**
288 * \brief Get channel search timeout event
289 * \return event ID
290 */
292 /**
293 * \brief calculates the data rate of each modulation and save them for future use
294 */
295 void SetDataRates();
296 /**
297 * Get the data rate corresponding to a modulation type
298 * \return the data rate
299 * \param modulationType the modulation that you want to get its data rate
300 */
301 uint32_t GetDataRate(ModulationType modulationType) const;
302 /**
303 * Get transmission time needed to send bytes at a given modulation
304 * \return the time needed
305 * \param size the number of byte to transmit
306 * \param modulationType the modulation that will be used to transmit the bytes
307 */
308 Time GetTransmissionTime(uint32_t size, ModulationType modulationType) const;
309 /**
310 * Get the number of symbols needed to transmit size bytes using the modulation modulationType
311 * \return the number of symbols needed
312 * \param size the number of byte to transmit
313 * \param modulationType the modulation that will be used to transmit the bytes
314 */
315 uint64_t GetNrSymbols(uint32_t size, ModulationType modulationType) const;
316 /**
317 * Get the maximum number of bytes that could be carried by symbols symbols using the modulation
318 * modulationType
319 * \param symbols the number of symbols to use
320 * \param modulationType the modulation that will be used
321 * \return the maximum number of bytes
322 */
323 uint64_t GetNrBytes(uint32_t symbols, ModulationType modulationType) const;
324 /**
325 * Get the transmit/receive transition gap
326 * \return the transmit/receive transition gap
327 */
328 uint16_t GetTtg() const;
329 /**
330 * Get the receive/transmit transition gap
331 * \return the receive/transmit transition gap
332 */
333 uint16_t GetRtg() const;
334 /**
335 * Get the frame duration code
336 * \return the frame duration code
337 */
338 uint8_t GetFrameDurationCode() const;
339 /**
340 * Get the frame duration corresponding to a given code
341 * \param frameDurationCode the frame duration code to use
342 * \return the frame duration
343 */
344 Time GetFrameDuration(uint8_t frameDurationCode) const;
345 /**
346 * \brief computes the Physical parameters and store them
347 */
348 void SetPhyParameters();
349 void DoDispose() override;
350
351 /**
352 * Assign a fixed random variable stream number to the random variables
353 * used by this model. Return the number of streams (possibly zero) that
354 * have been assigned.
355 *
356 * \param stream first stream index to use
357 * \return the number of stream indices assigned by this model
358 */
359 virtual int64_t AssignStreams(int64_t stream) = 0;
360
361 private:
362 /**
363 * Get modulation FEC parameters
364 * \param modulationType the modultion type
365 * \param bitsPerSymbol the number of bits per symbol page
366 * \param fecCode the FEC code
367 */
369 uint8_t& bitsPerSymbol,
370 double& fecCode) const;
371 /// End scanning
372 void EndScanning();
373 /**
374 * Get transmission time
375 * \param size the transmission size
376 * \param modulationType the modulation type
377 * \returns the transmission time
378 */
379 virtual Time DoGetTransmissionTime(uint32_t size, ModulationType modulationType) const = 0;
380 /**
381 * Attach channel
382 * \param channel the wimax channel
383 */
384 virtual void DoAttach(Ptr<WimaxChannel> channel) = 0;
385 /// Set data rates
386 virtual void DoSetDataRates() = 0;
387 /**
388 * Get data rate
389 * \param modulationType the modulation type
390 * \returns the data rate
391 */
392 virtual uint32_t DoGetDataRate(ModulationType modulationType) const = 0;
393 /**
394 * Get number of symbols
395 * \param size the transmission size
396 * \param modulationType the modulation type
397 * \returns the number of symbols
398 */
399 virtual uint64_t DoGetNrSymbols(uint32_t size, ModulationType modulationType) const = 0;
400 /**
401 * Get number of bytes
402 * \param symbols the number of symbols
403 * \param modulationType the modulation type
404 * \returns the number of bytes
405 */
406 virtual uint64_t DoGetNrBytes(uint32_t symbols, ModulationType modulationType) const = 0;
407 /**
408 * Get TTG
409 * \returns the TTG
410 */
411 virtual uint16_t DoGetTtg() const = 0;
412 /**
413 * Get RTG
414 * \returns the RTG
415 */
416 virtual uint16_t DoGetRtg() const = 0;
417
418 /**
419 * Get frame duration code
420 * \returns the frame duration code
421 */
422 virtual uint8_t DoGetFrameDurationCode() const = 0;
423 /**
424 * Get frame duration
425 * \param frameDurationCode the frame duration code
426 * \returns the frame duration time
427 */
428 virtual Time DoGetFrameDuration(uint8_t frameDurationCode) const = 0;
429 /**
430 * Set phy parameters
431 */
432 virtual void DoSetPhyParameters() = 0;
433 /**
434 * Get sampling factor
435 * \return the sampling factor
436 */
437 virtual double DoGetSamplingFactor() const = 0;
438 /**
439 * Get NFFT
440 * \returns the NFFT
441 */
442 virtual uint16_t DoGetNfft() const = 0;
443 /**
444 * Get sampling frequency
445 * \returns the sampling frequency
446 */
447 virtual double DoGetSamplingFrequency() const = 0;
448 /**
449 * Get G value
450 * \returns he G value
451 */
452 virtual double DoGetGValue() const = 0;
453
456
457 uint64_t m_txFrequency; ///< transmit frequency
458 uint64_t m_rxFrequency; ///< receive frequency
459 uint64_t m_scanningFrequency; ///< scanning frequency
460 EventId m_dlChnlSrchTimeoutEvent; ///< DL channel search timeout event
461 bool m_duplex; ///< duplex
462 PhyState m_state; ///< state
463
465 Callback<void, bool, uint64_t> m_scanningCallback; ///< scanning callback function
466
467 uint8_t m_nrCarriers; ///< number of carriers
468 Time m_frameDuration; ///< in seconds
471 Time m_psDuration; ///< in seconds
472 Time m_symbolDuration; ///< in seconds
473 uint16_t m_psPerSymbol; ///< ps per sumbol
474 uint16_t m_psPerFrame; ///< ps per framce
475 uint32_t m_symbolsPerFrame; ///< symbols per frame
476};
477
478} // namespace ns3
479
480#endif /* WIMAX_PHY_H */
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
Smart pointer class similar to boost::intrusive_ptr.
The SendParams class defines the parameters with which Send() function of a particular PHY is called.
Definition send-params.h:31
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
WiMAX PHY entity.
Definition wimax-phy.h:39
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
@ MODULATION_TYPE_QPSK_12
Definition wimax-phy.h:45
@ MODULATION_TYPE_QAM16_12
Definition wimax-phy.h:47
@ MODULATION_TYPE_QAM64_34
Definition wimax-phy.h:50
@ MODULATION_TYPE_QAM16_34
Definition wimax-phy.h:48
@ MODULATION_TYPE_QAM64_23
Definition wimax-phy.h:49
@ MODULATION_TYPE_QPSK_34
Definition wimax-phy.h:46
@ MODULATION_TYPE_BPSK_12
Definition wimax-phy.h:44
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.
virtual int64_t AssignStreams(int64_t stream)=0
Assign a fixed random variable stream number to the random variables used by this model.
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
PhyType
PhyType enumeration.
Definition wimax-phy.h:64
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.
virtual void Send(SendParams *params)=0
send a packet on the 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 PhyType GetPhyType() const =0
Get the type of the physical layer.
virtual uint32_t DoGetDataRate(ModulationType modulationType) const =0
Get data rate.
void GetModulationFecParams(ModulationType modulationType, uint8_t &bitsPerSymbol, double &fecCode) const
Get modulation FEC parameters.
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Time timeout