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>
81 virtual void SetBandwidth (uint8_t ulBandwidth, uint8_t dlBandwidth);
142 m_enbCphySapUser (0),
145 m_srsPeriodicity (0),
147 m_currentSrsOffset (0),
148 m_interferenceSampleCounter (0)
163 .AddConstructor<LteEnbPhy> ()
164 .AddAttribute (
"TxPower",
165 "Transmission power in dBm",
169 MakeDoubleChecker<double> ())
170 .AddAttribute (
"NoiseFigure",
171 "Loss (dB) in the Signal-to-Noise-Ratio due to "
172 "non-idealities in the receiver. According to Wikipedia "
173 "(http://en.wikipedia.org/wiki/Noise_figure), this is "
174 "\"the difference in decibels (dB) between"
175 " the noise output of the actual receiver to "
176 "the noise output of an ideal receiver with "
177 "the same overall gain and bandwidth when the receivers "
178 "are connected to sources at the standard noise "
179 "temperature T0.\" In this model, we consider T0 = 290K.",
183 MakeDoubleChecker<double> ())
184 .AddAttribute (
"MacToChannelDelay",
185 "The delay in TTI units that occurs between "
186 "a scheduling decision in the MAC and the actual "
187 "start of the transmission by the PHY. This is "
188 "intended to be used to model the latency of real PHY "
189 "and MAC implementations.",
193 MakeUintegerChecker<uint8_t> ())
194 .AddTraceSource (
"ReportUeSinr",
195 "Report UEs' averaged linear SINR",
197 "ns3::LteEnbPhy::ReportUeSinrTracedCallback")
198 .AddAttribute (
"UeSinrSamplePeriod",
199 "The sampling period for reporting UEs' SINR stats.",
202 MakeUintegerChecker<uint16_t> ())
203 .AddTraceSource (
"ReportInterference",
204 "Report linear interference power per PHY RB",
206 "ns3::LteEnbPhy::ReportInterferenceTracedCallback")
207 .AddAttribute (
"InterferenceSamplePeriod",
208 "The sampling period for reporting interference stats",
211 MakeUintegerChecker<uint16_t> ())
212 .AddTraceSource (
"DlPhyTransmission",
213 "DL transmission PHY layer statistics.",
215 "ns3::PhyTransmissionStatParameters::TracedCallback")
216 .AddAttribute (
"DlSpectrumPhy",
217 "The downlink LteSpectrumPhy associated to this LtePhy",
221 MakePointerChecker <LteSpectrumPhy> ())
222 .AddAttribute (
"UlSpectrumPhy",
223 "The uplink LteSpectrumPhy associated to this LtePhy",
227 MakePointerChecker <LteSpectrumPhy> ())
328 std::list<Ptr<LteControlMessage> > l;
330 std::list<UlDciLteControlMessage> l1;
335 std::list<UlDciLteControlMessage> l1;
362 std::set <uint16_t>::iterator it;
380 std::set <uint16_t>::iterator it;
448 std::map<uint16_t, double>::iterator it =
m_paMap.find (rnti);
507 std::list<Ptr<LteControlMessage> >::iterator it;
508 for (it = msgList.begin (); it != msgList.end (); it++)
510 switch ((*it)->GetMessageType ())
572 mibMsg->SetMib (
m_mib);
611 std::list<UlDciLteControlMessage> uldcilist =
DequeueUlDci ();
612 std::list<UlDciLteControlMessage>::iterator dciIt = uldcilist.begin ();
613 NS_LOG_DEBUG (
this <<
" eNB Expected TBs " << uldcilist.size ());
614 for (dciIt = uldcilist.begin (); dciIt!=uldcilist.end (); dciIt++)
616 std::set <uint16_t>::iterator it2;
627 std::vector <int> rbMap;
628 for (
int i = (*dciIt).GetDci ().m_rbStart; i < (*dciIt).GetDci ().m_rbStart + (*dciIt).GetDci ().m_rbLen; i++)
632 m_uplinkSpectrumPhy->AddExpectedTb ((*dciIt).GetDci ().m_rnti, (*dciIt).GetDci ().m_ndi, (*dciIt).GetDci ().m_tbSize, (*dciIt).GetDci ().m_mcs, rbMap, 0 , 0 , 0 ,
false );
633 if ((*dciIt).GetDci ().m_ndi==1)
635 NS_LOG_DEBUG (
this <<
" RNTI " << (*dciIt).GetDci ().m_rnti <<
" NEW TB");
639 NS_LOG_DEBUG (
this <<
" RNTI " << (*dciIt).GetDci ().m_rnti <<
" HARQ RETX");
648 if (ctrlMsg.size () > 0)
650 std::list<Ptr<LteControlMessage> >::iterator it;
651 it = ctrlMsg.begin ();
652 while (it != ctrlMsg.end ())
661 for (
int i = 0; i < 32; i++)
663 if (((dci->GetDci ().m_rbBitmap & mask) >> i) == 1)
675 for (uint8_t i = 0; i < dci->GetDci ().m_mcs.size (); i++)
681 params.
m_rnti = dci->GetDci ().m_rnti;
684 params.
m_mcs = dci->GetDci ().m_mcs.at (i);
685 params.
m_size = dci->GetDci ().m_tbsSize.at (i);
686 params.
m_rv = dci->GetDci ().m_rv.at (i);
687 params.
m_ndi = dci->GetDci ().m_ndi.at (i);
700 for (std::list<RarLteControlMessage::Rar>::const_iterator it = rarMsg->RarListBegin (); it != rarMsg->RarListEnd (); ++it)
702 if (it->rarPayload.m_grant.m_ulDelay ==
true)
706 UlGrant_s ulGrant = it->rarPayload.m_grant;
753 std::vector <int> dlRb;
776 std::list<Ptr<LteControlMessage> > ctrlMsgList;
777 ctrlMsgList.clear ();
834 m_interferenceSampleCounter = 0;
850 Values::const_iterator it;
856 double sinrdb = 10 * std::log10 ((*it));
871 NS_LOG_FUNCTION (
this << (uint32_t) ulBandwidth << (uint32_t) dlBandwidth);
881 for (
int i = 0; i < 4; i++)
883 if (dlBandwidth < Type0AllocationRbg[i])
921 std::map<uint16_t, double>::iterator it =
m_paMap.find (rnti);
934 std::map<uint16_t, double>::iterator it =
m_paMap.find (rnti);
938 m_paMap.insert (std::pair<uint16_t, double> (rnti, pa));
951 Values::const_iterator it;
958 double sinrdb = 10 * log10 ((*it));
976 (i > 0) ? (srsSum / i) : DBL_MAX);
1015 std::list<UlDciLteControlMessage>
1021 std::list<UlDciLteControlMessage> ret =
m_ulDciQueue.at (0);
1023 std::list<UlDciLteControlMessage> l;
1030 std::list<UlDciLteControlMessage> l;
1032 std::list<UlDciLteControlMessage> emptylist;
1056 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 ...
Simulation virtual time values and global simulation resolution.
uint8_t m_txMode
the transmission Mode
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint16_t m_interferenceSampleCounter
void DoSetCellId(uint16_t cellId)
double m_noiseFigure
Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.
uint32_t m_nrSubFrames
The subframe number currently served.
static uint16_t double2fpS11dot3(double val)
double m_txPower
Transmission power in dBm.
uint16_t m_dlEarfcn
The downlink carrier frequency.
virtual void SendMacPdu(Ptr< Packet > p)
Send the MAC PDU to the channel.
uint16_t m_srsSamplePeriod
The UeSinrSamplePeriod trace source.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
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)
Remove the given RNTI from the list of attached UE m_ueAttached.
std::list< UlDciLteControlMessage > DequeueUlDci(void)
std::vector< Ptr< PacketBurst > > m_packetBurstQueue
A queue of packet bursts to be sent.
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
For storing info on future receptions.
std::map< int, double > m_dlPowerAllocationMap
DL power allocation map.
virtual void SendLteControlMessage(Ptr< LteControlMessage > msg)
Send SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual Ptr< SpectrumValue > CreateTxPowerSpectralDensityWithPowerAllocation()
Create the PSD for TX with power allocation for each RB.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< LteSpectrumPhy > m_downlinkSpectrumPhy
The downlink LteSpectrumPhy associated to this LtePhy.
std::map< uint16_t, double > m_paMap
P_A per UE RNTI.
See section 4.3.2 ulDciListElement.
TracedCallback< uint16_t, uint16_t, double > m_reportUeSinr
The ReportUeSinr trace source.
See section 4.3.24 cqiListElement.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_FATAL_ERROR(msg)
Fatal error handling.
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)
std::vector< int > m_dlDataRbMap
uint32_t m_nrFrames
The frame number currently served.
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
uint8_t m_ulBandwidth
The UL bandwidth in number of PRBs.
virtual void ReceiveRachPreamble(uint32_t prachId)=0
notify the reception of a RACH preamble on the PRACH
std::vector< int > m_listOfDownlinkSubchannel
A vector of integers, if the i-th value is j it means that the j-th resource block is used for transm...
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
double GetNoiseFigure() const
void CreateSrsReport(uint16_t rnti, double srs)
static const int Type0AllocationRbg[4]
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
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void DoDispose()
Destructor implementation.
void DoSetMasterInformationBlock(LteRrcSap::MasterInformationBlock mib)
virtual void DoInitialize(void)
Initialize() implementation.
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
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
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
The InterferenceSamplePeriod attribute.
virtual void ReceiveLteControlMessage(Ptr< LteControlMessage > msg)
Receive the control message.
uint16_t m_ulEarfcn
The uplink carrier frequency.
void StartSubFrame(void)
Start a LTE sub frame.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
See section 4.3.3 vendorSpecifiListElement.
bool AddUePhy(uint16_t rnti)
Add the given RNTI to the list of attached UE m_ueAttached.
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
uint8_t m_macChTtiDelay
Delay between MAC and channel layer in terms of TTIs.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void UlInfoListElementHarqFeeback(UlInfoListElement_s params)=0
Notify the HARQ on the UL tranmission status.
LteEnbPhySapProvider * GetLteEnbPhySapProvider()
Get the PHY SAP provider.
Hold objects of type Ptr.
LteRrcSap::MasterInformationBlock m_mib
The Master Information Block message to be broadcasted every frame.
void DoRemoveUe(uint16_t rnti)
void SetControlMessages(Ptr< LteControlMessage > m)
LteEnbPhySapProvider * m_enbPhySapProvider
uint16_t m_currentSrsOffset
void SetTxPower(double pow)
void SetDci(UlDciListElement_s dci)
add a DCI into the message
uint8_t m_dlBandwidth
The DL bandwidth in number of PRBs.
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.
void SetDownlinkSubChannelsWithPowerAllocation(std::vector< int > mask)
set the resource blocks (a.k.a.
static Time Now(void)
Return the current simulation virtual time.
int8_t DoGetReferenceSignalPower() const
virtual void SetCellId(uint16_t cellId)
LteEnbCphySapProvider * GetLteEnbCphySapProvider()
Get the CPHY SAP provider.
uint16_t m_cellId
Cell identifier.
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)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
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
Duration of the data portion of a DL subframe.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
uint8_t m_layer
the layer (cw) of the transmission
void StartFrame(void)
Start a LTE frame.
Time Seconds(double value)
Construct a Time in the indicated unit.
std::vector< int > GetDownlinkSubChannels(void)
std::vector< uint16_t > m_srsUeOffset
void DoSetTransmissionMode(uint16_t rnti, uint8_t txMode)
uint8_t m_rbgSize
The RB gruop size according to the bandwidth.
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)
void GeneratePowerAllocationMap(uint16_t rnti, int rbId)
Generate power allocation map (i.e.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Values::const_iterator ConstValuesBegin() const
LteRrcSap::SystemInformationBlockType1 m_sib1
The System Information Block Type 1 message to be broadcasted.
std::vector< std::list< Ptr< LteControlMessage > > > m_controlMessagesQueue
A queue of control messages to be sent.
LteEnbPhy models the physical layer for the eNodeB.
Ptr< LteSpectrumPhy > m_uplinkSpectrumPhy
The uplink LteSpectrumPhy associated to this LtePhy.
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
The ReportInterference trace source.
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.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Set of values corresponding to a given SpectrumModel.
virtual void DoDispose(void)
Destructor implementation.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void PhyPduReceived(Ptr< Packet > p)
PhySpectrum received a new PHY-PDU.
std::set< uint16_t > m_ueAttached
List of RNTI of attached UEs.
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
Get an approximation of the time stored in this instance in the indicated unit.
TypeId SetParent(TypeId tid)
void SetLteEnbCphySapUser(LteEnbCphySapUser *s)
Set the CPHY SAP User.
virtual void DoInitialize(void)
Initialize() implementation.
uint16_t m_rnti
C-RNTI scheduled.
The LtePhy models the physical layer of LTE.
TracedCallback< PhyTransmissionStatParameters > m_dlPhyTransmission
The DlPhyTransmission trace source.
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 DoSetPa(uint16_t rnti, double pa)
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
Delay from the start of a DL subframe to transmission of the data portion.