22#include "ns3/simulator.h" 
   23#include "ns3/packet.h" 
   25#include "ns3/uinteger.h" 
   26#include "ns3/double.h" 
   27#include "ns3/string.h" 
   31#include "ns3/packet-burst.h" 
   34#include "ns3/trace-source-accessor.h" 
   48    .SetGroupName (
"Wimax")
 
   52    .AddAttribute (
"NoiseFigure",
 
   53                   "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.",
 
   56                   MakeDoubleChecker<double> ())
 
   58    .AddAttribute (
"TxPower",
 
   59                   "Transmission power (dB).",
 
   62                   MakeDoubleChecker<double> ())
 
   65                   "This is the ratio of CP time to useful time.",
 
   68                   MakeDoubleChecker<double> ())
 
   70    .AddAttribute (
"TxGain",
 
   71                   "Transmission gain (dB).",
 
   74                   MakeDoubleChecker<double> ())
 
   76    .AddAttribute (
"RxGain",
 
   77                   "Reception gain (dB).",
 
   80                   MakeDoubleChecker<double> ())
 
   82    .AddAttribute (
"Nfft",
 
   86                   MakeUintegerChecker<uint16_t> (256, 1024))
 
   88    .AddAttribute (
"TraceFilePath",
 
   89                   "Path to the directory containing SNR to block error rate files",
 
   95    .AddTraceSource (
"Rx", 
"Receive trace",
 
   97                     "ns3::PacketBurst::TracedCallback")
 
   98    .AddTraceSource (
"Tx", 
"Transmit trace",
 
  100                     "ns3::PacketBurst::TracedCallback")
 
  102    .AddTraceSource (
"PhyTxBegin",
 
  103                     "Trace source indicating a packet has begun transmitting over the channel medium",
 
  105                     "ns3::PacketBurst::TracedCallback")
 
  107    .AddTraceSource (
"PhyTxEnd",
 
  108                     "Trace source indicating a packet has been completely transmitted over the channel",
 
  110                     "ns3::PacketBurst::TracedCallback")
 
  112    .AddTraceSource (
"PhyTxDrop",
 
  113                     "Trace source indicating a packet has been dropped by the device during transmission",
 
  115                     "ns3::PacketBurst::TracedCallback")
 
  117    .AddTraceSource (
"PhyRxBegin",
 
  118                     "Trace source indicating a packet has begun being received from the channel medium by the device",
 
  120                     "ns3::PacketBurst::TracedCallback")
 
  122    .AddTraceSource (
"PhyRxEnd",
 
  123                     "Trace source indicating a packet has been completely received from the channel medium by the device",
 
  125                     "ns3::PacketBurst::TracedCallback")
 
  127    .AddTraceSource (
"PhyRxDrop",
 
  128                     "Trace source indicating a packet has been dropped by the device during reception",
 
  130                     "ns3::PacketBurst::TracedCallback");
 
  169  m_URNG = CreateObject<UniformRandomVariable> ();
 
  293  bool isLastFecBlock = 0;
 
  304      isLastFecBlock = 
true;
 
  308      isLastFecBlock = 
false;
 
  363  double SNR = rxPower - Nwb;
 
  366  double I1 = record->
GetI1 ();
 
  367  double I2 = record->
GetI2 ();
 
  373  if (rand < blockErrorRate)
 
  377  if (rand > blockErrorRate)
 
  382  if (blockErrorRate == 1.0)
 
  386  if (blockErrorRate == 0.0)
 
  392  NS_LOG_INFO (
"PHY: Receive rxPower=" << rxPower << 
", Nwb=" << Nwb << 
", SNR=" << SNR << 
", Modulation=" 
  393                                       << modulationType << 
", BlocErrorRate=" << blockErrorRate << 
", drop=" << (
int) drop);
 
  487  bvec buffer (burst->GetSize () * 8, 0);
 
  489  std::list<Ptr<Packet> > packets = burst->GetPackets ();
 
  495      uint8_t *pstart = (uint8_t*) std::malloc (packet->
GetSize ());
 
  496      std::memset (pstart, 0, packet->
GetSize ());
 
  503          for (uint8_t l = 0; l < 8; l++)
 
  505              temp[l] = (bool)((((uint8_t) pstart[i]) >> (7 - l)) & 0x01);
 
  506              buffer.at (j * 8 + l) = temp[l];
 
  527  uint8_t init[buffer.size () / 8];
 
  528  uint8_t *pstart = init;
 
  532  for (
uint32_t i = 0; i < buffer.size (); i += 8)
 
  536      for (
int l = 0; l < 8; l++)
 
  538          bool bin = buffer.at (i + l);
 
  539          temp += (uint8_t)(bin * std::pow (2.0, (7 - l)));
 
  542      *(pstart + j) = temp;
 
  545  uint16_t bufferSize = buffer.size () / 8;
 
  548  while (pos < bufferSize)
 
  552      uint8_t ht = (pstart[pos] >> 7) & 0x01;
 
  561          uint8_t Len_MSB = pstart[pos + 1] & 0x07;
 
  562          packetSize = (uint16_t)((uint16_t)(Len_MSB << 8) | (uint16_t)(pstart[pos + 2]));
 
  570      RecvBurst->AddPacket (p);
 
  586          fecBlock = 
bvec (buffer.begin () + i, buffer.end ());
 
  591          fecBlock = 
bvec (buffer.begin () + i, buffer.begin () + i + 
m_blockSize);
 
  608      buffer.insert (buffer.begin () + i, tmpRecFecBloc.begin (), tmpRecFecBloc.end ());
 
  629                                            uint8_t &bitsPerSymbol,
 
  630                                            double &fecCode)
 const 
  632  switch (modulationType)
 
  668  uint8_t bitsPerSymbol = 0;
 
  672  uint16_t bitsTransmittedPerSymbol = (uint16_t)(bitsPerSymbol * 
GetNrCarriers () * fecCode);
 
  675  return (
uint32_t) symbolsPerSecond * bitsTransmittedPerSymbol;
 
  681  switch (modulationType)
 
  743  switch (modulationType)
 
  770  return blockSize * 8; 
 
  778  switch (modulationType)
 
  805  return blockSize * 8; 
 
  835  uint16_t duration = 0;
 
  887  switch (frameDurationCode)
 
  924  uint16_t nrBlocks = (burstSize * 8) / blockSize;
 
  926  if ((burstSize * 8) % blockSize > 0)
 
  947  Time psDuration = 
Seconds ((
double) 4 / samplingFrequency);
 
  952  double subcarrierSpacing = samplingFrequency / 
DoGetNfft ();
 
  953  double tb = (
double) 1 / subcarrierSpacing; 
 
  984  if (channelBandwidth % 1750000 == 0)
 
  986      return (
double) 8 / 7;
 
  988  else if (channelBandwidth % 1500000 == 0)
 
  990      return (
double) 86 / 75;
 
  992  else if (channelBandwidth % 1250000 == 0)
 
  994      return (
double) 144 / 125;
 
  996  else if (channelBandwidth % 2750000 == 0)
 
  998      return (
double) 316 / 275;
 
 1000  else if (channelBandwidth % 2000000 == 0)
 
 1002      return (
double) 57 / 50;
 
 1006      NS_LOG_DEBUG (
"Oops may be wrong channel bandwidth for OFDM PHY!");
 
 1010  return (
double) 8 / 7;
 
This class can be used to hold variables of floating point type such as 'double' or 'float'.
 
Ptr< PacketBurst > GetBurst() const
 
uint8_t GetModulationType() const
 
uint8_t GetDirection() const
 
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
 
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
 
Smart pointer class similar to boost::intrusive_ptr.
 
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
 
This class handles the SNR to BlcER traces.
 
void ActivateLoss(bool loss)
If activate loss is called with false, all the returned BlcER will be 0 (no losses)
 
void ReLoadTraces(void)
Reloads the trace.
 
std::string GetTraceFilePath(void)
 
SNRToBlockErrorRateRecord * GetSNRToBlockErrorRateRecord(double SNR, uint8_t modulation)
returns a record of type SNRToBlockErrorRateRecord corresponding to a given modulation and SNR value
 
void SetTraceFilePath(char *traceFilePath)
Set the path of the repository containing the traces.
 
void LoadTraces(void)
Loads the traces form the repository specified in the constructor or set by SetTraceFilePath function...
 
This class represents a record (handled by SnrToBlockErrorRate manager) that keeps a mapping between ...
 
The SendParams class defines the parameters with which Send() function of a particular PHY is called.
 
SimpleOfdmWimaxChannel class.
 
SimpleOfdmWimaxPhy class.
 
void GetModulationFecParams(WimaxPhy::ModulationType modulationType, uint8_t &bitsPerSymbol, double &fecCode) const
Get moduleation FEC parameters.
 
void NotifyRxBegin(Ptr< PacketBurst > burst)
Public method used to fire a PhyRxBegin trace.
 
TracedCallback< Ptr< PacketBurst > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
 
double GetNoiseFigure(void) const
 
void NotifyRxEnd(Ptr< PacketBurst > burst)
Public method used to fire a PhyRxEnd trace.
 
static TypeId GetTypeId(void)
Get the type ID.
 
uint32_t m_dataRateQpsk12
data rate
 
TracedCallback< Ptr< PacketBurst > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
 
double m_txPower
transmit power
 
double DoGetSamplingFactor(void) const
Get sampling factor.
 
uint32_t DoGetDataRate(WimaxPhy::ModulationType modulationType) const
Get data rate.
 
TracedCallback< Ptr< PacketBurst > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
 
void EndReceive(Ptr< const PacketBurst > burst)
End receive.
 
void DoSetGValue(double g)
Set G value.
 
uint32_t CalculateDataRate(WimaxPhy::ModulationType modulationType) const
Calculate data rate.
 
TracedCallback< Ptr< PacketBurst > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
 
void StartSendDummyFecBlock(bool isFirstBlock, WimaxPhy::ModulationType modulationType, uint8_t direction)
Start end dummy FEC block.
 
TracedCallback< Ptr< PacketBurst > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium.
 
double m_txGain
transmit gain
 
void EndSend(void)
End send.
 
uint16_t DoGetTtg(void) const
Get TTG.
 
void ActivateLoss(bool loss)
if called with true it will enable the loss model
 
uint32_t m_dataRateQam16_34
data rate
 
uint16_t m_nbErroneousBlock
erroneous blocks
 
uint16_t m_nrBlocks
number of blocks
 
WimaxPhy::PhyType GetPhyType(void) const
returns the type this physical layer
 
uint16_t m_blockSize
block size
 
Time DoGetFrameDuration(uint8_t frameDurationCode) const
Get frame duration.
 
void SetTraceFilePath(std::string path)
Set trace file path.
 
void DoSetPhyParameters(void)
Set Phy parameters.
 
double m_rxGain
receive gain
 
void SetNoiseFigure(double nf)
set the noise figure of the device
 
void SetRxGain(double rxgain)
Set receive gsain.
 
void EndSendFecBlock(WimaxPhy::ModulationType modulationType, uint8_t direction)
End send FEC block.
 
uint32_t m_dataRateQpsk34
data rate
 
Ptr< PacketBurst > m_currentBurst
current burst
 
Ptr< UniformRandomVariable > m_URNG
Provides uniform random variables.
 
double DoGetGValue(void) const
Get G value.
 
void DoSetNfft(uint16_t nfft)
Set NFFT.
 
void NotifyRxDrop(Ptr< PacketBurst > burst)
Public method used to fire a PhyRxDrop trace.
 
uint16_t GetNrBlocks(uint32_t burstSize, WimaxPhy::ModulationType modulationType) const
Get number of blocks.
 
void EndReceiveFecBlock(uint32_t burstSize, WimaxPhy::ModulationType modulationType, uint8_t direction, uint8_t drop, Ptr< PacketBurst > burst)
End receive FEC block.
 
uint16_t m_nrRecivedFecBlocks
number received FEC blocks
 
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
 
void NotifyTxEnd(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxEnd trace.
 
double m_noiseFigure
noise figure
 
void SetBlockParameters(uint32_t burstSize, WimaxPhy::ModulationType modulationType)
Set block parameters.
 
uint16_t DoGetNfft(void) const
Get NFFT.
 
uint32_t m_dataRateQam64_34
data rate
 
uint32_t m_dataRateBpsk12
data rate
 
bvec ConvertBurstToBits(Ptr< const PacketBurst > burst)
Convert burst to bits.
 
void SetTxPower(double txPower)
set the transmission power
 
~SimpleOfdmWimaxPhy(void)
 
uint64_t DoGetNrBytes(uint32_t symbols, WimaxPhy::ModulationType modulationType) const
Get number of bytes.
 
uint64_t DoGetNrSymbols(uint32_t size, WimaxPhy::ModulationType modulationType) const
Get number of symbols.
 
@ FRAME_DURATION_12_POINT_5_MS
 
@ FRAME_DURATION_2_POINT_5_MS
 
SNRToBlockErrorRateManager * m_snrToBlockErrorRateManager
SNR to block error rate manager.
 
TracedCallback< Ptr< const PacketBurst > > m_traceTx
trace transmit callback
 
std::string GetTraceFilePath(void) const
Get trace file path.
 
std::list< bvec > * m_fecBlocks
the FEC blocks
 
double DoGetSamplingFrequency(void) const
Get sampling frequency.
 
double GetTxGain(void) const
Get transmit gain.
 
uint32_t m_dataRateQam16_12
data rate
 
uint8_t DoGetFrameDurationCode(void) const
Get frame duration code.
 
double GetTxPower(void) const
 
void DoAttach(Ptr< WimaxChannel > channel)
Attach the physical layer to a channel.
 
uint32_t GetBandwidth(void) const
 
uint32_t GetCodedFecBlockSize(WimaxPhy::ModulationType modulationType) const
Get coded FEC block size.
 
std::list< bvec > * m_receivedFecBlocks
a list of received FEC blocks until they are combined to recreate the full burst buffer
 
uint32_t GetFecBlockSize(WimaxPhy::ModulationType type) const
Get FEC block size.
 
void SetTxGain(double txgain)
Set transmit gain.
 
uint16_t m_nrRemainingBlocksToSend
number of remaining blocks to send
 
void SetBandwidth(uint32_t BW)
Set the bandwidth.
 
void InitSimpleOfdmWimaxPhy(void)
Initialize simple OFDM WIMAX Phy.
 
Time GetBlockTransmissionTime(WimaxPhy::ModulationType modulationType) const
Get block transmission time.
 
void Send(Ptr< PacketBurst > burst, WimaxPhy::ModulationType modulationType, uint8_t direction)
Sends a burst on the channel.
 
uint16_t DoGetRtg(void) const
Get RTG.
 
Ptr< PacketBurst > ConvertBitsToBurst(bvec buffer)
Convert bits to burst.
 
void DoDispose(void)
Destructor implementation.
 
void SetSNRToBlockErrorRateTracesPath(char *tracesPath)
Set the path of the repository containing the traces.
 
uint32_t m_currentBurstSize
current burst size
 
void NotifyTxDrop(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxDrop trace.
 
bvec RecreateBuffer()
Recreate buffer.
 
void NotifyTxBegin(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxBegin trace.
 
void DoSetDataRates(void)
Set data rates.
 
uint32_t m_paddingBits
padding bits
 
Time DoGetTransmissionTime(uint32_t size, WimaxPhy::ModulationType modulationType) const
Get transmission time.
 
Time m_blockTime
block time
 
void CreateFecBlocks(const bvec &buffer, WimaxPhy::ModulationType modulationType)
Create FEC blocks.
 
TracedCallback< Ptr< PacketBurst > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet as it tries to transmit it.
 
uint16_t m_fecBlockSize
in bits, size of FEC block transmitted after PHY operations
 
double GetRxGain(void) const
Get receive gain.
 
TracedCallback< Ptr< const PacketBurst > > m_traceRx
trace receive callback
 
uint32_t m_dataRateQam64_23
data rate
 
void StartReceive(uint32_t burstSize, bool isFirstBlock, uint64_t frequency, WimaxPhy::ModulationType modulationType, uint8_t direction, double rxPower, Ptr< PacketBurst > burst)
start the reception of a fec block
 
uint32_t m_nrFecBlocksSent
counting the number of FEC blocks sent (within a burst)
 
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
 
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
 
Hold variables of type string.
 
Simulation virtual time values and global simulation resolution.
 
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
 
a unique identifier for an interface.
 
TypeId SetParent(TypeId tid)
Set the parent TypeId.
 
Hold an unsigned integer type.
 
uint8_t GetNrCarriers(void) const
Get the number of carriers in the physical frame.
 
ModulationType
ModulationType enumeration.
 
@ MODULATION_TYPE_QPSK_12
 
@ MODULATION_TYPE_QAM16_12
 
@ MODULATION_TYPE_QAM64_34
 
@ MODULATION_TYPE_QAM16_34
 
@ MODULATION_TYPE_QAM64_23
 
@ MODULATION_TYPE_QPSK_34
 
@ MODULATION_TYPE_BPSK_12
 
void SetSymbolDuration(Time symbolDuration)
set the OFDM symbol duration
 
void SetChannelBandwidth(uint32_t channelBandwidth)
Set the channel bandwidth.
 
Time GetSymbolDuration(void) const
Get the OFDM symbol duration.
 
PhyType
PhyType enumeration.
 
virtual void DoDispose(void)
Destructor implementation.
 
void SetSymbolsPerFrame(uint32_t symbolsPerFrame)
set the number of symbols per frame
 
Time GetFrameDuration(void) const
Get the frame duration.
 
void SetNrCarriers(uint8_t nrCarriers)
Set the number of carriers in the physical frame.
 
Ptr< WimaxChannel > GetChannel(void) const
 
uint32_t GetChannelBandwidth(void) const
Get the channel bandwidth.
 
void SetPsPerFrame(uint16_t psPerFrame)
set the number of physical slots per frame
 
uint64_t GetTxFrequency(void) const
Get the transmission frequency.
 
Callback< void, Ptr< const PacketBurst > > GetReceiveCallback(void) const
 
bool IsDuplex(void) const
Check if configured in duplex mode.
 
void SetSimplex(uint64_t frequency)
configure the physical layer in simplex mode
 
EventId GetChnlSrchTimeoutEvent(void) const
Get channel search timeout event.
 
uint64_t GetScanningFrequency(void) const
Get the scanning frequency.
 
void SetPsDuration(Time psDuration)
set the physical slot duration
 
void SetState(PhyState state)
set the state of the device
 
uint64_t GetRxFrequency(void) const
Get the reception frequency.
 
PhyState GetState(void) const
Get the state of the device.
 
void SetPsPerSymbol(uint16_t psPerSymbol)
set the number of physical slots per symbol
 
void SetScanningCallback(void) const
calls the scanning call back function
 
uint16_t GetPsPerSymbol(void) const
Get the number of physical slots per symbol.
 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
 
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
 
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
 
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
 
Ptr< const AttributeChecker > MakeStringChecker(void)
 
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
 
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
 
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
 
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
 
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
 
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
 
Time Seconds(double value)
Construct a Time in the indicated unit.
 
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
 
Every class exported by the ns3 library is enclosed in the ns3 namespace.
 
U * PeekPointer(const Ptr< U > &p)
 
std::vector< bool > bvec
boolean vector typedef
 
static const uint32_t packetSize
Pcket size generated at the AP.