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/lte-ue-rrc.h>
30 #include <ns3/lte-ue-mac.h>
31 #include <ns3/lte-enb-mac.h>
32 #include <ns3/lte-enb-net-device.h>
33 #include <ns3/lte-enb-phy.h>
34 #include <ns3/lte-ue-phy.h>
35 #include <ns3/lte-spectrum-phy.h>
36 #include <ns3/lte-sinr-chunk-processor.h>
37 #include <ns3/single-model-spectrum-channel.h>
38 #include <ns3/friis-spectrum-propagation-loss.h>
39 #include <ns3/isotropic-antenna-model.h>
40 #include <ns3/lte-enb-net-device.h>
41 #include <ns3/lte-ue-net-device.h>
42 #include <ns3/ff-mac-scheduler.h>
43 #include <ns3/lte-rlc.h>
44 #include <ns3/lte-rlc-um.h>
45 #include <ns3/lte-rlc-am.h>
47 #include <ns3/epc-helper.h>
49 #include <ns3/buildings-propagation-loss-model.h>
50 #include <ns3/lte-spectrum-value-helper.h>
79 NS_LOG_LOGIC (
this <<
" using a SpectrumPropagationLossModel in DL");
84 NS_LOG_LOGIC (
this <<
" using a PropagationLossModel in DL");
86 NS_ASSERT_MSG (dlPlm != 0,
" " << m_downlinkPathlossModel <<
" is neither PropagationLossModel nor SpectrumPropagationLossModel");
94 NS_LOG_LOGIC (
this <<
" using a SpectrumPropagationLossModel in UL");
99 NS_LOG_LOGIC (
this <<
" using a PropagationLossModel in UL");
108 m_fadingModule->
Start ();
112 m_macStats = CreateObject<MacStatsCalculator> ();
113 m_rlcStats = CreateObject<RadioBearerStatsCalculator> (
"RLC");
114 m_pdcpStats = CreateObject<RadioBearerStatsCalculator> (
"PDCP");
131 .AddConstructor<LteHelper> ()
132 .AddAttribute (
"Scheduler",
133 "The type of scheduler to be used for eNBs",
136 MakeStringChecker ())
137 .AddAttribute (
"PathlossModel",
138 "The type of pathloss model to be used",
141 MakeStringChecker ())
142 .AddAttribute (
"FadingModel",
143 "The type of fading model to be used",
146 MakeStringChecker ())
147 .AddAttribute (
"EpsBearerToRlcMapping",
148 "Specify which type of RLC will be used for each type of EPS bearer. ",
293 devices.
Add (device);
307 devices.
Add (device);
322 ulPhy->AddCtrlSinrChunkProcessor (pCtrl);
325 ulPhy->AddDataSinrChunkProcessor (pData);
331 NS_ASSERT_MSG (mm,
"MobilityModel needs to be set on node before calling LteHelper::InstallUeDevice ()");
332 dlPhy->SetMobility (mm);
333 ulPhy->SetMobility (mm);
336 NS_ASSERT_MSG (antenna,
"error in creating the AntennaModel object");
337 dlPhy->SetAntenna (antenna);
338 ulPhy->SetAntenna (antenna);
366 phy->SetDevice (dev);
367 dlPhy->SetDevice (dev);
368 ulPhy->SetDevice (dev);
381 NS_LOG_WARN (
"DL propagation model does not have a Frequency attribute");
388 NS_LOG_WARN (
"UL propagation model does not have a Frequency attribute");
415 dlPhy->AddCtrlSinrChunkProcessor (pCtrl);
418 dlPhy->AddDataSinrChunkProcessor (pData);
424 NS_ASSERT_MSG (mm,
"MobilityModel needs to be set on node before calling LteHelper::InstallUeDevice ()");
425 dlPhy->SetMobility (mm);
426 ulPhy->SetMobility (mm);
430 NS_ASSERT_MSG (antenna,
"error in creating the AntennaModel object");
431 dlPhy->SetAntenna (antenna);
432 ulPhy->SetAntenna (antenna);
446 phy->SetDevice (dev);
447 dlPhy->SetDevice (dev);
448 ulPhy->SetDevice (dev);
487 enbPhy->AddUePhy (rnti);
519 double minDistance = std::numeric_limits<double>::infinity ();
525 if (distance < minDistance)
527 minDistance = distance;
528 closestEnbDevice = *i;
532 Attach (ueDevice, closestEnbDevice);
554 uint16_t rnti = ueRrc->
GetRnti ();
650 int64_t currentStream = stream;
672 return (currentStream - stream);
683 std::string ueMapPath = path.substr (0, path.find (
"/RadioBearerMap"));
686 if (match.
GetN () != 0)
706 std::string enbNetDevicePath = path.substr (0, path.find (
"/LteEnbRrc"));
709 if (match.
GetN () != 0)
717 NS_FATAL_ERROR (
"Lookup " << enbNetDevicePath <<
" got no matches");
729 std::string lteUeNetDevicePath = path.substr (0, path.find (
"/LteUeRrc"));
732 if (match.
GetN () != 0)
740 NS_FATAL_ERROR (
"Lookup " << lteUeNetDevicePath <<
" got no matches");
750 std::ostringstream oss;
751 std::string p = path.substr (0, path.find (
"/LteEnbMac"));
753 p +=
"/LteEnbRrc/UeMap/" + oss.str ();
755 NS_LOG_LOGIC (
"FindImsiFromEnbMac: " << path <<
", " << rnti <<
", " << imsi);
764 std::ostringstream oss;
765 std::string p = path.substr (0, path.find (
"/LteEnbMac"));
767 p +=
"/LteEnbRrc/UeMap/" + oss.str ();
769 NS_LOG_LOGIC (
"FindCellIdFromEnbMac: " << path <<
", "<< rnti <<
", " << cellId);
776 uint16_t rnti, uint8_t lcid, uint32_t packetSize)
778 NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize);
799 rlcStats->
DlTxPdu (cellId, imsi, rnti, lcid, packetSize);
804 uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
806 NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
817 rlcStats->
DlRxPdu (imsi, rnti, lcid, packetSize, delay);
824 Config::Connect (
"/NodeList/*/DeviceList/*/LteEnbRrc/UeMap/*/RadioBearerMap/*/LteRlc/TxPDU",
826 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/RadioBearerMap/*/LteRlc/RxPDU",
832 uint16_t rnti, uint8_t lcid, uint32_t packetSize)
834 NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize);
845 rlcStats->
UlTxPdu (imsi, rnti, lcid, packetSize);
850 uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
852 NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
873 rlcStats->
UlRxPdu (cellId, imsi, rnti, lcid, packetSize, delay);
879 std::string path, uint32_t frameNo, uint32_t subframeNo,
880 uint16_t rnti, uint8_t mcsTb1, uint16_t sizeTb1,
881 uint8_t mcsTb2, uint16_t sizeTb2)
885 std::ostringstream pathAndRnti;
886 pathAndRnti << path <<
"/" << rnti;
908 macStats->
DlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcsTb1, sizeTb1, mcsTb2, sizeTb2);
914 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/RadioBearerMap/*/LteRlc/TxPDU",
916 Config::Connect (
"/NodeList/*/DeviceList/*/LteEnbRrc/UeMap/*/RadioBearerMap/*/LteRlc/RxPDU",
937 uint32_t frameNo, uint32_t subframeNo, uint16_t rnti,
938 uint8_t mcs, uint16_t size)
943 std::ostringstream pathAndRnti;
944 pathAndRnti << path <<
"/" << rnti;
965 macStats->
UlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcs, size);
992 Config::Connect (
"/NodeList/*/DeviceList/*/LteEnbRrc/UeMap/*/RadioBearerMap/*/LtePdcp/TxPDU",
994 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/RadioBearerMap/*/LtePdcp/RxPDU",
1001 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/RadioBearerMap/*/LtePdcp/TxPDU",
1003 Config::Connect (
"/NodeList/*/DeviceList/*/LteEnbRrc/UeMap/*/RadioBearerMap/*/LtePdcp/RxPDU",