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->AddSinrChunkProcessor (p);
325 ulPhy->AddSinrChunkProcessor (pPem);
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);
380 NS_LOG_WARN (
"DL propagation model does not have a Frequency attribute");
387 NS_LOG_WARN (
"UL propagation model does not have a Frequency attribute");
414 dlPhy->AddSinrChunkProcessor (p);
417 dlPhy->AddSinrChunkProcessor (pPem);
423 NS_ASSERT_MSG (mm,
"MobilityModel needs to be set on node before calling LteHelper::InstallUeDevice ()");
424 dlPhy->SetMobility (mm);
425 ulPhy->SetMobility (mm);
429 NS_ASSERT_MSG (antenna,
"error in creating the AntennaModel object");
430 dlPhy->SetAntenna (antenna);
431 ulPhy->SetAntenna (antenna);
445 phy->SetDevice (dev);
446 dlPhy->SetDevice (dev);
447 ulPhy->SetDevice (dev);
484 enbPhy->AddUePhy (rnti, uePhy);
515 double minDistance = std::numeric_limits<double>::infinity ();
521 if (distance < minDistance)
523 minDistance = distance;
524 closestEnbDevice = *i;
528 Attach (ueDevice, closestEnbDevice);
550 uint16_t rnti = ueRrc->
GetRnti ();
646 int64_t currentStream = stream;
668 return (currentStream - stream);
679 std::string ueMapPath = path.substr (0, path.find (
"/RadioBearerMap"));
682 if (match.
GetN () != 0)
702 std::string enbNetDevicePath = path.substr (0, path.find (
"/LteEnbRrc"));
705 if (match.
GetN () != 0)
713 NS_FATAL_ERROR (
"Lookup " << enbNetDevicePath <<
" got no matches");
725 std::string lteUeNetDevicePath = path.substr (0, path.find (
"/LteUeRrc"));
728 if (match.
GetN () != 0)
736 NS_FATAL_ERROR (
"Lookup " << lteUeNetDevicePath <<
" got no matches");
746 std::ostringstream oss;
747 std::string p = path.substr (0, path.find (
"/LteEnbMac"));
749 p +=
"/LteEnbRrc/UeMap/" + oss.str ();
751 NS_LOG_LOGIC (
"FindImsiFromEnbMac: " << path <<
", " << rnti <<
", " << imsi);
760 std::ostringstream oss;
761 std::string p = path.substr (0, path.find (
"/LteEnbMac"));
763 p +=
"/LteEnbRrc/UeMap/" + oss.str ();
765 NS_LOG_LOGIC (
"FindCellIdFromEnbMac: " << path <<
", "<< rnti <<
", " << cellId);
772 uint16_t rnti, uint8_t lcid, uint32_t packetSize)
774 NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize);
795 rlcStats->
DlTxPdu (cellId, imsi, rnti, lcid, packetSize);
800 uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
802 NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
813 rlcStats->
DlRxPdu (imsi, rnti, lcid, packetSize, delay);
820 Config::Connect (
"/NodeList/*/DeviceList/*/LteEnbRrc/UeMap/*/RadioBearerMap/*/LteRlc/TxPDU",
822 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/RadioBearerMap/*/LteRlc/RxPDU",
828 uint16_t rnti, uint8_t lcid, uint32_t packetSize)
830 NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize);
841 rlcStats->
UlTxPdu (imsi, rnti, lcid, packetSize);
846 uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
848 NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
869 rlcStats->
UlRxPdu (cellId, imsi, rnti, lcid, packetSize, delay);
875 std::string path, uint32_t frameNo, uint32_t subframeNo,
876 uint16_t rnti, uint8_t mcsTb1, uint16_t sizeTb1,
877 uint8_t mcsTb2, uint16_t sizeTb2)
881 std::ostringstream pathAndRnti;
882 pathAndRnti << path <<
"/" << rnti;
904 macStats->
DlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcsTb1, sizeTb1, mcsTb2, sizeTb2);
910 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/RadioBearerMap/*/LteRlc/TxPDU",
912 Config::Connect (
"/NodeList/*/DeviceList/*/LteEnbRrc/UeMap/*/RadioBearerMap/*/LteRlc/RxPDU",
933 uint32_t frameNo, uint32_t subframeNo, uint16_t rnti,
934 uint8_t mcs, uint16_t size)
939 std::ostringstream pathAndRnti;
940 pathAndRnti << path <<
"/" << rnti;
961 macStats->
UlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcs, size);
988 Config::Connect (
"/NodeList/*/DeviceList/*/LteEnbRrc/UeMap/*/RadioBearerMap/*/LtePdcp/TxPDU",
990 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/RadioBearerMap/*/LtePdcp/RxPDU",
997 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/RadioBearerMap/*/LtePdcp/TxPDU",
999 Config::Connect (
"/NodeList/*/DeviceList/*/LteEnbRrc/UeMap/*/RadioBearerMap/*/LtePdcp/RxPDU",