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>
75 virtual void SetBandwidth (uint8_t ulBandwidth, uint8_t dlBandwidth);
136 m_enbCphySapUser (0),
139 m_srsPeriodicity (0),
140 m_srsStartTime (Seconds (0)),
141 m_currentSrsOffset (0),
142 m_interferenceSampleCounter (0)
157 .AddConstructor<LteEnbPhy> ()
158 .AddAttribute (
"TxPower",
159 "Transmission power in dBm",
163 MakeDoubleChecker<double> ())
164 .AddAttribute (
"NoiseFigure",
165 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
166 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
167 "\"the difference in decibels (dB) between"
168 " the noise output of the actual receiver to the noise output of an "
169 " ideal receiver with the same overall gain and bandwidth when the receivers "
170 " are connected to sources at the standard noise temperature T0.\" "
171 "In this model, we consider T0 = 290K.",
175 MakeDoubleChecker<double> ())
176 .AddAttribute (
"MacToChannelDelay",
177 "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.",
181 MakeUintegerChecker<uint8_t> ())
182 .AddTraceSource (
"ReportUeSinr",
183 "Report UEs' averaged linear SINR",
185 .AddAttribute (
"UeSinrSamplePeriod",
186 "The sampling period for reporting UEs' SINR stats (default value 1)",
189 MakeUintegerChecker<uint16_t> ())
190 .AddTraceSource (
"ReportInterference",
191 "Report linear interference power per PHY RB",
193 .AddAttribute (
"InterferenceSamplePeriod",
194 "The sampling period for reporting interference stats (default value 1)",
197 MakeUintegerChecker<uint16_t> ())
198 .AddTraceSource (
"DlPhyTransmission",
199 "DL transmission PHY layer statistics.",
201 .AddAttribute (
"DlSpectrumPhy",
202 "The downlink LteSpectrumPhy associated to this LtePhy",
206 MakePointerChecker <LteSpectrumPhy> ())
207 .AddAttribute (
"UlSpectrumPhy",
208 "The uplink LteSpectrumPhy associated to this LtePhy",
212 MakePointerChecker <LteSpectrumPhy> ())
306 std::list<Ptr<LteControlMessage> > l;
308 std::list<UlDciLteControlMessage> l1;
313 std::list<UlDciLteControlMessage> l1;
340 std::set <uint16_t>::iterator it;
358 std::set <uint16_t>::iterator it;
451 std::list<Ptr<LteControlMessage> >::iterator it;
452 for (it = msgList.begin (); it != msgList.end(); it++)
454 switch ((*it)->GetMessageType ())
516 mibMsg->SetMib (
m_mib);
555 std::list<UlDciLteControlMessage> uldcilist =
DequeueUlDci ();
556 std::list<UlDciLteControlMessage>::iterator dciIt = uldcilist.begin ();
557 NS_LOG_DEBUG (
this <<
" eNB Expected TBs " << uldcilist.size ());
558 for (dciIt = uldcilist.begin (); dciIt!=uldcilist.end (); dciIt++)
560 std::set <uint16_t>::iterator it2;
571 std::vector <int> rbMap;
572 for (
int i = (*dciIt).GetDci ().m_rbStart; i < (*dciIt).GetDci ().m_rbStart + (*dciIt).GetDci ().m_rbLen; i++)
576 m_uplinkSpectrumPhy->AddExpectedTb ((*dciIt).GetDci ().m_rnti, (*dciIt).GetDci ().m_ndi, (*dciIt).GetDci ().m_tbSize, (*dciIt).GetDci ().m_mcs, rbMap, 0 , 0 , 0 ,
false );
577 if ((*dciIt).GetDci ().m_ndi==1)
579 NS_LOG_DEBUG (
this <<
" RNTI " << (*dciIt).GetDci ().m_rnti <<
" NEW TB");
583 NS_LOG_DEBUG (
this <<
" RNTI " << (*dciIt).GetDci ().m_rnti <<
" HARQ RETX");
591 if (ctrlMsg.size () > 0)
593 std::list<Ptr<LteControlMessage> >::iterator it;
594 it = ctrlMsg.begin ();
595 while (it != ctrlMsg.end ())
604 for (
int i = 0; i < 32; i++)
606 if (((dci->GetDci ().m_rbBitmap & mask) >> i) == 1)
617 for (uint8_t i = 0; i < dci->GetDci ().m_mcs.size (); i++)
623 params.
m_rnti = dci->GetDci ().m_rnti;
626 params.
m_mcs = dci->GetDci ().m_mcs.at (i);
627 params.
m_size = dci->GetDci ().m_tbsSize.at (i);
628 params.
m_rv = dci->GetDci ().m_rv.at (i);
629 params.
m_ndi = dci->GetDci ().m_ndi.at (i);
642 for (std::list<RarLteControlMessage::Rar>::const_iterator it = rarMsg->RarListBegin (); it != rarMsg->RarListEnd (); ++it)
644 if (it->rarPayload.m_grant.m_ulDelay ==
true)
648 UlGrant_s ulGrant = it->rarPayload.m_grant;
695 std::vector <int> dlRb;
718 std::list<Ptr<LteControlMessage> > ctrlMsgList;
719 ctrlMsgList.clear ();
776 m_interferenceSampleCounter = 0;
792 Values::const_iterator it;
798 double sinrdb = 10 * std::log10 ((*it));
813 NS_LOG_FUNCTION (
this << (uint32_t) ulBandwidth << (uint32_t) dlBandwidth);
823 for (
int i = 0; i < 4; i++)
825 if (dlBandwidth < Type0AllocationRbg[i])
865 Values::const_iterator it;
872 double sinrdb = 10 * log10 ((*it));
890 (i > 0) ? (srsSum / i) : DBL_MAX);
929 std::list<UlDciLteControlMessage>
935 std::list<UlDciLteControlMessage> ret =
m_ulDciQueue.at (0);
937 std::list<UlDciLteControlMessage> l;
944 std::list<UlDciLteControlMessage> l;
946 std::list<UlDciLteControlMessage> emptylist;
970 std::map <uint16_t,uint16_t>::iterator it =
m_srsCounter.find (rnti);
Values::const_iterator ConstValuesEnd() const
Template for the implementation of the LteEnbCphySapProvider as a member of an owner class of type C ...
keep track of time values and allow control of global simulation resolution
uint8_t m_txMode
the transmission Mode
#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.
void CalcChannelQualityForUe(std::vector< double > sinr, Ptr< LteSpectrumPhy > ue)
Calculate the channel quality for a given UE.
The Uplink Data Control Indicator messages defines the RB allocation for the users in the uplink...
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)
virtual void ReportRsReceivedPower(const SpectrumValue &power)
generate a report based on the linear RS power perceived during CTRL frame NOTE: used only by UE for ...
void DoSetSystemInformationBlockType1(LteRrcSap::SystemInformationBlockType1 sib1)
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.
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
Ptr< LteSpectrumPhy > m_downlinkSpectrumPhy
See section 4.3.2 ulDciListElement.
TracedCallback< uint16_t, uint16_t, double > m_reportUeSinr
Trace reporting the linear average of SRS SINRs uint16_t cellId, uint16_t rnti, double sinrLinear...
See section 4.3.24 cqiListElement.
Service Access Point (SAP) offered by the UE PHY to the UE RRC for control purposes.
EnbMemberLteEnbPhySapProvider(LteEnbPhy *phy)
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Service Access Point (SAP) offered by the eNB-PHY to the eNB-MAC.
See section 4.3.12 ulInfoListElement.
uint8_t m_rv
the redundancy version (HARQ)
NS_LOG_COMPONENT_DEFINE("LteEnbPhy")
std::vector< int > m_dlDataRbMap
std::map< uint16_t, uint16_t > m_srsCounter
Service Access Point (SAP) offered by the eNB-PHY to the eNB-MAC.
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
notify the reception of a RACH preamble on the PRACH
std::vector< int > m_listOfDownlinkSubchannel
double GetNoiseFigure() const
void CreateSrsReport(uint16_t rnti, double srs)
void SetMacChDelay(uint8_t delay)
The attribute can be read.
static TypeId GetTypeId(void)
virtual void GenerateCtrlCqiReport(const SpectrumValue &sinr)
generate a CQI report based on the given SINR of Ctrl frame
LteEnbCphySapProvider * m_enbCphySapProvider
uint16_t GetSrsSubframeOffset(uint16_t srcCi) const
std::vector< struct VendorSpecificListElement_s > m_vendorSpecificList
void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
void DoSetMasterInformationBlock(LteRrcSap::MasterInformationBlock mib)
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
virtual void GenerateDataCqiReport(const SpectrumValue &sinr)
generate a CQI report based on the given SINR of Data frame (used for PUSCH CQIs) ...
uint8_t GetRbgSize(void) const
Ptr< LteHarqPhy > m_harqPhyModule
Ptr< LteSpectrumPhy > GetDlSpectrumPhy() const
uint64_t m_imsi
IMSI of the scheduled UE.
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)
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)
generate a report based on the linear interference and noise power perceived during DATA frame NOTE: ...
See section 4.3.23 dlInfoListElement.
See section 4.3.14 macCEListElement.
void DoSetBandwidth(uint8_t ulBandwidth, uint8_t dlBandwidth)
uint8_t m_mcs
MCS for transport block.
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
Notify the HARQ on the UL tranmission status.
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)
Schedule an event to expire Now.
uint16_t m_size
Size of transport block.
static Time Now(void)
Return the "current simulation time".
virtual void SetCellId(uint16_t cellId)
LteEnbCphySapProvider * GetLteEnbCphySapProvider()
Get the CPHY SAP provider.
uint8_t m_ndi
new data indicator flag
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)
create a spectrum value representing the power spectral density of a signal to be transmitted...
uint8_t DoGetMacChTtiDelay()
friend class EnbMemberLteEnbPhySapProvider
std::list< Ptr< LteControlMessage > > GetControlMessages(void)
Parameters of the SCHED_UL_CQI_INFO_REQ primitive.
Ptr< PacketBurst > GetPacketBurst(void)
void DoSetSrsConfigurationIndex(uint16_t rnti, uint16_t srcCi)
uint16_t m_cellId
Cell ID of the attached Enb.
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)
uint8_t m_layer
the layer (cw) of the transmission
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
LteRrcSap::SystemInformationBlockType1 m_sib1
std::vector< std::list< Ptr< LteControlMessage > > > m_controlMessagesQueue
LteEnbPhy models the physical layer for the eNodeB.
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)
Service Access Point (SAP) offered by the UE PHY to the UE RRC for control purposes.
TracedCallback< uint16_t, Ptr< SpectrumValue > > m_reportInterferenceTrace
Trace reporting the interference per PHY RB (TS 36.214 section 5.2.2, measured on DATA) uint16_t cell...
void SendDataChannels(Ptr< PacketBurst > pb)
Send the PDSCH.
virtual void ReceivePhyPdu(Ptr< Packet > p)=0
Called by the Phy to notify the MAC of the reception of a new PHY-PDU.
Hold a floating point type.
Set of values corresponding to a given SpectrumModel.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
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)
This method is called only once by Object::Initialize.
uint16_t m_rnti
C-RNTI scheduled.
The LtePhy models the physical layer of LTE.
TracedCallback< PhyTransmissionStatParameters > m_dlPhyTransmission
Trace information regarding PHY stats from UL Tx perspective PhyTrasmissionStatParameters see lte-com...
static Ptr< SpectrumValue > CreateNoisePowerSpectralDensity(uint16_t earfcn, uint8_t bandwidth, double noiseFigure)
create a SpectrumValue that models the power spectral density of AWGN
#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