22 #include <ns3/object-factory.h>
26 #include <ns3/simulator.h>
27 #include <ns3/attribute-accessor-helper.h>
28 #include <ns3/double.h>
39 #include <ns3/lte-common.h>
40 #include <ns3/lte-vendor-specific-parameters.h>
43 #include <ns3/node-list.h>
45 #include <ns3/lte-ue-net-device.h>
46 #include <ns3/pointer.h>
74 virtual void SetBandwidth (uint8_t ulBandwidth, uint8_t dlBandwidth);
135 m_enbCphySapUser (0),
138 m_srsPeriodicity (0),
139 m_srsStartTime (Seconds (0)),
140 m_currentSrsOffset (0),
141 m_interferenceSampleCounter (0)
156 .AddConstructor<LteEnbPhy> ()
157 .AddAttribute (
"TxPower",
158 "Transmission power in dBm",
162 MakeDoubleChecker<double> ())
163 .AddAttribute (
"NoiseFigure",
164 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
165 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
166 "\"the difference in decibels (dB) between"
167 " the noise output of the actual receiver to the noise output of an "
168 " ideal receiver with the same overall gain and bandwidth when the receivers "
169 " are connected to sources at the standard noise temperature T0.\" "
170 "In this model, we consider T0 = 290K.",
174 MakeDoubleChecker<double> ())
175 .AddAttribute (
"MacToChannelDelay",
176 "The delay in TTI units that occurs between a scheduling decision in the MAC and the actual start of the transmission by the PHY. This is intended to be used to model the latency of real PHY and MAC implementations.",
180 MakeUintegerChecker<uint8_t> ())
181 .AddTraceSource (
"ReportUeSinr",
182 "Report UEs' averaged linear SINR",
184 .AddAttribute (
"UeSinrSamplePeriod",
185 "The sampling period for reporting UEs' SINR stats (default value 1)",
188 MakeUintegerChecker<uint16_t> ())
189 .AddTraceSource (
"ReportInterference",
190 "Report linear interference power per PHY RB",
192 .AddAttribute (
"InterferenceSamplePeriod",
193 "The sampling period for reporting interference stats (default value 1)",
196 MakeUintegerChecker<uint16_t> ())
197 .AddTraceSource (
"DlPhyTransmission",
198 "DL transmission PHY layer statistics.",
200 .AddAttribute (
"DlSpectrumPhy",
201 "The downlink LteSpectrumPhy associated to this LtePhy",
205 MakePointerChecker <LteSpectrumPhy> ())
206 .AddAttribute (
"UlSpectrumPhy",
207 "The uplink LteSpectrumPhy associated to this LtePhy",
211 MakePointerChecker <LteSpectrumPhy> ())
305 std::list<Ptr<LteControlMessage> > l;
307 std::list<UlDciLteControlMessage> l1;
312 std::list<UlDciLteControlMessage> l1;
339 std::set <uint16_t>::iterator it;
357 std::set <uint16_t>::iterator it;
450 std::list<Ptr<LteControlMessage> >::iterator it;
451 for (it = msgList.begin (); it != msgList.end(); it++)
453 switch ((*it)->GetMessageType ())
515 mibMsg->SetMib (
m_mib);
539 std::list<UlDciLteControlMessage> uldcilist =
DequeueUlDci ();
540 std::list<UlDciLteControlMessage>::iterator dciIt = uldcilist.begin ();
541 NS_LOG_DEBUG (
this <<
" eNB Expected TBs " << uldcilist.size ());
542 for (dciIt = uldcilist.begin (); dciIt!=uldcilist.end (); dciIt++)
544 std::set <uint16_t>::iterator it2;
555 std::vector <int> rbMap;
556 for (
int i = (*dciIt).GetDci ().m_rbStart; i < (*dciIt).GetDci ().m_rbStart + (*dciIt).GetDci ().m_rbLen; i++)
560 m_uplinkSpectrumPhy->AddExpectedTb ((*dciIt).GetDci ().m_rnti, (*dciIt).GetDci ().m_ndi, (*dciIt).GetDci ().m_tbSize, (*dciIt).GetDci ().m_mcs, rbMap, 0 , 0 , 0 ,
false );
561 if ((*dciIt).GetDci ().m_ndi==1)
563 NS_LOG_DEBUG (
this <<
" RNTI " << (*dciIt).GetDci ().m_rnti <<
" NEW TB");
567 NS_LOG_DEBUG (
this <<
" RNTI " << (*dciIt).GetDci ().m_rnti <<
" HARQ RETX");
575 if (ctrlMsg.size () > 0)
577 std::list<Ptr<LteControlMessage> >::iterator it;
578 it = ctrlMsg.begin ();
579 while (it != ctrlMsg.end ())
588 for (
int i = 0; i < 32; i++)
590 if (((dci->GetDci ().m_rbBitmap & mask) >> i) == 1)
601 for (uint8_t i = 0; i < dci->GetDci ().m_mcs.size (); i++)
607 params.
m_rnti = dci->GetDci ().m_rnti;
610 params.
m_mcs = dci->GetDci ().m_mcs.at (i);
611 params.
m_size = dci->GetDci ().m_tbsSize.at (i);
612 params.
m_rv = dci->GetDci ().m_rv.at (i);
613 params.
m_ndi = dci->GetDci ().m_ndi.at (i);
626 for (std::list<RarLteControlMessage::Rar>::const_iterator it = rarMsg->RarListBegin (); it != rarMsg->RarListEnd (); ++it)
628 if (it->rarPayload.m_grant.m_ulDelay ==
true)
632 UlGrant_s ulGrant = it->rarPayload.m_grant;
679 std::vector <int> dlRb;
702 std::list<Ptr<LteControlMessage> > ctrlMsgList;
703 ctrlMsgList.clear ();
760 m_interferenceSampleCounter = 0;
776 Values::const_iterator it;
782 double sinrdb = 10 * std::log10 ((*it));
797 NS_LOG_FUNCTION (
this << (uint32_t) ulBandwidth << (uint32_t) dlBandwidth);
807 for (
int i = 0; i < 4; i++)
809 if (dlBandwidth < Type0AllocationRbg[i])
849 Values::const_iterator it;
856 double sinrdb = 10 * log10 ((*it));
874 (i > 0) ? (srsSum / i) : DBL_MAX);
913 std::list<UlDciLteControlMessage>
919 std::list<UlDciLteControlMessage> ret =
m_ulDciQueue.at (0);
921 std::list<UlDciLteControlMessage> l;
928 std::list<UlDciLteControlMessage> l;
930 std::list<UlDciLteControlMessage> emptylist;
954 std::map <uint16_t,uint16_t>::iterator it =
m_srsCounter.find (rnti);
Values::const_iterator ConstValuesEnd() const
keep track of time values and allow control of global simulation resolution
#define NS_LOG_FUNCTION(parameters)
uint16_t m_interferenceSampleCounter
void DoSetCellId(uint16_t cellId)
static uint16_t double2fpS11dot3(double val)
virtual void SendMacPdu(Ptr< Packet > p)
Send the MAC PDU to the channel.
uint16_t m_srsSamplePeriod
void SetDownlinkSubChannels(std::vector< int > mask)
set the resource blocks (a.k.a. sub channels) to be used in the downlink for transmission ...
void CalcChannelQualityForUe(std::vector< double > sinr, Ptr< LteSpectrumPhy > ue)
Calculate the channel quality for a given UE.
bool DeleteUePhy(uint16_t rnti)
std::list< UlDciLteControlMessage > DequeueUlDci(void)
std::vector< Ptr< PacketBurst > > m_packetBurstQueue
virtual uint8_t GetMacChTtiDelay()
Get the delay from MAC to Channel expressed in TTIs.
virtual void ReceiveLteControlMessageList(std::list< Ptr< LteControlMessage > >)
PhySpectrum received a new list of LteControlMessage.
enum ns3::UlCqi_s::Type_e m_type
void DoSendLteControlMessage(Ptr< LteControlMessage > msg)
uint16_t GetSrsPeriodicity(uint16_t srcCi) const
double GetTti(void) const
std::vector< uint16_t > m_sinr
virtual Ptr< SpectrumValue > CreateTxPowerSpectralDensity()
Create the PSD for TX.
std::vector< std::list< UlDciLteControlMessage > > m_ulDciQueue
virtual void SendLteControlMessage(Ptr< LteControlMessage > msg)
Send SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
Ptr< LteSpectrumPhy > m_downlinkSpectrumPhy
See section 4.3.2 ulDciListElement.
TracedCallback< uint16_t, uint16_t, double > m_reportUeSinr
See section 4.3.24 cqiListElement.
EnbMemberLteEnbPhySapProvider(LteEnbPhy *phy)
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
See section 4.3.12 ulInfoListElement.
NS_LOG_COMPONENT_DEFINE("LteEnbPhy")
std::vector< int > m_dlDataRbMap
std::map< uint16_t, uint16_t > m_srsCounter
void DoSetEarfcn(uint16_t dlEarfcn, uint16_t ulEarfcn)
LteEnbPhySapUser * m_enbPhySapUser
#define NS_FATAL_ERROR(msg)
fatal error handling
virtual void ReceiveRachPreamble(uint32_t prachId)=0
std::vector< int > m_listOfDownlinkSubchannel
double GetNoiseFigure() const
void CreateSrsReport(uint16_t rnti, double srs)
void SetMacChDelay(uint8_t delay)
static TypeId GetTypeId(void)
virtual void GenerateCtrlCqiReport(const SpectrumValue &sinr)
LteEnbCphySapProvider * m_enbCphySapProvider
uint16_t GetSrsSubframeOffset(uint16_t srcCi) const
std::vector< struct VendorSpecificListElement_s > m_vendorSpecificList
void DoSetMasterInformationBlock(LteRrcSap::MasterInformationBlock mib)
virtual void DoInitialize(void)
virtual void GenerateDataCqiReport(const SpectrumValue &sinr)
uint8_t GetRbgSize(void) const
Ptr< LteHarqPhy > m_harqPhyModule
Ptr< LteSpectrumPhy > GetDlSpectrumPhy() const
std::map< uint16_t, uint16_t > m_srsSampleCounterMap
virtual void ReceiveLteUlHarqFeedback(UlInfoListElement_s mes)
PhySpectrum generated a new UL HARQ feedback.
Hold an unsigned integer type.
virtual void SetBandwidth(uint8_t ulBandwidth, uint8_t dlBandwidth)
void SetHarqPhyModule(Ptr< LteHarqPhy > harq)
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
Define the RNTI that has generated the.
uint16_t m_interferenceSamplePeriod
virtual void ReceiveLteControlMessage(Ptr< LteControlMessage > msg)
Receive the control message.
void StartSubFrame(void)
Start a LTE sub frame.
#define NS_LOG_LOGIC(msg)
See section 4.3.3 vendorSpecifiListElement.
bool AddUePhy(uint16_t rnti)
virtual void ReportInterference(const SpectrumValue &interf)
See section 4.3.23 dlInfoListElement.
See section 4.3.14 macCEListElement.
void DoSetBandwidth(uint8_t ulBandwidth, uint8_t dlBandwidth)
Substitutive structure for specifying BuildRarListElement_s::m_grant field.
void SendControlChannels(std::list< Ptr< LteControlMessage > > ctrlMsgList)
Send the PDCCH and PCFICH in the first 3 symbols.
double GetTxPower() const
virtual void UlInfoListElementHarqFeeback(UlInfoListElement_s params)=0
LteEnbPhySapProvider * GetLteEnbPhySapProvider()
Get the PHY SAP provider.
LteRrcSap::MasterInformationBlock m_mib
void DoRemoveUe(uint16_t rnti)
void SetControlMessages(Ptr< LteControlMessage > m)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
LteEnbPhySapProvider * m_enbPhySapProvider
uint16_t m_currentSrsOffset
void SetTxPower(double pow)
void SetDci(UlDciListElement_s dci)
add a DCI into the message
void DoAddUe(uint16_t rnti)
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
virtual void SetCellId(uint16_t cellId)
LteEnbCphySapProvider * GetLteEnbCphySapProvider()
Get the CPHY SAP provider.
FfMacSchedSapProvider::SchedUlCqiInfoReqParameters CreatePuschCqiReport(const SpectrumValue &sinr)
Create the UL CQI feedback from SINR values perceived at the physical layer with the PUSCH signal rec...
LteEnbCphySapUser * m_enbCphySapUser
#define NS_ASSERT_MSG(condition, message)
static Ptr< SpectrumValue > CreateTxPowerSpectralDensity(uint16_t earfcn, uint8_t bandwidth, double powerTx, std::vector< int > activeRbs)
uint8_t DoGetMacChTtiDelay()
friend class EnbMemberLteEnbPhySapProvider
std::list< Ptr< LteControlMessage > > GetControlMessages(void)
Ptr< PacketBurst > GetPacketBurst(void)
void DoSetSrsConfigurationIndex(uint16_t rnti, uint16_t srcCi)
void SetNoiseFigure(double pow)
void SetLteEnbPhySapUser(LteEnbPhySapUser *s)
Set the PHY SAP User.
static const Time DL_DATA_DURATION
int Type0AllocationRbg[4]
#define NS_LOG_DEBUG(msg)
void StartFrame(void)
Start a LTE frame.
std::vector< int > GetDownlinkSubChannels(void)
std::vector< uint16_t > m_srsUeOffset
void DoSetTransmissionMode(uint16_t rnti, uint8_t txMode)
virtual void UlCqiReport(FfMacSchedSapProvider::SchedUlCqiInfoReqParameters ulcqi)=0
Returns to MAC level the UL-CQI evaluated.
FfMacSchedSapProvider::SchedUlCqiInfoReqParameters CreateSrsCqiReport(const SpectrumValue &sinr)
Create the UL CQI feedback from SINR values perceived at the physical layer with the SRS signal recei...
void QueueUlDci(UlDciLteControlMessage m)
#define NS_LOG_ERROR(msg)
Values::const_iterator ConstValuesBegin() const
std::vector< std::list< Ptr< LteControlMessage > > > m_controlMessagesQueue
Ptr< LteSpectrumPhy > m_uplinkSpectrumPhy
virtual void SubframeIndication(uint32_t frameNo, uint32_t subframeNo)=0
Trigger the start from a new frame (input from Phy layer)
TracedCallback< uint16_t, Ptr< SpectrumValue > > m_reportInterferenceTrace
void SendDataChannels(Ptr< PacketBurst > pb)
Send the PDSCH.
virtual void ReceivePhyPdu(Ptr< Packet > p)=0
Hold an floating point type.
virtual void ReportRsReceivedPower(const SpectrumValue &interf)
Set of values corresponding to a given SpectrumModel.
virtual void DoDispose(void)
void PhyPduReceived(Ptr< Packet > p)
PhySpectrum received a new PHY-PDU.
std::set< uint16_t > m_ueAttached
Ptr< LteSpectrumPhy > GetUlSpectrumPhy() const
void SetMacPdu(Ptr< Packet > p)
a unique identifier for an interface.
uint8_t GetMacChDelay(void) const
int64_t GetMilliSeconds(void) const
TypeId SetParent(TypeId tid)
void SetLteEnbCphySapUser(LteEnbCphySapUser *s)
Set the CPHY SAP User.
virtual void DoInitialize(void)
TracedCallback< PhyTransmissionStatParameters > m_dlPhyTransmission
static Ptr< SpectrumValue > CreateNoisePowerSpectralDensity(uint16_t earfcn, uint8_t bandwidth, double noiseFigure)
#define UL_PUSCH_TTIS_DELAY
uint16_t m_srsPeriodicity
void EndFrame(void)
End a LTE frame.
void DoSendMacPdu(Ptr< Packet > p)
Queue the MAC PDU to be sent (according to m_macChTtiDelay)
void EndSubFrame(void)
End a LTE sub frame.
virtual void ReceiveLteControlMessage(Ptr< LteControlMessage > msg)=0
Receive SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
static const Time DL_CTRL_DELAY_FROM_SUBFRAME_START