11#include "nr-test-ue-measurements.h"
13#include "ns3/boolean.h"
14#include "ns3/callback.h"
15#include "ns3/config.h"
16#include "ns3/double.h"
18#include "ns3/ff-mac-scheduler.h"
19#include "ns3/internet-stack-helper.h"
20#include "ns3/ipv4-address-helper.h"
21#include "ns3/ipv4-interface-container.h"
22#include "ns3/ipv4-static-routing-helper.h"
24#include "ns3/mobility-helper.h"
25#include "ns3/net-device-container.h"
26#include "ns3/node-container.h"
27#include "ns3/nr-common.h"
28#include "ns3/nr-epc-helper.h"
29#include "ns3/nr-gnb-net-device.h"
30#include "ns3/nr-gnb-phy.h"
31#include "ns3/nr-gnb-rrc.h"
32#include "ns3/nr-helper.h"
33#include "ns3/nr-point-to-point-epc-helper.h"
34#include "ns3/nr-ue-net-device.h"
35#include "ns3/nr-ue-phy.h"
36#include "ns3/nr-ue-rrc.h"
37#include "ns3/point-to-point-epc-helper.h"
38#include "ns3/point-to-point-helper.h"
39#include "ns3/simulator.h"
40#include "ns3/string.h"
44NS_LOG_COMPONENT_DEFINE(
"NrUeMeasurementsTest");
56 uint8_t componentCarrierId)
76NrUeMeasurementsTestSuite::NrUeMeasurementsTestSuite()
77 : TestSuite(
"nr-ue-measurements", Type::SYSTEM)
86 TestCase::Duration::EXTENSIVE);
94 TestCase::Duration::EXTENSIVE);
102 TestCase::Duration::EXTENSIVE);
110 TestCase::Duration::EXTENSIVE);
118 TestCase::Duration::EXTENSIVE);
126 TestCase::Duration::EXTENSIVE);
134 TestCase::Duration::EXTENSIVE);
142 TestCase::Duration::EXTENSIVE);
150 TestCase::Duration::EXTENSIVE);
158 TestCase::Duration::EXTENSIVE);
166 TestCase::Duration::QUICK);
174 TestCase::Duration::EXTENSIVE);
182 TestCase::Duration::EXTENSIVE);
190 TestCase::Duration::EXTENSIVE);
198 TestCase::Duration::EXTENSIVE);
206 TestCase::Duration::EXTENSIVE);
214 TestCase::Duration::EXTENSIVE);
222 TestCase::Duration::EXTENSIVE);
245 m_rsrpDbmUeServingCell(rsrpDbmUe1),
246 m_rsrpDbmUeNeighborCell(rsrpDbmUe2),
247 m_rsrqDbUeServingCell(rsrqDbUe1),
248 m_rsrqDbUeNeighborCell(rsrqDbUe2)
250 NS_LOG_INFO(
"Test UE Measurements d1 = " << d1 <<
" m. and d2 = " << d2 <<
" m.");
253NrUeMeasurementsTestCase::~NrUeMeasurementsTestCase()
258NrUeMeasurementsTestCase::DoRun()
260 NS_LOG_INFO(
this <<
" " << GetName());
262 Config::SetDefault(
"ns3::NrSpectrumPhy::DataErrorModelEnabled", BooleanValue(
false));
264 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
265 nrHelper->SetAttribute(
"UseIdealRrc", BooleanValue(
false));
266 Config::SetDefault(
"ns3::NrGnbPhy::TxPower", DoubleValue(30));
267 Config::SetDefault(
"ns3::NrUePhy::TxPower", DoubleValue(23));
270 Config::SetDefault(
"ns3::NrUePhy::EnableUplinkPowerControl", BooleanValue(
false));
275 NodeContainer nrNodes;
276 NodeContainer ueNodes1;
277 NodeContainer ueNodes2;
281 NodeContainer allNodes = NodeContainer(nrNodes, ueNodes1, ueNodes2);
291 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
292 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
293 positionAlloc->Add(Vector(m_d2, m_d1, 0.0));
294 positionAlloc->Add(Vector(0.0, m_d1, 0.0));
295 positionAlloc->Add(Vector(m_d2, 0.0, 0.0));
296 MobilityHelper mobility;
297 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
298 mobility.SetPositionAllocator(positionAlloc);
299 mobility.Install(allNodes);
301 auto bandwidthAndBWPPair = nrHelper->CreateBandwidthParts({{2.8e9, 5e6, 1}},
"UMa");
303 NetDeviceContainer nrDevs;
304 NetDeviceContainer ueDevs1;
305 NetDeviceContainer ueDevs2;
306 nrHelper->SetSchedulerTypeId(TypeId::LookupByName(
"ns3::NrMacSchedulerTdmaRR"));
307 nrDevs = nrHelper->InstallGnbDevice(nrNodes, bandwidthAndBWPPair.second);
308 ueDevs1 = nrHelper->InstallUeDevice(ueNodes1, bandwidthAndBWPPair.second);
309 ueDevs2 = nrHelper->InstallUeDevice(ueNodes2, bandwidthAndBWPPair.second);
312 for (uint32_t i = 0; i < ueDevs1.GetN(); i++)
314 nrHelper->AttachToGnb(ueDevs1.Get(i), nrDevs.Get(0));
316 for (uint32_t i = 0; i < ueDevs2.GetN(); i++)
318 nrHelper->AttachToGnb(ueDevs2.Get(i), nrDevs.Get(1));
324 nrHelper->ActivateDataRadioBearer(ueDevs1, bearer);
325 nrHelper->ActivateDataRadioBearer(ueDevs2, bearer);
327 Config::Connect(
"/NodeList/2/DeviceList/0/$ns3::NrNetDevice/$ns3::NrUeNetDevice/"
328 "ComponentCarrierMapUe/*/NrUePhy/ReportUeMeasurements",
329 MakeBoundCallback(&ReportUeMeasurementsCallback,
this));
330 Config::Connect(
"/NodeList/0/DeviceList/0/NrGnbRrc/RecvMeasurementReport",
331 MakeBoundCallback(&RecvMeasurementReportCallback,
this));
333 Config::Connect(
"/NodeList/3/DeviceList/0/$ns3::NrNetDevice/$ns3::NrUeNetDevice/"
334 "ComponentCarrierMapUe/*/NrUePhy/ReportUeMeasurements",
335 MakeBoundCallback(&ReportUeMeasurementsCallback,
this));
336 Config::Connect(
"/NodeList/1/DeviceList/0/NrGnbRrc/RecvMeasurementReport",
337 MakeBoundCallback(&RecvMeasurementReportCallback,
this));
340 Simulator::Stop(Seconds(0.800));
343 Simulator::Destroy();
355 if (Simulator::Now() > MilliSeconds(400))
359 NS_LOG_DEBUG(
"UE serving cellId " << cellId <<
" Rxed RSRP " << rsrp <<
" thr "
360 << m_rsrpDbmUeServingCell <<
" RSRQ " << rsrq
361 <<
" thr " << m_rsrqDbUeServingCell);
362 NS_TEST_ASSERT_MSG_EQ_TOL(m_rsrpDbmUeServingCell, rsrp, 0.2,
"Wrong RSRP UE 1");
363 NS_TEST_ASSERT_MSG_EQ_TOL(m_rsrqDbUeServingCell, rsrq, 0.2,
"Wrong RSRQ UE 1");
367 NS_LOG_DEBUG(
"UE neighbor cellId " << cellId <<
" Rxed RSRP " << rsrp <<
" thr "
368 << m_rsrpDbmUeNeighborCell <<
" RSRQ " << rsrq
369 <<
" thr " << m_rsrqDbUeNeighborCell);
370 NS_TEST_ASSERT_MSG_EQ_TOL(m_rsrpDbmUeNeighborCell, rsrp, 0.2,
"Wrong RSRP UE 2");
371 NS_TEST_ASSERT_MSG_EQ_TOL(m_rsrqDbUeNeighborCell, rsrq, 0.2,
"Wrong RSRQ UE ");
384 if (Simulator::Now() > MilliSeconds(400))
388 NS_LOG_DEBUG(
this <<
"Serving Cell: received IMSI " << imsi <<
" CellId " << cellId
389 <<
" RNTI " << rnti <<
" thr "
391 m_rsrpDbmUeServingCell)
396 m_rsrqDbUeServingCell));
397 NS_TEST_ASSERT_MSG_EQ(
407 NS_LOG_DEBUG(
this <<
"Neighbor cell: received IMSI " << imsi <<
" CellId " << cellId
408 <<
" RNTI " << rnti <<
" thr "
410 m_rsrpDbmUeNeighborCell)
415 m_rsrqDbUeNeighborCell));
416 NS_TEST_ASSERT_MSG_EQ(
420 NS_TEST_ASSERT_MSG_EQ(
435operator<<(std::vector<Time>& v,
const uint64_t& ms)
441 v.push_back(MilliSeconds(ms) + NR_UE_MEASUREMENT_REPORT_DELAY);
446operator<<(std::vector<uint8_t>& v,
const uint8_t& range)
456NrUeMeasurementsPiecewiseTestSuite1::NrUeMeasurementsPiecewiseTestSuite1()
457 : TestSuite(
"nr-ue-measurements-piecewise-1", Type::SYSTEM)
459 std::vector<Time> expectedTime;
460 std::vector<uint8_t> expectedRsrp;
472 expectedTime.clear();
473 expectedTime << 200 << 320 << 440 << 560 << 680 << 800 << 920 << 1040 << 1160 << 1280 << 1400
474 << 1520 << 1640 << 1760 << 1880 << 2000 << 2120;
475 expectedRsrp.clear();
476 expectedRsrp << 67 << 67 << 57 << 57 << 66 << 47 << 47 << 66 << 66 << 57 << 51 << 51 << 47 << 47
479 "Piecewise test case 1 - Event A1 with very low threshold",
483 TestCase::Duration::EXTENSIVE);
487 expectedTime.clear();
488 expectedTime << 200 << 320 << 440 << 560 << 680 << 1000 << 1120 << 1240 << 1360 << 2000 << 2120;
489 expectedRsrp.clear();
490 expectedRsrp << 67 << 67 << 57 << 57 << 66 << 66 << 66 << 57 << 57 << 57 << 57;
492 "Piecewise test case 1 - Event A1 with normal threshold",
496 TestCase::Duration::EXTENSIVE);
500 expectedTime.clear();
501 expectedTime << 264 << 384 << 504 << 624 << 744 << 1064 << 1184 << 1304 << 1424 << 2064 << 2184;
502 expectedRsrp.clear();
503 expectedRsrp << 67 << 67 << 57 << 66 << 66 << 66 << 66 << 57 << 51 << 57 << 57;
505 "Piecewise test case 1 - Event A1 with short time-to-trigger",
509 TestCase::Duration::QUICK);
513 expectedTime.clear();
514 expectedTime << 328 << 448 << 568 << 688 << 808 << 1128 << 1248 << 1368 << 1488 << 2128;
515 expectedRsrp.clear();
516 expectedRsrp << 67 << 57 << 57 << 66 << 47 << 66 << 57 << 57 << 51 << 57;
518 "Piecewise test case 1 - Event A1 with long time-to-trigger",
522 TestCase::Duration::EXTENSIVE);
526 expectedTime.clear();
527 expectedTime << 456 << 576 << 696 << 816 << 936 << 1056 << 1176 << 1296 << 1416 << 1536;
528 expectedRsrp.clear();
529 expectedRsrp << 57 << 57 << 66 << 47 << 47 << 66 << 66 << 57 << 51 << 51;
531 "Piecewise test case 1 - Event A1 with super time-to-trigger",
535 TestCase::Duration::EXTENSIVE);
540 expectedTime.clear();
541 expectedTime << 200 << 320 << 440 << 560 << 680 << 1000 << 1120 << 1240 << 1360 << 1480 << 2200;
542 expectedRsrp.clear();
543 expectedRsrp << 67 << 67 << 57 << 57 << 66 << 66 << 66 << 57 << 57 << 51 << 67;
549 TestCase::Duration::QUICK);
554 expectedTime.clear();
555 expectedRsrp.clear();
557 "Piecewise test case 1 - Event A1 with very high threshold",
561 TestCase::Duration::TAKES_FOREVER);
568 expectedTime.clear();
569 expectedRsrp.clear();
571 "Piecewise test case 1 - Event A2 with very low threshold",
575 TestCase::Duration::TAKES_FOREVER);
579 expectedTime.clear();
580 expectedTime << 800 << 920 << 1400 << 1520 << 1640 << 1760 << 1880;
581 expectedRsrp.clear();
582 expectedRsrp << 47 << 47 << 51 << 51 << 47 << 47 << 51;
584 "Piecewise test case 1 - Event A2 with normal threshold",
588 TestCase::Duration::QUICK);
592 expectedTime.clear();
593 expectedTime << 864 << 984 << 1464 << 1584 << 1704 << 1824 << 1944;
594 expectedRsrp.clear();
595 expectedRsrp << 47 << 47 << 51 << 51 << 47 << 51 << 51;
597 "Piecewise test case 1 - Event A2 with short time-to-trigger",
601 TestCase::Duration::EXTENSIVE);
605 expectedTime.clear();
606 expectedTime << 928 << 1048 << 1528 << 1648 << 1768 << 1888 << 2008;
607 expectedRsrp.clear();
608 expectedRsrp << 47 << 66 << 51 << 47 << 47 << 51 << 57;
610 "Piecewise test case 1 - Event A2 with long time-to-trigger",
614 TestCase::Duration::TAKES_FOREVER);
618 expectedTime.clear();
619 expectedTime << 1656 << 1776 << 1896 << 2016 << 2136;
620 expectedRsrp.clear();
621 expectedRsrp << 47 << 47 << 51 << 57 << 57;
623 "Piecewise test case 1 - Event A2 with super time-to-trigger",
627 TestCase::Duration::QUICK);
632 expectedTime.clear();
633 expectedTime << 800 << 920 << 1600 << 1720 << 1840 << 1960 << 2080;
634 expectedRsrp.clear();
635 expectedRsrp << 47 << 47 << 47 << 47 << 51 << 51 << 57;
641 TestCase::Duration::EXTENSIVE);
646 expectedTime.clear();
647 expectedTime << 200 << 320 << 440 << 560 << 680 << 800 << 920 << 1040 << 1160 << 1280 << 1400
648 << 1520 << 1640 << 1760 << 1880 << 2000 << 2120;
649 expectedRsrp.clear();
650 expectedRsrp << 67 << 67 << 57 << 57 << 66 << 47 << 47 << 66 << 66 << 57 << 51 << 51 << 47 << 47
653 "Piecewise test case 1 - Event A2 with very high threshold",
657 TestCase::Duration::EXTENSIVE);
666 expectedTime.clear();
667 expectedRsrp.clear();
677 TestCase::Duration::EXTENSIVE);
687 TestCase::Duration::EXTENSIVE);
698 TestCase::Duration::EXTENSIVE);
715 std::vector<Time> expectedTime,
716 std::vector<uint8_t> expectedRsrp)
719 m_expectedTime(expectedTime),
720 m_expectedRsrp(expectedRsrp)
723 uint16_t size = m_expectedTime.size();
725 if (size != m_expectedRsrp.size())
727 NS_FATAL_ERROR(
"Vectors of expected results are not of the same size");
730 m_itExpectedTime = m_expectedTime.begin();
731 m_itExpectedRsrp = m_expectedRsrp.begin();
733 NS_LOG_INFO(
this <<
" name=" << name);
736NrUeMeasurementsPiecewiseTestCase1::~NrUeMeasurementsPiecewiseTestCase1()
738 NS_LOG_FUNCTION(
this);
742NrUeMeasurementsPiecewiseTestCase1::DoRun()
744 NS_LOG_INFO(
this <<
" " << GetName());
746 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
747 nrHelper->SetAttribute(
"UseIdealRrc", BooleanValue(
true));
748 Config::SetDefault(
"ns3::NrGnbPhy::TxPower", DoubleValue(30));
749 Config::SetDefault(
"ns3::NrUePhy::TxPower", DoubleValue(23));
752 Config::SetDefault(
"ns3::NrUePhy::EnableUplinkPowerControl", BooleanValue(
false));
755 NodeContainer nrNodes;
756 NodeContainer ueNodes;
771 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
772 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
773 positionAlloc->Add(Vector(100.0, 0.0, 0.0));
774 MobilityHelper mobility;
775 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
776 mobility.SetPositionAllocator(positionAlloc);
777 mobility.Install(nrNodes);
778 mobility.Install(ueNodes);
779 m_ueMobility = ueNodes.Get(0)->GetObject<MobilityModel>();
782 Config::SetDefault(
"ns3::NrGnbRrc::RsrpFilterCoefficient", UintegerValue(0));
784 auto bandwidthAndBWPPair = nrHelper->CreateBandwidthParts({{2.8e9, 5e6, 1}},
"UMa");
786 NetDeviceContainer nrDevs;
787 NetDeviceContainer ueDevs;
788 nrHelper->SetSchedulerTypeId(TypeId::LookupByName(
"ns3::NrMacSchedulerTdmaRR"));
789 nrDevs = nrHelper->InstallGnbDevice(nrNodes, bandwidthAndBWPPair.second);
790 ueDevs = nrHelper->InstallUeDevice(ueNodes, bandwidthAndBWPPair.second);
793 Ptr<NrGnbRrc> nrRrc = nrDevs.Get(0)->GetObject<
NrGnbNetDevice>()->GetRrc();
794 m_expectedMeasId = nrRrc->AddUeMeasReportConfig(m_config).at(0);
797 nrHelper->AttachToGnb(ueDevs.Get(0), nrDevs.Get(0));
802 nrHelper->ActivateDataRadioBearer(ueDevs, bearer);
806 "/NodeList/0/DeviceList/0/NrGnbRrc/RecvMeasurementReport",
818 Simulator::Schedule(MilliSeconds(301),
819 &NrUeMeasurementsPiecewiseTestCase1::TeleportVeryFar,
821 Simulator::Schedule(MilliSeconds(401),
822 &NrUeMeasurementsPiecewiseTestCase1::TeleportVeryNear,
824 Simulator::Schedule(MilliSeconds(601),
825 &NrUeMeasurementsPiecewiseTestCase1::TeleportVeryFar,
827 Simulator::Schedule(MilliSeconds(801),
828 &NrUeMeasurementsPiecewiseTestCase1::TeleportVeryNear,
830 Simulator::Schedule(MilliSeconds(1001),
831 &NrUeMeasurementsPiecewiseTestCase1::TeleportNear,
833 Simulator::Schedule(MilliSeconds(1201), &NrUeMeasurementsPiecewiseTestCase1::TeleportFar,
this);
834 Simulator::Schedule(MilliSeconds(1401),
835 &NrUeMeasurementsPiecewiseTestCase1::TeleportVeryFar,
837 Simulator::Schedule(MilliSeconds(1601), &NrUeMeasurementsPiecewiseTestCase1::TeleportFar,
this);
838 Simulator::Schedule(MilliSeconds(1801),
839 &NrUeMeasurementsPiecewiseTestCase1::TeleportNear,
841 Simulator::Schedule(MilliSeconds(2001),
842 &NrUeMeasurementsPiecewiseTestCase1::TeleportVeryNear,
846 Simulator::Stop(Seconds(2.201));
848 Simulator::Destroy();
853NrUeMeasurementsPiecewiseTestCase1::DoTeardown()
855 NS_LOG_FUNCTION(
this);
856 bool hasEnded = m_itExpectedTime == m_expectedTime.end();
857 NS_TEST_ASSERT_MSG_EQ(hasEnded,
859 "Reporting should have occurred at " << m_itExpectedTime->As(Time::S));
860 hasEnded = m_itExpectedRsrp == m_expectedRsrp.end();
872 NS_LOG_FUNCTION(
this << context);
873 NS_ASSERT(rnti == 1);
874 NS_ASSERT(cellId == 1);
890 "Report should not have neighboring cells information");
891 NS_TEST_ASSERT_MSG_EQ(measResults.
measResultListEutra.size(), 0,
"Unexpected report size");
893 bool hasEnded = m_itExpectedTime == m_expectedTime.end();
894 NS_TEST_ASSERT_MSG_EQ(hasEnded,
896 "Reporting should not have occurred at "
897 << Simulator::Now().As(Time::S));
900 hasEnded = m_itExpectedRsrp == m_expectedRsrp.end();
901 NS_ASSERT(!hasEnded);
904 uint64_t timeNowMs = Simulator::Now().GetMilliSeconds();
905 uint64_t timeExpectedMs = m_itExpectedTime->GetMilliSeconds();
909 uint16_t referenceRsrp = *m_itExpectedRsrp;
912 NS_TEST_ASSERT_MSG_EQ(timeNowMs,
914 "Reporting should not have occurred at this time");
915 NS_TEST_ASSERT_MSG_EQ(observedRsrp,
917 "The RSRP observed differs with the reference RSRP");
925NrUeMeasurementsPiecewiseTestCase1::TeleportVeryNear()
927 NS_LOG_FUNCTION(
this);
928 m_ueMobility->SetPosition(Vector(100.0, 0.0, 0.0));
932NrUeMeasurementsPiecewiseTestCase1::TeleportNear()
934 NS_LOG_FUNCTION(
this);
935 m_ueMobility->SetPosition(Vector(300.0, 0.0, 0.0));
939NrUeMeasurementsPiecewiseTestCase1::TeleportFar()
941 NS_LOG_FUNCTION(
this);
942 m_ueMobility->SetPosition(Vector(600.0, 0.0, 0.0));
946NrUeMeasurementsPiecewiseTestCase1::TeleportVeryFar()
948 NS_LOG_FUNCTION(
this);
949 m_ueMobility->SetPosition(Vector(1000.0, 0.0, 0.0));
958NrUeMeasurementsPiecewiseTestSuite2::NrUeMeasurementsPiecewiseTestSuite2()
959 : TestSuite(
"nr-ue-measurements-piecewise-2", Type::SYSTEM)
961 std::vector<Time> expectedTime;
962 std::vector<uint8_t> expectedRsrp;
979 expectedTime.clear();
980 expectedTime << 200 << 440 << 680 << 920 << 1160 << 1400 << 1640 << 1880 << 2120;
981 expectedRsrp.clear();
982 expectedRsrp << 73 << 63 << 72 << 52 << 72 << 56 << 52 << 56 << 59;
984 "Piecewise test case 2 - Event A1 with very low threshold",
988 TestCase::Duration::EXTENSIVE);
992 expectedTime.clear();
993 expectedTime << 200 << 440 << 680 << 1000 << 1240 << 2000;
994 expectedRsrp.clear();
995 expectedRsrp << 73 << 63 << 72 << 72 << 59 << 59;
997 "Piecewise test case 2 - Event A1 with normal threshold",
1001 TestCase::Duration::TAKES_FOREVER);
1005 expectedTime.clear();
1006 expectedTime << 200 << 440 << 680 << 1000 << 1240 << 1480 << 2200;
1007 expectedRsrp.clear();
1008 expectedRsrp << 73 << 63 << 72 << 72 << 59 << 56 << 72;
1014 TestCase::Duration::EXTENSIVE);
1019 expectedTime.clear();
1020 expectedRsrp.clear();
1022 "Piecewise test case 2 - Event A1 with very high threshold",
1026 TestCase::Duration::TAKES_FOREVER);
1033 expectedTime.clear();
1034 expectedRsrp.clear();
1036 "Piecewise test case 2 - Event A2 with very low threshold",
1040 TestCase::Duration::TAKES_FOREVER);
1044 expectedTime.clear();
1045 expectedTime << 800 << 1400 << 1640 << 1880;
1046 expectedRsrp.clear();
1047 expectedRsrp << 52 << 56 << 52 << 56;
1049 "Piecewise test case 2 - Event A2 with normal threshold",
1053 TestCase::Duration::TAKES_FOREVER);
1057 expectedTime.clear();
1058 expectedTime << 800 << 1600 << 1840 << 2080;
1059 expectedRsrp.clear();
1060 expectedRsrp << 52 << 52 << 56 << 59;
1066 TestCase::Duration::EXTENSIVE);
1071 expectedTime.clear();
1072 expectedTime << 200 << 440 << 680 << 920 << 1160 << 1400 << 1640 << 1880 << 2120;
1073 expectedRsrp.clear();
1074 expectedRsrp << 73 << 63 << 72 << 52 << 72 << 56 << 52 << 56 << 59;
1076 "Piecewise test case 2 - Event A2 with very high threshold",
1080 TestCase::Duration::TAKES_FOREVER);
1088 expectedTime.clear();
1089 expectedTime << 800 << 1600;
1090 expectedRsrp.clear();
1091 expectedRsrp << 52 << 52;
1093 "Piecewise test case 2 - Event A3 with positive offset",
1097 TestCase::Duration::QUICK);
1101 expectedTime.clear();
1102 expectedTime << 800 << 1400 << 1640 << 1880;
1103 expectedRsrp.clear();
1104 expectedRsrp << 52 << 56 << 52 << 56;
1110 TestCase::Duration::EXTENSIVE);
1114 expectedTime.clear();
1115 expectedTime << 960 << 1560 << 1800 << 2040;
1116 expectedRsrp.clear();
1117 expectedRsrp << 52 << 56 << 56 << 59;
1119 "Piecewise test case 2 - Event A3 with short time-to-trigger",
1123 TestCase::Duration::EXTENSIVE);
1127 expectedTime.clear();
1128 expectedTime << 1720 << 1960 << 2200;
1129 expectedRsrp.clear();
1130 expectedRsrp << 52 << 56 << 72;
1132 "Piecewise test case 2 - Event A3 with super time-to-trigger",
1136 TestCase::Duration::QUICK);
1142 expectedTime.clear();
1143 expectedTime << 800 << 1000 << 1600 << 1840 << 2080 << 2200;
1144 expectedRsrp.clear();
1145 expectedRsrp << 52 << 72 << 52 << 56 << 59 << 72;
1151 TestCase::Duration::QUICK);
1157 expectedTime.clear();
1158 expectedTime << 400 << 800 << 1200 << 1440 << 1680 << 1920 << 2160;
1159 expectedRsrp.clear();
1160 expectedRsrp << 63 << 52 << 59 << 56 << 52 << 56 << 59;
1162 "Piecewise test case 2 - Event A3 with negative offset",
1166 TestCase::Duration::EXTENSIVE);
1174 expectedTime.clear();
1175 expectedTime << 200 << 440 << 680 << 920 << 1160 << 1400 << 1640 << 1880 << 2120;
1176 expectedRsrp.clear();
1177 expectedRsrp << 73 << 63 << 72 << 52 << 72 << 56 << 52 << 56 << 59;
1179 "Piecewise test case 2 - Event A4 with very low threshold",
1183 TestCase::Duration::QUICK);
1187 expectedTime.clear();
1188 expectedTime << 400 << 800 << 1400 << 1640 << 1880;
1189 expectedRsrp.clear();
1190 expectedRsrp << 63 << 52 << 56 << 52 << 56;
1192 "Piecewise test case 2 - Event A4 with normal threshold",
1196 TestCase::Duration::EXTENSIVE);
1200 expectedTime.clear();
1201 expectedTime << 560 << 960 << 1560 << 1800 << 2040;
1202 expectedRsrp.clear();
1203 expectedRsrp << 63 << 52 << 56 << 56 << 59;
1205 "Piecewise test case 2 - Event A4 with short time-to-trigger",
1209 TestCase::Duration::QUICK);
1213 expectedTime.clear();
1214 expectedTime << 1720 << 1960 << 2200;
1215 expectedRsrp.clear();
1216 expectedRsrp << 52 << 56 << 72;
1218 "Piecewise test case 2 - Event A4 with super time-to-trigger",
1222 TestCase::Duration::TAKES_FOREVER);
1227 expectedTime.clear();
1228 expectedTime << 400 << 800 << 1600 << 1840 << 2080;
1229 expectedRsrp.clear();
1230 expectedRsrp << 63 << 52 << 52 << 56 << 59;
1236 TestCase::Duration::QUICK);
1241 expectedTime.clear();
1242 expectedRsrp.clear();
1244 "Piecewise test case 2 - Event A4 with very high threshold",
1248 TestCase::Duration::TAKES_FOREVER);
1257 expectedTime.clear();
1258 expectedRsrp.clear();
1260 "Piecewise test case 2 - Event A5 with low-low threshold",
1264 TestCase::Duration::EXTENSIVE);
1269 "Piecewise test case 2 - Event A5 with low-normal threshold",
1273 TestCase::Duration::TAKES_FOREVER);
1278 "Piecewise test case 2 - Event A5 with low-high threshold",
1282 TestCase::Duration::TAKES_FOREVER);
1287 expectedTime.clear();
1288 expectedTime << 800 << 1400 << 1640 << 1880;
1289 expectedRsrp.clear();
1290 expectedRsrp << 52 << 56 << 52 << 56;
1292 "Piecewise test case 2 - Event A5 with normal-low threshold",
1296 TestCase::Duration::EXTENSIVE);
1300 expectedTime.clear();
1301 expectedTime << 800 << 1400 << 1640 << 1880;
1302 expectedRsrp.clear();
1303 expectedRsrp << 52 << 56 << 52 << 56;
1305 "Piecewise test case 2 - Event A5 with normal-normal threshold",
1309 TestCase::Duration::EXTENSIVE);
1313 expectedTime.clear();
1314 expectedTime << 960 << 1560 << 1800 << 2040;
1315 expectedRsrp.clear();
1316 expectedRsrp << 52 << 56 << 56 << 59;
1318 "Piecewise test case 2 - Event A5 with short time-to-trigger",
1322 TestCase::Duration::TAKES_FOREVER);
1326 expectedTime.clear();
1327 expectedTime << 1720 << 1960 << 2200;
1328 expectedRsrp.clear();
1329 expectedRsrp << 52 << 56 << 72;
1331 "Piecewise test case 2 - Event A5 with super time-to-trigger",
1335 TestCase::Duration::QUICK);
1340 expectedTime.clear();
1341 expectedTime << 800 << 1600 << 1840 << 2080;
1342 expectedRsrp.clear();
1343 expectedRsrp << 52 << 52 << 56 << 59;
1349 TestCase::Duration::QUICK);
1354 expectedTime.clear();
1355 expectedRsrp.clear();
1357 "Piecewise test case 2 - Event A5 with normal-high threshold",
1361 TestCase::Duration::TAKES_FOREVER);
1366 expectedTime.clear();
1367 expectedTime << 200 << 440 << 680 << 920 << 1160 << 1400 << 1640 << 1880 << 2120;
1368 expectedRsrp.clear();
1369 expectedRsrp << 73 << 63 << 72 << 52 << 72 << 56 << 52 << 56 << 59;
1371 "Piecewise test case 2 - Event A5 with high-low threshold",
1375 TestCase::Duration::EXTENSIVE);
1379 expectedTime.clear();
1380 expectedTime << 400 << 800 << 1400 << 1640 << 1880;
1381 expectedRsrp.clear();
1382 expectedRsrp << 63 << 52 << 56 << 52 << 56;
1384 "Piecewise test case 2 - Event A5 with high-normal threshold",
1388 TestCase::Duration::TAKES_FOREVER);
1392 expectedTime.clear();
1393 expectedRsrp.clear();
1395 "Piecewise test case 2 - Event A5 with high-high threshold",
1399 TestCase::Duration::EXTENSIVE);
1416 std::vector<Time> expectedTime,
1417 std::vector<uint8_t> expectedRsrp)
1420 m_expectedTime(expectedTime),
1421 m_expectedRsrp(expectedRsrp)
1424 uint16_t size = m_expectedTime.size();
1426 if (size != m_expectedRsrp.size())
1428 NS_FATAL_ERROR(
"Vectors of expected results are not of the same size");
1431 m_itExpectedTime = m_expectedTime.begin();
1432 m_itExpectedRsrp = m_expectedRsrp.begin();
1434 NS_LOG_INFO(
this <<
" name=" << name);
1437NrUeMeasurementsPiecewiseTestCase2::~NrUeMeasurementsPiecewiseTestCase2()
1439 NS_LOG_FUNCTION(
this);
1443NrUeMeasurementsPiecewiseTestCase2::DoRun()
1445 NS_LOG_INFO(
this <<
" " << GetName());
1447 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
1448 nrHelper->SetAttribute(
"UseIdealRrc", BooleanValue(
true));
1450 Config::SetDefault(
"ns3::NrGnbPhy::TxPower", DoubleValue(30));
1451 Config::SetDefault(
"ns3::NrUePhy::TxPower", DoubleValue(23));
1453 Config::SetDefault(
"ns3::NrUePhy::EnableUplinkPowerControl", BooleanValue(
false));
1456 NodeContainer nrNodes;
1457 NodeContainer ueNodes;
1472 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
1473 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
1474 positionAlloc->Add(Vector(600.0, 0.0, 0.0));
1475 positionAlloc->Add(Vector(50.0, 0.0, 0.0));
1476 MobilityHelper mobility;
1477 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
1478 mobility.SetPositionAllocator(positionAlloc);
1479 mobility.Install(nrNodes);
1480 mobility.Install(ueNodes);
1481 m_ueMobility = ueNodes.Get(0)->GetObject<MobilityModel>();
1484 Config::SetDefault(
"ns3::NrGnbRrc::RsrpFilterCoefficient", UintegerValue(0));
1485 auto bandwidthAndBWPPair = nrHelper->CreateBandwidthParts({{2.8e9, 5e6, 1}},
"UMa");
1487 NetDeviceContainer nrDevs;
1488 NetDeviceContainer ueDevs;
1489 nrHelper->SetSchedulerTypeId(TypeId::LookupByName(
"ns3::NrMacSchedulerTdmaRR"));
1490 nrDevs = nrHelper->InstallGnbDevice(nrNodes, bandwidthAndBWPPair.second);
1491 ueDevs = nrHelper->InstallUeDevice(ueNodes, bandwidthAndBWPPair.second);
1494 Ptr<NrGnbRrc> nrRrc1 = nrDevs.Get(0)->GetObject<
NrGnbNetDevice>()->GetRrc();
1495 m_expectedMeasId = nrRrc1->AddUeMeasReportConfig(m_config).at(0);
1498 Ptr<NrGnbRrc> nrRrc2 = nrDevs.Get(1)->GetObject<
NrGnbNetDevice>()->GetRrc();
1499 nrRrc2->SetAttribute(
"AdmitHandoverRequest", BooleanValue(
false));
1502 nrHelper->AttachToGnb(ueDevs.Get(0), nrDevs.Get(0));
1507 nrHelper->ActivateDataRadioBearer(ueDevs, bearer);
1511 "/NodeList/0/DeviceList/0/NrGnbRrc/RecvMeasurementReport",
1523 Simulator::Schedule(MilliSeconds(301),
1524 &NrUeMeasurementsPiecewiseTestCase2::TeleportVeryFar,
1526 Simulator::Schedule(MilliSeconds(401),
1527 &NrUeMeasurementsPiecewiseTestCase2::TeleportVeryNear,
1529 Simulator::Schedule(MilliSeconds(601),
1530 &NrUeMeasurementsPiecewiseTestCase2::TeleportVeryFar,
1532 Simulator::Schedule(MilliSeconds(801),
1533 &NrUeMeasurementsPiecewiseTestCase2::TeleportVeryNear,
1535 Simulator::Schedule(MilliSeconds(1001),
1536 &NrUeMeasurementsPiecewiseTestCase2::TeleportNear,
1538 Simulator::Schedule(MilliSeconds(1201), &NrUeMeasurementsPiecewiseTestCase2::TeleportFar,
this);
1539 Simulator::Schedule(MilliSeconds(1401),
1540 &NrUeMeasurementsPiecewiseTestCase2::TeleportVeryFar,
1542 Simulator::Schedule(MilliSeconds(1601), &NrUeMeasurementsPiecewiseTestCase2::TeleportFar,
this);
1543 Simulator::Schedule(MilliSeconds(1801),
1544 &NrUeMeasurementsPiecewiseTestCase2::TeleportNear,
1546 Simulator::Schedule(MilliSeconds(2001),
1547 &NrUeMeasurementsPiecewiseTestCase2::TeleportVeryNear,
1551 Simulator::Stop(Seconds(2.201));
1553 Simulator::Destroy();
1558NrUeMeasurementsPiecewiseTestCase2::DoTeardown()
1560 NS_LOG_FUNCTION(
this);
1561 bool hasEnded = m_itExpectedTime == m_expectedTime.end();
1562 NS_TEST_ASSERT_MSG_EQ(hasEnded,
1564 "Reporting should have occurred at " << m_itExpectedTime->As(Time::S));
1565 hasEnded = m_itExpectedRsrp == m_expectedRsrp.end();
1566 NS_ASSERT(hasEnded);
1571 std::string context,
1577 NS_LOG_FUNCTION(
this << context);
1578 NS_ASSERT(rnti == 1);
1579 NS_ASSERT(cellId == 1);
1585 NS_LOG_DEBUG(
this <<
" Serving cellId=" << cellId
1600 "Unexpected report content");
1606 "Unexpected report content");
1609 NS_ASSERT(it->physCellId == 2);
1610 NS_TEST_ASSERT_MSG_EQ(it->haveCgiInfo,
1612 "Report contains cgi-info, which is not supported");
1613 NS_TEST_ASSERT_MSG_EQ(it->haveRsrpResult,
1615 "Report does not contain measured RSRP result");
1616 NS_TEST_ASSERT_MSG_EQ(it->haveRsrqResult,
1618 "Report does not contain measured RSRQ result");
1620 this <<
" Neighbour cellId=" << it->physCellId
1621 <<
" rsrp=" << (uint16_t)it->rsrpResult <<
" ("
1623 <<
" rsrq=" << (uint16_t)it->rsrqResult <<
" ("
1629 bool hasEnded = m_itExpectedTime == m_expectedTime.end();
1630 NS_TEST_ASSERT_MSG_EQ(hasEnded,
1632 "Reporting should not have occurred at "
1633 << Simulator::Now().As(Time::S));
1636 hasEnded = m_itExpectedRsrp == m_expectedRsrp.end();
1637 NS_ASSERT(!hasEnded);
1640 uint64_t timeNowMs = Simulator::Now().GetMilliSeconds();
1641 uint64_t timeExpectedMs = m_itExpectedTime->GetMilliSeconds();
1645 uint16_t referenceRsrp = *m_itExpectedRsrp;
1648 NS_TEST_ASSERT_MSG_EQ(timeNowMs,
1650 "Reporting should not have occurred at this time");
1651 NS_TEST_ASSERT_MSG_EQ(observedRsrp,
1653 "The RSRP observed differs with the reference RSRP");
1662NrUeMeasurementsPiecewiseTestCase2::TeleportVeryNear()
1664 NS_LOG_FUNCTION(
this);
1665 m_ueMobility->SetPosition(Vector(50.0, 0.0, 0.0));
1669NrUeMeasurementsPiecewiseTestCase2::TeleportNear()
1671 NS_LOG_FUNCTION(
this);
1672 m_ueMobility->SetPosition(Vector(250.0, 0.0, 0.0));
1676NrUeMeasurementsPiecewiseTestCase2::TeleportFar()
1678 NS_LOG_FUNCTION(
this);
1679 m_ueMobility->SetPosition(Vector(350.0, 0.0, 0.0));
1683NrUeMeasurementsPiecewiseTestCase2::TeleportVeryFar()
1685 NS_LOG_FUNCTION(
this);
1686 m_ueMobility->SetPosition(Vector(550.0, 0.0, 0.0));
1695NrUeMeasurementsPiecewiseTestSuite3::NrUeMeasurementsPiecewiseTestSuite3()
1696 : TestSuite(
"nr-ue-measurements-piecewise-3", Type::SYSTEM)
1698 std::vector<Time> expectedTime;
1719 expectedTime.clear();
1720 expectedTime << 200 << 440 << 680 << 920 << 1160 << 1400 << 1640 << 1880 << 2120;
1725 TestCase::Duration::QUICK);
1741 std::vector<Time> expectedTime)
1744 m_expectedTime(expectedTime)
1746 m_expectedMeasId = std::numeric_limits<uint8_t>::max();
1748 m_itExpectedTime = m_expectedTime.begin();
1750 NS_LOG_INFO(
this <<
" name=" << name);
1753NrUeMeasurementsPiecewiseTestCase3::~NrUeMeasurementsPiecewiseTestCase3()
1755 NS_LOG_FUNCTION(
this);
1759NrUeMeasurementsPiecewiseTestCase3::DoRun()
1761 NS_LOG_INFO(
this <<
" " << GetName());
1763 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
1764 nrHelper->SetAttribute(
"UseIdealRrc", BooleanValue(
true));
1766 Config::SetDefault(
"ns3::NrGnbPhy::TxPower", DoubleValue(30));
1767 Config::SetDefault(
"ns3::NrUePhy::TxPower", DoubleValue(23));
1769 Config::SetDefault(
"ns3::NrUePhy::EnableUplinkPowerControl", BooleanValue(
false));
1772 NodeContainer nrNodes;
1773 NodeContainer ueNodes;
1790 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
1791 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
1792 positionAlloc->Add(Vector(200.0, 0.0, 0.0));
1793 positionAlloc->Add(Vector(1000700.0, 0.0, 0.0));
1794 positionAlloc->Add(Vector(50.0, 0.0, 0.0));
1795 MobilityHelper mobility;
1796 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
1797 mobility.SetPositionAllocator(positionAlloc);
1798 mobility.Install(nrNodes);
1799 mobility.Install(ueNodes);
1800 m_gnbMobility = nrNodes.Get(2)->GetObject<MobilityModel>();
1803 Config::SetDefault(
"ns3::NrGnbRrc::RsrpFilterCoefficient", UintegerValue(0));
1804 auto bandwidthAndBWPPair = nrHelper->CreateBandwidthParts({{2.8e9, 5e6, 1}},
"UMa");
1806 NetDeviceContainer nrDevs;
1807 NetDeviceContainer ueDevs;
1808 nrHelper->SetSchedulerTypeId(TypeId::LookupByName(
"ns3::NrMacSchedulerTdmaRR"));
1809 nrDevs = nrHelper->InstallGnbDevice(nrNodes, bandwidthAndBWPPair.second);
1810 ueDevs = nrHelper->InstallUeDevice(ueNodes, bandwidthAndBWPPair.second);
1813 Ptr<NrGnbRrc> nrRrc1 = nrDevs.Get(0)->GetObject<
NrGnbNetDevice>()->GetRrc();
1814 m_expectedMeasId = nrRrc1->AddUeMeasReportConfig(m_config).at(0);
1817 Ptr<NrGnbRrc> nrRrc2 = nrDevs.Get(1)->GetObject<
NrGnbNetDevice>()->GetRrc();
1818 nrRrc2->SetAttribute(
"AdmitHandoverRequest", BooleanValue(
false));
1819 Ptr<NrGnbRrc> nrRrc3 = nrDevs.Get(2)->GetObject<
NrGnbNetDevice>()->GetRrc();
1820 nrRrc3->SetAttribute(
"AdmitHandoverRequest", BooleanValue(
false));
1823 nrHelper->AttachToGnb(ueDevs.Get(0), nrDevs.Get(0));
1828 nrHelper->ActivateDataRadioBearer(ueDevs, bearer);
1832 "/NodeList/0/DeviceList/0/NrGnbRrc/RecvMeasurementReport",
1841 Simulator::Schedule(MilliSeconds(301),
1842 &NrUeMeasurementsPiecewiseTestCase3::TeleportGnbNear,
1846 Simulator::Stop(Seconds(2.201));
1848 Simulator::Destroy();
1853NrUeMeasurementsPiecewiseTestCase3::DoTeardown()
1855 NS_LOG_FUNCTION(
this);
1856 bool hasEnded = m_itExpectedTime == m_expectedTime.end();
1857 NS_TEST_ASSERT_MSG_EQ(hasEnded,
1859 "Reporting should have occurred at " << m_itExpectedTime->GetSeconds()
1865 std::string context,
1871 NS_LOG_FUNCTION(
this << context);
1872 NS_ASSERT(rnti == 1);
1873 NS_ASSERT(cellId == 1);
1879 NS_LOG_DEBUG(
this <<
" Serving cellId=" << cellId
1894 "Unexpected report content");
1900 "Unexpected report content");
1905 NS_ASSERT(it.physCellId == 2 || it.physCellId == 3);
1906 NS_TEST_ASSERT_MSG_EQ(it.haveCgiInfo,
1908 "Report contains cgi-info, which is not supported");
1909 NS_TEST_ASSERT_MSG_EQ(it.haveRsrpResult,
1911 "Report does not contain measured RSRP result");
1912 NS_TEST_ASSERT_MSG_EQ(it.haveRsrqResult,
1914 "Report does not contain measured RSRQ result");
1916 this <<
" Neighbour cellId=" << it.physCellId
1917 <<
" rsrp=" << (uint16_t)it.rsrpResult <<
" ("
1919 <<
" rsrq=" << (uint16_t)it.rsrqResult <<
" ("
1926 bool hasEnded = m_itExpectedTime == m_expectedTime.end();
1927 NS_TEST_ASSERT_MSG_EQ(hasEnded,
1929 "Reporting should not have occurred at "
1930 << Simulator::Now().GetSeconds() <<
"s");
1934 uint64_t timeNowMs = Simulator::Now().GetMilliSeconds();
1935 uint64_t timeExpectedMs = m_itExpectedTime->GetMilliSeconds();
1938 NS_TEST_ASSERT_MSG_EQ(timeNowMs,
1940 "Reporting should not have occurred at this time");
1949NrUeMeasurementsPiecewiseTestCase3::TeleportGnbNear()
1951 NS_LOG_FUNCTION(
this);
1952 m_gnbMobility->SetPosition(Vector(700.0, 0.0, 0.0));
1961NrUeMeasurementsHandoverTestSuite::NrUeMeasurementsHandoverTestSuite()
1962 : TestSuite(
"nr-ue-measurements-handover", Type::SYSTEM)
1964 std::list<NrRrcSap::ReportConfigEutra> sourceConfigList;
1965 std::list<NrRrcSap::ReportConfigEutra> targetConfigList;
1966 std::vector<Time> expectedTime;
1967 std::vector<uint8_t> expectedRsrp;
1975 sourceConfig.
reportInterval = NrRrcSap::ReportConfigEutra::MS240;
1976 sourceConfigList.push_back(sourceConfig);
1984 targetConfig.
reportInterval = NrRrcSap::ReportConfigEutra::MS240;
1985 targetConfigList.push_back(targetConfig);
1990 sourceConfigList.front().
reportInterval = NrRrcSap::ReportConfigEutra::MS480;
1991 targetConfigList.front().
reportInterval = NrRrcSap::ReportConfigEutra::MS240;
1992 expectedTime.clear();
1993 expectedTime << 200 << 680 << 1200 << 1440 << 1680 << 1920;
1994 expectedRsrp.clear();
1995 expectedRsrp << 55 << 55 << 53 << 53 << 53 << 53;
2003 TestCase::Duration::TAKES_FOREVER);
2006 sourceConfigList.front().reportInterval = NrRrcSap::ReportConfigEutra::MS120;
2007 targetConfigList.front().reportInterval = NrRrcSap::ReportConfigEutra::MS640;
2008 expectedTime.clear();
2009 expectedTime << 200 << 320 << 440 << 560 << 680 << 800 << 920 << 1200 << 1840;
2010 expectedRsrp.clear();
2011 expectedRsrp << 55 << 55 << 55 << 55 << 55 << 55 << 55 << 53 << 53;
2019 TestCase::Duration::QUICK);
2023 sourceConfigList.front().reportInterval = NrRrcSap::ReportConfigEutra::MS240;
2024 targetConfigList.front().reportInterval = NrRrcSap::ReportConfigEutra::MS240;
2025 sourceConfigList.front().threshold1.range = 54;
2026 sourceConfigList.front().threshold2.range = 54;
2027 sourceConfigList.front().a3Offset = 1;
2028 targetConfigList.front().threshold1.range = 54;
2029 targetConfigList.front().threshold2.range = 54;
2030 targetConfigList.front().a3Offset = 1;
2035 expectedTime.clear();
2036 expectedTime << 200 << 440 << 680 << 920 << 1200 << 1440 << 1680 << 1920;
2037 expectedRsrp.clear();
2038 expectedRsrp << 55 << 55 << 55 << 55 << 53 << 53 << 53 << 53;
2045 TestCase::Duration::EXTENSIVE);
2050 expectedTime.clear();
2051 expectedRsrp.clear();
2058 TestCase::Duration::TAKES_FOREVER);
2063 expectedTime.clear();
2064 expectedTime << 1200 << 1440 << 1680 << 1920;
2065 expectedRsrp.clear();
2066 expectedRsrp << 53 << 53 << 53 << 53;
2073 TestCase::Duration::TAKES_FOREVER);
2078 expectedTime.clear();
2079 expectedTime << 1200 << 1440 << 1680 << 1920;
2080 expectedRsrp.clear();
2081 expectedRsrp << 53 << 53 << 53 << 53;
2088 TestCase::Duration::QUICK);
2093 expectedTime.clear();
2094 expectedTime << 1200 << 1440 << 1680 << 1920;
2095 expectedRsrp.clear();
2096 expectedRsrp << 53 << 53 << 53 << 53;
2103 TestCase::Duration::EXTENSIVE);
2108 expectedTime.clear();
2109 expectedTime << 1200 << 1440 << 1680 << 1920;
2110 expectedRsrp.clear();
2111 expectedRsrp << 53 << 53 << 53 << 53;
2118 TestCase::Duration::TAKES_FOREVER);
2123 expectedTime.clear();
2124 expectedTime << 1200 << 1440 << 1680 << 1920;
2125 expectedRsrp.clear();
2126 expectedRsrp << 53 << 53 << 53 << 53;
2133 TestCase::Duration::TAKES_FOREVER);
2138 expectedTime.clear();
2139 expectedTime << 1200 << 1440 << 1680 << 1920;
2140 expectedRsrp.clear();
2141 expectedRsrp << 53 << 53 << 53 << 53;
2148 TestCase::Duration::EXTENSIVE);
2152 sourceConfigList.front().threshold1.range = 52;
2153 targetConfigList.front().threshold1.range = 56;
2158 expectedTime.clear();
2159 expectedTime << 200 << 440 << 680 << 920;
2160 expectedRsrp.clear();
2161 expectedRsrp << 55 << 55 << 55 << 55;
2169 TestCase::Duration::EXTENSIVE);
2174 expectedTime.clear();
2175 expectedTime << 1200 << 1440 << 1680 << 1920;
2176 expectedRsrp.clear();
2177 expectedRsrp << 53 << 53 << 53 << 53;
2185 TestCase::Duration::QUICK);
2189 sourceConfigList.front().a3Offset = -30;
2191 targetConfigList.front().a3Offset = 30;
2192 expectedTime.clear();
2193 expectedTime << 200 << 440 << 680 << 920;
2194 expectedRsrp.clear();
2195 expectedRsrp << 55 << 55 << 55 << 55;
2203 TestCase::Duration::QUICK);
2208 expectedTime.clear();
2209 expectedTime << 200 << 440 << 680 << 920;
2210 expectedRsrp.clear();
2211 expectedRsrp << 55 << 55 << 55 << 55;
2219 TestCase::Duration::EXTENSIVE);
2223 sourceConfigList.front().threshold2.range = 52;
2225 targetConfigList.front().threshold2.range = 56;
2226 expectedTime.clear();
2227 expectedRsrp.clear();
2235 TestCase::Duration::EXTENSIVE);
2240 sourceConfigList.front().a3Offset = 1;
2241 sourceConfigList.front().threshold1.range = 0;
2242 sourceConfigList.front().threshold2.range = 0;
2244 targetConfigList.front().a3Offset = 1;
2245 targetConfigList.front().threshold1.range = 0;
2246 targetConfigList.front().threshold2.range = 0;
2249 sourceConfigList.front().timeToTrigger = 1024;
2250 targetConfigList.front().timeToTrigger = 100;
2251 expectedTime.clear();
2252 expectedTime << 1300 << 1540 << 1780;
2253 expectedRsrp.clear();
2254 expectedRsrp << 53 << 53 << 53;
2261 TestCase::Duration::QUICK);
2264 sourceConfigList.front().timeToTrigger = 1024;
2265 targetConfigList.front().timeToTrigger = 640;
2266 expectedTime.clear();
2267 expectedTime << 1224 << 1464 << 1704 << 1944 << 2840 << 3080 << 3320 << 3560 << 3800 << 4040;
2268 expectedRsrp.clear();
2269 expectedRsrp << 55 << 55 << 55 << 55 << 53 << 53 << 53 << 53 << 53 << 53;
2276 TestCase::Duration::EXTENSIVE);
2292 std::list<NrRrcSap::ReportConfigEutra> sourceConfigList,
2293 std::list<NrRrcSap::ReportConfigEutra> targetConfigList,
2294 std::vector<Time> expectedTime,
2295 std::vector<uint8_t> expectedRsrp,
2298 m_sourceConfigList(sourceConfigList),
2299 m_targetConfigList(targetConfigList),
2300 m_expectedTime(expectedTime),
2301 m_expectedRsrp(expectedRsrp),
2302 m_duration(duration)
2305 uint16_t size = m_expectedTime.size();
2307 if (size != m_expectedRsrp.size())
2309 NS_FATAL_ERROR(
"Vectors of expected results are not of the same size");
2312 m_itExpectedTime = m_expectedTime.begin();
2313 m_itExpectedRsrp = m_expectedRsrp.begin();
2315 NS_LOG_INFO(
this <<
" name=" << name);
2318NrUeMeasurementsHandoverTestCase::~NrUeMeasurementsHandoverTestCase()
2320 NS_LOG_FUNCTION(
this);
2324NrUeMeasurementsHandoverTestCase::DoRun()
2326 NS_LOG_INFO(
this <<
" " << GetName());
2328 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
2329 Ptr<NrPointToPointEpcHelper> nrEpcHelper = CreateObject<NrPointToPointEpcHelper>();
2330 nrHelper->SetEpcHelper(nrEpcHelper);
2331 nrHelper->SetAttribute(
"UseIdealRrc", BooleanValue(
true));
2332 Config::SetDefault(
"ns3::NrGnbPhy::TxPower", DoubleValue(30));
2333 Config::SetDefault(
"ns3::NrUePhy::TxPower", DoubleValue(23));
2336 Config::SetDefault(
"ns3::NrUePhy::EnableUplinkPowerControl", BooleanValue(
false));
2339 NodeContainer nrNodes;
2340 NodeContainer ueNodes;
2353 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
2354 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
2355 positionAlloc->Add(Vector(900.0, 0.0, 0.0));
2356 positionAlloc->Add(Vector(400.0, 0.0, 0.0));
2357 MobilityHelper mobility;
2358 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
2359 mobility.SetPositionAllocator(positionAlloc);
2360 mobility.Install(nrNodes);
2361 mobility.Install(ueNodes);
2364 Ptr<Node> pgw = nrEpcHelper->GetPgwNode();
2367 NodeContainer remoteHostContainer;
2368 remoteHostContainer.Create(1);
2369 Ptr<Node> remoteHost = remoteHostContainer.Get(0);
2370 InternetStackHelper internet;
2371 internet.Install(remoteHostContainer);
2374 PointToPointHelper p2ph;
2375 p2ph.SetDeviceAttribute(
"DataRate", DataRateValue(DataRate(
"100Gb/s")));
2376 p2ph.SetDeviceAttribute(
"Mtu", UintegerValue(1500));
2377 p2ph.SetChannelAttribute(
"Delay", TimeValue(Seconds(0.010)));
2378 NetDeviceContainer internetDevices = p2ph.Install(pgw, remoteHost);
2379 Ipv4AddressHelper ipv4h;
2380 ipv4h.SetBase(
"1.0.0.0",
"255.0.0.0");
2381 Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign(internetDevices);
2384 Ipv4StaticRoutingHelper ipv4RoutingHelper;
2385 Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
2386 ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
2387 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address(
"7.0.0.0"), Ipv4Mask(
"255.0.0.0"), 1);
2390 Config::SetDefault(
"ns3::NrGnbRrc::RsrpFilterCoefficient", UintegerValue(4));
2393 auto bandwidthAndBWPPair = nrHelper->CreateBandwidthParts({{2.8e9, 5e6, 1}},
"UMa");
2395 NetDeviceContainer nrDevs;
2396 NetDeviceContainer ueDevs;
2397 nrDevs = nrHelper->InstallGnbDevice(nrNodes, bandwidthAndBWPPair.second);
2398 ueDevs = nrHelper->InstallUeDevice(ueNodes, bandwidthAndBWPPair.second);
2402 Ptr<NrGnbRrc> nrRrc1 = nrDevs.Get(0)->GetObject<
NrGnbNetDevice>()->GetRrc();
2403 Ptr<NrGnbRrc> nrRrc2 = nrDevs.Get(1)->GetObject<
NrGnbNetDevice>()->GetRrc();
2405 for (
auto itReportConfig = m_sourceConfigList.begin();
2406 itReportConfig != m_sourceConfigList.end();
2409 measId = nrRrc1->AddUeMeasReportConfig(*itReportConfig).at(0);
2410 m_expectedSourceCellMeasId.insert(measId);
2413 for (
auto itReportConfig = m_targetConfigList.begin();
2414 itReportConfig != m_targetConfigList.end();
2417 measId = nrRrc2->AddUeMeasReportConfig(*itReportConfig).at(0);
2418 m_expectedTargetCellMeasId.insert(measId);
2422 internet.Install(ueNodes);
2423 Ipv4InterfaceContainer ueIpIfaces;
2424 ueIpIfaces = nrEpcHelper->AssignUeIpv4Address(NetDeviceContainer(ueDevs));
2427 nrHelper->AttachToGnb(ueDevs.Get(0), nrDevs.Get(0));
2430 nrHelper->AddX2Interface(nrNodes);
2434 "/NodeList/3/DeviceList/0/NrGnbRrc/RecvMeasurementReport",
2439 "/NodeList/4/DeviceList/0/NrGnbRrc/RecvMeasurementReport",
2443 nrHelper->HandoverRequest(MilliSeconds(m_duration.GetMilliSeconds() / 2),
2449 Simulator::Stop(m_duration);
2451 Simulator::Destroy();
2456NrUeMeasurementsHandoverTestCase::DoTeardown()
2458 NS_LOG_FUNCTION(
this);
2459 bool hasEnded = m_itExpectedTime == m_expectedTime.end();
2460 NS_TEST_ASSERT_MSG_EQ(hasEnded,
2462 "Reporting should have occurred at " << m_itExpectedTime->As(Time::S));
2463 hasEnded = m_itExpectedRsrp == m_expectedRsrp.end();
2464 NS_ASSERT(hasEnded);
2475 NS_LOG_FUNCTION(
this << context << (uint16_t)measId);
2477 bool isCorrectMeasId;
2480 auto itMeasId = m_expectedSourceCellMeasId.find(measId);
2481 isCorrectMeasId = (itMeasId != m_expectedSourceCellMeasId.end());
2483 else if (cellId == 2)
2485 auto itMeasId = m_expectedTargetCellMeasId.find(measId);
2486 isCorrectMeasId = (itMeasId != m_expectedTargetCellMeasId.end());
2490 NS_FATAL_ERROR(
"Invalid cell ID " << cellId);
2493 if (isCorrectMeasId)
2497 NS_LOG_DEBUG(
this <<
" Serving cellId=" << cellId
2512 "Unexpected report content");
2518 "Unexpected report content");
2521 NS_ASSERT(it->physCellId != cellId);
2522 NS_ASSERT(it->physCellId <= 2);
2523 NS_TEST_ASSERT_MSG_EQ(it->haveCgiInfo,
2525 "Report contains cgi-info, which is not supported");
2526 NS_TEST_ASSERT_MSG_EQ(it->haveRsrpResult,
2528 "Report does not contain measured RSRP result");
2529 NS_TEST_ASSERT_MSG_EQ(it->haveRsrqResult,
2531 "Report does not contain measured RSRQ result");
2533 this <<
" Neighbour cellId=" << it->physCellId
2534 <<
" rsrp=" << (uint16_t)it->rsrpResult <<
" ("
2536 <<
" rsrq=" << (uint16_t)it->rsrqResult <<
" ("
2542 bool hasEnded = m_itExpectedTime == m_expectedTime.end();
2543 NS_TEST_ASSERT_MSG_EQ(hasEnded,
2545 "Reporting should not have occurred at "
2546 << Simulator::Now().As(Time::S));
2549 hasEnded = m_itExpectedRsrp == m_expectedRsrp.end();
2550 NS_ASSERT(!hasEnded);
2553 uint64_t timeNowMs = Simulator::Now().GetMilliSeconds();
2554 uint64_t timeExpectedMs = m_itExpectedTime->GetMilliSeconds();
2558 uint16_t referenceRsrp = *m_itExpectedRsrp;
2561 NS_TEST_ASSERT_MSG_EQ(timeNowMs,
2563 "Reporting should not have occurred at this time");
2564 NS_TEST_ASSERT_MSG_EQ(observedRsrp,
2566 "The RSRP observed differs with the reference RSRP");
Testing UE measurements in NR with simulation of 2 eNodeB and 1 UE in a handover configuration.
NrUeMeasurementsHandoverTestCase(std::string name, std::list< NrRrcSap::ReportConfigEutra > sourceConfigList, std::list< NrRrcSap::ReportConfigEutra > targetConfigList, std::vector< Time > expectedTime, std::vector< uint8_t > expectedRsrp, Time duration)
void RecvMeasurementReportCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, NrRrcSap::MeasurementReport report)
Triggers when either one of the eNodeBs receives measurement report from UE, then perform verificatio...
Test suite for generating calls to UE measurements test case ns3::NrUeMeasurementsHandoverTestCase.
Testing UE measurements in NR with simulation of 1 eNodeB and 1 UE in piecewise configuration and 120...
NrUeMeasurementsPiecewiseTestCase1(std::string name, NrRrcSap::ReportConfigEutra config, std::vector< Time > expectedTime, std::vector< uint8_t > expectedRsrp)
void RecvMeasurementReportCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, NrRrcSap::MeasurementReport report)
Triggers when eNodeB receives measurement report from UE, then perform verification on it.
Testing UE measurements in NR with simulation of 2 eNodeB and 1 UE in piecewise configuration and 240...
NrUeMeasurementsPiecewiseTestCase2(std::string name, NrRrcSap::ReportConfigEutra config, std::vector< Time > expectedTime, std::vector< uint8_t > expectedRsrp)
void RecvMeasurementReportCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, NrRrcSap::MeasurementReport report)
Triggers when eNodeB receives measurement report from UE, then perform verification on it.
Testing UE measurements in NR with simulation of 3 eNodeB and 1 UE in piecewise configuration and 240...
NrUeMeasurementsPiecewiseTestCase3(std::string name, NrRrcSap::ReportConfigEutra config, std::vector< Time > expectedTime)
void RecvMeasurementReportCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, NrRrcSap::MeasurementReport report)
Triggers when eNodeB receives measurement report from UE, then perform verification on it.
Test suite for generating calls to UE measurements test case ns3::NrUeMeasurementsPiecewiseTestCase1.
Test suite for generating calls to UE measurements test case ns3::NrUeMeasurementsPiecewiseTestCase2.
Test suite for generating calls to UE measurements test case ns3::NrUeMeasurementsPiecewiseTestCase3.
Test that UE measurements calculation works properly in a scenario with 2 eNodeBs and 2UEs....
NrUeMeasurementsTestCase(std::string name, double d1, double d2, double rsrpDbmUe1, double rsrpDbmUe2, double rsrqDbUe1, double rsrqDbUe2)
void RecvMeasurementReport(uint64_t imsi, uint16_t cellId, uint16_t rnti, NrRrcSap::MeasurementReport meas)
void ReportUeMeasurements(uint16_t rnti, uint16_t cellId, double rsrp, double rsrq, bool servingCell)
Test that UE Measurements (see 36.214) calculation works fine in a multi-cell interference scenario.
@ ShannonModel
Shannon based model (very conservative)
This class contains the specification of EPS Bearers.
@ GBR_CONV_VOICE
GBR Conversational Voice.
The NrGnbNetDevice class.
static double RsrqRange2Db(uint8_t range)
static double RsrpRange2Dbm(uint8_t range)
static uint8_t Dbm2RsrpRange(double dbm)
static uint8_t Db2RsrqRange(double db)
static NrUeMeasurementsPiecewiseTestSuite3 nrUeMeasurementsPiecewiseTestSuite3
static NrUeMeasurementsTestSuite nrUeMeasurementsTestSuite
static NrUeMeasurementsPiecewiseTestSuite1 nrUeMeasurementsPiecewiseTestSuite1
static NrUeMeasurementsHandoverTestSuite nrUeMeasurementsHandoverTestSuite
static NrUeMeasurementsPiecewiseTestSuite2 nrUeMeasurementsPiecewiseTestSuite2
uint8_t rsrpResult
the RSRP result
uint8_t rsrqResult
the RSRQ result
bool haveMeasResultNeighCells
have measure result neighbor cells
MeasResultPCell measResultPCell
measurement result primary cell
std::list< MeasResultEutra > measResultListEutra
measure result list eutra
MeasurementReport structure.
MeasResults measResults
measure results
Specifies criteria for triggering of an E-UTRA measurement reporting event.
enum ns3::NrRrcSap::ReportConfigEutra::@5 triggerQuantity
Trigger type enumeration.
@ RSRP
Reference Signal Received Power.
enum ns3::NrRrcSap::ReportConfigEutra::@7 reportInterval
Report interval enumeration.
@ EVENT_A2
Event A2: Serving becomes worse than absolute threshold.
@ EVENT_A1
Event A1: Serving becomes better than absolute threshold.
@ EVENT_A4
Event A4: Neighbour becomes better than absolute threshold.
@ EVENT_A3
Event A3: Neighbour becomes amount of offset better than PCell.
ThresholdEutra threshold2
Threshold for event A5.
enum ns3::NrRrcSap::ReportConfigEutra::@4 eventId
Event enumeration.
ThresholdEutra threshold1
Threshold for event A1, A2, A4, and A5.
enum ns3::NrRrcSap::ReportConfigEutra::@3 triggerType
Trigger enumeration.
enum ns3::NrRrcSap::ThresholdEutra::@2 choice
Threshold enumeration.
uint8_t range
Value range used in RSRP/RSRQ threshold.
@ THRESHOLD_RSRP
RSRP is used for the threshold.