24 #include <ns3/string.h>
26 #include <ns3/abort.h>
27 #include <ns3/pointer.h>
28 #include <ns3/lte-enb-rrc.h>
29 #include <ns3/epc-ue-nas.h>
30 #include <ns3/epc-enb-application.h>
31 #include <ns3/lte-ue-rrc.h>
32 #include <ns3/lte-ue-mac.h>
33 #include <ns3/lte-enb-mac.h>
34 #include <ns3/lte-enb-net-device.h>
35 #include <ns3/lte-enb-phy.h>
36 #include <ns3/lte-ue-phy.h>
37 #include <ns3/lte-spectrum-phy.h>
38 #include <ns3/lte-sinr-chunk-processor.h>
39 #include <ns3/multi-model-spectrum-channel.h>
40 #include <ns3/friis-spectrum-propagation-loss.h>
41 #include <ns3/trace-fading-loss-model.h>
42 #include <ns3/isotropic-antenna-model.h>
43 #include <ns3/lte-enb-net-device.h>
44 #include <ns3/lte-ue-net-device.h>
45 #include <ns3/ff-mac-scheduler.h>
46 #include <ns3/lte-rlc.h>
47 #include <ns3/lte-rlc-um.h>
48 #include <ns3/lte-rlc-am.h>
49 #include <ns3/epc-enb-s1-sap.h>
50 #include <ns3/lte-rrc-protocol-ideal.h>
51 #include <ns3/lte-rrc-protocol-real.h>
52 #include <ns3/mac-stats-calculator.h>
53 #include <ns3/phy-stats-calculator.h>
54 #include <ns3/phy-tx-stats-calculator.h>
55 #include <ns3/phy-rx-stats-calculator.h>
56 #include <ns3/epc-helper.h>
58 #include <ns3/buildings-propagation-loss-model.h>
59 #include <ns3/lte-spectrum-value-helper.h>
60 #include <ns3/epc-x2.h>
69 : m_fadingStreamsAssigned (false),
91 NS_LOG_LOGIC (
this <<
" using a SpectrumPropagationLossModel in DL");
96 NS_LOG_LOGIC (
this <<
" using a PropagationLossModel in DL");
98 NS_ASSERT_MSG (dlPlm != 0,
" " << m_downlinkPathlossModel <<
" is neither PropagationLossModel nor SpectrumPropagationLossModel");
106 NS_LOG_LOGIC (
this <<
" using a SpectrumPropagationLossModel in UL");
111 NS_LOG_LOGIC (
this <<
" using a PropagationLossModel in UL");
123 m_phyStats = CreateObject<PhyStatsCalculator> ();
126 m_macStats = CreateObject<MacStatsCalculator> ();
142 .AddConstructor<LteHelper> ()
143 .AddAttribute (
"Scheduler",
144 "The type of scheduler to be used for eNBs. "
145 "The allowed values for this attributes are the type names "
146 "of any class inheriting from ns3::FfMacScheduler.",
149 MakeStringChecker ())
150 .AddAttribute (
"PathlossModel",
151 "The type of pathloss model to be used. "
152 "The allowed values for this attributes are the type names "
153 "of any class inheriting from ns3::PropagationLossModel.",
156 MakeStringChecker ())
157 .AddAttribute (
"FadingModel",
158 "The type of fading model to be used."
159 "The allowed values for this attributes are the type names "
160 "of any class inheriting from ns3::SpectrumPropagationLossModel."
161 "If the type is set to an empty string, no fading model is used.",
164 MakeStringChecker ())
165 .AddAttribute (
"UseIdealRrc",
166 "If true, LteRrcProtocolIdeal will be used for RRC signaling. "
167 "If false, LteRrcProtocolReal will be used.",
170 MakeBooleanChecker ())
310 devices.
Add (device);
324 devices.
Add (device);
343 dlPhy->SetHarqPhyModule (harq);
344 ulPhy->SetHarqPhyModule (harq);
345 phy->SetHarqPhyModule (harq);
348 ulPhy->AddCtrlSinrChunkProcessor (pCtrl);
351 ulPhy->AddDataSinrChunkProcessor (pData);
354 ulPhy->AddInterferenceDataChunkProcessor (pInterf);
360 NS_ASSERT_MSG (mm,
"MobilityModel needs to be set on node before calling LteHelper::InstallUeDevice ()");
361 dlPhy->SetMobility (mm);
362 ulPhy->SetMobility (mm);
365 NS_ASSERT_MSG (antenna,
"error in creating the AntennaModel object");
366 dlPhy->SetAntenna (antenna);
367 ulPhy->SetAntenna (antenna);
376 rrcProtocol->SetLteEnbRrcSapProvider (rrc->GetLteEnbRrcSapProvider ());
377 rrc->SetLteEnbRrcSapUser (rrcProtocol->GetLteEnbRrcSapUser ());
378 rrc->AggregateObject (rrcProtocol);
379 rrcProtocol->SetCellId (cellId);
384 rrcProtocol->SetLteEnbRrcSapProvider (rrc->GetLteEnbRrcSapProvider ());
385 rrc->SetLteEnbRrcSapUser (rrcProtocol->GetLteEnbRrcSapUser ());
386 rrc->AggregateObject (rrcProtocol);
387 rrcProtocol->SetCellId (cellId);
393 rrc->GetAttribute (
"EpsBearerToRlcMapping", epsBearerToRlcMapping);
401 rrc->SetLteEnbCmacSapProvider (mac->GetLteEnbCmacSapProvider ());
402 mac->SetLteEnbCmacSapUser (rrc->GetLteEnbCmacSapUser ());
403 rrc->SetLteMacSapProvider (mac->GetLteMacSapProvider ());
405 mac->SetFfMacSchedSapProvider (sched->GetFfMacSchedSapProvider ());
406 mac->SetFfMacCschedSapProvider (sched->GetFfMacCschedSapProvider ());
408 sched->SetFfMacSchedSapUser (mac->GetFfMacSchedSapUser ());
409 sched->SetFfMacCschedSapUser (mac->GetFfMacCschedSapUser ());
411 phy->SetLteEnbPhySapUser (mac->GetLteEnbPhySapUser ());
412 mac->SetLteEnbPhySapProvider (phy->GetLteEnbPhySapProvider ());
415 phy->SetLteEnbCphySapUser (rrc->GetLteEnbCphySapUser ());
416 rrc->SetLteEnbCphySapProvider (phy->GetLteEnbCphySapProvider ());
423 dev->SetAttribute (
"FfMacScheduler",
PointerValue (sched));
426 phy->SetDevice (dev);
427 dlPhy->SetDevice (dev);
428 ulPhy->SetDevice (dev);
442 NS_LOG_WARN (
"DL propagation model does not have a Frequency attribute");
449 NS_LOG_WARN (
"UL propagation model does not have a Frequency attribute");
462 NS_ASSERT_MSG (enbApp != 0,
"cannot retrieve EpcEnbApplication");
465 rrc->SetS1SapProvider (enbApp->GetS1SapProvider ());
466 enbApp->SetS1SapUser (rrc->GetS1SapUser ());
470 x2->SetEpcX2SapUser (rrc->GetEpcX2SapUser ());
471 rrc->SetEpcX2SapProvider (x2->GetEpcX2SapProvider ());
487 dlPhy->SetHarqPhyModule (harq);
488 ulPhy->SetHarqPhyModule (harq);
489 phy->SetHarqPhyModule (harq);
492 dlPhy->AddRsPowerChunkProcessor (pRs);
495 dlPhy->AddInterferenceCtrlChunkProcessor (pInterf);
498 dlPhy->AddCtrlSinrChunkProcessor (pCtrl);
501 dlPhy->AddDataSinrChunkProcessor (pData);
507 NS_ASSERT_MSG (mm,
"MobilityModel needs to be set on node before calling LteHelper::InstallUeDevice ()");
508 dlPhy->SetMobility (mm);
509 ulPhy->SetMobility (mm);
512 NS_ASSERT_MSG (antenna,
"error in creating the AntennaModel object");
513 dlPhy->SetAntenna (antenna);
514 ulPhy->SetAntenna (antenna);
522 rrcProtocol->SetUeRrc (rrc);
523 rrc->AggregateObject (rrcProtocol);
524 rrcProtocol->SetLteUeRrcSapProvider (rrc->GetLteUeRrcSapProvider ());
525 rrc->SetLteUeRrcSapUser (rrcProtocol->GetLteUeRrcSapUser ());
530 rrcProtocol->SetUeRrc (rrc);
531 rrc->AggregateObject (rrcProtocol);
532 rrcProtocol->SetLteUeRrcSapProvider (rrc->GetLteUeRrcSapProvider ());
533 rrc->SetLteUeRrcSapUser (rrcProtocol->GetLteUeRrcSapUser ());
538 rrc->SetUseRlcSm (
false);
542 nas->SetAsSapProvider (rrc->GetAsSapProvider ());
543 rrc->SetAsSapUser (nas->GetAsSapUser ());
545 rrc->SetLteUeCmacSapProvider (mac->GetLteUeCmacSapProvider ());
546 mac->SetLteUeCmacSapUser (rrc->GetLteUeCmacSapUser ());
547 rrc->SetLteMacSapProvider (mac->GetLteMacSapProvider ());
549 phy->SetLteUePhySapUser (mac->GetLteUePhySapUser ());
550 mac->SetLteUePhySapProvider (phy->GetLteUePhySapProvider ());
552 phy->SetLteUeCphySapUser (rrc->GetLteUeCphySapUser ());
553 rrc->SetLteUeCphySapProvider (phy->GetLteUeCphySapProvider ());
558 phy->SetDevice (dev);
559 dlPhy->SetDevice (dev);
560 ulPhy->SetDevice (dev);
561 nas->SetDevice (dev);
601 ueNas->Connect (enbLteDevice->GetCellId (), enbLteDevice->GetDlEarfcn ());
632 double minDistance = std::numeric_limits<double>::infinity ();
638 if (distance < minDistance)
640 minDistance = distance;
641 closestEnbDevice = *i;
645 Attach (ueDevice, closestEnbDevice);
666 uint64_t imsi = ueDevice->GetObject<
LteUeNetDevice> ()->GetImsi ();
667 m_epcHelper->ActivateEpsBearer (ueDevice, imsi, tft, bearer);
675 void ActivateDrb (uint64_t imsi, uint16_t cellId, uint16_t rnti);
685 m_ueDevice (ueDevice),
695 a->ActivateDrb (imsi, cellId, rnti);
706 uint16_t rnti = ueRrc->GetRnti();
709 NS_ASSERT (ueRrc->GetCellId () == enbLteDevice->GetCellId ());
718 enbRrc->GetS1SapUser ()->DataRadioBearerSetupRequest (params);
738 std::ostringstream path;
739 path <<
"/NodeList/" << enbLteDevice->GetNode ()->GetId ()
740 <<
"/DeviceList/" << enbLteDevice->GetIfIndex ()
741 <<
"/LteEnbRrc/ConnectionEstablished";
773 NS_ASSERT_MSG (
m_epcHelper,
"Handover requires the use of the EPC - did you forget to call LteHelper::SetEpcHelper () ?");
782 uint16_t targetCellId = targetEnbDev->GetObject<
LteEnbNetDevice> ()->GetCellId ();
784 uint16_t rnti = ueDev->GetObject<
LteUeNetDevice> ()->GetRrc ()->GetRnti ();
785 sourceRrc->SendHandoverRequest (rnti, targetCellId);
852 m_rlcStats = CreateObject<RadioBearerStatsCalculator> (
"RLC");
859 int64_t currentStream = stream;
865 currentStream += tflm->AssignStreams (currentStream);
878 currentStream += dlPhy->AssignStreams (currentStream);
879 currentStream += ulPhy->AssignStreams (currentStream);
887 currentStream += dlPhy->AssignStreams (currentStream);
888 currentStream += ulPhy->AssignStreams (currentStream);
889 currentStream += ueMac->AssignStreams (currentStream);
892 return (currentStream - stream);
910 Config::Connect (
"/NodeList/*/DeviceList/*/LteEnbPhy/DlPhyTransmission",
917 Config::Connect (
"/NodeList/*/DeviceList/*/LteUePhy/UlPhyTransmission",
924 Config::Connect (
"/NodeList/*/DeviceList/*/LteUePhy/DlSpectrumPhy/DlPhyReception",
931 Config::Connect (
"/NodeList/*/DeviceList/*/LteEnbPhy/UlSpectrumPhy/UlPhyReception",
964 Config::Connect (
"/NodeList/*/DeviceList/*/LteUePhy/ReportCurrentCellRsrpSinr",
974 Config::Connect (
"/NodeList/*/DeviceList/*/LteEnbPhy/ReportInterference",
989 m_pdcpStats = CreateObject<RadioBearerStatsCalculator> (
"PDCP");
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
TypeId GetTypeId(void) const
Ptr< Object > m_uplinkPathlossModel
keep track of time values and allow control of global simulation resolution
void SetPathlossModelAttribute(std::string n, const AttributeValue &v)
virtual void AddPropagationLossModel(Ptr< PropagationLossModel > loss)=0
void EnableDlRxPhyTraces(void)
smart pointer class similar to boost::intrusive_ptr
RadioBearerStatsConnector m_radioBearerStatsConnector
#define NS_LOG_FUNCTION(parameters)
Ptr< NetDevice > InstallSingleEnbDevice(Ptr< Node > n)
static TypeId GetTypeId(void)
NetDeviceContainer InstallEnbDevice(NodeContainer c)
std::vector< Ptr< Node > >::const_iterator Iterator
void EnableLogComponents(void)
hold variables of type string
void HandoverRequest(Time hoTime, Ptr< NetDevice > ueDev, Ptr< NetDevice > sourceEnbDev, Ptr< NetDevice > targetEnbDev)
static void DlSchedulingCallback(Ptr< MacStatsCalculator > macStats, std::string path, uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2)
bool m_fadingStreamsAssigned
ObjectFactory m_fadingModelFactory
static void ActivateCallback(Ptr< DrbActivator > a, std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
Hold a value for an Attribute.
void EnableDlPhyTraces(void)
virtual void ReceiveLteControlMessageList(std::list< Ptr< LteControlMessage > >)
PhySpectrum received a new list of LteControlMessage.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
static Vector GetPosition(Ptr< Node > node)
DrbActivator(Ptr< NetDevice > ueDevice, EpsBearer bearer)
void SetUeAntennaModelAttribute(std::string n, const AttributeValue &v)
void SetFadingModel(std::string model)
static Ptr< EpcTft > Default()
void ReportUeSinr(uint16_t cellId, uint64_t imsi, uint16_t rnti, double sinrLinear)
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
void EnableRlcTraces(void)
void SetTypeId(TypeId tid)
Ptr< PhyStatsCalculator > m_phyStats
void EnablePdcpStats(Ptr< RadioBearerStatsCalculator > pdcpStats)
Ptr< PhyRxStatsCalculator > m_phyRxStats
std::string m_fadingModelType
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
bool SetAttributeFailSafe(std::string name, const AttributeValue &value)
virtual void DoDispose(void)
void SetUeAntennaModelType(std::string type)
#define NS_LOG_FUNCTION_NOARGS()
Ptr< MacStatsCalculator > m_macStats
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
void Connect(std::string path, const CallbackBase &cb)
ObjectFactory m_ulPathlossModelFactory
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
ObjectFactory m_channelFactory
void EnableUlRxPhyTraces(void)
void SetSchedulerType(std::string type)
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
Ptr< RadioBearerStatsCalculator > m_rlcStats
void EnablePdcpTraces(void)
void AttachToClosestEnb(NetDeviceContainer ueDevices, NetDeviceContainer enbDevices)
static void ReportCurrentCellRsrpSinrCallback(Ptr< PhyStatsCalculator > phyStats, std::string path, uint16_t cellId, uint16_t rnti, double rsrp, double sinr)
Keep track of the current position and velocity of an object.
Ptr< Object > m_downlinkPathlossModel
static double GetCarrierFrequency(uint16_t earfcn)
Ptr< Application > GetApplication(uint32_t index) const
Ptr< NetDevice > m_ueDevice
hold variables of type 'enum'
void DoHandoverRequest(Ptr< NetDevice > ueDev, Ptr< NetDevice > sourceEnbDev, Ptr< NetDevice > targetEnbDev)
Ptr< Object > Create(void) const
double CalculateDistance(const Vector3D &a, const Vector3D &b)
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
void EnableRlcStats(Ptr< RadioBearerStatsCalculator > rlcStats)
virtual void ReceiveLteUlHarqFeedback(UlInfoListElement_s mes)
PhySpectrum generated a new UL HARQ feedback.
Hold an unsigned integer type.
void SetSchedulerAttribute(std::string n, const AttributeValue &v)
Ptr< NetDevice > InstallSingleUeDevice(Ptr< Node > n)
void Attach(NetDeviceContainer ueDevices, Ptr< NetDevice > enbDevice)
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
static TypeId GetTypeId(void)
ObjectFactory m_enbAntennaModelFactory
holds a vector of ns3::NetDevice pointers
virtual void AddSpectrumPropagationLossModel(Ptr< SpectrumPropagationLossModel > loss)=0
void EnablePhyTraces(void)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
fading loss model based on precalculated fading traces
#define NS_LOG_LOGIC(msg)
void SetEnbAntennaModelType(std::string type)
static TypeId GetTypeId()
ObjectFactory m_dlPathlossModelFactory
void SetSpectrumChannelType(std::string type)
static TypeId GetTypeId(void)
void SetFadingModelAttribute(std::string n, const AttributeValue &v)
void EnableDlMacTraces(void)
virtual void ReceiveLteDlHarqFeedback(DlInfoListElement_s mes)
PhySpectrum generated a new DL HARQ feedback.
void ActivateDedicatedEpsBearer(NetDeviceContainer ueDevices, EpsBearer bearer, Ptr< EpcTft > tft)
keep track of a set of node pointers.
hold objects of type Ptr<T>
void EnableUlTxPhyTraces(void)
Ptr< SpectrumChannel > m_uplinkChannel
static void DlPhyTransmissionCallback(Ptr< PhyTxStatsCalculator > phyTxStats, std::string path, PhyTransmissionStatParameters params)
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
void AddX2Interface(NodeContainer enbNodes)
std::string GetName(void) const
void Set(std::string name, const AttributeValue &value)
ObjectFactory m_schedulerFactory
void EnableUlPhyTraces(void)
void EnableDlTxPhyTraces(void)
friend class ObjectFactory
Ptr< SpectrumPropagationLossModel > m_fadingModule
static void DlPhyReceptionCallback(Ptr< PhyRxStatsCalculator > phyRxStats, std::string path, PhyReceptionStatParameters params)
void Receive(Ptr< Packet > p)
void EnableUlMacTraces(void)
static void UlPhyReceptionCallback(Ptr< PhyRxStatsCalculator > phyRxStats, std::string path, PhyReceptionStatParameters params)
static void UlSchedulingCallback(Ptr< MacStatsCalculator > macStats, std::string path, uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcs, uint16_t size)
#define NS_ASSERT_MSG(condition, message)
Ptr< EpcHelper > m_epcHelper
Ptr< RadioBearerStatsCalculator > GetRlcStats(void)
NetDeviceContainer InstallUeDevice(NodeContainer c)
Ptr< PhyTxStatsCalculator > m_phyTxStats
Ptr< RadioBearerStatsCalculator > GetPdcpStats(void)
static void UlPhyTransmissionCallback(Ptr< PhyTxStatsCalculator > phyTxStats, std::string path, PhyTransmissionStatParameters params)
virtual void DoDispose(void)
Modelize the propagation loss through a transmission medium.
void SetEpcHelper(Ptr< EpcHelper > h)
uint32_t AddDevice(Ptr< NetDevice > device)
void SetPathlossModelType(std::string type)
std::vector< Ptr< NetDevice > >::const_iterator Iterator
virtual void ReceiveLteControlMessageList(std::list< Ptr< LteControlMessage > >)
void ActivateDrb(uint64_t imsi, uint16_t cellId, uint16_t rnti)
virtual void ReceivePss(uint16_t cellId, Ptr< SpectrumValue > p)
void SetEnbAntennaModelAttribute(std::string n, const AttributeValue &v)
void SetSpectrumChannelAttribute(std::string n, const AttributeValue &v)
void PhyPduReceived(Ptr< Packet > p)
PhySpectrum received a new PHY-PDU.
void ReportInterference(uint16_t cellId, Ptr< SpectrumValue > interference)
virtual void DoInitialize(void)
spectrum-aware propagation loss model
void EnableMacTraces(void)
a base class which provides memory management and object aggregation
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if cond is true.
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
Ptr< RadioBearerStatsCalculator > m_pdcpStats
Hold an floating point type.
ObjectFactory m_ueAntennaModelFactory
Ptr< T > GetObject(void) const
A template-based reference counting class.
void PhyPduReceived(Ptr< Packet > p)
PhySpectrum received a new PHY-PDU.
a unique identifier for an interface.
ObjectFactory m_enbNetDeviceFactory
Ptr< SpectrumChannel > m_downlinkChannel
TypeId SetParent(TypeId tid)
virtual void DoInitialize(void)
std::string GetSchedulerType() const
void LogComponentEnable(char const *name, enum LogLevel level)
void SetEnbDeviceAttribute(std::string n, const AttributeValue &v)