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> 94 virtual void SetBandwidth (uint8_t ulBandwidth, uint8_t dlBandwidth);
100 virtual void SetCellId (uint16_t cellId);
158 m_enbCphySapUser (0),
161 m_srsPeriodicity (0),
163 m_currentSrsOffset (0),
164 m_interferenceSampleCounter (0)
180 .AddAttribute (
"TxPower",
181 "Transmission power in dBm",
185 MakeDoubleChecker<double> ())
186 .AddAttribute (
"NoiseFigure",
187 "Loss (dB) in the Signal-to-Noise-Ratio due to " 188 "non-idealities in the receiver. According to Wikipedia " 189 "(http://en.wikipedia.org/wiki/Noise_figure), this is " 190 "\"the difference in decibels (dB) between" 191 " the noise output of the actual receiver to " 192 "the noise output of an ideal receiver with " 193 "the same overall gain and bandwidth when the receivers " 194 "are connected to sources at the standard noise " 195 "temperature T0.\" In this model, we consider T0 = 290K.",
199 MakeDoubleChecker<double> ())
200 .AddAttribute (
"MacToChannelDelay",
201 "The delay in TTI units that occurs between " 202 "a scheduling decision in the MAC and the actual " 203 "start of the transmission by the PHY. This is " 204 "intended to be used to model the latency of real PHY " 205 "and MAC implementations.",
209 MakeUintegerChecker<uint8_t> ())
210 .AddTraceSource (
"ReportUeSinr",
211 "Report UEs' averaged linear SINR",
213 "ns3::LteEnbPhy::ReportUeSinrTracedCallback")
214 .AddAttribute (
"UeSinrSamplePeriod",
215 "The sampling period for reporting UEs' SINR stats.",
218 MakeUintegerChecker<uint16_t> ())
219 .AddTraceSource (
"ReportInterference",
220 "Report linear interference power per PHY RB",
222 "ns3::LteEnbPhy::ReportInterferenceTracedCallback")
223 .AddAttribute (
"InterferenceSamplePeriod",
224 "The sampling period for reporting interference stats",
227 MakeUintegerChecker<uint16_t> ())
228 .AddTraceSource (
"DlPhyTransmission",
229 "DL transmission PHY layer statistics.",
231 "ns3::PhyTransmissionStatParameters::TracedCallback")
232 .AddAttribute (
"DlSpectrumPhy",
233 "The downlink LteSpectrumPhy associated to this LtePhy",
237 MakePointerChecker <LteSpectrumPhy> ())
238 .AddAttribute (
"UlSpectrumPhy",
239 "The uplink LteSpectrumPhy associated to this LtePhy",
243 MakePointerChecker <LteSpectrumPhy> ())
268 bool haveNodeId =
false;
275 nodeId = node->
GetId ();
363 std::list<Ptr<LteControlMessage> > l;
365 std::list<UlDciLteControlMessage> l1;
370 std::list<UlDciLteControlMessage> l1;
397 std::set <uint16_t>::iterator it;
415 std::set <uint16_t>::iterator it;
483 std::map<uint16_t, double>::iterator it =
m_paMap.find (rnti);
542 std::list<Ptr<LteControlMessage> >::iterator it;
543 for (it = msgList.begin (); it != msgList.end (); it++)
545 switch ((*it)->GetMessageType ())
607 mibMsg->SetMib (
m_mib);
646 std::list<UlDciLteControlMessage> uldcilist =
DequeueUlDci ();
647 std::list<UlDciLteControlMessage>::iterator dciIt = uldcilist.begin ();
648 NS_LOG_DEBUG (
this <<
" eNB Expected TBs " << uldcilist.size ());
649 for (dciIt = uldcilist.begin (); dciIt!=uldcilist.end (); dciIt++)
651 std::set <uint16_t>::iterator it2;
662 std::vector <int> rbMap;
663 for (
int i = (*dciIt).GetDci ().m_rbStart; i < (*dciIt).GetDci ().m_rbStart + (*dciIt).GetDci ().m_rbLen; i++)
667 m_uplinkSpectrumPhy->AddExpectedTb ((*dciIt).GetDci ().m_rnti, (*dciIt).GetDci ().m_ndi, (*dciIt).GetDci ().m_tbSize, (*dciIt).GetDci ().m_mcs, rbMap, 0 , 0 , 0 ,
false );
668 if ((*dciIt).GetDci ().m_ndi==1)
670 NS_LOG_DEBUG (
this <<
" RNTI " << (*dciIt).GetDci ().m_rnti <<
" NEW TB");
674 NS_LOG_DEBUG (
this <<
" RNTI " << (*dciIt).GetDci ().m_rnti <<
" HARQ RETX");
683 if (ctrlMsg.size () > 0)
685 std::list<Ptr<LteControlMessage> >::iterator it;
686 it = ctrlMsg.begin ();
687 while (it != ctrlMsg.end ())
696 for (
int i = 0; i < 32; i++)
698 if (((dci->GetDci ().m_rbBitmap & mask) >> i) == 1)
710 for (uint8_t i = 0; i < dci->GetDci ().m_mcs.size (); i++)
716 params.
m_rnti = dci->GetDci ().m_rnti;
719 params.
m_mcs = dci->GetDci ().m_mcs.at (i);
720 params.
m_size = dci->GetDci ().m_tbsSize.at (i);
721 params.
m_rv = dci->GetDci ().m_rv.at (i);
722 params.
m_ndi = dci->GetDci ().m_ndi.at (i);
736 for (std::list<RarLteControlMessage::Rar>::const_iterator it = rarMsg->RarListBegin (); it != rarMsg->RarListEnd (); ++it)
738 if (it->rarPayload.m_grant.m_ulDelay ==
true)
742 UlGrant_s ulGrant = it->rarPayload.m_grant;
789 std::vector <int> dlRb;
812 std::list<Ptr<LteControlMessage> > ctrlMsgList;
813 ctrlMsgList.clear ();
886 Values::const_iterator it;
892 double sinrdb = 10 * std::log10 ((*it));
907 NS_LOG_FUNCTION (
this << (uint32_t) ulBandwidth << (uint32_t) dlBandwidth);
917 for (
int i = 0; i < 4; i++)
957 std::map<uint16_t, double>::iterator it =
m_paMap.find (rnti);
970 std::map<uint16_t, double>::iterator it =
m_paMap.find (rnti);
974 m_paMap.insert (std::pair<uint16_t, double> (rnti, pa));
987 Values::const_iterator it;
994 double sinrdb = 10 * log10 ((*it));
1012 (i > 0) ? (srsSum / i) : DBL_MAX);
1051 std::list<UlDciLteControlMessage>
1057 std::list<UlDciLteControlMessage> ret =
m_ulDciQueue.at (0);
1059 std::list<UlDciLteControlMessage> l;
1066 std::list<UlDciLteControlMessage> l;
1068 std::list<UlDciLteControlMessage> emptylist;
1092 std::map <uint16_t,uint16_t>::iterator it =
m_srsCounter.find (rnti);
void DoSetEarfcn(uint32_t dlEarfcn, uint32_t ulEarfcn)
Set EARFCN.
Template for the implementation of the LteEnbCphySapProvider as a member of an owner class of type C ...
virtual void DoInitialize(void)
Initialize() implementation.
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
interference sample counter
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)
Convert from double to fixed point S11.3 notation.
double m_txPower
Transmission power in dBm.
virtual void SendMacPdu(Ptr< Packet > p)
Send the MAC PDU to the channel.
uint16_t m_srsSamplePeriod
The UeSinrSamplePeriod trace source.
uint32_t GetId(void) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
uint8_t m_componentCarrierId
component carrier Id used to address sap
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...
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
double GetNoiseFigure() const
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
type
void DoSendLteControlMessage(Ptr< LteControlMessage > msg)
Send LTE Control Message function.
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)
Set system information block.
std::vector< uint16_t > m_sinr
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.
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)
Report a fatal error with a message and terminate.
Service Access Point (SAP) offered by the UE PHY to the UE RRC for control purposes.
uint16_t GetSrsPeriodicity(uint16_t srcCi) const
EnbMemberLteEnbPhySapProvider(LteEnbPhy *phy)
Constructor.
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
DL data RB map.
uint32_t m_nrFrames
The frame number currently served.
Values::const_iterator ConstValuesBegin() const
bool m_cqiRequest
CQI request?
std::map< uint16_t, uint16_t > m_srsCounter
SRS counter.
Service Access Point (SAP) offered by the eNB-PHY to the eNB-MAC.
LteEnbPhySapUser * m_enbPhySapUser
ENB Phy SAP user.
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.
static Ptr< SpectrumValue > CreateNoisePowerSpectralDensity(uint32_t earfcn, uint8_t bandwidth, double noiseFigure)
create a SpectrumValue that models the power spectral density of AWGN
void CreateSrsReport(uint16_t rnti, double srs)
Create SRS report function.
static const int Type0AllocationRbg[4]
Type 0 RGB allocation.
void SetMacChDelay(uint8_t delay)
The attribute can be read.
static TypeId GetTypeId(void)
Get the type ID.
virtual void GenerateCtrlCqiReport(const SpectrumValue &sinr)
generate a CQI report based on the given SINR of Ctrl frame
double GetTti(void) const
LteEnbCphySapProvider * m_enbCphySapProvider
ENB CPhy SAP provider.
uint8_t GetRbgSize(void) const
std::vector< struct VendorSpecificListElement_s > m_vendorSpecificList
vendor specific list
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
void DoDispose()
Destructor implementation.
void DoSetMasterInformationBlock(LteRrcSap::MasterInformationBlock mib)
Set master information block.
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) ...
Ptr< LteHarqPhy > m_harqPhyModule
HARQ Phy module.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
uint64_t m_imsi
IMSI of the scheduled UE.
static Ptr< SpectrumValue > CreateTxPowerSpectralDensity(uint32_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...
std::map< uint16_t, uint16_t > m_srsSampleCounterMap
SRS sample counter map.
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)
Set bandwidth function.
void SetHarqPhyModule(Ptr< LteHarqPhy > harq)
PhySpectrum generated a new UL HARQ feedback.
bool m_cqiRequest
CQI request.
Define the RNTI that has generated the.
TracedCallback< uint16_t, uint16_t, double, uint8_t > m_reportUeSinr
The ReportUeSinr trace source.
uint16_t m_interferenceSamplePeriod
The InterferenceSamplePeriod attribute.
uint16_t GetSrsSubframeOffset(uint16_t srcCi) const
virtual void ReceiveLteControlMessage(Ptr< LteControlMessage > msg)
Receive the control message.
void StartSubFrame(void)
Start a LTE sub frame.
struct UlCqi_s m_ulCqi
UL CQI.
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)
Set bandwidth function.
uint8_t m_mcs
MCS for transport block.
Substitutive structure for specifying BuildRarListElement_s::m_grant field.
uint32_t m_dlEarfcn
The downlink carrier frequency.
Ptr< LteSpectrumPhy > GetDlSpectrumPhy() const
void SendControlChannels(std::list< Ptr< LteControlMessage > > ctrlMsgList)
Send the PDCCH and PCFICH in the first 3 symbols.
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<T>.
LteRrcSap::MasterInformationBlock m_mib
The Master Information Block message to be broadcasted every frame.
void DoRemoveUe(uint16_t rnti)
Remove UE.
void SetControlMessages(Ptr< LteControlMessage > m)
LteEnbPhySapProvider * m_enbPhySapProvider
ENB Phy SAP provider.
uint16_t m_currentSrsOffset
current SRS offset
void SetTxPower(double pow)
Values::const_iterator ConstValuesEnd() const
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)
Add UE.
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.
virtual void SetCellId(uint16_t cellId)
Set Cell ID function.
LteEnbCphySapProvider * GetLteEnbCphySapProvider()
Get the CPHY SAP provider.
uint16_t m_cellId
Cell identifier.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
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
ENB CPhy SAP user.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
int8_t DoGetReferenceSignalPower() const
uint8_t DoGetMacChTtiDelay()
Get MAC ch TTI delay function.
static void ScheduleWithContext(uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event with the given context.
Ptr< LteNetDevice > m_netDevice
Pointer to the NetDevice where this PHY layer is attached.
friend class EnbMemberLteEnbPhySapProvider
allow EnbMemberLteEnbPhySapProvider class friend access
std::list< Ptr< LteControlMessage > > GetControlMessages(void)
Parameters of the SCHED_UL_CQI_INFO_REQ primitive.
LteEnbPhy * m_phy
the ENB Phy
Ptr< PacketBurst > GetPacketBurst(void)
void DoSetSrsConfigurationIndex(uint16_t rnti, uint16_t srcCi)
Set source configuration index.
uint16_t m_cellId
Cell ID of the attached Enb.
void SetNoiseFigure(double pow)
void SetLteEnbPhySapUser(LteEnbPhySapUser *s)
Set the PHY SAP User.
Time m_srsStartTime
SRS start time.
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
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.
double GetTxPower() const
std::vector< int > GetDownlinkSubChannels(void)
std::vector< uint16_t > m_srsUeOffset
SRS UE offset.
void DoSetTransmissionMode(uint16_t rnti, uint8_t txMode)
Set transmission mode.
uint8_t m_rbgSize
The RB group 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.
uint8_t m_ccId
component carrier id
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.
uint32_t m_ulEarfcn
The uplink carrier frequency.
Ptr< LteSpectrumPhy > GetUlSpectrumPhy() const
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.
PhyTransmissionStatParameters structure.
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'...
int64_t m_timestamp
in millisecond
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.
void SetMacPdu(Ptr< Packet > p)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void SetLteEnbCphySapUser(LteEnbCphySapUser *s)
Set the CPHY SAP User.
uint16_t m_rnti
C-RNTI scheduled.
The LtePhy models the physical layer of LTE.
TracedCallback< PhyTransmissionStatParameters > m_dlPhyTransmission
The DlPhyTransmission trace source.
#define UL_PUSCH_TTIS_DELAY
uint16_t m_srsPeriodicity
SRS periodicity.
void EndFrame(void)
End a LTE frame.
void DoSetPa(uint16_t rnti, double pa)
Set 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.
uint8_t GetMacChDelay(void) const
static const Time DL_CTRL_DELAY_FROM_SUBFRAME_START
Delay from the start of a DL subframe to transmission of the data portion.