21 #include "ns3/simulator.h"
22 #include "ns3/packet.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"
37 NS_OBJECT_ENSURE_REGISTERED (WimaxPhy);
39 TypeId WimaxPhy::GetTypeId (
void)
41 static TypeId tid = TypeId (
"ns3::WimaxPhy").SetParent<Object> ()
43 .AddAttribute (
"Channel",
47 MakePointerChecker<WimaxChannel> ())
49 .AddAttribute (
"FrameDuration",
50 "The frame duration in seconds.",
55 .AddAttribute (
"Frequency",
56 "The central frequency in KHz.",
57 UintegerValue (5000000),
59 MakeUintegerChecker<uint32_t> (1000000, 11000000))
61 .AddAttribute (
"Bandwidth",
62 "The channel bandwidth in Hz.",
63 UintegerValue (10000000),
65 MakeUintegerChecker<uint32_t> (5000000, 30000000))
71 WimaxPhy::WimaxPhy (
void)
72 : m_state (PHY_STATE_IDLE),
74 m_frameDuration (
Seconds (0.01)),
75 m_frequency (5000000),
76 m_channelBandwidth (10000000),
90 WimaxPhy::~WimaxPhy (
void)
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");
132 m_state = PHY_STATE_SCANNING;
133 m_scanningFrequency = frequency;
135 m_scanningCallback = callback;
139 WimaxPhy::EndScanning (
void)
141 m_scanningCallback (
false, m_scanningFrequency);
147 m_rxCallback = callback;
159 m_txFrequency = txFrequency;
160 m_rxFrequency = rxFrequency;
166 m_txFrequency = frequency;
167 m_rxFrequency = frequency;
173 return m_rxFrequency;
179 return m_txFrequency;
185 return m_scanningFrequency;
206 WimaxPhy::GetChnlSrchTimeoutEvent (
void)
const
208 return m_dlChnlSrchTimeoutEvent;
226 return DoGetDataRate (modulationType);
232 return DoGetTransmissionTime (size, modulationType);
238 return DoGetNrSymbols (size, modulationType);
244 return DoGetNrBytes (symbols, modulationType);
260 WimaxPhy::GetFrameDurationCode (
void)
const
262 return DoGetFrameDurationCode ();
268 return DoGetFrameDuration (frameDurationCode);
276 DoSetPhyParameters ();
282 m_nrCarriers = nrCarriers;
294 m_frameDuration = frameDuration;
306 return m_frameDuration;
312 m_frequency = frequency;
324 m_channelBandwidth = channelBandwidth;
330 return m_channelBandwidth;
342 return DoGetSamplingFactor ();
348 return DoGetSamplingFrequency ();
354 m_psDuration = psDuration;
366 m_symbolDuration = symbolDuration;
372 return m_symbolDuration;
378 return DoGetGValue ();
384 m_psPerSymbol = psPerSymbol;
390 return m_psPerSymbol;
396 m_psPerFrame = psPerFrame;
408 m_symbolsPerFrame = symbolsPerFrame;
414 return m_symbolsPerFrame;
425 m_mobility = mobility;
Time GetPsDuration(void) const
Callback< void, Ptr< const PacketBurst > > GetReceiveCallback(void) const
smart pointer class similar to boost::intrusive_ptr
void SetFrequency(uint32_t frequency)
set the frequency on which the device should lock
void SetFrameDuration(Time frameDuration)
Set the frame duration.
virtual void DoDispose(void)
bool IsDuplex(void) const
uint32_t GetChannelBandwidth(void) const
uint32_t GetSymbolsPerFrame(void) const
#define NS_LOG_COMPONENT_DEFINE(name)
void SetSimplex(uint64_t frequency)
configure the physical layer in simplex mode
uint64_t GetRxFrequency(void) const
double GetSamplingFactor(void) const
Time GetSymbolDuration(void) const
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
void SetSymbolsPerFrame(uint32_t symbolsPerFrame)
set the number of symbols per frame
void SetPsDuration(Time psDuration)
set the physical slot duration in seconds
Time GetFrameDuration(void) const
void SetReceiveCallback(Callback< void, Ptr< const PacketBurst > > callback)
set the callback function to call when a burst is received
Time GetTransmissionTime(uint32_t size, ModulationType modulationType) const
uint16_t GetTtg(void) const
void SetScanningCallback(void) const
calls the scanning call back function
uint16_t GetNfft(void) const
void SetPsPerSymbol(uint16_t psPerSymbol)
set the number of physical slots per symbol
uint64_t GetNrSymbols(uint32_t size, ModulationType modulationType) const
Ptr< WimaxChannel > GetChannel(void) const
Time GetFrameDurationSec(void) const
uint8_t GetNrCarriers(void) const
double GetGValue(void) const
void SetChannelBandwidth(uint32_t channelBandwidth)
Set the channel bandwidth.
uint64_t GetNrBytes(uint32_t symbols, ModulationType modulationType) const
uint16_t GetPsPerSymbol(void) const
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...
Ptr< NetDevice > GetDevice(void) const
#define NS_ASSERT_MSG(condition, message)
void Attach(Ptr< WimaxChannel > channel)
void SetSymbolDuration(Time symbolDuration)
set the OFMD symbol duration in second
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
uint16_t GetPsPerFrame(void) const
an identifier for simulation events.
virtual Ptr< Object > GetMobility(void)
void SetDuplex(uint64_t rxFrequency, uint64_t txFrequency)
configure the physical layer in duplex mode
void SetDevice(Ptr< WimaxNetDevice > device)
Set the device in which this physical layer is installed.
void SetState(PhyState state)
set the state of the device
uint16_t GetRtg(void) const
void SetDataRates(void)
calculates the data rate of each modulation and save them for future use
uint32_t GetDataRate(ModulationType modulationType) const
void SetNrCarriers(uint8_t nrCarriers)
Set the number of carriers in the physical frame.
double GetSamplingFrequency(void) const
uint64_t GetTxFrequency(void) const
void SetPsPerFrame(uint16_t psPerFrame)
set the number of physical slot per frame
uint32_t GetFrequency(void) const
void SetPhyParameters(void)
computes the Physical parameters and store them
virtual void SetMobility(Ptr< Object > mobility)
set the mobility model of the device
PhyState GetState(void) const
uint64_t GetScanningFrequency(void) const