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" 
   50     .AddAttribute (
"NoiseFigure",
 
   51                    "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.",
 
   54                    MakeDoubleChecker<double> ())
 
   56     .AddAttribute (
"TxPower",
 
   57                    "Transmission power (dB).",
 
   60                    MakeDoubleChecker<double> ())
 
   63                    "This is the ratio of CP time to useful time.",
 
   66                    MakeDoubleChecker<double> ())
 
   68     .AddAttribute (
"TxGain",
 
   69                    "Transmission gain (dB).",
 
   72                    MakeDoubleChecker<double> ())
 
   74     .AddAttribute (
"RxGain",
 
   75                    "Reception gain (dB).",
 
   78                    MakeDoubleChecker<double> ())
 
   80     .AddAttribute (
"Nfft",
 
   84                    MakeUintegerChecker<uint16_t> (256, 1024))
 
   86     .AddAttribute (
"TraceFilePath",
 
   87                    "Path to the directory containing SNR to block error rate files",
 
   97     .AddTraceSource (
"PhyTxBegin",
 
   98                      "Trace source indicating a packet has begun transmitting over the channel medium",
 
  101     .AddTraceSource (
"PhyTxEnd",
 
  102                      "Trace source indicating a packet has been completely transmitted over the channel",
 
  105     .AddTraceSource (
"PhyTxDrop",
 
  106                      "Trace source indicating a packet has been dropped by the device during transmission",
 
  109     .AddTraceSource (
"PhyRxBegin",
 
  110                      "Trace source indicating a packet has begun being received from the channel medium by the device",
 
  113     .AddTraceSource (
"PhyRxEnd",
 
  114                      "Trace source indicating a packet has been completely received from the channel medium by the device",
 
  117     .AddTraceSource (
"PhyRxDrop",
 
  118                      "Trace source indicating a packet has been dropped by the device during reception",
 
  143   m_g = (double) 1 / 4;
 
  158   m_URNG = CreateObject<UniformRandomVariable> ();
 
  282   bool isLastFecBlock = 0;
 
  293       isLastFecBlock = 
true;
 
  297       isLastFecBlock = 
false;
 
  352   double SNR = rxPower - Nwb;
 
  355   double I1 = record->
GetI1 ();
 
  356   double I2 = record->
GetI2 ();
 
  362   if (rand < blockErrorRate)
 
  366   if (rand > blockErrorRate)
 
  371   if (blockErrorRate == 1.0)
 
  375   if (blockErrorRate == 0.0)
 
  381   NS_LOG_INFO (
"PHY: Receive rxPower=" << rxPower << 
", Nwb=" << Nwb << 
", SNR=" << SNR << 
", Modulation=" 
  382                                        << modulationType << 
", BlocErrorRate=" << blockErrorRate << 
", drop=" << (
int) drop);
 
  476   bvec buffer (burst->GetSize () * 8, 0);
 
  478   std::list<Ptr<Packet> > packets = burst->GetPackets ();
 
  484       uint8_t *pstart = (uint8_t*) std::malloc (packet->
GetSize ());
 
  485       std::memset (pstart, 0, packet->
GetSize ());
 
  490       for (uint32_t i = 0; i < packet->
GetSize (); i++)
 
  492           for (uint8_t l = 0; l < 8; l++)
 
  494               temp[l] = (bool)((((uint8_t) pstart[i]) >> (7 - l)) & 0x01);
 
  495               buffer.at (j * 8 + l) = temp[l];
 
  516   uint8_t init[buffer.size () / 8];
 
  517   uint8_t *pstart = init;
 
  521   for (uint32_t i = 0; i < buffer.size (); i += 8)
 
  525       for (
int l = 0; l < 8; l++)
 
  527           bool bin = buffer.at (i + l);
 
  528           temp += (uint8_t)(bin * std::pow (2.0, (7 - l)));
 
  531       *(pstart + j) = temp;
 
  534   uint16_t bufferSize = buffer.size () / 8;
 
  537   while (pos < bufferSize)
 
  539       uint16_t packetSize = 0;
 
  541       uint8_t ht = (pstart[pos] >> 7) & 0x01;
 
  550           uint8_t Len_MSB = pstart[pos + 1] & 0x07;
 
  551           packetSize = (uint16_t)((uint16_t)(Len_MSB << 8) | (uint16_t)(pstart[pos + 2]));
 
  558       Ptr<Packet> p = Create<Packet> (&(pstart[pos]), packetSize);
 
  559       RecvBurst->AddPacket (p);
 
  575           fecBlock = 
bvec (buffer.begin () + i, buffer.end ());
 
  580           fecBlock = 
bvec (buffer.begin () + i, buffer.begin () + i + 
m_blockSize);
 
  597       buffer.insert (buffer.begin () + i, tmpRecFecBloc.begin (), tmpRecFecBloc.end ());
 
  618                                             uint8_t &bitsPerSymbol,
 
  619                                             double &fecCode)
 const 
  621   switch (modulationType)
 
  625       fecCode = (double) 1 / 2;
 
  629       fecCode = (double) 1 / 2;
 
  633       fecCode = (double) 3 / 4;
 
  637       fecCode = (double) 1 / 2;
 
  641       fecCode = (double) 3 / 4;
 
  645       fecCode = (double) 2 / 3;
 
  657   uint8_t bitsPerSymbol = 0;
 
  661   uint16_t bitsTransmittedPerSymbol = (uint16_t)(bitsPerSymbol * 
GetNrCarriers () * fecCode);
 
  664   return (uint32_t) symbolsPerSecond * bitsTransmittedPerSymbol;
 
  670   switch (modulationType)
 
  731   uint32_t blockSize = 0;
 
  732   switch (modulationType)
 
  759   return blockSize * 8; 
 
  766   uint32_t blockSize = 0;
 
  767   switch (modulationType)
 
  794   return blockSize * 8; 
 
  824   uint16_t duration = 0;
 
  876   switch (frameDurationCode)
 
  879       return Seconds (2.5);
 
  894       return Seconds (12.5);
 
  913   uint16_t nrBlocks = (burstSize * 8) / blockSize;
 
  915   if ((burstSize * 8) % blockSize > 0)
 
  936   Time psDuration = Seconds ((
double) 4 / samplingFrequency);
 
  941   double subcarrierSpacing = samplingFrequency / 
DoGetNfft ();
 
  942   double tb = (double) 1 / subcarrierSpacing; 
 
  944   Time symbolDuration = Seconds (tb + tg); 
 
  973   if (channelBandwidth % 1750000 == 0)
 
  975       return (
double) 8 / 7;
 
  977   else if (channelBandwidth % 1500000 == 0)
 
  979       return (
double) 86 / 75;
 
  981   else if (channelBandwidth % 1250000 == 0)
 
  983       return (
double) 144 / 125;
 
  985   else if (channelBandwidth % 2750000 == 0)
 
  987       return (
double) 316 / 275;
 
  989   else if (channelBandwidth % 2000000 == 0)
 
  991       return (
double) 57 / 50;
 
  995       NS_LOG_DEBUG (
"Oops may be wrong channel bandwidth for OFDM PHY!");
 
  999   return (
double) 8 / 7;
 
void SetNoiseFigure(double nf)
set the noise figure of the device 
 
uint32_t GetCodedFecBlockSize(WimaxPhy::ModulationType modulationType) const 
 
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 
 
keep track of time values and allow control of global simulation resolution 
 
~SimpleOfdmWimaxPhy(void)
 
Callback< void, Ptr< const PacketBurst > > GetReceiveCallback(void) const 
 
smart pointer class similar to boost::intrusive_ptr 
 
#define NS_LOG_FUNCTION(parameters)
 
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream. 
 
void SetSNRToBlockErrorRateTracesPath(char *tracesPath)
Set the path of the repository containing the traces. 
 
TracedCallback< Ptr< PacketBurst > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium. 
 
void EndReceiveFecBlock(uint32_t burstSize, WimaxPhy::ModulationType modulationType, uint8_t direction, uint8_t drop, Ptr< PacketBurst > burst)
 
hold variables of type string 
 
void Send(Ptr< PacketBurst > burst, WimaxPhy::ModulationType modulationType, uint8_t direction)
Sends a burst on the channel. 
 
double DoGetSamplingFrequency(void) const 
 
void NotifyRxDrop(Ptr< PacketBurst > burst)
Public method used to fire a PhyRxDrop trace. 
 
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
 
void NotifyRxBegin(Ptr< PacketBurst > burst)
Public method used to fire a PhyRxBegin trace. 
 
TracedCallback< Ptr< const PacketBurst > > m_traceRx
 
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
 
uint32_t m_dataRateQam64_23
 
bool IsDuplex(void) const 
 
void InitSimpleOfdmWimaxPhy(void)
 
uint32_t GetChannelBandwidth(void) const 
 
#define NS_ASSERT(condition)
 
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
 
std::string GetTraceFilePath(void)
 
std::list< bvec > * m_receivedFecBlocks
 
uint32_t GetSize(void) const 
 
SNRToBlockErrorRateManager * m_snrToBlockErrorRateManager
 
void SetSimplex(uint64_t frequency)
configure the physical layer in simplex mode 
 
void NotifyTxDrop(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxDrop trace. 
 
Time DoGetTransmissionTime(uint32_t size, WimaxPhy::ModulationType modulationType) const 
 
uint64_t GetRxFrequency(void) const 
 
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...
 
uint8_t DoGetFrameDurationCode(void) const 
 
Time GetSymbolDuration(void) const 
 
void NotifyTxBegin(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxBegin trace. 
 
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached. 
 
uint32_t DoGetDataRate(WimaxPhy::ModulationType modulationType) const 
 
void SetTraceFilePath(std::string path)
 
double DoGetSamplingFactor(void) const 
 
void SetSymbolsPerFrame(uint32_t symbolsPerFrame)
set the number of symbols per frame 
 
TracedCallback< Ptr< PacketBurst > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet as it tries to transmit it. 
 
double DoGetGValue(void) const 
 
void SetPsDuration(Time psDuration)
set the physical slot duration in seconds 
 
Time GetFrameDuration(void) const 
 
void SetBandwidth(uint32_t BW)
Set the bandwidth. 
 
#define NS_FATAL_ERROR(msg)
fatal error handling 
 
This class represents a record (handled by SnrToBlockErrorRate manager) that keeps a mapping between ...
 
void CreateFecBlocks(const bvec &buffer, WimaxPhy::ModulationType modulationType)
 
void EndSendFecBlock(WimaxPhy::ModulationType modulationType, uint8_t direction)
 
TracedCallback< Ptr< PacketBurst > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium. 
 
SNRToBlockErrorRateRecord * GetSNRToBlockErrorRateRecord(double SNR, uint8_t modulation)
returns a record of type SNRToBlockErrorRateRecord corresponding to a given modulation and SNR value ...
 
double GetTxGain(void) const 
 
Ptr< UniformRandomVariable > m_URNG
Provides uniform random variables. 
 
double GetSeconds(void) const 
 
bvec ConvertBurstToBits(Ptr< const PacketBurst > burst)
 
void DoSetDataRates(void)
 
double GetRxGain(void) const 
 
uint16_t m_nrRecivedFecBlocks
 
uint32_t m_nrFecBlocksSent
 
uint16_t DoGetTtg(void) const 
 
The SendParams class defines the parameters with which Send() function of a particular PHY is called...
 
Time GetBlockTransmissionTime(WimaxPhy::ModulationType modulationType) const 
 
Time DoGetFrameDuration(uint8_t frameDurationCode) const 
 
void SetScanningCallback(void) const 
calls the scanning call back function 
 
Hold an unsigned integer type. 
 
void Send(Time BlockTime, uint32_t burstSize, Ptr< WimaxPhy > phy, bool isFirstBlock, bool isLastBlock, uint64_t frequency, WimaxPhy::ModulationType modulationType, uint8_t direction, double txPowerDbm, Ptr< PacketBurst > burst)
Sends a dummy fec block to all connected physical devices. 
 
T * PeekPointer(const Ptr< T > &p)
 
uint32_t m_dataRateQpsk12
 
void EndReceive(Ptr< const PacketBurst > burst)
 
uint16_t DoGetNfft(void) const 
 
void ActivateLoss(bool loss)
If activate loss is called with false, all the returned BlcER will be 0 (no losses) ...
 
void SetPsPerSymbol(uint16_t psPerSymbol)
set the number of physical slots per symbol 
 
void SetTraceFilePath(char *traceFilePath)
Set the path of the repository containing the traces. 
 
Ptr< WimaxChannel > GetChannel(void) const 
 
void SetRxGain(double rxgain)
 
uint32_t m_dataRateQpsk34
 
uint8_t GetNrCarriers(void) const 
 
Ptr< PacketBurst > m_currentBurst
 
void LoadTraces(void)
Loads the traces form the repository specified in the constructor or setted by SetTraceFilePath funct...
 
void NotifyRxEnd(Ptr< PacketBurst > burst)
Public method used to fire a PhyRxEnd trace. 
 
void StartSendDummyFecBlock(bool isFirstBlock, WimaxPhy::ModulationType modulationType, uint8_t direction)
 
static TypeId GetTypeId(void)
 
void SetChannelBandwidth(uint32_t channelBandwidth)
Set the channel bandwidth. 
 
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
 
double GetTxPower(void) const 
 
uint8_t GetDirection() const 
 
void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
 
double GetNoiseFigure(void) const 
 
uint16_t DoGetRtg(void) const 
 
uint32_t m_currentBurstSize
 
uint16_t GetPsPerSymbol(void) const 
 
void DoAttach(Ptr< WimaxChannel > channel)
Attach the physical layer to a channel. 
 
void ActivateLoss(bool loss)
if called with true it will enable the loss model 
 
uint64_t DoGetNrBytes(uint32_t symbols, WimaxPhy::ModulationType modulationType) const 
 
uint64_t DoGetNrSymbols(uint32_t size, WimaxPhy::ModulationType modulationType) const 
 
void SetTxGain(double txgain)
 
void NotifyTxEnd(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxEnd trace. 
 
uint32_t CalculateDataRate(WimaxPhy::ModulationType modulationType) const 
 
uint32_t m_dataRateQam64_34
 
#define NS_ASSERT_MSG(condition, message)
 
TracedCallback< Ptr< PacketBurst > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium. 
 
std::string GetTraceFilePath(void) const 
 
void SetTxPower(double txPower)
set the transmission power 
 
TracedCallback< Ptr< PacketBurst > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium. ...
 
void SetSymbolDuration(Time symbolDuration)
set the OFMD symbol duration in second 
 
uint32_t m_dataRateBpsk12
 
uint16_t GetNrBlocks(uint32_t burstSize, WimaxPhy::ModulationType modulationType) const 
 
uint32_t GetBandwidth(void) const 
 
uint16_t m_nbErroneousBlock
 
#define NS_LOG_DEBUG(msg)
 
Ptr< PacketBurst > ConvertBitsToBurst(bvec buffer)
 
void SetState(PhyState state)
set the state of the device 
 
uint8_t GetModulationType() const 
 
uint32_t m_dataRateQam16_34
 
void SetBlockParameters(uint32_t burstSize, WimaxPhy::ModulationType modulationType)
 
WimaxPhy::PhyType GetPhyType(void) const 
returns the type this physical layer 
 
void SetNrCarriers(uint8_t nrCarriers)
Set the number of carriers in the physical frame. 
 
uint32_t CopyData(uint8_t *buffer, uint32_t size) const 
Copy the packet contents to a byte buffer. 
 
void GetModulationFecParams(WimaxPhy::ModulationType modulationType, uint8_t &bitsPerSymbol, double &fecCode) const 
 
Ptr< PacketBurst > GetBurst() const 
 
uint32_t GetFecBlockSize(WimaxPhy::ModulationType type) const 
 
uint64_t GetTxFrequency(void) const 
 
This class handles the SNR to BlcER traces. 
 
void DoSetPhyParameters(void)
 
EventId GetChnlSrchTimeoutEvent(void) const 
 
uint32_t m_dataRateQam16_12
 
void SetPsPerFrame(uint16_t psPerFrame)
set the number of physical slot per frame 
 
Hold a floating point type. 
 
uint16_t m_nrRemainingBlocksToSend
 
a unique identifier for an interface. 
 
TypeId SetParent(TypeId tid)
 
void ReLoadTraces(void)
Reloads the trace. 
 
PhyState GetState(void) const 
 
uint64_t GetScanningFrequency(void) const 
 
TracedCallback< Ptr< PacketBurst > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received. 
 
TracedCallback< Ptr< const PacketBurst > > m_traceTx
 
std::list< bvec > * m_fecBlocks
 
NS_LOG_COMPONENT_DEFINE("SimpleOfdmWimaxPhy")