24 #include <ns3/object-factory.h> 
   27 #include <ns3/simulator.h> 
   28 #include <ns3/trace-source-accessor.h> 
   29 #include <ns3/antenna-model.h> 
   36 #include <ns3/lte-mi-error-model.h> 
   37 #include <ns3/lte-radio-bearer-tag.h> 
   38 #include <ns3/boolean.h> 
   39 #include <ns3/double.h> 
   40 #include <ns3/config.h> 
  118   m_transmissionMode (0),
 
  122   m_random = CreateObject<UniformRandomVariable> ();
 
  128   for (uint8_t i = 0; i < 7; i++)
 
  191     .AddTraceSource (
"TxStart",
 
  192                      "Trace fired when a new transmission is started",
 
  194     .AddTraceSource (
"TxEnd",
 
  195                      "Trace fired when a previosuly started transmission is finished",
 
  197     .AddTraceSource (
"RxStart",
 
  198                      "Trace fired when the start of a signal is detected",
 
  200     .AddTraceSource (
"RxEndOk",
 
  201                      "Trace fired when a previosuly started RX terminates successfully",
 
  203     .AddTraceSource (
"RxEndError",
 
  204                      "Trace fired when a previosuly started RX terminates with an error",
 
  206     .AddAttribute (
"DataErrorModelEnabled",
 
  207                     "Activate/Deactivate the error model of data (TBs of PDSCH and PUSCH) [by default is active].",
 
  210                     MakeBooleanChecker ())
 
  211     .AddAttribute (
"CtrlErrorModelEnabled",
 
  212                     "Activate/Deactivate the error model of control (PCFICH-PDCCH decodification) [by default is active].",
 
  215                     MakeBooleanChecker ())
 
  216     .AddTraceSource (
"DlPhyReception",
 
  217                      "DL reception PHY layer statistics.",
 
  219     .AddTraceSource (
"UlPhyReception",
 
  220                      "DL reception PHY layer statistics.",
 
  431       NS_FATAL_ERROR (
"cannot TX while RX: according to FDD channel acces, the physical layer for transmission cannot be used for reception");
 
  435       NS_FATAL_ERROR (
"cannot TX while already TX: the MAC should avoid this");
 
  455       txParams->duration = duration;
 
  456       txParams->txPhy = GetObject<SpectrumPhy> ();
 
  459       txParams->packetBurst = pb;
 
  460       txParams->ctrlMsgList = ctrlMsgList;
 
  488       NS_FATAL_ERROR (
"cannot TX while RX: according to FDD channel acces, the physical layer for transmission cannot be used for reception");
 
  492       NS_FATAL_ERROR (
"cannot TX while already TX: the MAC should avoid this");
 
  513       txParams->txPhy = GetObject<SpectrumPhy> ();
 
  518       txParams->ctrlMsgList = ctrlMsgList;
 
  545       NS_FATAL_ERROR (
"cannot TX while RX: according to FDD channel acces, the physical layer for transmission cannot be used for reception");
 
  549       NS_FATAL_ERROR (
"cannot TX while already TX: the MAC should avoid this");
 
  570       txParams->txPhy = GetObject<SpectrumPhy> ();
 
  621   Time duration = spectrumRxParams->duration;
 
  626   if (lteDataRxParams != 0)
 
  635       if ((lteDlCtrlRxParams!=0)||(lteUlSrsRxParams!=0))
 
  657         NS_FATAL_ERROR (
"cannot RX while TX: according to FDD channel access, the physical layer for transmission cannot be used for reception");
 
  673               NS_LOG_LOGIC (
this << 
" synchronized with this signal (cellId=" << params->cellId << 
")");
 
  681                   NS_LOG_LOGIC (
this << 
" scheduling EndRx with delay " << params->duration.GetSeconds () << 
"s");
 
  696               if (params->packetBurst)
 
  703                 NS_LOG_DEBUG (
this << 
" insert msgs " << params->ctrlMsgList.size ());
 
  710               NS_LOG_LOGIC (
this << 
" not in sync with this signal (cellId="  
  711               << params->cellId  << 
", m_cellId=" << 
m_cellId << 
")");
 
  733       NS_FATAL_ERROR (
"cannot RX while TX: according to FDD channel access, the physical layer for transmission cannot be used for reception");
 
  750         if (lteDlCtrlRxParams!=0)
 
  752             cellId = lteDlCtrlRxParams->cellId;
 
  758             cellId = lteUlSrsRxParams->cellId;
 
  764               if (lteDlCtrlRxParams->pss == 
true)
 
  775           NS_LOG_LOGIC (
this << 
" synchronized with this signal (cellId=" << cellId << 
")");
 
  783             NS_LOG_LOGIC (
this << 
" scheduling EndRx with delay " << params->duration);
 
  812           NS_LOG_LOGIC (
this << 
" not in sync with this signal (cellId="  
  813           << cellId  << 
", m_cellId=" << 
m_cellId << 
")");          
 
  836 LteSpectrumPhy::AddExpectedTb (uint16_t  rnti, uint8_t ndi, uint16_t size, uint8_t mcs, std::vector<int> map, uint8_t layer, uint8_t harqId,uint8_t rv,  
bool downlink)
 
  838   NS_LOG_FUNCTION (
this << 
" rnti: " << rnti << 
" NDI " << (uint16_t)ndi << 
" size " << size << 
" mcs " << (uint16_t)mcs << 
" layer " << (uint16_t)layer << 
" rv " << (uint16_t)rv);
 
  842   expectedTbs_t::iterator it;
 
  850   tbInfo_t tbInfo = {ndi, size, mcs, map, harqId, rv, 0.0, downlink, 
false, 
false};
 
  851   m_expectedTbs.insert (std::pair<TbId_t, tbInfo_t> (tbId,tbInfo));
 
  881           if ((*itTb).second.ndi == 0)
 
  884               uint16_t ulHarqId = 0;
 
  885               if ((*itTb).second.downlink)
 
  887                   harqInfoList = 
m_harqPhyModule->GetHarqProcessInfoDl ((*itTb).second.harqProcessId, (*itTb).first.m_layer);
 
  891                   harqInfoList = 
m_harqPhyModule->GetHarqProcessInfoUl ((*itTb).first.m_rnti, ulHarqId);
 
  895           (*itTb).second.mi = tbStats.
mi;
 
  897           NS_LOG_DEBUG (
this << 
"RNTI " << (*itTb).first.m_rnti << 
" size " << (*itTb).second.size << 
" mcs " << (uint32_t)(*itTb).second.mcs << 
" bitmap " << (*itTb).second.rbBitmap.size () << 
" layer " << (uint16_t)(*itTb).first.m_layer << 
" TBLER " << tbStats.
tbler << 
" corrupted " << (*itTb).second.corrupt);
 
  903           params.
m_rnti = (*itTb).first.m_rnti;
 
  905           params.
m_layer =  (*itTb).first.m_layer;
 
  906           params.
m_mcs = (*itTb).second.mcs;
 
  907           params.
m_size = (*itTb).second.size;
 
  908           params.
m_rv = (*itTb).second.rv;
 
  909           params.
m_ndi = (*itTb).second.ndi;
 
  911           if ((*itTb).second.downlink)
 
  919               params.
m_rv = harqInfoList.size ();
 
  926     std::map <uint16_t, DlInfoListElement_s> harqDlInfoMap;
 
  934             (*j)->PeekPacketTag (tag);
 
  942                 if (!(*itTb).second.corrupt)
 
  958                 if (!(*itTb).second.harqFeedbackSent)
 
  960                     (*itTb).second.harqFeedbackSent = 
true;
 
  961                     if (!(*itTb).second.downlink)
 
  965                         harqUlInfo.
m_tpc = 0;
 
  966                         if ((*itTb).second.corrupt)
 
  985                         std::map <uint16_t, DlInfoListElement_s>::iterator itHarq = harqDlInfoMap.find (tbId.
m_rnti);
 
  986                         if (itHarq==harqDlInfoMap.end ())
 
  992                             if ((*itTb).second.corrupt)
 
  995                                 NS_LOG_DEBUG (
this << 
" RNTI " << tbId.
m_rnti << 
" harqId " << (uint16_t)(*itTb).second.harqProcessId << 
" layer " <<(uint16_t)tbId.
m_layer << 
" send DL-HARQ-NACK");
 
 1002                                 NS_LOG_DEBUG (
this << 
" RNTI " << tbId.
m_rnti << 
" harqId " << (uint16_t)(*itTb).second.harqProcessId << 
" layer " <<(uint16_t)tbId.
m_layer << 
" size " << (*itTb).second.size << 
" send DL-HARQ-ACK");
 
 1003                                 m_harqPhyModule->ResetDlHarqProcessStatus ((*itTb).second.harqProcessId);
 
 1005                             harqDlInfoMap.insert (std::pair <uint16_t, DlInfoListElement_s> (tbId.
m_rnti, harqDlInfo));
 
 1009                           if ((*itTb).second.corrupt)
 
 1012                               NS_LOG_DEBUG (
this << 
" RNTI " << tbId.
m_rnti << 
" harqId " << (uint16_t)(*itTb).second.harqProcessId << 
" layer " <<(uint16_t)tbId.
m_layer << 
" size " << (*itHarq).second.m_harqStatus.size () << 
" send DL-HARQ-NACK");
 
 1019                               NS_LOG_DEBUG (
this << 
" RNTI " << tbId.
m_rnti << 
" harqId " << (uint16_t)(*itTb).second.harqProcessId << 
" layer " << (uint16_t)tbId.
m_layer << 
" size " << (*itHarq).second.m_harqStatus.size () << 
" send DL-HARQ-ACK");
 
 1020                               m_harqPhyModule->ResetDlHarqProcessStatus ((*itTb).second.harqProcessId);
 
 1030   std::map <uint16_t, DlInfoListElement_s>::iterator itHarq;
 
 1031   for (itHarq = harqDlInfoMap.begin (); itHarq != harqDlInfoMap.end (); itHarq++)
 
 1079       NS_LOG_DEBUG (
this << 
" PCFICH-PDCCH Decodification, errorRate " << errorRate << 
" error " << error);
 
 1162   NS_LOG_FUNCTION (
this << 
" txmode " << (uint16_t)txMode << 
" gain " << gain);
 
 1164   gain = std::pow (10.0, (gain / 10.0));
 
 1169   std::vector <double> temp;
 
 1172   for (uint8_t i = 0; i < temp.size (); i++)
 
static const Time UL_SRS_DURATION
 
Ptr< LteHarqPhy > m_harqPhyModule
 
void SetLtePhyTxEndCallback(LtePhyTxEndCallback c)
set the callback for the end of a TX, as part of the interconnections between the PHY and the MAC ...
 
Simulation virtual time values and global simulation resolution. 
 
smart pointer class similar to boost::intrusive_ptr 
 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
 
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream. 
 
void StartRxData(Ptr< LteSpectrumSignalParametersDataFrame > params)
 
Abstract base class for Spectrum-aware PHY layers. 
 
Ptr< LteInterference > m_interferenceCtrl
 
LtePhyRxCtrlEndOkCallback m_ltePhyRxCtrlEndOkCallback
 
uint8_t m_mcs
MCS for transport block. 
 
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory. 
 
TracedCallback< Ptr< const PacketBurst > > m_phyTxEndTrace
 
uint16_t GetRnti(void) const 
 
void SetState(State newState)
Set the state of the phy layer. 
 
bool IsNull(void) const 
Check for null implementation. 
 
void AddInterferenceCtrlChunkProcessor(Ptr< LteSinrChunkProcessor > p)
LteSinrChunkProcessor devoted to evaluate interference + noise power in control symbols of the subfra...
 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
 
uint8_t m_rv
the redundancy version (HARQ) 
 
TracedCallback< Ptr< const Packet > > m_phyRxEndErrorTrace
 
void SetLtePhyRxDataEndErrorCallback(LtePhyRxDataEndErrorCallback c)
set the callback for the end of a RX in error, as part of the interconnections between the PHY and th...
 
Channel is IDLE, no packet is being transmitted. 
 
void SetTxModeGain(uint8_t txMode, double gain)
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
LtePhyRxCtrlEndErrorCallback m_ltePhyRxCtrlEndErrorCallback
 
void SetTransmissionMode(uint8_t txMode)
 
Ptr< SpectrumChannel > m_channel
 
std::list< Ptr< LteControlMessage > > m_txControlMessageList
 
LtePhyTxEndCallback m_ltePhyTxEndCallback
 
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
 
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO. 
 
#define NS_FATAL_ERROR(msg)
fatal error handling 
 
expectedTbs_t m_expectedTbs
 
Ptr< LteInterference > m_interferenceData
 
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached. 
 
Ptr< SpectrumChannel > GetChannel()
 
LtePhyRxDataEndErrorCallback m_ltePhyRxDataEndErrorCallback
 
See section 4.3.12 ulInfoListElement. 
 
static TbStats_t GetTbDecodificationStats(const SpectrumValue &sinr, const std::vector< int > &map, uint16_t size, uint8_t mcs, HarqProcessInfoList_t miHistory)
run the error-model algorithm for the specified TB 
 
void SetNoisePowerSpectralDensity(Ptr< const SpectrumValue > noisePsd)
set the noise power spectral density 
 
Ptr< UniformRandomVariable > m_random
Provides uniform random variables. 
 
void SetDevice(Ptr< NetDevice > d)
set the associated NetDevice instance 
 
std::list< Ptr< PacketBurst > > m_rxPacketBurstList
 
static const Time DL_CTRL_DURATION
 
void SetLtePhyUlHarqFeedbackCallback(LtePhyUlHarqFeedbackCallback c)
set the callback for the UL HARQ feedback as part of the interconnections between the LteSpectrumPhy ...
 
void ChangeState(State newState)
 
std::list< Ptr< LteControlMessage > > m_rxControlMessageList
 
void SetLtePhyRxCtrlEndOkCallback(LtePhyRxCtrlEndOkCallback c)
set the callback for the successful end of a RX ctrl frame, as part of the interconnections between t...
 
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
set the Power Spectral Density of outgoing signals in W/Hz. 
 
void SetLtePhyRxCtrlEndErrorCallback(LtePhyRxCtrlEndErrorCallback c)
set the callback for the erroneous end of a RX ctrl frame, as part of the interconnections between th...
 
Ptr< AntennaModel > m_antenna
 
TracedCallback< Ptr< const PacketBurst > > m_phyRxStartTrace
 
LtePhyRxDataEndOkCallback m_ltePhyRxDataEndOkCallback
 
static uint8_t TxMode2LayerNum(uint8_t txMode)
 
static const double EffectiveCodingRate[29]
 
bool StartTxDataFrame(Ptr< PacketBurst > pb, std::list< Ptr< LteControlMessage > > ctrlMsgList, Time duration)
Start a transmission of data frame in DL and UL. 
 
uint8_t m_transmissionMode
 
uint8_t m_layer
the layer (cw) of the transmission 
 
Ptr< MobilityModel > m_mobility
 
void SetHarqPhyModule(Ptr< LteHarqPhy > harq)
 
virtual ~LteSpectrumPhy()
 
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
 
static double GetPcfichPdcchError(const SpectrumValue &sinr)
run the error-model algorithm for the specified PCFICH+PDCCH channels 
 
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC. 
 
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
 
See section 4.3.23 dlInfoListElement. 
 
bool operator<(const int64x64_t &lhs, const int64x64_t &rhs)
Less than operator. 
 
void StartRxCtrl(Ptr< SpectrumSignalParameters > params)
 
Ptr< NetDevice > GetDevice()
get the associated NetDevice instance 
 
Ptr< SpectrumValue > m_txPsd
 
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output 
 
Ptr< Packet > Copy(void) const 
performs a COW copy of the packet. 
 
void SetAntenna(Ptr< AntennaModel > a)
set the AntennaModel to be used 
 
void AddRsPowerChunkProcessor(Ptr< LteSinrChunkProcessor > p)
 
EventId m_endRxDlCtrlEvent
 
bool m_dataErrorModelEnabled
 
uint8_t m_ndi
new data indicator flag 
 
void AddExpectedTb(uint16_t rnti, uint8_t ndi, uint16_t size, uint8_t mcs, std::vector< int > map, uint8_t layer, uint8_t harqId, uint8_t rv, bool downlink)
 
Ptr< const SpectrumModel > GetRxSpectrumModel() const 
 
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
 
Ptr< AntennaModel > GetRxAntenna()
get the AntennaModel used by the NetDevice for reception 
 
Ptr< MobilityModel > GetMobility()
get the associated MobilityModel instance 
 
Ptr< const SpectrumModel > m_rxSpectrumModel
 
LtePhyDlHarqFeedbackCallback m_ltePhyDlHarqFeedbackCallback
 
std::vector< enum HarqStatus_e > m_harqStatus
 
Ptr< PacketBurst > m_txPacketBurst
 
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device. 
 
uint8_t m_txMode
the transmission Mode 
 
uint16_t m_size
Size of transport block. 
 
void Reset()
reset the internal state 
 
TracedCallback< PhyReceptionStatParameters > m_ulPhyReception
Trace information regarding PHY stats from UL Rx perspective PhyReceptionStatParameters (see lte-comm...
 
static Time Now(void)
Return the "current simulation time". 
 
Ptr< NetDevice > m_device
 
bool m_ctrlErrorModelEnabled
 
uint8_t m_correctness
correctness of the TB received 
 
LtePhyUlHarqFeedbackCallback m_ltePhyUlHarqFeedbackCallback
 
static TypeId GetTypeId(void)
 
TracedCallback< Ptr< const Packet > > m_phyRxEndOkTrace
 
bool StartTxDlCtrlFrame(std::list< Ptr< LteControlMessage > > ctrlMsgList, bool pss)
Start a transmission of control frame in DL. 
 
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
 
uint16_t m_rnti
C-RNTI scheduled. 
 
uint16_t m_cellId
Cell ID of the attached Enb. 
 
void SetLtePhyDlHarqFeedbackCallback(LtePhyDlHarqFeedbackCallback c)
set the callback for the DL HARQ feedback as part of the interconnections between the LteSpectrumPhy ...
 
void AddCtrlSinrChunkProcessor(Ptr< LteSinrChunkProcessor > p)
 
void AddDataSinrChunkProcessor(Ptr< LteSinrChunkProcessor > p)
 
void SetLtePhyRxPssCallback(LtePhyRxPssCallback c)
set the callback for the reception of the PSS as part of the interconnections between the LteSpectrum...
 
LtePhyRxPssCallback m_ltePhyRxPssCallback
 
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG. 
 
bool operator==(const EventId &a, const EventId &b)
 
void AddInterferenceDataChunkProcessor(Ptr< LteSinrChunkProcessor > p)
LteSinrChunkProcessor devoted to evaluate interference + noise power in data symbols of the subframe...
 
EventId m_endRxUlSrsEvent
 
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method. 
 
Tag used to define the RNTI and LC id for each MAC packet trasmitted. 
 
void SetLtePhyRxDataEndOkCallback(LtePhyRxDataEndOkCallback c)
set the callback for the successful end of a RX, as part of the interconnections between the PHY and ...
 
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device. 
 
enum ns3::UlInfoListElement_s::ReceptionStatus_e m_receptionStatus
 
void StartRx(Ptr< SpectrumSignalParameters > params)
Notify the SpectrumPhy instance of an incoming signal. 
 
Hold a floating point type. 
 
TracedCallback< Ptr< const PacketBurst > > m_phyTxStartTrace
 
void SetAttribute(std::string name, const AttributeValue &value)
 
Set of values corresponding to a given SpectrumModel. 
 
uint64_t m_imsi
IMSI of the scheduled UE. 
 
a unique identifier for an interface. 
 
uint8_t GetLayer(void) const 
 
void UpdateSinrPerceived(const SpectrumValue &sinr)
 
int64_t GetMilliSeconds(void) const 
 
TypeId SetParent(TypeId tid)
 
bool StartTxUlSrsFrame()
Start a transmission of control frame in UL. 
 
void SetCellId(uint16_t cellId)
 
SpectrumValue m_sinrPerceived
 
std::vector< double > m_txModeGain
 
TracedCallback< PhyReceptionStatParameters > m_dlPhyReception
Trace information regarding PHY stats from DL Rx perspective PhyReceptionStatParameters (see lte-comm...
 
std::vector< HarqProcessInfoElement_t > HarqProcessInfoList_t