18#include <ns3/attribute-accessor-helper.h>
19#include <ns3/double.h>
21#include <ns3/object-factory.h>
22#include <ns3/simulator.h>
28#include <ns3/node-list.h>
30#include <ns3/pointer.h>
79 virtual void SetBandwidth(uint16_t ulBandwidth, uint16_t dlBandwidth);
138 m_enbPhySapUser(nullptr),
139 m_enbCphySapUser(nullptr),
144 m_currentSrsOffset(0),
145 m_interferenceSampleCounter(0)
162 .AddAttribute(
"TxPower",
163 "Transmission power in dBm",
169 "Loss (dB) in the Signal-to-Noise-Ratio due to "
170 "non-idealities in the receiver. According to Wikipedia "
171 "(http://en.wikipedia.org/wiki/Noise_figure), this is "
172 "\"the difference in decibels (dB) between"
173 " the noise output of the actual receiver to "
174 "the noise output of an ideal receiver with "
175 "the same overall gain and bandwidth when the receivers "
176 "are connected to sources at the standard noise "
177 "temperature T0.\" In this model, we consider T0 = 290K.",
183 "The delay in TTI units that occurs between "
184 "a scheduling decision in the MAC and the actual "
185 "start of the transmission by the PHY. This is "
186 "intended to be used to model the latency of real PHY "
187 "and MAC implementations.",
191 .AddTraceSource(
"ReportUeSinr",
192 "Report UEs' averaged linear SINR",
194 "ns3::LteEnbPhy::ReportUeSinrTracedCallback")
195 .AddAttribute(
"UeSinrSamplePeriod",
196 "The sampling period for reporting UEs' SINR stats.",
200 .AddTraceSource(
"ReportInterference",
201 "Report linear interference power per PHY RB",
203 "ns3::LteEnbPhy::ReportInterferenceTracedCallback")
204 .AddAttribute(
"InterferenceSamplePeriod",
205 "The sampling period for reporting interference stats",
209 .AddTraceSource(
"DlPhyTransmission",
210 "DL transmission PHY layer statistics.",
212 "ns3::PhyTransmissionStatParameters::TracedCallback")
213 .AddAttribute(
"DlSpectrumPhy",
214 "The downlink LteSpectrumPhy associated to this LtePhy",
219 .AddAttribute(
"UlSpectrumPhy",
220 "The uplink LteSpectrumPhy associated to this LtePhy",
250 NS_ABORT_MSG_IF(!node,
"Node is not available in the LteNetDevice of LteEnbPhy");
336 std::list<Ptr<LteControlMessage>> l;
338 std::list<UlDciLteControlMessage> l1;
343 std::list<UlDciLteControlMessage> l1;
515 for (
auto it = msgList.begin(); it != msgList.end(); it++)
517 switch ((*it)->GetMessageType())
575 mibMsg->SetMib(
m_mib);
607 "the SRS index check code assumes that subframeNo starts at 1");
614 std::list<UlDciLteControlMessage> uldcilist =
DequeueUlDci();
615 NS_LOG_DEBUG(
this <<
" eNB Expected TBs " << uldcilist.size());
616 for (
auto dciIt = uldcilist.begin(); dciIt != uldcilist.end(); dciIt++)
628 std::vector<int> rbMap;
629 for (
int i = (*dciIt).GetDci().m_rbStart;
630 i < (*dciIt).GetDci().m_rbStart + (*dciIt).GetDci().m_rbLen;
636 (*dciIt).GetDci().m_ndi,
637 (*dciIt).GetDci().m_tbSize,
638 (*dciIt).GetDci().m_mcs,
644 if ((*dciIt).GetDci().m_ndi == 1)
646 NS_LOG_DEBUG(
this <<
" RNTI " << (*dciIt).GetDci().m_rnti <<
" NEW TB");
650 NS_LOG_DEBUG(
this <<
" RNTI " << (*dciIt).GetDci().m_rnti <<
" HARQ RETX");
659 if (!ctrlMsg.empty())
661 auto it = ctrlMsg.begin();
662 while (it != ctrlMsg.end())
671 for (
int i = 0; i < 32; i++)
673 if (((dci->GetDci().m_rbBitmap & mask) >> i) == 1)
687 for (std::size_t i = 0; i < dci->GetDci().m_mcs.size(); i++)
693 params.m_rnti = dci->GetDci().m_rnti;
696 params.m_mcs = dci->GetDci().m_mcs.at(i);
697 params.m_size = dci->GetDci().m_tbsSize.at(i);
698 params.m_rv = dci->GetDci().m_rv.at(i);
699 params.m_ndi = dci->GetDci().m_ndi.at(i);
712 for (
auto it = rarMsg->RarListBegin(); it != rarMsg->RarListEnd(); ++it)
714 if (it->rarPayload.m_grant.m_ulDelay)
718 UlGrant_s ulGrant = it->rarPayload.m_grant;
762 std::vector<int> dlRb;
784 std::list<Ptr<LteControlMessage>> ctrlMsgList;
857 double sinrdb = 10 * std::log10(*it);
879 for (
int i = 0; i < 4; i++)
937 auto ctrlMsgListIt = ctrlMessageList.begin();
938 while (ctrlMsgListIt != ctrlMessageList.end())
944 if (dci->GetDci().m_rnti == rnti)
947 << rnti <<
" is deleted");
948 ctrlMsgListIt = ctrlMessageList.erase(ctrlMsgListIt);
958 if (dci->GetDci().m_rnti == rnti)
961 << rnti <<
" is deleted");
962 ctrlMsgListIt = ctrlMessageList.erase(ctrlMsgListIt);
986 m_paMap.insert(std::pair<uint16_t, double>(rnti, pa));
1001 double srsSum = 0.0;
1004 double sinrdb = 10 * log10(*it);
1058std::list<UlDciLteControlMessage>
1064 std::list<UlDciLteControlMessage> ret =
m_ulDciQueue.at(0);
1066 std::list<UlDciLteControlMessage> l;
1073 std::list<UlDciLteControlMessage> l;
1075 std::list<UlDciLteControlMessage> emptylist;
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.
AttributeValue implementation for Pointer.
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 > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
#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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
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.
Ptr< const AttributeChecker > MakeUintegerChecker()
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.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Ptr< const AttributeChecker > MakeDoubleChecker()
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
static const int Type0AllocationRbg[4]
Type 0 RBG 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