29#include <ns3/attribute-accessor-helper.h>
30#include <ns3/double.h>
32#include <ns3/object-factory.h>
33#include <ns3/simulator.h>
39#include <ns3/node-list.h>
41#include <ns3/pointer.h>
90 virtual void SetBandwidth(uint16_t ulBandwidth, uint16_t dlBandwidth);
149 m_enbPhySapUser(nullptr),
150 m_enbCphySapUser(nullptr),
155 m_currentSrsOffset(0),
156 m_interferenceSampleCounter(0)
173 .AddAttribute(
"TxPower",
174 "Transmission power in dBm",
177 MakeDoubleChecker<double>())
180 "Loss (dB) in the Signal-to-Noise-Ratio due to "
181 "non-idealities in the receiver. According to Wikipedia "
182 "(http://en.wikipedia.org/wiki/Noise_figure), this is "
183 "\"the difference in decibels (dB) between"
184 " the noise output of the actual receiver to "
185 "the noise output of an ideal receiver with "
186 "the same overall gain and bandwidth when the receivers "
187 "are connected to sources at the standard noise "
188 "temperature T0.\" In this model, we consider T0 = 290K.",
191 MakeDoubleChecker<double>())
194 "The delay in TTI units that occurs between "
195 "a scheduling decision in the MAC and the actual "
196 "start of the transmission by the PHY. This is "
197 "intended to be used to model the latency of real PHY "
198 "and MAC implementations.",
201 MakeUintegerChecker<uint8_t>())
202 .AddTraceSource(
"ReportUeSinr",
203 "Report UEs' averaged linear SINR",
205 "ns3::LteEnbPhy::ReportUeSinrTracedCallback")
206 .AddAttribute(
"UeSinrSamplePeriod",
207 "The sampling period for reporting UEs' SINR stats.",
210 MakeUintegerChecker<uint16_t>())
211 .AddTraceSource(
"ReportInterference",
212 "Report linear interference power per PHY RB",
214 "ns3::LteEnbPhy::ReportInterferenceTracedCallback")
215 .AddAttribute(
"InterferenceSamplePeriod",
216 "The sampling period for reporting interference stats",
219 MakeUintegerChecker<uint16_t>())
220 .AddTraceSource(
"DlPhyTransmission",
221 "DL transmission PHY layer statistics.",
223 "ns3::PhyTransmissionStatParameters::TracedCallback")
224 .AddAttribute(
"DlSpectrumPhy",
225 "The downlink LteSpectrumPhy associated to this LtePhy",
229 MakePointerChecker<LteSpectrumPhy>())
230 .AddAttribute(
"UlSpectrumPhy",
231 "The uplink LteSpectrumPhy associated to this LtePhy",
235 MakePointerChecker<LteSpectrumPhy>());
261 NS_ABORT_MSG_IF(!node,
"Node is not available in the LteNetDevice of LteEnbPhy");
347 std::list<Ptr<LteControlMessage>> l;
349 std::list<UlDciLteControlMessage> l1;
354 std::list<UlDciLteControlMessage> l1;
381 std::set<uint16_t>::iterator it;
399 std::set<uint16_t>::iterator it;
464 std::map<uint16_t, double>::iterator it =
m_paMap.find(rnti);
528 std::list<Ptr<LteControlMessage>>::iterator it;
529 for (it = msgList.begin(); it != msgList.end(); it++)
531 switch ((*it)->GetMessageType())
535 DynamicCast<RachPreambleLteControlMessage>(*it);
561 DynamicCast<DlHarqFeedbackLteControlMessage>(*it);
589 mibMsg->SetMib(
m_mib);
621 "the SRS index check code assumes that subframeNo starts at 1");
628 std::list<UlDciLteControlMessage> uldcilist =
DequeueUlDci();
629 std::list<UlDciLteControlMessage>::iterator dciIt = uldcilist.begin();
630 NS_LOG_DEBUG(
this <<
" eNB Expected TBs " << uldcilist.size());
631 for (dciIt = uldcilist.begin(); dciIt != uldcilist.end(); dciIt++)
633 std::set<uint16_t>::iterator it2;
644 std::vector<int> rbMap;
645 for (
int i = (*dciIt).GetDci().m_rbStart;
646 i < (*dciIt).GetDci().m_rbStart + (*dciIt).GetDci().m_rbLen;
652 (*dciIt).GetDci().m_ndi,
653 (*dciIt).GetDci().m_tbSize,
654 (*dciIt).GetDci().m_mcs,
660 if ((*dciIt).GetDci().m_ndi == 1)
662 NS_LOG_DEBUG(
this <<
" RNTI " << (*dciIt).GetDci().m_rnti <<
" NEW TB");
666 NS_LOG_DEBUG(
this <<
" RNTI " << (*dciIt).GetDci().m_rnti <<
" HARQ RETX");
675 if (!ctrlMsg.empty())
677 std::list<Ptr<LteControlMessage>>::iterator it;
678 it = ctrlMsg.begin();
679 while (it != ctrlMsg.end())
688 for (
int i = 0; i < 32; i++)
690 if (((dci->GetDci().m_rbBitmap & mask) >> i) == 1)
704 for (std::size_t i = 0; i < dci->GetDci().m_mcs.size(); i++)
710 params.m_rnti = dci->GetDci().m_rnti;
713 params.m_mcs = dci->GetDci().m_mcs.at(i);
714 params.m_size = dci->GetDci().m_tbsSize.at(i);
715 params.m_rv = dci->GetDci().m_rv.at(i);
716 params.m_ndi = dci->GetDci().m_ndi.at(i);
729 for (std::list<RarLteControlMessage::Rar>::const_iterator it =
730 rarMsg->RarListBegin();
731 it != rarMsg->RarListEnd();
734 if (it->rarPayload.m_grant.m_ulDelay)
738 UlGrant_s ulGrant = it->rarPayload.m_grant;
782 std::vector<int> dlRb;
804 std::list<Ptr<LteControlMessage>> ctrlMsgList;
873 Values::const_iterator it;
878 double sinrdb = 10 * std::log10((*it));
900 for (
int i = 0; i < 4; i++)
939 std::map<uint16_t, double>::iterator it =
m_paMap.find(rnti);
958 std::list<Ptr<LteControlMessage>>::iterator ctrlMsgListIt = ctrlMessageList.begin();
959 while (ctrlMsgListIt != ctrlMessageList.end())
964 auto dci = DynamicCast<DlDciLteControlMessage>(msg);
965 if (dci->GetDci().m_rnti == rnti)
968 << rnti <<
" is deleted");
969 ctrlMsgListIt = ctrlMessageList.erase(ctrlMsgListIt);
978 auto dci = DynamicCast<UlDciLteControlMessage>(msg);
979 if (dci->GetDci().m_rnti == rnti)
982 << rnti <<
" is deleted");
983 ctrlMsgListIt = ctrlMessageList.erase(ctrlMsgListIt);
1003 std::map<uint16_t, double>::iterator it =
m_paMap.find(rnti);
1007 m_paMap.insert(std::pair<uint16_t, double>(rnti, pa));
1019 Values::const_iterator it;
1023 double srsSum = 0.0;
1026 double sinrdb = 10 * log10((*it));
1080std::list<UlDciLteControlMessage>
1086 std::list<UlDciLteControlMessage> ret =
m_ulDciQueue.at(0);
1088 std::list<UlDciLteControlMessage> l;
1095 std::list<UlDciLteControlMessage> l;
1097 std::list<UlDciLteControlMessage> emptylist;
1122 std::map<uint16_t, uint16_t>::iterator it =
m_srsCounter.find(rnti);
This class can be used to hold variables of floating point type such as 'double' or 'float'.
void SendMacPdu(Ptr< Packet > p) override
Send the MAC PDU to the channel.
EnbMemberLteEnbPhySapProvider(LteEnbPhy *phy)
Constructor.
virtual void SetBandwidth(uint16_t ulBandwidth, uint16_t dlBandwidth)
Set bandwidth function.
uint8_t GetMacChTtiDelay() override
Get the delay from MAC to Channel expressed in TTIs.
LteEnbPhy * m_phy
the ENB Phy
virtual void SetCellId(uint16_t cellId)
Set Cell ID function.
void SendLteControlMessage(Ptr< LteControlMessage > msg) override
Send SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
Service Access Point (SAP) offered by the UE PHY to the UE RRC for control purposes.
Service Access Point (SAP) offered by the UE PHY to the UE RRC for control purposes.
LteEnbPhy models the physical layer for the eNodeB.
uint16_t m_srsPeriodicity
SRS periodicity.
double GetTxPower() const
Time m_srsStartTime
SRS start time.
int8_t DoGetReferenceSignalPower() const
void StartSubFrame()
Start a LTE sub frame.
void CreateSrsReport(uint16_t rnti, double srs)
Create SRS report function.
uint16_t m_interferenceSamplePeriod
The InterferenceSamplePeriod attribute.
virtual void ReportUlHarqFeedback(UlInfoListElement_s mes)
Report the uplink HARQ feedback generated by LteSpectrumPhy to MAC.
std::list< UlDciLteControlMessage > DequeueUlDci()
uint16_t m_srsSamplePeriod
The UeSinrSamplePeriod trace source.
void SetLteEnbCphySapUser(LteEnbCphySapUser *s)
Set the CPHY SAP User.
FfMacSchedSapProvider::SchedUlCqiInfoReqParameters CreatePuschCqiReport(const SpectrumValue &sinr)
Create the UL CQI feedback from SINR values perceived at the physical layer with the PUSCH signal rec...
uint32_t m_nrSubFrames
The subframe number currently served.
std::set< uint16_t > m_ueAttached
List of RNTI of attached UEs.
LteEnbPhySapProvider * GetLteEnbPhySapProvider()
Get the PHY SAP provider.
void SetLteEnbPhySapUser(LteEnbPhySapUser *s)
Set the PHY SAP User.
void DoSetMasterInformationBlock(LteRrcSap::MasterInformationBlock mib)
Set master information block.
bool DeleteUePhy(uint16_t rnti)
Remove the given RNTI from the list of attached UE m_ueAttached.
std::vector< std::list< UlDciLteControlMessage > > m_ulDciQueue
For storing info on future receptions.
double GetNoiseFigure() const
void SetTxPower(double pow)
std::vector< int > m_dlDataRbMap
DL data RB map.
TracedCallback< uint16_t, uint16_t, double, uint8_t > m_reportUeSinr
The ReportUeSinr trace source.
Ptr< LteSpectrumPhy > GetDlSpectrumPhy() const
void DoDispose() override
Destructor implementation.
void GenerateCtrlCqiReport(const SpectrumValue &sinr) override
generate a CQI report based on the given SINR of Ctrl frame
void GenerateDataCqiReport(const SpectrumValue &sinr) override
generate a CQI report based on the given SINR of Data frame (used for PUSCH CQIs)
void SendDataChannels(Ptr< PacketBurst > pb)
Send the PDSCH.
std::map< uint16_t, uint16_t > m_srsSampleCounterMap
SRS sample counter map.
void DoSetSrsConfigurationIndex(uint16_t rnti, uint16_t srcCi)
Set source configuration index.
void PhyPduReceived(Ptr< Packet > p)
PhySpectrum received a new PHY-PDU.
FfMacSchedSapProvider::SchedUlCqiInfoReqParameters CreateSrsCqiReport(const SpectrumValue &sinr)
Create the UL CQI feedback from SINR values perceived at the physical layer with the SRS signal recei...
LteEnbPhySapUser * m_enbPhySapUser
ENB Phy SAP user.
void EndFrame()
End a LTE frame.
void CalcChannelQualityForUe(std::vector< double > sinr, Ptr< LteSpectrumPhy > ue)
Calculate the channel quality for a given UE.
void DoSetPa(uint16_t rnti, double pa)
Set PA.
uint8_t GetMacChDelay() const
uint16_t m_currentSrsOffset
current SRS offset
void DoSetEarfcn(uint32_t dlEarfcn, uint32_t ulEarfcn)
Set EARFCN.
Ptr< SpectrumValue > CreateTxPowerSpectralDensity() override
Create the PSD for TX.
void DoSetTransmissionMode(uint16_t rnti, uint8_t txMode)
Set transmission mode.
LteEnbPhySapProvider * m_enbPhySapProvider
ENB Phy SAP provider.
uint8_t DoGetMacChTtiDelay()
Get MAC ch TTI delay function.
std::map< int, double > m_dlPowerAllocationMap
DL power allocation map.
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...
void GeneratePowerAllocationMap(uint16_t rnti, int rbId)
Generate power allocation map (i.e.
void QueueUlDci(UlDciLteControlMessage m)
void SetNoiseFigure(double pow)
std::map< uint16_t, uint16_t > m_srsCounter
SRS counter.
void SetMacChDelay(uint8_t delay)
void SetHarqPhyModule(Ptr< LteHarqPhy > harq)
Set the HARQ Phy module.
virtual void ReceiveLteControlMessageList(std::list< Ptr< LteControlMessage > > msgList)
PhySpectrum received a new list of LteControlMessage.
void SendControlChannels(std::list< Ptr< LteControlMessage > > ctrlMsgList)
Send the PDCCH and PCFICH in the first 3 symbols.
void DoRemoveUe(uint16_t rnti)
Remove UE.
void SetDownlinkSubChannelsWithPowerAllocation(std::vector< int > mask)
set the resource blocks (a.k.a.
void ReportRsReceivedPower(const SpectrumValue &power) override
generate a report based on the linear RS power perceived during CTRL frame NOTE: used only by UE for ...
LteRrcSap::MasterInformationBlock m_mib
The Master Information Block message to be broadcasted every frame.
void DoSendMacPdu(Ptr< Packet > p) override
Queue the MAC PDU to be sent (according to m_macChTtiDelay)
void ReportInterference(const SpectrumValue &interf) override
generate a report based on the linear interference and noise power perceived during DATA frame NOTE: ...
TracedCallback< uint16_t, Ptr< SpectrumValue > > m_reportInterferenceTrace
The ReportInterference trace source.
Ptr< LteSpectrumPhy > GetUlSpectrumPhy() const
void DoAddUe(uint16_t rnti)
Add UE.
friend class EnbMemberLteEnbPhySapProvider
allow EnbMemberLteEnbPhySapProvider class friend access
void DoSetSystemInformationBlockType1(LteRrcSap::SystemInformationBlockType1 sib1)
Set system information block.
void DoSendLteControlMessage(Ptr< LteControlMessage > msg)
Send LTE Control Message function.
virtual Ptr< SpectrumValue > CreateTxPowerSpectralDensityWithPowerAllocation()
Create the PSD for TX with power allocation for each RB.
bool AddUePhy(uint16_t rnti)
Add the given RNTI to the list of attached UE m_ueAttached.
void DoInitialize() override
Initialize() implementation.
LteRrcSap::SystemInformationBlockType1 m_sib1
The System Information Block Type 1 message to be broadcasted.
std::map< uint16_t, double > m_paMap
P_A per UE RNTI.
void DoSetBandwidth(uint16_t ulBandwidth, uint16_t dlBandwidth)
Set bandwidth function.
void EndSubFrame()
End a LTE sub frame.
LteEnbCphySapUser * m_enbCphySapUser
ENB CPhy SAP user.
uint16_t m_interferenceSampleCounter
interference sample counter
void SetDownlinkSubChannels(std::vector< int > mask)
set the resource blocks (a.k.a.
virtual void ReceiveLteControlMessage(Ptr< LteControlMessage > msg)
Receive the control message.
void StartFrame()
Start a LTE frame.
uint32_t m_nrFrames
The frame number currently served.
LteEnbCphySapProvider * m_enbCphySapProvider
ENB CPhy SAP provider.
std::vector< uint16_t > m_srsUeOffset
SRS UE offset.
LteEnbCphySapProvider * GetLteEnbCphySapProvider()
Get the CPHY SAP provider.
TracedCallback< PhyTransmissionStatParameters > m_dlPhyTransmission
The DlPhyTransmission trace source.
std::vector< int > GetDownlinkSubChannels()
Ptr< LteHarqPhy > m_harqPhyModule
HARQ Phy module.
friend class MemberLteEnbCphySapProvider< LteEnbPhy >
allow MemberLteEnbCphySapProvider<LteEnbPhy> class friend access
static TypeId GetTypeId()
Get the type ID.
Service Access Point (SAP) offered by the eNB-PHY to the eNB-MAC.
Service Access Point (SAP) offered by the eNB-PHY to the eNB-MAC.
virtual void ReceivePhyPdu(Ptr< Packet > p)=0
Called by the Phy to notify the MAC of the reception of a new PHY-PDU.
virtual void UlCqiReport(FfMacSchedSapProvider::SchedUlCqiInfoReqParameters ulcqi)=0
Returns to MAC level the UL-CQI evaluated.
virtual void UlInfoListElementHarqFeedback(UlInfoListElement_s params)=0
Notify the HARQ on the UL transmission status.
virtual void ReceiveLteControlMessage(Ptr< LteControlMessage > msg)=0
Receive SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
virtual void ReceiveRachPreamble(uint32_t prachId)=0
notify the reception of a RACH preamble on the PRACH
virtual void SubframeIndication(uint32_t frameNo, uint32_t subframeNo)=0
Trigger the start from a new frame (input from Phy layer)
static uint16_t double2fpS11dot3(double val)
Convert from double to fixed point S11.3 notation.
The LtePhy models the physical layer of LTE.
void DoSetCellId(uint16_t cellId)
double m_txPower
Transmission power in dBm.
uint8_t GetRbgSize() const
void DoDispose() override
Destructor implementation.
uint16_t GetSrsPeriodicity(uint16_t srcCi) const
std::vector< Ptr< PacketBurst > > m_packetBurstQueue
A queue of packet bursts to be sent.
uint16_t m_ulBandwidth
The UL bandwidth in number of PRBs.
Ptr< PacketBurst > GetPacketBurst()
uint8_t m_componentCarrierId
component carrier Id used to address sap
double m_noiseFigure
Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.
uint32_t m_ulEarfcn
The uplink carrier frequency.
uint16_t m_dlBandwidth
The DL bandwidth in number of PRBs.
Ptr< LteSpectrumPhy > m_downlinkSpectrumPhy
The downlink LteSpectrumPhy associated to this LtePhy.
void SetMacPdu(Ptr< Packet > p)
std::list< Ptr< LteControlMessage > > GetControlMessages()
uint16_t GetSrsSubframeOffset(uint16_t srcCi) const
Ptr< LteNetDevice > m_netDevice
Pointer to the NetDevice where this PHY layer is attached.
uint16_t m_cellId
Cell identifier.
void SetControlMessages(Ptr< LteControlMessage > m)
uint32_t m_dlEarfcn
The downlink carrier frequency.
Ptr< LteSpectrumPhy > m_uplinkSpectrumPhy
The uplink LteSpectrumPhy associated to this LtePhy.
std::vector< std::list< Ptr< LteControlMessage > > > m_controlMessagesQueue
A queue of control messages to be sent.
uint8_t m_rbgSize
The RB group size according to the bandwidth.
uint8_t m_macChTtiDelay
Delay between MAC and channel layer in terms of TTIs.
static Ptr< SpectrumValue > CreateNoisePowerSpectralDensity(uint32_t earfcn, uint16_t bandwidth, double noiseFigure)
create a SpectrumValue that models the power spectral density of AWGN
static Ptr< SpectrumValue > CreateTxPowerSpectralDensity(uint32_t earfcn, uint16_t bandwidth, double powerTx, std::vector< int > activeRbs)
create a spectrum value representing the power spectral density of a signal to be transmitted.
virtual void DoInitialize()
Initialize() implementation.
Hold objects of type Ptr<T>.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static Time Now()
Return the current simulation virtual time.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Set of values corresponding to a given SpectrumModel.
Values::const_iterator ConstValuesBegin() const
Values::const_iterator ConstValuesEnd() const
Define the RNTI that has generated the.
Simulation virtual time values and global simulation resolution.
int64_t GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
a unique identifier for an interface.
@ ATTR_GET
The attribute can be read.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
The Uplink Data Control Indicator messages defines the RB allocation for the users in the uplink.
void SetDci(UlDciListElement_s dci)
add a DCI into the message
#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)
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
#define UL_PUSCH_TTIS_DELAY
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const Time DL_CTRL_DELAY_FROM_SUBFRAME_START
Delay from the start of a DL subframe to transmission of the data portion.
static const Time DL_DATA_DURATION
Duration of the data portion of a DL subframe.
static const int Type0AllocationRbg[4]
Type 0 RGB allocation.
See section 4.3.24 cqiListElement.
See section 4.3.23 dlInfoListElement.
Parameters of the SCHED_UL_CQI_INFO_REQ primitive.
std::vector< VendorSpecificListElement_s > m_vendorSpecificList
vendor specific list
See section 4.3.14 macCEListElement.
PhyTransmissionStatParameters structure.
std::vector< uint16_t > m_sinr
SINR.
See section 4.3.2 ulDciListElement.
int8_t m_tpc
Tx power control command.
bool m_cqiRequest
CQI request.
Substitutive structure for specifying BuildRarListElement_s::m_grant field.
int8_t m_tpc
Tx power control command.
bool m_cqiRequest
CQI request?
See section 4.3.12 ulInfoListElement.
See section 4.3.3 vendorSpecificListElement.
Ptr< VendorSpecificValue > m_value
value