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/isotropic-antenna-model.h>
42 #include <ns3/lte-enb-net-device.h>
43 #include <ns3/lte-ue-net-device.h>
44 #include <ns3/ff-mac-scheduler.h>
45 #include <ns3/lte-rlc.h>
46 #include <ns3/lte-rlc-um.h>
47 #include <ns3/lte-rlc-am.h>
48 #include <ns3/epc-enb-s1-sap.h>
49 #include <ns3/lte-rrc-protocol-ideal.h>
50 #include <ns3/lte-rrc-protocol-real.h>
52 #include <ns3/epc-helper.h>
54 #include <ns3/buildings-propagation-loss-model.h>
55 #include <ns3/lte-spectrum-value-helper.h>
56 #include <ns3/epc-x2.h>
86 NS_LOG_LOGIC (
this <<
" using a SpectrumPropagationLossModel in DL");
91 NS_LOG_LOGIC (
this <<
" using a PropagationLossModel in DL");
93 NS_ASSERT_MSG (dlPlm != 0,
" " << m_downlinkPathlossModel <<
" is neither PropagationLossModel nor SpectrumPropagationLossModel");
101 NS_LOG_LOGIC (
this <<
" using a SpectrumPropagationLossModel in UL");
106 NS_LOG_LOGIC (
this <<
" using a PropagationLossModel in UL");
119 m_phyStats = CreateObject<PhyStatsCalculator> ();
122 m_macStats = CreateObject<MacStatsCalculator> ();
138 .AddConstructor<LteHelper> ()
139 .AddAttribute (
"Scheduler",
140 "The type of scheduler to be used for eNBs",
143 MakeStringChecker ())
144 .AddAttribute (
"PathlossModel",
145 "The type of pathloss model to be used",
148 MakeStringChecker ())
149 .AddAttribute (
"FadingModel",
150 "The type of fading model to be used. If the type is set "
151 "to an empty string, no fading model is used.",
154 MakeStringChecker ())
155 .AddAttribute (
"UseIdealRrc",
156 "If true, LteRrcProtocolIdeal will be used for RRC signaling. "
157 "If false, LteRrcProtocolReal will be used.",
160 MakeBooleanChecker ())
294 devices.
Add (device);
308 devices.
Add (device);
327 dlPhy->SetHarqPhyModule (harq);
328 ulPhy->SetHarqPhyModule (harq);
329 phy->SetHarqPhyModule (harq);
332 ulPhy->AddCtrlSinrChunkProcessor (pCtrl);
335 ulPhy->AddDataSinrChunkProcessor (pData);
338 ulPhy->AddInterferenceChunkProcessor (pInterf);
344 NS_ASSERT_MSG (mm,
"MobilityModel needs to be set on node before calling LteHelper::InstallUeDevice ()");
345 dlPhy->SetMobility (mm);
346 ulPhy->SetMobility (mm);
349 NS_ASSERT_MSG (antenna,
"error in creating the AntennaModel object");
350 dlPhy->SetAntenna (antenna);
351 ulPhy->SetAntenna (antenna);
360 rrcProtocol->SetLteEnbRrcSapProvider (rrc->GetLteEnbRrcSapProvider ());
361 rrc->SetLteEnbRrcSapUser (rrcProtocol->GetLteEnbRrcSapUser ());
362 rrc->AggregateObject (rrcProtocol);
363 rrcProtocol->SetCellId (cellId);
368 rrcProtocol->SetLteEnbRrcSapProvider (rrc->GetLteEnbRrcSapProvider ());
369 rrc->SetLteEnbRrcSapUser (rrcProtocol->GetLteEnbRrcSapUser ());
370 rrc->AggregateObject (rrcProtocol);
371 rrcProtocol->SetCellId (cellId);
377 rrc->GetAttribute (
"EpsBearerToRlcMapping", epsBearerToRlcMapping);
399 phy->SetLteEnbCphySapUser (rrc->GetLteEnbCphySapUser ());
400 rrc->SetLteEnbCphySapProvider (phy->GetLteEnbCphySapProvider ());
410 phy->SetDevice (dev);
411 dlPhy->SetDevice (dev);
412 ulPhy->SetDevice (dev);
426 NS_LOG_WARN (
"DL propagation model does not have a Frequency attribute");
433 NS_LOG_WARN (
"UL propagation model does not have a Frequency attribute");
446 NS_ASSERT_MSG (enbApp != 0,
"cannot retrieve EpcEnbApplication");
449 rrc->SetS1SapProvider (enbApp->GetS1SapProvider ());
450 enbApp->SetS1SapUser (rrc->GetS1SapUser ());
454 x2->SetEpcX2SapUser (rrc->GetEpcX2SapUser ());
455 rrc->SetEpcX2SapProvider (x2->GetEpcX2SapProvider ());
471 dlPhy->SetHarqPhyModule (harq);
472 ulPhy->SetHarqPhyModule (harq);
473 phy->SetHarqPhyModule (harq);
476 dlPhy->AddRsPowerChunkProcessor (pRs);
479 dlPhy->AddCtrlSinrChunkProcessor (pCtrl);
482 dlPhy->AddDataSinrChunkProcessor (pData);
488 NS_ASSERT_MSG (mm,
"MobilityModel needs to be set on node before calling LteHelper::InstallUeDevice ()");
489 dlPhy->SetMobility (mm);
490 ulPhy->SetMobility (mm);
493 NS_ASSERT_MSG (antenna,
"error in creating the AntennaModel object");
494 dlPhy->SetAntenna (antenna);
495 ulPhy->SetAntenna (antenna);
503 rrcProtocol->SetUeRrc (rrc);
504 rrc->AggregateObject (rrcProtocol);
505 rrcProtocol->SetLteUeRrcSapProvider (rrc->GetLteUeRrcSapProvider ());
506 rrc->SetLteUeRrcSapUser (rrcProtocol->GetLteUeRrcSapUser ());
511 rrcProtocol->SetUeRrc (rrc);
512 rrc->AggregateObject (rrcProtocol);
513 rrcProtocol->SetLteUeRrcSapProvider (rrc->GetLteUeRrcSapProvider ());
514 rrc->SetLteUeRrcSapUser (rrcProtocol->GetLteUeRrcSapUser ());
519 rrc->SetUseRlcSm (
false);
533 phy->SetLteUeCphySapUser (rrc->GetLteUeCphySapUser ());
534 rrc->SetLteUeCphySapProvider (phy->GetLteUeCphySapProvider ());
539 phy->SetDevice (dev);
540 dlPhy->SetDevice (dev);
541 ulPhy->SetDevice (dev);
542 nas->SetDevice (dev);
581 ueNas->Connect (enbLteDevice->GetCellId (), enbLteDevice->GetDlEarfcn ());
612 double minDistance = std::numeric_limits<double>::infinity ();
618 if (distance < minDistance)
620 minDistance = distance;
621 closestEnbDevice = *i;
625 Attach (ueDevice, closestEnbDevice);
655 void ActivateDrb (uint64_t imsi, uint16_t cellId, uint16_t rnti);
665 m_ueDevice (ueDevice),
675 a->ActivateDrb (imsi, cellId, rnti);
686 uint16_t rnti = ueRrc->
GetRnti();
718 std::ostringstream path;
719 path <<
"/NodeList/" << enbLteDevice->
GetNode ()->
GetId ()
720 <<
"/DeviceList/" << enbLteDevice->
GetIfIndex ()
721 <<
"/LteEnbRrc/ConnectionEstablished";
753 NS_ASSERT_MSG (
m_epcHelper,
"Handover requires the use of the EPC - did you forget to call LteHelper::SetEpcHelper () ?");
832 m_rlcStats = CreateObject<RadioBearerStatsCalculator> (
"RLC");
839 int64_t currentStream = stream;
863 return (currentStream - stream);
874 std::string ueMapPath = path.substr (0, path.find (
"/DataRadioBearerMap"));
877 if (match.
GetN () != 0)
897 std::string ueRlcPath = path.substr (0, path.find (
"/LteUePhy"));
898 ueRlcPath +=
"/LteUeRrc";
901 if (match.
GetN () != 0)
924 if (match.
GetN () != 0)
944 std::string enbNetDevicePath = path.substr (0, path.find (
"/LteEnbRrc"));
946 if (match.
GetN () != 0)
954 NS_FATAL_ERROR (
"Lookup " << enbNetDevicePath <<
" got no matches");
964 std::ostringstream oss;
965 std::string p = path.substr (0, path.find (
"/LteEnbMac"));
967 p +=
"/LteEnbRrc/UeMap/" + oss.str ();
969 NS_LOG_LOGIC (
"FindImsiFromEnbMac: " << path <<
", " << rnti <<
", " << imsi);
978 std::ostringstream oss;
979 std::string p = path.substr (0, path.find (
"/LteEnbMac"));
981 p +=
"/LteEnbRrc/UeMap/" + oss.str ();
983 NS_LOG_LOGIC (
"FindCellIdFromEnbMac: " << path <<
", "<< rnti <<
", " << cellId);
993 if (path.find (
"/DlPhyTransmission"))
996 std::ostringstream oss;
997 std::string p = path.substr (0, path.find (
"/LteEnbPhy"));
999 p +=
"/LteEnbRrc/UeMap/" + oss.str ();
1001 NS_LOG_LOGIC (
"FindImsiForEnb[Tx]: " << path <<
", " << rnti <<
", " << imsi);
1003 else if (path.find (
"/UlPhyReception"))
1005 std::string p = path.substr (0, path.find (
"/LteUePhy"));
1007 NS_LOG_LOGIC (
"FindImsiForEnb[Rx]: " << path <<
", " << rnti <<
", " << imsi);
1018 if (path.find (
"/UlPhyTransmission"))
1020 std::string p = path.substr (0, path.find (
"/LteUePhy"));
1022 NS_LOG_LOGIC (
"FindImsiForUe[Tx]: " << path <<
", " << rnti <<
", " << imsi);
1024 else if (path.find (
"/DlPhyReception"))
1027 std::ostringstream oss;
1028 std::string p = path.substr (0, path.find (
"/LteEnbPhy"));
1030 p +=
"/LteEnbRrc/UeMap/" + oss.str ();
1032 NS_LOG_LOGIC (
"FindImsiForUe[Rx]: " << path <<
", " << rnti <<
", " << imsi);
1043 std::ostringstream pathAndRnti;
1044 pathAndRnti << path <<
"/" << params.
m_rnti;
1047 imsi = phyTxStats->
GetImsiPath (pathAndRnti.str ());
1052 phyTxStats->
SetImsiPath (pathAndRnti.str (), imsi);
1065 std::ostringstream pathAndRnti;
1066 pathAndRnti << path <<
"/" << params.
m_rnti;
1069 imsi = phyTxStats->
GetImsiPath (pathAndRnti.str ());
1074 phyTxStats->
SetImsiPath (pathAndRnti.str (), imsi);
1088 std::ostringstream pathAndRnti;
1089 pathAndRnti << path <<
"/" << params.
m_rnti;
1092 imsi = phyRxStats->
GetImsiPath (pathAndRnti.str ());
1097 phyRxStats->
SetImsiPath (pathAndRnti.str (), imsi);
1110 std::ostringstream pathAndRnti;
1111 pathAndRnti << path <<
"/" << params.
m_rnti;
1114 imsi = phyRxStats->
GetImsiPath (pathAndRnti.str ());
1119 phyRxStats->
SetImsiPath (pathAndRnti.str (), imsi);
1140 Config::Connect (
"/NodeList/*/DeviceList/*/LteEnbPhy/DlPhyTransmission",
1147 Config::Connect (
"/NodeList/*/DeviceList/*/LteUePhy/UlPhyTransmission",
1154 Config::Connect (
"/NodeList/*/DeviceList/*/LteUePhy/DlSpectrumPhy/DlPhyReception",
1161 Config::Connect (
"/NodeList/*/DeviceList/*/LteEnbPhy/UlSpectrumPhy/UlPhyReception",
1169 std::string path, uint32_t frameNo, uint32_t subframeNo,
1170 uint16_t rnti, uint8_t mcsTb1, uint16_t sizeTb1,
1171 uint8_t mcsTb2, uint16_t sizeTb2)
1175 std::ostringstream pathAndRnti;
1176 pathAndRnti << path <<
"/" << rnti;
1179 imsi = macStats->
GetImsiPath (pathAndRnti.str ());
1187 uint16_t cellId = 0;
1198 macStats->
DlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcsTb1, sizeTb1, mcsTb2, sizeTb2);
1221 uint32_t frameNo, uint32_t subframeNo, uint16_t rnti,
1222 uint8_t mcs, uint16_t size)
1227 std::ostringstream pathAndRnti;
1228 pathAndRnti << path <<
"/" << rnti;
1231 imsi = macStats->
GetImsiPath (pathAndRnti.str ());
1238 uint16_t cellId = 0;
1249 macStats->
UlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcs, size);
1262 std::string path, uint16_t cellId, uint16_t rnti,
1263 double rsrp,
double sinr)
1267 std::string pathUePhy = path.substr (0, path.find (
"/ReportCurrentCellRsrpSinr"));
1285 Config::Connect (
"/NodeList/*/DeviceList/*/LteUePhy/ReportCurrentCellRsrpSinr",
1291 uint16_t cellId, uint16_t rnti,
double sinrLinear)
1296 std::ostringstream pathAndRnti;
1297 pathAndRnti << path <<
"/" << rnti;
1298 std::string pathEnbMac = path.substr (0, path.find (
"LteEnbPhy/ReportUeSinr"));
1299 pathEnbMac +=
"LteEnbMac/DlScheduling";
1302 imsi = phyStats->
GetImsiPath (pathAndRnti.str ());
1310 phyStats->
ReportUeSinr (cellId, imsi, rnti, sinrLinear);
1327 Config::Connect (
"/NodeList/*/DeviceList/*/LteEnbPhy/ReportInterference",
1342 m_pdcpStats = CreateObject<RadioBearerStatsCalculator> (
"PDCP");