A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lte-test-ue-measurements.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Manuel Requena <manuel.requena@cttc.es>
19  * Nicola Baldo <nbaldo@cttc.es>
20  * Marco Miozzo <mmiozzo@cttc.es>
21  * Budiarto Herman <budiarto.herman@magister.fi>
22  */
23 
24 #include <ns3/simulator.h>
25 #include <ns3/log.h>
26 #include <ns3/callback.h>
27 #include <ns3/config.h>
28 #include <ns3/string.h>
29 #include <ns3/double.h>
30 #include <ns3/enum.h>
31 #include <ns3/boolean.h>
32 
33 #include <ns3/mobility-helper.h>
34 #include <ns3/lte-helper.h>
35 #include <ns3/point-to-point-epc-helper.h>
36 #include <ns3/internet-stack-helper.h>
37 #include <ns3/point-to-point-helper.h>
38 #include <ns3/ipv4-address-helper.h>
39 #include <ns3/ipv4-static-routing-helper.h>
40 
41 #include <ns3/node-container.h>
42 #include <ns3/net-device-container.h>
43 #include <ns3/ipv4-interface-container.h>
44 
45 #include <ns3/ff-mac-scheduler.h>
46 #include <ns3/lte-enb-net-device.h>
47 #include <ns3/lte-enb-phy.h>
48 #include <ns3/lte-enb-rrc.h>
49 #include <ns3/lte-ue-net-device.h>
50 #include <ns3/lte-ue-phy.h>
51 #include <ns3/lte-ue-rrc.h>
52 
55 #include <ns3/lte-common.h>
56 
57 NS_LOG_COMPONENT_DEFINE ("LteUeMeasurementsTest");
58 
59 namespace ns3 {
60 
61 
62 // ===== LTE-UE-MEASUREMENTS TEST SUITE ==================================== //
63 
64 void
66  std::string path, uint16_t rnti, uint16_t cellId,
67  double rsrp, double rsrq, bool servingCell)
68 {
69  testcase->ReportUeMeasurements (rnti, cellId, rsrp, rsrq, servingCell);
70 }
71 
72 void
74  std::string path, uint64_t imsi, uint16_t cellId,
75  uint16_t rnti, LteRrcSap::MeasurementReport meas)
76 {
77  testcase->RecvMeasurementReport (imsi, cellId, rnti, meas);
78 }
79 
80 
81 /*
82  * Test Suite
83  */
84 
86  : TestSuite ("lte-ue-measurements", SYSTEM)
87 {
88 
89  AddTestCase (new LteUeMeasurementsTestCase ("d1=10, d2=10000", 10.000000, 10000.000000, -53.739702, -113.739702, -3.010305, -63.010305), TestCase::EXTENSIVE);
90  AddTestCase (new LteUeMeasurementsTestCase ("d1=20, d2=10000", 20.000000, 10000.000000, -59.760302, -113.739702, -3.010319, -56.989719), TestCase::EXTENSIVE);
91  AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=10000", 50.000000, 10000.000000, -67.719102, -113.739702, -3.010421, -49.031021), TestCase::EXTENSIVE);
92  AddTestCase (new LteUeMeasurementsTestCase ("d1=100, d2=10000", 100.000000, 10000.000000, -73.739702, -113.739702, -3.010783, -43.010783), TestCase::EXTENSIVE);
93  AddTestCase (new LteUeMeasurementsTestCase ("d1=200, d2=10000", 200.000000, 10000.000000, -79.760302, -113.739702, -3.012232, -36.991632), TestCase::EXTENSIVE);
94  AddTestCase (new LteUeMeasurementsTestCase ("d1=100, d2=10000", 100.000000, 10000.000000, -73.739702, -113.739702, -3.010783, -43.010783), TestCase::EXTENSIVE);
95  AddTestCase (new LteUeMeasurementsTestCase ("d1=200, d2=10000", 200.000000, 10000.000000, -79.760302, -113.739702, -3.012232, -36.991632), TestCase::EXTENSIVE);
96  AddTestCase (new LteUeMeasurementsTestCase ("d1=500, d2=10000", 500.000000, 10000.000000, -87.719102, -113.739702, -3.022359, -29.042959), TestCase::EXTENSIVE);
97  AddTestCase (new LteUeMeasurementsTestCase ("d1=1000, d2=10000", 1000.000000, 10000.000000, -93.739702, -113.739702, -3.058336, -23.058336), TestCase::EXTENSIVE);
98  AddTestCase (new LteUeMeasurementsTestCase ("d1=2000, d2=10000", 2000.000000, 10000.000000, -99.760302, -113.739702, -3.199337, -17.178738), TestCase::EXTENSIVE);
99  AddTestCase (new LteUeMeasurementsTestCase ("d1=5000, d2=10000", 5000.000000, 10000.000000, -107.719102, -113.739702, -4.075793, -10.096393), TestCase::QUICK);
100  AddTestCase (new LteUeMeasurementsTestCase ("d1=10000, d2=10000", 10000.000000, 10000.000000, -113.739702, -113.739702, -6.257687, -6.257687), TestCase::EXTENSIVE);
101  AddTestCase (new LteUeMeasurementsTestCase ("d1=20000, d2=10000", 20000.000000, 10000.000000, -119.760302, -113.739702, -10.373365, -4.352765), TestCase::EXTENSIVE);
102  AddTestCase (new LteUeMeasurementsTestCase ("d1=50000, d2=10000", 50000.000000, 10000.000000, -127.719102, -113.739702, -17.605046, -3.625645), TestCase::EXTENSIVE);
103  AddTestCase (new LteUeMeasurementsTestCase ("d1=100000, d2=10000", 100000.000000, 10000.000000, -133.739702, -113.739702, -23.511071, -3.511071), TestCase::EXTENSIVE);
104  AddTestCase (new LteUeMeasurementsTestCase ("d1=200000, d2=10000", 200000.000000, 10000.000000, -139.760302, -113.739702, -29.502549, -3.481949), TestCase::EXTENSIVE);
105  AddTestCase (new LteUeMeasurementsTestCase ("d1=500000, d2=10000", 500000.000000, 10000.000000, -147.719102, -113.739702, -37.453160, -3.473760), TestCase::EXTENSIVE);
106  AddTestCase (new LteUeMeasurementsTestCase ("d1=1000000, d2=10000", 1000000.000000, 10000.000000, -153.739702, -113.739702, -43.472589, -3.472589), TestCase::EXTENSIVE);
107 }
108 
110 
111 
112 /*
113  * Test Case
114  */
115 
117  double d1, double d2,
118  double rsrpDbmUe1,
119  double rsrpDbmUe2,
120  double rsrqDbUe1,
121  double rsrqDbUe2)
122  : TestCase (name),
123  m_d1 (d1),
124  m_d2 (d2),
125  m_rsrpDbmUeServingCell (rsrpDbmUe1),
126  m_rsrpDbmUeNeighborCell (rsrpDbmUe2),
127  m_rsrqDbUeServingCell (rsrqDbUe1),
128  m_rsrqDbUeNeighborCell (rsrqDbUe2)
129 {
130  NS_LOG_INFO ("Test UE Measurements d1 = " << d1 << " m. and d2 = " << d2 << " m.");
131 }
132 
134 {
135 }
136 
137 void
139 {
140  NS_LOG_INFO (this << " " << GetName ());
141 
142  Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
143  Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
144  Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
145  Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005));
146  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
147  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
148  lteHelper->SetAttribute ("UseIdealRrc", BooleanValue (false));
149 
150  // LogComponentEnable ("LteUeMeasurementsTest", LOG_LEVEL_ALL);
151 
152  // Create Nodes: eNodeB and UE
153  NodeContainer enbNodes;
154  NodeContainer ueNodes1;
155  NodeContainer ueNodes2;
156  enbNodes.Create (2);
157  ueNodes1.Create (1);
158  ueNodes2.Create (1);
159  NodeContainer allNodes = NodeContainer (enbNodes, ueNodes1, ueNodes2);
160 
161  // the topology is the following:
162  // d2
163  // UE1-----------eNB2
164  // | |
165  // d1| |d1
166  // | d2 |
167  // eNB1----------UE2
168  //
169  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
170  positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // eNB1
171  positionAlloc->Add (Vector (m_d2, m_d1, 0.0)); // eNB2
172  positionAlloc->Add (Vector (0.0, m_d1, 0.0)); // UE1
173  positionAlloc->Add (Vector (m_d2, 0.0, 0.0)); // UE2
174  MobilityHelper mobility;
175  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
176  mobility.SetPositionAllocator (positionAlloc);
177  mobility.Install (allNodes);
178 
179  // Create Devices and install them in the Nodes (eNB and UE)
180  NetDeviceContainer enbDevs;
181  NetDeviceContainer ueDevs1;
182  NetDeviceContainer ueDevs2;
183  lteHelper->SetSchedulerType ("ns3::RrFfMacScheduler");
184  lteHelper->SetSchedulerAttribute ("UlCqiFilter", EnumValue (FfMacScheduler::PUSCH_UL_CQI));
185  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
186  ueDevs1 = lteHelper->InstallUeDevice (ueNodes1);
187  ueDevs2 = lteHelper->InstallUeDevice (ueNodes2);
188 
189  // Attach UEs to eNodeBs
190  lteHelper->Attach (ueDevs1, enbDevs.Get (0));
191  lteHelper->Attach (ueDevs2, enbDevs.Get (1));
192 
193  // Activate an EPS bearer
195  EpsBearer bearer (q);
196  lteHelper->ActivateDataRadioBearer (ueDevs1, bearer);
197  lteHelper->ActivateDataRadioBearer (ueDevs2, bearer);
198 
199  // Use testing chunk processor in the PHY layer
200  // It will be used to test that the SNR is as intended
201  // we plug in two instances, one for DL and one for UL
202 
203  Ptr<LtePhy> ue1Phy = ueDevs1.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
204  Ptr<LteTestSinrChunkProcessor> testDlSinr1 = Create<LteTestSinrChunkProcessor> (ue1Phy);
205  ue1Phy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr1);
206 
207  Ptr<LtePhy> enb1phy = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
208  Ptr<LteTestSinrChunkProcessor> testUlSinr1 = Create<LteTestSinrChunkProcessor> (enb1phy);
209  enb1phy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr1);
210 
211  Config::Connect ("/NodeList/2/DeviceList/0/LteUePhy/ReportUeMeasurements",
213  Config::Connect ("/NodeList/0/DeviceList/0/LteEnbRrc/RecvMeasurementReport",
215 
216  // same as above for eNB2 and UE2
217 
218  Ptr<LtePhy> ue2Phy = ueDevs2.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
219  Ptr<LteTestSinrChunkProcessor> testDlSinr2 = Create<LteTestSinrChunkProcessor> (ue2Phy);
220  ue2Phy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr2);
221 
222  Ptr<LtePhy> enb2phy = enbDevs.Get (1)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
223  Ptr<LteTestSinrChunkProcessor> testUlSinr2 = Create<LteTestSinrChunkProcessor> (enb2phy);
224  enb1phy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr2);
225 
226  Config::Connect ("/NodeList/3/DeviceList/0/LteUePhy/ReportUeMeasurements",
228  Config::Connect ("/NodeList/1/DeviceList/0/LteEnbRrc/RecvMeasurementReport",
230 
231  // need to allow for RRC connection establishment + SRS
232  Simulator::Stop (Seconds (0.800));
233  Simulator::Run ();
234 
236 
237 }
238 
239 void
240 LteUeMeasurementsTestCase::ReportUeMeasurements (uint16_t rnti, uint16_t cellId,
241  double rsrp, double rsrq,
242  bool servingCell)
243 {
244  // need to allow for RRC connection establishment + CQI feedback reception + UE measurements filtering (200 ms)
245  if (Simulator::Now () > MilliSeconds (400))
246  {
247  if (servingCell)
248  {
249  NS_LOG_DEBUG ("UE serving cellId " << cellId << " Rxed RSRP " << rsrp << " thr " << m_rsrpDbmUeServingCell << " RSRQ " << rsrq << " thr " << m_rsrqDbUeServingCell);
250  NS_TEST_ASSERT_MSG_EQ_TOL (m_rsrpDbmUeServingCell, rsrp, 0.2, "Wrong RSRP UE 1");
251  NS_TEST_ASSERT_MSG_EQ_TOL (m_rsrqDbUeServingCell, rsrq, 0.2, "Wrong RSRQ UE 1");
252  }
253  else
254  {
255  NS_LOG_DEBUG ("UE neighbor cellId " << cellId << " Rxed RSRP " << rsrp << " thr " << m_rsrpDbmUeNeighborCell << " RSRQ " << rsrq << " thr " << m_rsrqDbUeNeighborCell);
256  NS_TEST_ASSERT_MSG_EQ_TOL (m_rsrpDbmUeNeighborCell, rsrp, 0.2, "Wrong RSRP UE 2");
257  NS_TEST_ASSERT_MSG_EQ_TOL (m_rsrqDbUeNeighborCell, rsrq, 0.2, "Wrong RSRQ UE ");
258  }
259  }
260 }
261 
262 void
263 LteUeMeasurementsTestCase::RecvMeasurementReport (uint64_t imsi, uint16_t cellId, uint16_t rnti,
265 {
266  // need to allow for RRC connection establishment + CQI feedback reception + UE measurements filtering (200 ms)
267  if (Simulator::Now () > MilliSeconds (400))
268  {
269  if (cellId == imsi)
270  {
271  NS_LOG_DEBUG (this << "Serving Cell: received IMSI " << imsi << " CellId " << cellId << " RNTI " << rnti
273  << " RSRP " << (uint16_t) meas.measResults.rsrpResult
274  << " RSRQ " << (uint16_t)meas.measResults.rsrqResult
278  "Wrong RSRP ");
281  "Wrong RSRQ ");
282  }
283  else
284  {
285  NS_LOG_DEBUG (this << "Neighbor cell: received IMSI " << imsi << " CellId " << cellId << " RNTI " << rnti
287  << " RSRP " << (uint16_t) meas.measResults.rsrpResult
288  << " RSRQ " << (uint16_t)meas.measResults.rsrqResult
292  "Wrong RSRP ");
295  "Wrong RSRQ ");
296  }
297  }
298 }
299 
300 
301 // ===== LTE-UE-MEASUREMENTS-PIECEWISE-1 TEST SUITE ======================== //
302 
303 /*
304  * Overloaded operators, for the convenience of defining test cases
305  */
306 
307 std::vector<Time>&
308 operator<< (std::vector<Time>& v, const uint64_t& ms)
309 {
310  /*
311  * Prior attempt to use seconds as unit of choice resulted in precision lost.
312  * Therefore milliseconds are used now instead.
313  */
314  v.push_back (MilliSeconds (ms) + UE_MEASUREMENT_REPORT_DELAY);
315  return v;
316 }
317 
318 std::vector<uint8_t>&
319 operator<< (std::vector<uint8_t>& v, const uint8_t& range)
320 {
321  v.push_back (range);
322  return v;
323 }
324 
325 
326 /*
327  * Test Suite
328  */
329 
331  : TestSuite ("lte-ue-measurements-piecewise-1", SYSTEM)
332 {
333  std::vector<Time> expectedTime;
334  std::vector<uint8_t> expectedRsrp;
335 
336  // === Event A1 (serving cell becomes better than threshold) ===
337 
338  // With very low threshold
343  config.threshold1.range = 0;
346  expectedTime.clear ();
347  expectedTime << 200 << 320 << 440 << 560 << 680 << 800 << 920 << 1040 << 1160 << 1280
348  << 1400 << 1520 << 1640 << 1760 << 1880 << 2000 << 2120;
349  expectedRsrp.clear ();
350  expectedRsrp << 67 << 67 << 57 << 57 << 66 << 47 << 47 << 66 << 66 << 57
351  << 51 << 51 << 47 << 47 << 51 << 57 << 57;
352  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A1 with very low threshold",
353  config, expectedTime, expectedRsrp),
355 
356  // With normal threshold
357  config.threshold1.range = 54;
358  expectedTime.clear ();
359  expectedTime << 200 << 320 << 440 << 560 << 680 << 1000 << 1120 << 1240 << 1360 << 2000
360  << 2120;
361  expectedRsrp.clear ();
362  expectedRsrp << 67 << 67 << 57 << 57 << 66 << 66 << 66 << 57 << 57 << 57
363  << 57;
364  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A1 with normal threshold",
365  config, expectedTime, expectedRsrp),
367 
368  // With short time-to-trigger
369  config.timeToTrigger = 64;
370  expectedTime.clear ();
371  expectedTime << 264 << 384 << 504 << 624 << 744 << 1064 << 1184 << 1304 << 1424 << 2064
372  << 2184;
373  expectedRsrp.clear ();
374  expectedRsrp << 67 << 67 << 57 << 66 << 66 << 66 << 66 << 57 << 51 << 57
375  << 57;
376  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A1 with short time-to-trigger",
377  config, expectedTime, expectedRsrp),
379 
380  // With long time-to-trigger
381  config.timeToTrigger = 128;
382  expectedTime.clear ();
383  expectedTime << 328 << 448 << 568 << 688 << 808 << 1128 << 1248 << 1368 << 1488 << 2128;
384  expectedRsrp.clear ();
385  expectedRsrp << 67 << 57 << 57 << 66 << 47 << 66 << 57 << 57 << 51 << 57;
386  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A1 with long time-to-trigger",
387  config, expectedTime, expectedRsrp),
389 
390  // With super time-to-trigger
391  config.timeToTrigger = 256;
392  expectedTime.clear ();
393  expectedTime << 456 << 576 << 696 << 816 << 936 << 1056 << 1176 << 1296 << 1416 << 1536;
394  expectedRsrp.clear ();
395  expectedRsrp << 57 << 57 << 66 << 47 << 47 << 66 << 66 << 57 << 51 << 51;
396  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A1 with super time-to-trigger",
397  config, expectedTime, expectedRsrp),
399 
400  // With hysteresis
401  config.hysteresis = 8;
402  config.timeToTrigger = 0;
403  expectedTime.clear ();
404  expectedTime << 200 << 320 << 440 << 560 << 680 << 1000 << 1120 << 1240 << 1360 << 1480
405  << 2200;
406  expectedRsrp.clear ();
407  expectedRsrp << 67 << 67 << 57 << 57 << 66 << 66 << 66 << 57 << 57 << 51
408  << 67;
409  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A1 with hysteresis",
410  config, expectedTime, expectedRsrp),
412 
413  // With very high threshold
414  config.threshold1.range = 97;
415  config.hysteresis = 0;
416  expectedTime.clear ();
417  expectedRsrp.clear ();
418  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A1 with very high threshold",
419  config, expectedTime, expectedRsrp),
421 
422  // === Event A2 (serving cell becomes worse than threshold) ===
423 
424  // With very low threshold
426  config.threshold1.range = 0;
427  expectedTime.clear ();
428  expectedRsrp.clear ();
429  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A2 with very low threshold",
430  config, expectedTime, expectedRsrp),
432 
433  // With normal threshold
434  config.threshold1.range = 54;
435  expectedTime.clear ();
436  expectedTime << 800 << 920 << 1400 << 1520 << 1640 << 1760 << 1880;
437  expectedRsrp.clear ();
438  expectedRsrp << 47 << 47 << 51 << 51 << 47 << 47 << 51;
439  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A2 with normal threshold",
440  config, expectedTime, expectedRsrp),
442 
443  // With short time-to-trigger
444  config.timeToTrigger = 64;
445  expectedTime.clear ();
446  expectedTime << 864 << 984 << 1464 << 1584 << 1704 << 1824 << 1944;
447  expectedRsrp.clear ();
448  expectedRsrp << 47 << 47 << 51 << 51 << 47 << 51 << 51;
449  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A2 with short time-to-trigger",
450  config, expectedTime, expectedRsrp),
452 
453  // With long time-to-trigger
454  config.timeToTrigger = 128;
455  expectedTime.clear ();
456  expectedTime << 928 << 1048 << 1528 << 1648 << 1768 << 1888 << 2008;
457  expectedRsrp.clear ();
458  expectedRsrp << 47 << 66 << 51 << 47 << 47 << 51 << 57;
459  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A2 with long time-to-trigger",
460  config, expectedTime, expectedRsrp),
462 
463  // With super time-to-trigger
464  config.timeToTrigger = 256;
465  expectedTime.clear ();
466  expectedTime << 1656 << 1776 << 1896 << 2016 << 2136;
467  expectedRsrp.clear ();
468  expectedRsrp << 47 << 47 << 51 << 57 << 57;
469  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A2 with super time-to-trigger",
470  config, expectedTime, expectedRsrp),
472 
473  // With hysteresis
474  config.hysteresis = 8;
475  config.timeToTrigger = 0;
476  expectedTime.clear ();
477  expectedTime << 800 << 920 << 1600 << 1720 << 1840 << 1960 << 2080;
478  expectedRsrp.clear ();
479  expectedRsrp << 47 << 47 << 47 << 47 << 51 << 51 << 57;
480  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A2 with hysteresis",
481  config, expectedTime, expectedRsrp),
483 
484  // With very high threshold
485  config.threshold1.range = 97;
486  config.hysteresis = 0;
487  expectedTime.clear ();
488  expectedTime << 200 << 320 << 440 << 560 << 680 << 800 << 920 << 1040 << 1160 << 1280
489  << 1400 << 1520 << 1640 << 1760 << 1880 << 2000 << 2120;
490  expectedRsrp.clear ();
491  expectedRsrp << 67 << 67 << 57 << 57 << 66 << 47 << 47 << 66 << 66 << 57
492  << 51 << 51 << 47 << 47 << 51 << 57 << 57;
493  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A2 with very high threshold",
494  config, expectedTime, expectedRsrp),
496 
497  /*
498  * Event A3, A4, and A5 are not tested intensively here because they depend on
499  * the existence of at least one neighbouring cell, which is not available in
500  * this configuration. Piecewise configuration #2 includes a neighbouring
501  * cell, hence more thorough tests on these events are performed there.
502  */
503 
504  expectedTime.clear ();
505  expectedRsrp.clear ();
506 
507  // === Event A3 (neighbour becomes offset better than PCell) ===
508 
510  config.a3Offset = 0;
511  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A3",
512  config, expectedTime, expectedRsrp),
514 
515  // === Event A4 (neighbour becomes better than threshold) ===
516 
518  config.threshold1.range = 54;
519  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A4",
520  config, expectedTime, expectedRsrp),
522 
523  // === Event A5 (PCell becomes worse than absolute threshold1 AND neighbour becomes better than another absolute threshold2) ===
524 
526  config.threshold2.range = 58;
527  AddTestCase (new LteUeMeasurementsPiecewiseTestCase1 ("Piecewise test case 1 - Event A5",
528  config, expectedTime, expectedRsrp),
530 
531 } // end of LteUeMeasurementsPiecewiseTestSuite1::LteUeMeasurementsPiecewiseTestSuite1
532 
534 
535 
536 /*
537  * Test Case
538  */
539 
541  std::string name, LteRrcSap::ReportConfigEutra config,
542  std::vector<Time> expectedTime, std::vector<uint8_t> expectedRsrp)
543  : TestCase (name),
544  m_config (config),
545  m_expectedTime (expectedTime),
546  m_expectedRsrp (expectedRsrp)
547 {
548  // input sanity check
549  uint16_t size = m_expectedTime.size ();
550 
551  if (size != m_expectedRsrp.size ())
552  {
553  NS_FATAL_ERROR ("Vectors of expected results are not of the same size");
554  }
555 
556  m_itExpectedTime = m_expectedTime.begin ();
557  m_itExpectedRsrp = m_expectedRsrp.begin ();
558 
559  NS_LOG_INFO (this << " name=" << name);
560 }
561 
563 {
564  NS_LOG_FUNCTION (this);
565 }
566 
567 void
569 {
570  NS_LOG_INFO (this << " " << GetName ());
571 
572  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
573  lteHelper->SetAttribute ("PathlossModel",
574  StringValue ("ns3::FriisSpectrumPropagationLossModel"));
575  lteHelper->SetAttribute ("UseIdealRrc", BooleanValue (true));
576 
577  // Create Nodes: eNodeB and UE
578  NodeContainer enbNodes;
579  NodeContainer ueNodes;
580  enbNodes.Create (1);
581  ueNodes.Create (1);
582 
583  /*
584  * The topology is the following:
585  *
586  * eNodeB UE
587  * | |
588  * x ----- x --------- x --------------- x ------------------- x
589  * 100 m | 200 m | 300 m | 400 m |
590  * | | | |
591  * VeryNear Near Far VeryFar
592  */
593 
594  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
595  positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // eNodeB
596  positionAlloc->Add (Vector (100.0, 0.0, 0.0)); // UE
597  MobilityHelper mobility;
598  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
599  mobility.SetPositionAllocator (positionAlloc);
600  mobility.Install (enbNodes);
601  mobility.Install (ueNodes);
602  m_ueMobility = ueNodes.Get (0)->GetObject<MobilityModel> ();
603 
604  // Disable layer-3 filtering
605  Config::SetDefault ("ns3::LteEnbRrc::RsrpFilterCoefficient",
606  UintegerValue (0));
607 
608  // Create Devices and install them in the Nodes (eNB and UE)
609  NetDeviceContainer enbDevs;
610  NetDeviceContainer ueDevs;
611  lteHelper->SetSchedulerType ("ns3::RrFfMacScheduler");
612  lteHelper->SetSchedulerAttribute ("UlCqiFilter",
614  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
615  ueDevs = lteHelper->InstallUeDevice (ueNodes);
616 
617  // Setup UE measurement configuration
618  Ptr<LteEnbRrc> enbRrc = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ()->GetRrc ();
619  m_expectedMeasId = enbRrc->AddUeMeasReportConfig (m_config);
620 
621  // Attach UE to eNodeB
622  lteHelper->Attach (ueDevs.Get (0), enbDevs.Get (0));
623 
624  // Activate an EPS bearer
626  EpsBearer bearer (q);
627  lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
628 
629  // Connect to trace sources
630  Config::Connect ("/NodeList/0/DeviceList/0/LteEnbRrc/RecvMeasurementReport",
632  this));
633 
634  /*
635  * Schedule "teleports"
636  * 0 1 2
637  * +-------------------+-------------------+---------> time
638  * VeryNear |------ ---- ---- --------
639  * Near | ---- ----
640  * Far | ---- ----
641  * VeryFar | -- ---- ----
642  */
643  Simulator::Schedule (MilliSeconds (301),
645  Simulator::Schedule (MilliSeconds (401),
647  Simulator::Schedule (MilliSeconds (601),
649  Simulator::Schedule (MilliSeconds (801),
651  Simulator::Schedule (MilliSeconds (1001),
653  Simulator::Schedule (MilliSeconds (1201),
655  Simulator::Schedule (MilliSeconds (1401),
657  Simulator::Schedule (MilliSeconds (1601),
659  Simulator::Schedule (MilliSeconds (1801),
661  Simulator::Schedule (MilliSeconds (2001),
663 
664  // Run simulation
665  Simulator::Stop (Seconds (2.201));
666  Simulator::Run ();
668 
669 } // end of void LteUeMeasurementsPiecewiseTestCase1::DoRun ()
670 
671 void
673 {
674  NS_LOG_FUNCTION (this);
675  bool hasEnded = m_itExpectedTime == m_expectedTime.end ();
676  NS_TEST_ASSERT_MSG_EQ (hasEnded, true,
677  "Reporting should have occurred at " << m_itExpectedTime->GetSeconds () << "s");
678  hasEnded = m_itExpectedRsrp == m_expectedRsrp.end ();
679  NS_ASSERT (hasEnded);
680 }
681 
682 void
684  std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti,
686 {
687  NS_LOG_FUNCTION (this << context);
688  NS_ASSERT (rnti == 1);
689  NS_ASSERT (cellId == 1);
690 
691  if (report.measResults.measId == m_expectedMeasId)
692  {
693  // verifying the report completeness
694  LteRrcSap::MeasResults measResults = report.measResults;
695  NS_LOG_DEBUG (this << " rsrp=" << (uint16_t) measResults.rsrpResult
696  << " (" << EutranMeasurementMapping::RsrpRange2Dbm (measResults.rsrpResult) << " dBm)"
697  << " rsrq=" << (uint16_t) measResults.rsrqResult
698  << " (" << EutranMeasurementMapping::RsrqRange2Db (measResults.rsrqResult) << " dB)");
700  "Report should not have neighboring cells information");
701  NS_TEST_ASSERT_MSG_EQ (measResults.measResultListEutra.size (), 0,
702  "Unexpected report size");
703 
704  bool hasEnded = m_itExpectedTime == m_expectedTime.end ();
705  NS_TEST_ASSERT_MSG_EQ (hasEnded, false,
706  "Reporting should not have occurred at "
707  << Simulator::Now ().GetSeconds () << "s");
708  if (!hasEnded)
709  {
710  hasEnded = m_itExpectedRsrp == m_expectedRsrp.end ();
711  NS_ASSERT (!hasEnded);
712 
713  // using milliseconds to avoid floating-point comparison
714  uint64_t timeNowMs = Simulator::Now ().GetMilliSeconds ();
715  uint64_t timeExpectedMs = m_itExpectedTime->GetMilliSeconds ();
717 
718  uint16_t observedRsrp = measResults.rsrpResult;
719  uint16_t referenceRsrp = *m_itExpectedRsrp;
721 
722  NS_TEST_ASSERT_MSG_EQ (timeNowMs, timeExpectedMs,
723  "Reporting should not have occurred at this time");
724  NS_TEST_ASSERT_MSG_EQ (observedRsrp, referenceRsrp,
725  "The RSRP observed differs with the reference RSRP");
726  } // end of if (!hasEnded)
727 
728  } // end of if (measResults.measId == m_expectedMeasId)
729 
730 } // end of LteUeMeasurementsPiecewiseTestCase1::RecvMeasurementReportCallback
731 
732 void
734 {
735  NS_LOG_FUNCTION (this);
736  m_ueMobility->SetPosition (Vector (100.0, 0.0, 0.0));
737 }
738 
739 void
741 {
742  NS_LOG_FUNCTION (this);
743  m_ueMobility->SetPosition (Vector (300.0, 0.0, 0.0));
744 }
745 
746 void
748 {
749  NS_LOG_FUNCTION (this);
750  m_ueMobility->SetPosition (Vector (600.0, 0.0, 0.0));
751 }
752 
753 void
755 {
756  NS_LOG_FUNCTION (this);
757  m_ueMobility->SetPosition (Vector (1000.0, 0.0, 0.0));
758 }
759 
760 
761 // ===== LTE-UE-MEASUREMENTS-PIECEWISE-2 TEST SUITE ======================== //
762 
763 /*
764  * Test Suite
765  */
766 
768  : TestSuite ("lte-ue-measurements-piecewise-2", SYSTEM)
769 {
770  std::vector<Time> expectedTime;
771  std::vector<uint8_t> expectedRsrp;
772 
773  /*
774  * Higher level of fullness/duration are given to Event A1 and A2 because they
775  * are supposed to be more intensively tested in Piecewise configuration #1.
776  */
777 
778  // === Event A1 (serving cell becomes better than threshold) ===
779 
780  // With very low threshold
785  config.threshold1.range = 0;
788  expectedTime.clear ();
789  expectedTime << 200 << 440 << 680 << 920 << 1160 << 1400 << 1640 << 1880 << 2120;
790  expectedRsrp.clear ();
791  expectedRsrp << 73 << 63 << 72 << 52 << 72 << 56 << 52 << 56 << 59;
792  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A1 with very low threshold",
793  config, expectedTime, expectedRsrp),
795 
796  // With normal threshold
797  config.threshold1.range = 58;
798  expectedTime.clear ();
799  expectedTime << 200 << 440 << 680 << 1000 << 1240 << 2000;
800  expectedRsrp.clear ();
801  expectedRsrp << 73 << 63 << 72 << 72 << 59 << 59;
802  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A1 with normal threshold",
803  config, expectedTime, expectedRsrp),
805 
806  // With hysteresis
807  config.hysteresis = 6;
808  expectedTime.clear ();
809  expectedTime << 200 << 440 << 680 << 1000 << 1240 << 1480 << 2200;
810  expectedRsrp.clear ();
811  expectedRsrp << 73 << 63 << 72 << 72 << 59 << 56 << 72;
812  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A1 with hysteresis",
813  config, expectedTime, expectedRsrp),
815 
816  // With very high threshold
817  config.threshold1.range = 97;
818  config.hysteresis = 0;
819  expectedTime.clear ();
820  expectedRsrp.clear ();
821  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A1 with very high threshold",
822  config, expectedTime, expectedRsrp),
824 
825  // === Event A2 (serving cell becomes worse than threshold) ===
826 
827  // With very low threshold
829  config.threshold1.range = 0;
830  expectedTime.clear ();
831  expectedRsrp.clear ();
832  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A2 with very low threshold",
833  config, expectedTime, expectedRsrp),
835 
836  // With normal threshold
837  config.threshold1.range = 58;
838  expectedTime.clear ();
839  expectedTime << 800 << 1400 << 1640 << 1880;
840  expectedRsrp.clear ();
841  expectedRsrp << 52 << 56 << 52 << 56;
842  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A2 with normal threshold",
843  config, expectedTime, expectedRsrp),
845 
846  // With hysteresis
847  config.hysteresis = 6;
848  expectedTime.clear ();
849  expectedTime << 800 << 1600 << 1840 << 2080;
850  expectedRsrp.clear ();
851  expectedRsrp << 52 << 52 << 56 << 59;
852  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A2 with hysteresis",
853  config, expectedTime, expectedRsrp),
855 
856  // With very high threshold
857  config.threshold1.range = 97;
858  config.hysteresis = 0;
859  expectedTime.clear ();
860  expectedTime << 200 << 440 << 680 << 920 << 1160 << 1400 << 1640 << 1880 << 2120;
861  expectedRsrp.clear ();
862  expectedRsrp << 73 << 63 << 72 << 52 << 72 << 56 << 52 << 56 << 59;
863  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A2 with very high threshold",
864  config, expectedTime, expectedRsrp),
866 
867  // === Event A3 (neighbour becomes offset better than PCell) ===
868 
869  // With positive offset
871  config.threshold1.range = 0;
872  config.a3Offset = 7;
873  expectedTime.clear ();
874  expectedTime << 800 << 1600;
875  expectedRsrp.clear ();
876  expectedRsrp << 52 << 52;
877  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A3 with positive offset",
878  config, expectedTime, expectedRsrp),
880 
881  // With zero offset
882  config.a3Offset = 0;
883  expectedTime.clear ();
884  expectedTime << 800 << 1400 << 1640 << 1880;
885  expectedRsrp.clear ();
886  expectedRsrp << 52 << 56 << 52 << 56;
887  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A3 with zero offset",
888  config, expectedTime, expectedRsrp),
890 
891  // With short time-to-trigger
892  config.timeToTrigger = 160;
893  expectedTime.clear ();
894  expectedTime << 960 << 1560 << 1800 << 2040;
895  expectedRsrp.clear ();
896  expectedRsrp << 52 << 56 << 56 << 59;
897  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A3 with short time-to-trigger",
898  config, expectedTime, expectedRsrp),
900 
901  // With super time-to-trigger
902  config.timeToTrigger = 320;
903  expectedTime.clear ();
904  expectedTime << 1720 << 1960 << 2200;
905  expectedRsrp.clear ();
906  expectedRsrp << 52 << 56 << 72;
907  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A3 with super time-to-trigger",
908  config, expectedTime, expectedRsrp),
910 
911  // With hysteresis and reportOnLeave
912  config.hysteresis = 6;
913  config.reportOnLeave = true;
914  config.timeToTrigger = 0;
915  expectedTime.clear ();
916  expectedTime << 800 << 1000 << 1600 << 1840 << 2080 << 2200;
917  expectedRsrp.clear ();
918  expectedRsrp << 52 << 72 << 52 << 56 << 59 << 72;
919  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A3 with hysteresis",
920  config, expectedTime, expectedRsrp),
922 
923  // With negative offset
924  config.a3Offset = -7;
925  config.hysteresis = 0;
926  config.reportOnLeave = false;
927  expectedTime.clear ();
928  expectedTime << 400 << 800 << 1200 << 1440 << 1680 << 1920 << 2160;
929  expectedRsrp.clear ();
930  expectedRsrp << 63 << 52 << 59 << 56 << 52 << 56 << 59;
931  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A3 with negative offset",
932  config, expectedTime, expectedRsrp),
934 
935  // === Event A4 (neighbour becomes better than threshold) ===
936 
937  // With very low threshold
939  config.threshold1.range = 0;
940  config.a3Offset = 0;
941  expectedTime.clear ();
942  expectedTime << 200 << 440 << 680 << 920 << 1160 << 1400 << 1640 << 1880 << 2120;
943  expectedRsrp.clear ();
944  expectedRsrp << 73 << 63 << 72 << 52 << 72 << 56 << 52 << 56 << 59;
945  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A4 with very low threshold",
946  config, expectedTime, expectedRsrp),
948 
949  // With normal threshold
950  config.threshold1.range = 58;
951  expectedTime.clear ();
952  expectedTime << 400 << 800 << 1400 << 1640 << 1880;
953  expectedRsrp.clear ();
954  expectedRsrp << 63 << 52 << 56 << 52 << 56;
955  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A4 with normal threshold",
956  config, expectedTime, expectedRsrp),
958 
959  // With short time-to-trigger
960  config.timeToTrigger = 160;
961  expectedTime.clear ();
962  expectedTime << 560 << 960 << 1560 << 1800 << 2040;
963  expectedRsrp.clear ();
964  expectedRsrp << 63 << 52 << 56 << 56 << 59;
965  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A4 with short time-to-trigger",
966  config, expectedTime, expectedRsrp),
968 
969  // With super time-to-trigger
970  config.timeToTrigger = 320;
971  expectedTime.clear ();
972  expectedTime << 1720 << 1960 << 2200;
973  expectedRsrp.clear ();
974  expectedRsrp << 52 << 56 << 72;
975  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A4 with super time-to-trigger",
976  config, expectedTime, expectedRsrp),
978 
979  // With hysteresis
980  config.hysteresis = 6;
981  config.timeToTrigger = 0;
982  expectedTime.clear ();
983  expectedTime << 400 << 800 << 1600 << 1840 << 2080;
984  expectedRsrp.clear ();
985  expectedRsrp << 63 << 52 << 52 << 56 << 59;
986  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A4 with hysteresis",
987  config, expectedTime, expectedRsrp),
989 
990  // With very high threshold
991  config.threshold1.range = 97;
992  config.hysteresis = 0;
993  expectedTime.clear ();
994  expectedRsrp.clear ();
995  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A4 with very high threshold",
996  config, expectedTime, expectedRsrp),
998 
999  // === Event A5 (PCell becomes worse than absolute threshold1 AND neighbour becomes better than another absolute threshold2) ===
1000 
1001  // With low-low threshold
1003  config.threshold1.range = 0;
1004  config.threshold2.range = 0;
1005  expectedTime.clear ();
1006  expectedRsrp.clear ();
1007  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A5 with low-low threshold",
1008  config, expectedTime, expectedRsrp),
1010 
1011  // With low-normal threshold
1012  config.threshold2.range = 58;
1013  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A5 with low-normal threshold",
1014  config, expectedTime, expectedRsrp),
1016 
1017  // With low-high threshold
1018  config.threshold2.range = 97;
1019  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A5 with low-high threshold",
1020  config, expectedTime, expectedRsrp),
1022 
1023  // With normal-low threshold
1024  config.threshold1.range = 58;
1025  config.threshold2.range = 0;
1026  expectedTime.clear ();
1027  expectedTime << 800 << 1400 << 1640 << 1880;
1028  expectedRsrp.clear ();
1029  expectedRsrp << 52 << 56 << 52 << 56;
1030  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A5 with normal-low threshold",
1031  config, expectedTime, expectedRsrp),
1033 
1034  // With normal-normal threshold
1035  config.threshold2.range = 58;
1036  expectedTime.clear ();
1037  expectedTime << 800 << 1400 << 1640 << 1880;
1038  expectedRsrp.clear ();
1039  expectedRsrp << 52 << 56 << 52 << 56;
1040  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A5 with normal-normal threshold",
1041  config, expectedTime, expectedRsrp),
1043 
1044  // With short time-to-trigger
1045  config.timeToTrigger = 160;
1046  expectedTime.clear ();
1047  expectedTime << 960 << 1560 << 1800 << 2040;
1048  expectedRsrp.clear ();
1049  expectedRsrp << 52 << 56 << 56 << 59;
1050  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A5 with short time-to-trigger",
1051  config, expectedTime, expectedRsrp),
1053 
1054  // With super time-to-trigger
1055  config.timeToTrigger = 320;
1056  expectedTime.clear ();
1057  expectedTime << 1720 << 1960 << 2200;
1058  expectedRsrp.clear ();
1059  expectedRsrp << 52 << 56 << 72;
1060  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A5 with super time-to-trigger",
1061  config, expectedTime, expectedRsrp),
1062  TestCase::QUICK);
1063 
1064  // With hysteresis
1065  config.hysteresis = 6;
1066  config.timeToTrigger = 0;
1067  expectedTime.clear ();
1068  expectedTime << 800 << 1600 << 1840 << 2080;
1069  expectedRsrp.clear ();
1070  expectedRsrp << 52 << 52 << 56 << 59;
1071  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A5 with hysteresis",
1072  config, expectedTime, expectedRsrp),
1073  TestCase::QUICK);
1074 
1075  // With normal-high threshold
1076  config.threshold2.range = 97;
1077  config.hysteresis = 0;
1078  expectedTime.clear ();
1079  expectedRsrp.clear ();
1080  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A5 with normal-high threshold",
1081  config, expectedTime, expectedRsrp),
1083 
1084  // With high-low threshold
1085  config.threshold1.range = 97;
1086  config.threshold2.range = 0;
1087  expectedTime.clear ();
1088  expectedTime << 200 << 440 << 680 << 920 << 1160 << 1400 << 1640 << 1880 << 2120;
1089  expectedRsrp.clear ();
1090  expectedRsrp << 73 << 63 << 72 << 52 << 72 << 56 << 52 << 56 << 59;
1091  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A5 with high-low threshold",
1092  config, expectedTime, expectedRsrp),
1094 
1095  // With high-normal threshold
1096  config.threshold2.range = 58;
1097  expectedTime.clear ();
1098  expectedTime << 400 << 800 << 1400 << 1640 << 1880;
1099  expectedRsrp.clear ();
1100  expectedRsrp << 63 << 52 << 56 << 52 << 56;
1101  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A5 with high-normal threshold",
1102  config, expectedTime, expectedRsrp),
1104 
1105  // With high-high threshold
1106  config.threshold2.range = 97;
1107  expectedTime.clear ();
1108  expectedRsrp.clear ();
1109  AddTestCase (new LteUeMeasurementsPiecewiseTestCase2 ("Piecewise test case 2 - Event A5 with high-high threshold",
1110  config, expectedTime, expectedRsrp),
1112 
1113 } // end of LteUeMeasurementsPiecewiseTestSuite2::LteUeMeasurementsPiecewiseTestSuite2
1114 
1116 
1117 
1118 /*
1119  * Test Case
1120  */
1121 
1123  std::string name, LteRrcSap::ReportConfigEutra config,
1124  std::vector<Time> expectedTime, std::vector<uint8_t> expectedRsrp)
1125  : TestCase (name),
1126  m_config (config),
1127  m_expectedTime (expectedTime),
1128  m_expectedRsrp (expectedRsrp)
1129 {
1130  // input sanity check
1131  uint16_t size = m_expectedTime.size ();
1132 
1133  if (size != m_expectedRsrp.size ())
1134  {
1135  NS_FATAL_ERROR ("Vectors of expected results are not of the same size");
1136  }
1137 
1138  m_itExpectedTime = m_expectedTime.begin ();
1139  m_itExpectedRsrp = m_expectedRsrp.begin ();
1140 
1141  NS_LOG_INFO (this << " name=" << name);
1142 }
1143 
1145 {
1146  NS_LOG_FUNCTION (this);
1147 }
1148 
1149 void
1151 {
1152  NS_LOG_INFO (this << " " << GetName ());
1153 
1154  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
1155  lteHelper->SetAttribute ("PathlossModel",
1156  StringValue ("ns3::FriisSpectrumPropagationLossModel"));
1157  lteHelper->SetAttribute ("UseIdealRrc", BooleanValue (true));
1158 
1159  // Create Nodes: eNodeB and UE
1160  NodeContainer enbNodes;
1161  NodeContainer ueNodes;
1162  enbNodes.Create (2);
1163  ueNodes.Create (1);
1164 
1165  /*
1166  * The topology is the following:
1167  *
1168  * eNodeB UE eNodeB
1169  * | | |
1170  * x ---- x --------------- x ------- x --------------- x ---- x
1171  * 50 m | 200 m | 100 m | 200 m | 50 m
1172  * | | | |
1173  * VeryNear Near Far VeryFar
1174  */
1175 
1176  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1177  positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // Serving eNodeB
1178  positionAlloc->Add (Vector (600.0, 0.0, 0.0)); // Neighbour eNodeB
1179  positionAlloc->Add (Vector (50.0, 0.0, 0.0)); // UE
1180  MobilityHelper mobility;
1181  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1182  mobility.SetPositionAllocator (positionAlloc);
1183  mobility.Install (enbNodes);
1184  mobility.Install (ueNodes);
1185  m_ueMobility = ueNodes.Get (0)->GetObject<MobilityModel> ();
1186 
1187  // Disable layer-3 filtering
1188  Config::SetDefault ("ns3::LteEnbRrc::RsrpFilterCoefficient",
1189  UintegerValue (0));
1190 
1191  // Create Devices and install them in the Nodes (eNB and UE)
1192  NetDeviceContainer enbDevs;
1193  NetDeviceContainer ueDevs;
1194  lteHelper->SetSchedulerType ("ns3::RrFfMacScheduler");
1195  lteHelper->SetSchedulerAttribute ("UlCqiFilter",
1197  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
1198  ueDevs = lteHelper->InstallUeDevice (ueNodes);
1199 
1200  // Setup UE measurement configuration in serving cell
1201  Ptr<LteEnbRrc> enbRrc1 = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ()->GetRrc ();
1202  m_expectedMeasId = enbRrc1->AddUeMeasReportConfig (m_config);
1203 
1204  // Disable handover in neighbour cell
1205  Ptr<LteEnbRrc> enbRrc2 = enbDevs.Get (1)->GetObject<LteEnbNetDevice> ()->GetRrc ();
1206  enbRrc2->SetAttribute ("AdmitHandoverRequest", BooleanValue (false));
1207 
1208  // Attach UE to serving eNodeB
1209  lteHelper->Attach (ueDevs.Get (0), enbDevs.Get (0));
1210 
1211  // Activate an EPS bearer
1213  EpsBearer bearer (q);
1214  lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
1215 
1216  // Connect to trace sources in serving eNodeB
1217  Config::Connect ("/NodeList/0/DeviceList/0/LteEnbRrc/RecvMeasurementReport",
1219  this));
1220 
1221  /*
1222  * Schedule "teleports"
1223  * 0 1 2
1224  * +-------------------+-------------------+---------> time
1225  * VeryNear |------ ---- ---- --------
1226  * Near | ---- ----
1227  * Far | ---- ----
1228  * VeryFar | -- ---- ----
1229  */
1230  Simulator::Schedule (MilliSeconds (301),
1232  Simulator::Schedule (MilliSeconds (401),
1234  Simulator::Schedule (MilliSeconds (601),
1236  Simulator::Schedule (MilliSeconds (801),
1238  Simulator::Schedule (MilliSeconds (1001),
1240  Simulator::Schedule (MilliSeconds (1201),
1242  Simulator::Schedule (MilliSeconds (1401),
1244  Simulator::Schedule (MilliSeconds (1601),
1246  Simulator::Schedule (MilliSeconds (1801),
1248  Simulator::Schedule (MilliSeconds (2001),
1250 
1251  // Run simulation
1252  Simulator::Stop (Seconds (2.201));
1253  Simulator::Run ();
1254  Simulator::Destroy ();
1255 
1256 } // end of void LteUeMeasurementsPiecewiseTestCase2::DoRun ()
1257 
1258 void
1260 {
1261  NS_LOG_FUNCTION (this);
1262  bool hasEnded = m_itExpectedTime == m_expectedTime.end ();
1263  NS_TEST_ASSERT_MSG_EQ (hasEnded, true,
1264  "Reporting should have occurred at " << m_itExpectedTime->GetSeconds () << "s");
1265  hasEnded = m_itExpectedRsrp == m_expectedRsrp.end ();
1266  NS_ASSERT (hasEnded);
1267 }
1268 
1269 void
1271  std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti,
1273 {
1274  NS_LOG_FUNCTION (this << context);
1275  NS_ASSERT (rnti == 1);
1276  NS_ASSERT (cellId == 1);
1277 
1278  if (report.measResults.measId == m_expectedMeasId)
1279  {
1280  // verifying the report completeness
1281  LteRrcSap::MeasResults measResults = report.measResults;
1282  NS_LOG_DEBUG (this << " Serving cellId=" << cellId
1283  << " rsrp=" << (uint16_t) measResults.rsrpResult
1284  << " (" << EutranMeasurementMapping::RsrpRange2Dbm (measResults.rsrpResult) << " dBm)"
1285  << " rsrq=" << (uint16_t) measResults.rsrqResult
1286  << " (" << EutranMeasurementMapping::RsrqRange2Db (measResults.rsrqResult) << " dB)");
1287 
1288  // verifying reported best cells
1289  if (measResults.measResultListEutra.size () == 0)
1290  {
1291  NS_TEST_ASSERT_MSG_EQ (measResults.haveMeasResultNeighCells, false,
1292  "Unexpected report content");
1293  }
1294  else
1295  {
1297  "Unexpected report content");
1298  std::list<LteRrcSap::MeasResultEutra>::iterator it = measResults.measResultListEutra.begin ();
1299  NS_ASSERT (it != measResults.measResultListEutra.end ());
1300  NS_ASSERT (it->physCellId == 2);
1301  NS_TEST_ASSERT_MSG_EQ (it->haveCgiInfo, false,
1302  "Report contains cgi-info, which is not supported");
1303  NS_TEST_ASSERT_MSG_EQ (it->haveRsrpResult, true,
1304  "Report does not contain measured RSRP result");
1305  NS_TEST_ASSERT_MSG_EQ (it->haveRsrqResult, true,
1306  "Report does not contain measured RSRQ result");
1307  NS_LOG_DEBUG (this << " Neighbour cellId=" << it->physCellId
1308  << " rsrp=" << (uint16_t) it->rsrpResult
1309  << " (" << EutranMeasurementMapping::RsrpRange2Dbm (it->rsrpResult) << " dBm)"
1310  << " rsrq=" << (uint16_t) it->rsrqResult
1311  << " (" << EutranMeasurementMapping::RsrqRange2Db (it->rsrqResult) << " dB)");
1312 
1313  } // end of else of if (measResults.measResultListEutra.size () == 0)
1314 
1315  // verifying the report timing
1316  bool hasEnded = m_itExpectedTime == m_expectedTime.end ();
1317  NS_TEST_ASSERT_MSG_EQ (hasEnded, false,
1318  "Reporting should not have occurred at "
1319  << Simulator::Now ().GetSeconds () << "s");
1320  if (!hasEnded)
1321  {
1322  hasEnded = m_itExpectedRsrp == m_expectedRsrp.end ();
1323  NS_ASSERT (!hasEnded);
1324 
1325  // using milliseconds to avoid floating-point comparison
1326  uint64_t timeNowMs = Simulator::Now ().GetMilliSeconds ();
1327  uint64_t timeExpectedMs = m_itExpectedTime->GetMilliSeconds ();
1328  m_itExpectedTime++;
1329 
1330  uint16_t observedRsrp = measResults.rsrpResult;
1331  uint16_t referenceRsrp = *m_itExpectedRsrp;
1332  m_itExpectedRsrp++;
1333 
1334  NS_TEST_ASSERT_MSG_EQ (timeNowMs, timeExpectedMs,
1335  "Reporting should not have occurred at this time");
1336  NS_TEST_ASSERT_MSG_EQ (observedRsrp, referenceRsrp,
1337  "The RSRP observed differs with the reference RSRP");
1338 
1339  } // end of if (!hasEnded)
1340 
1341  } // end of if (report.measResults.measId == m_expectedMeasId)
1342 
1343 } // end of void LteUeMeasurementsPiecewiseTestCase2::RecvMeasurementReportCallback
1344 
1345 void
1347 {
1348  NS_LOG_FUNCTION (this);
1349  m_ueMobility->SetPosition (Vector (50.0, 0.0, 0.0));
1350 }
1351 
1352 void
1354 {
1355  NS_LOG_FUNCTION (this);
1356  m_ueMobility->SetPosition (Vector (250.0, 0.0, 0.0));
1357 }
1358 
1359 void
1361 {
1362  NS_LOG_FUNCTION (this);
1363  m_ueMobility->SetPosition (Vector (350.0, 0.0, 0.0));
1364 }
1365 
1366 void
1368 {
1369  NS_LOG_FUNCTION (this);
1370  m_ueMobility->SetPosition (Vector (550.0, 0.0, 0.0));
1371 }
1372 
1373 
1374 // ===== LTE-UE-MEASUREMENTS-HANDOVER TEST SUITE =========================== //
1375 
1376 /*
1377  * Test Suite
1378  */
1379 
1381  : TestSuite ("lte-ue-measurements-handover", SYSTEM)
1382 {
1383  std::list<LteRrcSap::ReportConfigEutra> sourceConfigList;
1384  std::list<LteRrcSap::ReportConfigEutra> targetConfigList;
1385  std::vector<Time> expectedTime;
1386  std::vector<uint8_t> expectedRsrp;
1387 
1388  LteRrcSap::ReportConfigEutra sourceConfig;
1392  sourceConfig.threshold1.range = 0;
1395  sourceConfigList.push_back (sourceConfig);
1396 
1397  LteRrcSap::ReportConfigEutra targetConfig;
1401  targetConfig.threshold1.range = 0;
1404  targetConfigList.push_back (targetConfig);
1405 
1406  // === Report interval difference ===
1407 
1408  // decreasing report interval
1409  sourceConfigList.front ().reportInterval = LteRrcSap::ReportConfigEutra::MS480;
1410  targetConfigList.front ().reportInterval = LteRrcSap::ReportConfigEutra::MS240;
1411  expectedTime.clear ();
1412  expectedTime << 200 << 680 << 1200 << 1440 << 1680 << 1920;
1413  expectedRsrp.clear ();
1414  expectedRsrp << 55 << 55 << 53 << 53 << 53 << 53;
1415  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - decreasing report interval",
1416  sourceConfigList, targetConfigList,
1417  expectedTime, expectedRsrp,
1418  Seconds (2)),
1420 
1421  // increasing report interval
1422  sourceConfigList.front ().reportInterval = LteRrcSap::ReportConfigEutra::MS120;
1423  targetConfigList.front ().reportInterval = LteRrcSap::ReportConfigEutra::MS640;
1424  expectedTime.clear ();
1425  expectedTime << 200 << 320 << 440 << 560 << 680 << 800 << 920 << 1200 << 1840;
1426  expectedRsrp.clear ();
1427  expectedRsrp << 55 << 55 << 55 << 55 << 55 << 55 << 55 << 53 << 53;
1428  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - increasing report interval",
1429  sourceConfigList, targetConfigList,
1430  expectedTime, expectedRsrp,
1431  Seconds (2)),
1432  TestCase::QUICK);
1433 
1434  // === Event difference ===
1435 
1436  sourceConfigList.front ().reportInterval = LteRrcSap::ReportConfigEutra::MS240;
1437  targetConfigList.front ().reportInterval = LteRrcSap::ReportConfigEutra::MS240;
1438  sourceConfigList.front ().threshold1.range = 54;
1439  sourceConfigList.front ().threshold2.range = 54;
1440  sourceConfigList.front ().a3Offset = 1;
1441  targetConfigList.front ().threshold1.range = 54;
1442  targetConfigList.front ().threshold2.range = 54;
1443  targetConfigList.front ().a3Offset = 1;
1444 
1445  // Event A1 to Event A2
1446  sourceConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A1;
1447  targetConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A2;
1448  expectedTime.clear ();
1449  expectedTime << 200 << 440 << 680 << 920 << 1200 << 1440 << 1680 << 1920;
1450  expectedRsrp.clear ();
1451  expectedRsrp << 55 << 55 << 55 << 55 << 53 << 53 << 53 << 53;
1452  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - Event A1 to Event A2",
1453  sourceConfigList, targetConfigList,
1454  expectedTime, expectedRsrp,
1455  Seconds (2)),
1457 
1458  // Event A2 to Event A1
1459  sourceConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A2;
1460  targetConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A1;
1461  expectedTime.clear ();
1462  expectedRsrp.clear ();
1463  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - Event A2 to Event A1",
1464  sourceConfigList, targetConfigList,
1465  expectedTime, expectedRsrp,
1466  Seconds (2)),
1468 
1469  // Event A3 to Event A4
1470  sourceConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A3;
1471  targetConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A4;
1472  expectedTime.clear ();
1473  expectedTime << 1200 << 1440 << 1680 << 1920;
1474  expectedRsrp.clear ();
1475  expectedRsrp << 53 << 53 << 53 << 53;
1476  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - Event A3 to Event A4",
1477  sourceConfigList, targetConfigList,
1478  expectedTime, expectedRsrp,
1479  Seconds (2)),
1481 
1482  // Event A4 to Event A3
1483  sourceConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A4;
1484  targetConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A3;
1485  expectedTime.clear ();
1486  expectedTime << 1200 << 1440 << 1680 << 1920;
1487  expectedRsrp.clear ();
1488  expectedRsrp << 53 << 53 << 53 << 53;
1489  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - Event A4 to Event A3",
1490  sourceConfigList, targetConfigList,
1491  expectedTime, expectedRsrp,
1492  Seconds (2)),
1493  TestCase::QUICK);
1494 
1495  // Event A2 to Event A3
1496  sourceConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A2;
1497  targetConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A3;
1498  expectedTime.clear ();
1499  expectedTime << 1200 << 1440 << 1680 << 1920;
1500  expectedRsrp.clear ();
1501  expectedRsrp << 53 << 53 << 53 << 53;
1502  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - Event A2 to Event A3",
1503  sourceConfigList, targetConfigList,
1504  expectedTime, expectedRsrp,
1505  Seconds (2)),
1507 
1508  // Event A3 to Event A2
1509  sourceConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A3;
1510  targetConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A2;
1511  expectedTime.clear ();
1512  expectedTime << 1200 << 1440 << 1680 << 1920;
1513  expectedRsrp.clear ();
1514  expectedRsrp << 53 << 53 << 53 << 53;
1515  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - Event A3 to Event A2",
1516  sourceConfigList, targetConfigList,
1517  expectedTime, expectedRsrp,
1518  Seconds (2)),
1520 
1521  // Event A4 to Event A5
1522  sourceConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A4;
1523  targetConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A5;
1524  expectedTime.clear ();
1525  expectedTime << 1200 << 1440 << 1680 << 1920;
1526  expectedRsrp.clear ();
1527  expectedRsrp << 53 << 53 << 53 << 53;
1528  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - Event A4 to Event A5",
1529  sourceConfigList, targetConfigList,
1530  expectedTime, expectedRsrp,
1531  Seconds (2)),
1533 
1534  // Event A5 to Event A4
1535  sourceConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A5;
1536  targetConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A4;
1537  expectedTime.clear ();
1538  expectedTime << 1200 << 1440 << 1680 << 1920;
1539  expectedRsrp.clear ();
1540  expectedRsrp << 53 << 53 << 53 << 53;
1541  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - Event A5 to Event A4",
1542  sourceConfigList, targetConfigList,
1543  expectedTime, expectedRsrp,
1544  Seconds (2)),
1546 
1547  // === Threshold/offset difference ===
1548 
1549  sourceConfigList.front ().threshold1.range = 52;
1550  targetConfigList.front ().threshold1.range = 56;
1551 
1552  // Event A1
1553  sourceConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A1;
1554  targetConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A1;
1555  expectedTime.clear ();
1556  expectedTime << 200 << 440 << 680 << 920;
1557  expectedRsrp.clear ();
1558  expectedRsrp << 55 << 55 << 55 << 55;
1559  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - Event A1 threshold difference",
1560  sourceConfigList, targetConfigList,
1561  expectedTime, expectedRsrp,
1562  Seconds (2)),
1564 
1565  // Event A2
1566  sourceConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A2;
1567  targetConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A2;
1568  expectedTime.clear ();
1569  expectedTime << 1200 << 1440 << 1680 << 1920;
1570  expectedRsrp.clear ();
1571  expectedRsrp << 53 << 53 << 53 << 53;
1572  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - Event A2 threshold difference",
1573  sourceConfigList, targetConfigList,
1574  expectedTime, expectedRsrp,
1575  Seconds (2)),
1576  TestCase::QUICK);
1577 
1578  // Event A3
1579  sourceConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A3;
1580  sourceConfigList.front ().a3Offset = -30;
1581  targetConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A3;
1582  targetConfigList.front ().a3Offset = 30;
1583  expectedTime.clear ();
1584  expectedTime << 200 << 440 << 680 << 920;
1585  expectedRsrp.clear ();
1586  expectedRsrp << 55 << 55 << 55 << 55;
1587  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - Event A3 offset difference",
1588  sourceConfigList, targetConfigList,
1589  expectedTime, expectedRsrp,
1590  Seconds (2)),
1591  TestCase::QUICK);
1592 
1593  // Event A4
1594  sourceConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A4;
1595  targetConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A4;
1596  expectedTime.clear ();
1597  expectedTime << 200 << 440 << 680 << 920;
1598  expectedRsrp.clear ();
1599  expectedRsrp << 55 << 55 << 55 << 55;
1600  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - Event A4 threshold difference",
1601  sourceConfigList, targetConfigList,
1602  expectedTime, expectedRsrp,
1603  Seconds (2)),
1605 
1606  // Event A5
1607  sourceConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A5;
1608  sourceConfigList.front ().threshold2.range = 52;
1609  targetConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A5;
1610  targetConfigList.front ().threshold2.range = 56;
1611  expectedTime.clear ();
1612  expectedRsrp.clear ();
1613  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - Event A5 threshold difference",
1614  sourceConfigList, targetConfigList,
1615  expectedTime, expectedRsrp,
1616  Seconds (2)),
1618 
1619  // === Time-to-trigger (TTT) difference ===
1620 
1621  sourceConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A1;
1622  sourceConfigList.front ().a3Offset = 1;
1623  sourceConfigList.front ().threshold1.range = 0;
1624  sourceConfigList.front ().threshold2.range = 0;
1625  targetConfigList.front ().eventId = LteRrcSap::ReportConfigEutra::EVENT_A1;
1626  targetConfigList.front ().a3Offset = 1;
1627  targetConfigList.front ().threshold1.range = 0;
1628  targetConfigList.front ().threshold2.range = 0;
1629 
1630  // decreasing time-to-trigger (short duration)
1631  sourceConfigList.front ().timeToTrigger = 1024;
1632  targetConfigList.front ().timeToTrigger = 100;
1633  expectedTime.clear ();
1634  expectedTime << 1300 << 1540 << 1780;
1635  expectedRsrp.clear ();
1636  expectedRsrp << 53 << 53 << 53;
1637  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - decreasing TTT (short)",
1638  sourceConfigList, targetConfigList,
1639  expectedTime, expectedRsrp,
1640  Seconds (2)),
1641  TestCase::QUICK);
1642 
1643  // decreasing time-to-trigger (longer duration)
1644  sourceConfigList.front ().timeToTrigger = 1024;
1645  targetConfigList.front ().timeToTrigger = 640;
1646  expectedTime.clear ();
1647  expectedTime << 1224 << 1464 << 1704 << 1944 << 2840 << 3080 << 3320 << 3560 << 3800 << 4040;
1648  expectedRsrp.clear ();
1649  expectedRsrp << 55 << 55 << 55 << 55 << 53 << 53 << 53 << 53 << 53 << 53;
1650  AddTestCase (new LteUeMeasurementsHandoverTestCase ("Handover test case - decreasing TTT (long)",
1651  sourceConfigList, targetConfigList,
1652  expectedTime, expectedRsrp,
1653  Seconds (4.2)),
1655 
1656 } // end of LteUeMeasurementsHandoverTestSuite::LteUeMeasurementsHandoverTestSuite
1657 
1659 
1660 
1661 /*
1662  * Test Case
1663  */
1664 
1666  std::string name,
1667  std::list<LteRrcSap::ReportConfigEutra> sourceConfigList,
1668  std::list<LteRrcSap::ReportConfigEutra> targetConfigList,
1669  std::vector<Time> expectedTime, std::vector<uint8_t> expectedRsrp,
1670  Time duration)
1671  : TestCase (name),
1672  m_sourceConfigList (sourceConfigList),
1673  m_targetConfigList (targetConfigList),
1674  m_expectedTime (expectedTime),
1675  m_expectedRsrp (expectedRsrp),
1676  m_duration (duration)
1677 {
1678  // input sanity check
1679  uint16_t size = m_expectedTime.size ();
1680 
1681  if (size != m_expectedRsrp.size ())
1682  {
1683  NS_FATAL_ERROR ("Vectors of expected results are not of the same size");
1684  }
1685 
1686  m_itExpectedTime = m_expectedTime.begin ();
1687  m_itExpectedRsrp = m_expectedRsrp.begin ();
1688 
1689  NS_LOG_INFO (this << " name=" << name);
1690 }
1691 
1693 {
1694  NS_LOG_FUNCTION (this);
1695 }
1696 
1697 void
1699 {
1700  NS_LOG_INFO (this << " " << GetName ());
1701 
1702  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
1703  Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper> ();
1704  lteHelper->SetEpcHelper (epcHelper);
1705  lteHelper->SetAttribute ("PathlossModel",
1706  StringValue ("ns3::FriisSpectrumPropagationLossModel"));
1707  lteHelper->SetAttribute ("UseIdealRrc", BooleanValue (true));
1708 
1709  // Create Nodes: eNodeB and UE
1710  NodeContainer enbNodes;
1711  NodeContainer ueNodes;
1712  enbNodes.Create (2);
1713  ueNodes.Create (1);
1714 
1715  /*
1716  * The topology is the following:
1717  *
1718  * eNodeB UE eNodeB
1719  * | | |
1720  * x ------------------- x ----------------------- x
1721  * 400 m 500 m
1722  */
1723 
1724  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1725  positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // Source eNodeB
1726  positionAlloc->Add (Vector (900.0, 0.0, 0.0)); // Target eNodeB
1727  positionAlloc->Add (Vector (400.0, 0.0, 0.0)); // UE
1728  MobilityHelper mobility;
1729  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1730  mobility.SetPositionAllocator (positionAlloc);
1731  mobility.Install (enbNodes);
1732  mobility.Install (ueNodes);
1733 
1734  // Create P-GW node
1735  Ptr<Node> pgw = epcHelper->GetPgwNode ();
1736 
1737  // Create a single RemoteHost
1738  NodeContainer remoteHostContainer;
1739  remoteHostContainer.Create (1);
1740  Ptr<Node> remoteHost = remoteHostContainer.Get (0);
1741  InternetStackHelper internet;
1742  internet.Install (remoteHostContainer);
1743 
1744  // Create the Internet
1745  PointToPointHelper p2ph;
1746  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
1747  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
1748  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
1749  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
1750  Ipv4AddressHelper ipv4h;
1751  ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
1752  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
1753 
1754  // Routing of the Internet Host (towards the LTE network)
1755  Ipv4StaticRoutingHelper ipv4RoutingHelper;
1756  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
1757  remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
1758 
1759  // Enable layer-3 filtering
1760  Config::SetDefault ("ns3::LteEnbRrc::RsrpFilterCoefficient",
1761  UintegerValue (4));
1762 
1763  // Disable control channel error model
1764  Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled",
1765  BooleanValue (false));
1766 
1767  // Create Devices and install them in the Nodes (eNB and UE)
1768  NetDeviceContainer enbDevs;
1769  NetDeviceContainer ueDevs;
1770  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
1771  ueDevs = lteHelper->InstallUeDevice (ueNodes);
1772 
1773  // Setup UE measurement configuration in eNodeBs
1774  uint8_t measId;
1775  std::list<LteRrcSap::ReportConfigEutra>::const_iterator itReportConfig;
1776  Ptr<LteEnbRrc> enbRrc1 = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ()->GetRrc ();
1777  Ptr<LteEnbRrc> enbRrc2 = enbDevs.Get (1)->GetObject<LteEnbNetDevice> ()->GetRrc ();
1778 
1779  for (itReportConfig = m_sourceConfigList.begin ();
1780  itReportConfig != m_sourceConfigList.end (); itReportConfig++)
1781  {
1782  measId = enbRrc1->AddUeMeasReportConfig (*itReportConfig);
1783  m_expectedSourceCellMeasId.insert (measId);
1784  }
1785 
1786  for (itReportConfig = m_targetConfigList.begin ();
1787  itReportConfig != m_targetConfigList.end (); itReportConfig++)
1788  {
1789  measId = enbRrc2->AddUeMeasReportConfig (*itReportConfig);
1790  m_expectedTargetCellMeasId.insert (measId);
1791  }
1792 
1793  // Install the IP stack on the UEs
1794  internet.Install (ueNodes);
1795  Ipv4InterfaceContainer ueIpIfaces;
1796  ueIpIfaces = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevs));
1797 
1798  // Assign IP address to UEs
1799  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
1800  {
1801  Ptr<Node> ueNode = ueNodes.Get (u);
1802  // Set the default gateway for the UE
1803  Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
1804  ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
1805  }
1806 
1807  // Attach UE to serving eNodeB
1808  lteHelper->Attach (ueDevs.Get (0), enbDevs.Get (0));
1809 
1810  // Add X2 interface
1811  lteHelper->AddX2Interface (enbNodes);
1812 
1813  // Connect to trace sources in source eNodeB
1814  Config::Connect ("/NodeList/1/DeviceList/0/LteEnbRrc/RecvMeasurementReport",
1816  this));
1817 
1818  // Connect to trace sources in target eNodeB
1819  Config::Connect ("/NodeList/2/DeviceList/0/LteEnbRrc/RecvMeasurementReport",
1821  this));
1822 
1823  // Schedule handover
1824  lteHelper->HandoverRequest (MilliSeconds (m_duration.GetMilliSeconds () / 2),
1825  ueDevs.Get (0), enbDevs.Get (0), enbDevs.Get (1));
1826 
1827  // Run simulation
1829  Simulator::Run ();
1830  Simulator::Destroy ();
1831 
1832 } // end of void LteUeMeasurementsHandoverTestCase::DoRun ()
1833 
1834 void
1836 {
1837  NS_LOG_FUNCTION (this);
1838  bool hasEnded = m_itExpectedTime == m_expectedTime.end ();
1839  NS_TEST_ASSERT_MSG_EQ (hasEnded, true,
1840  "Reporting should have occurred at " << m_itExpectedTime->GetSeconds () << "s");
1841  hasEnded = m_itExpectedRsrp == m_expectedRsrp.end ();
1842  NS_ASSERT (hasEnded);
1843 }
1844 
1845 void
1847  std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti,
1849 {
1850  uint8_t measId = report.measResults.measId;
1851  NS_LOG_FUNCTION (this << context << (uint16_t) measId);
1852 
1853  bool isCorrectMeasId;
1854  if (cellId == 1)
1855  {
1856  std::set<uint8_t>::iterator itMeasId = m_expectedSourceCellMeasId.find (measId);
1857  isCorrectMeasId = (itMeasId != m_expectedSourceCellMeasId.end ());
1858  }
1859  else if (cellId == 2)
1860  {
1861  std::set<uint8_t>::iterator itMeasId = m_expectedTargetCellMeasId.find (measId);
1862  isCorrectMeasId = (itMeasId != m_expectedTargetCellMeasId.end ());
1863  }
1864  else
1865  {
1866  NS_FATAL_ERROR ("Invalid cell ID " << cellId);
1867  }
1868 
1869  if (isCorrectMeasId)
1870  {
1871  // verifying the report completeness
1872  LteRrcSap::MeasResults measResults = report.measResults;
1873  NS_LOG_DEBUG (this << " Serving cellId=" << cellId
1874  << " rsrp=" << (uint16_t) measResults.rsrpResult
1875  << " (" << EutranMeasurementMapping::RsrpRange2Dbm (measResults.rsrpResult) << " dBm)"
1876  << " rsrq=" << (uint16_t) measResults.rsrqResult
1877  << " (" << EutranMeasurementMapping::RsrqRange2Db (measResults.rsrqResult) << " dB)");
1878 
1879  // verifying reported best cells
1880  if (measResults.measResultListEutra.size () == 0)
1881  {
1882  NS_TEST_ASSERT_MSG_EQ (measResults.haveMeasResultNeighCells, false,
1883  "Unexpected report content");
1884  }
1885  else
1886  {
1888  "Unexpected report content");
1889  std::list<LteRrcSap::MeasResultEutra>::iterator it = measResults.measResultListEutra.begin ();
1890  NS_ASSERT (it != measResults.measResultListEutra.end ());
1891  NS_ASSERT (it->physCellId != cellId);
1892  NS_ASSERT (it->physCellId <= 2);
1893  NS_TEST_ASSERT_MSG_EQ (it->haveCgiInfo, false,
1894  "Report contains cgi-info, which is not supported");
1895  NS_TEST_ASSERT_MSG_EQ (it->haveRsrpResult, true,
1896  "Report does not contain measured RSRP result");
1897  NS_TEST_ASSERT_MSG_EQ (it->haveRsrqResult, true,
1898  "Report does not contain measured RSRQ result");
1899  NS_LOG_DEBUG (this << " Neighbour cellId=" << it->physCellId
1900  << " rsrp=" << (uint16_t) it->rsrpResult
1901  << " (" << EutranMeasurementMapping::RsrpRange2Dbm (it->rsrpResult) << " dBm)"
1902  << " rsrq=" << (uint16_t) it->rsrqResult
1903  << " (" << EutranMeasurementMapping::RsrqRange2Db (it->rsrqResult) << " dB)");
1904 
1905  } // end of else of if (measResults.measResultListEutra.size () == 0)
1906 
1907  // verifying the report timing
1908  bool hasEnded = m_itExpectedTime == m_expectedTime.end ();
1909  NS_TEST_ASSERT_MSG_EQ (hasEnded, false,
1910  "Reporting should not have occurred at "
1911  << Simulator::Now ().GetSeconds () << "s");
1912  if (!hasEnded)
1913  {
1914  hasEnded = m_itExpectedRsrp == m_expectedRsrp.end ();
1915  NS_ASSERT (!hasEnded);
1916 
1917  // using milliseconds to avoid floating-point comparison
1918  uint64_t timeNowMs = Simulator::Now ().GetMilliSeconds ();
1919  uint64_t timeExpectedMs = m_itExpectedTime->GetMilliSeconds ();
1920  m_itExpectedTime++;
1921 
1922  uint16_t observedRsrp = measResults.rsrpResult;
1923  uint16_t referenceRsrp = *m_itExpectedRsrp;
1924  m_itExpectedRsrp++;
1925 
1926  NS_TEST_ASSERT_MSG_EQ (timeNowMs, timeExpectedMs,
1927  "Reporting should not have occurred at this time");
1928  NS_TEST_ASSERT_MSG_EQ (observedRsrp, referenceRsrp,
1929  "The RSRP observed differs with the reference RSRP");
1930 
1931  } // end of if (!hasEnded)
1932 
1933  } // end of if (report.measResults.measId == correctMeasId)
1934 
1935 } // end of void LteUeMeasurementsHandoverTestCase::RecvMeasurementReportCallback
1936 
1937 
1938 } // namespace ns3
1939 
std::list< LteRrcSap::ReportConfigEutra > m_sourceConfigList
The list of active report triggering configuration for the source eNodeB.
virtual void DoRun()
Setup the simulation with the intended UE measurement reporting configuration, run it...
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
Testing UE measurements in LTE with simulation of 2 eNodeB and 1 UE in a handover configuration...
Hold a bool native type.
Definition: boolean.h:38
RSRP is used for the threshold.
Definition: lte-rrc-sap.h:251
LteUeMeasurementsHandoverTestCase(std::string name, std::list< LteRrcSap::ReportConfigEutra > sourceConfigList, std::list< LteRrcSap::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, LteRrcSap::MeasurementReport report)
Triggers when eNodeB receives measurement report from UE, then perform verification on it...
holds a vector of std::pair of Ptr and interface index.
hold variables of type string
Definition: string.h:19
uint8_t hysteresis
Parameter used within the entry and leave condition of an event triggered reporting condition...
Definition: lte-rrc-sap.h:286
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
NetDeviceContainer Install(NodeContainer c)
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Definition: test.h:326
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:210
std::vector< Time >::iterator m_itExpectedTime
Pointer to the element of m_expectedTime which is expected to occur next in the simulation.
enum ns3::LteRrcSap::ReportConfigEutra::@70 eventId
Choice of E-UTRA event triggered reporting criteria.
void RecvMeasurementReportCallback(LteUeMeasurementsTestCase *testcase, std::string path, uint64_t imsi, uint16_t cellId, uint16_t rnti, LteRrcSap::MeasurementReport meas)
std::list< MeasResultEutra > measResultListEutra
Definition: lte-rrc-sap.h:519
A suite of tests to run.
Definition: test.h:1025
enum ns3::LteRrcSap::ReportConfigEutra::@69 triggerType
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Build bound Callbacks which take varying numbers of arguments, and potentially returning a value...
Definition: callback.h:1463
ThresholdEutra threshold1
Threshold for event A1, A2, A4, and A5.
Definition: lte-rrc-sap.h:276
Specifies criteria for triggering of an E-UTRA measurement reporting event.
Definition: lte-rrc-sap.h:258
Very long running test.
Definition: test.h:859
std::vector< uint8_t > m_expectedRsrp
The list of expected values of RSRP (in 3GPP range unit) from the measurement reports received...
#define NS_ASSERT(condition)
Definition: assert.h:64
static void Run(void)
Run the simulation until one of:
Definition: simulator.cc:157
aggregate IP/TCP/UDP functionality to existing Nodes.
Test that UE Measurements (see 36.214) calculation works fine in a multi-cell interference scenario...
#define NS_LOG_INFO(msg)
Definition: log.h:298
void RecvMeasurementReportCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, LteRrcSap::MeasurementReport report)
Triggers when eNodeB receives measurement report from UE, then perform verification on it...
Build a set of PointToPointNetDevice objects.
encapsulates test code
Definition: test.h:849
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Definition: simulator.h:824
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:728
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
NS_LOG_COMPONENT_DEFINE("LteUeMeasurementsTest")
static LteUeMeasurementsPiecewiseTestSuite2 lteUeMeasurementsPiecewiseTestSuite2
a 3d vector
Definition: vector.h:31
std::vector< uint8_t > m_expectedRsrp
The list of expected values of RSRP (in 3GPP range unit) from the measurement reports received...
std::set< uint8_t > m_expectedSourceCellMeasId
The list of measurement identities being tested in the source cell.
uint8_t m_expectedMeasId
The measurement identity being tested.
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
std::vector< Time > m_expectedTime
The list of expected time when measurement reports are received by eNodeB.
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
static double RsrqRange2Db(uint8_t range)
converts an RSRQ range to dB as per 3GPP TS 36.133 section 9.1.7 RSRQ Measurement Report Mapping ...
Definition: lte-common.cc:218
std::vector< Time >::iterator m_itExpectedTime
Pointer to the element of m_expectedTime which is expected to occur next in the simulation.
Class for representing data rates.
Definition: data-rate.h:71
Keep track of the current position and velocity of an object.
virtual void DoTeardown()
Runs at the end of the simulation, verifying that all expected measurement reports have been examined...
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:71
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
static const Time UE_MEASUREMENT_REPORT_DELAY
Artificial delay of UE measurements procedure.
Definition: lte-ue-rrc.h:56
hold variables of type 'enum'
Definition: enum.h:37
std::vector< uint8_t >::iterator m_itExpectedRsrp
Pointer to the element of m_expectedRsrp which is expected to occur next in the simulation.
hold objects of type ns3::Time
Definition: nstime.h:961
static LteUeMeasurementsHandoverTestSuite lteUeMeasurementsHandoverTestSuite
virtual void DoRun()
Setup the simulation with the intended UE measurement reporting configuration, run it...
Hold an unsigned integer type.
Definition: uinteger.h:46
static LteUeMeasurementsTestSuite lteUeMeasurementsTestSuite
Medium length test.
Definition: test.h:858
holds a vector of ns3::NetDevice pointers
LteRrcSap::ReportConfigEutra m_config
The active report triggering configuration.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1238
std::vector< uint8_t > m_expectedRsrp
The list of expected values of RSRP (in 3GPP range unit) from the measurement reports received...
std::list< LteRrcSap::ReportConfigEutra > m_targetConfigList
The list of active report triggering configuration for the target eNodeB.
void ReportUeMeasurements(uint16_t rnti, uint16_t cellId, double rsrp, double rsrq, bool servingCell)
void RecvMeasurementReportCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, LteRrcSap::MeasurementReport report)
Triggers when either one of the eNodeBs receives measurement report from UE, then perform verificatio...
static void Destroy(void)
Every event scheduled by the Simulator::insertAtDestroy method is invoked.
Definition: simulator.cc:121
std::vector< Time >::iterator m_itExpectedTime
Pointer to the element of m_expectedTime which is expected to occur next in the simulation.
Access to the Ipv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:75
virtual void DoTeardown()
Runs at the end of the simulation, verifying that all expected measurement reports have been examined...
Event A2: Serving becomes worse than absolute threshold.
Definition: lte-rrc-sap.h:269
Testing UE measurements in LTE with simulation of 2 eNodeB and 1 UE in piecewise configuration and 24...
Test suite for generating calls to UE measurements test case ns3::LteUeMeasurementsPiecewiseTestCase2...
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:667
bool reportOnLeave
Indicates whether or not the UE shall initiate the measurement reporting procedure when the leaving c...
Definition: lte-rrc-sap.h:280
keep track of a set of node pointers.
LteRrcSap::ReportConfigEutra m_config
The active report triggering configuration.
uint8_t m_expectedMeasId
The measurement identity being tested.
std::set< uint8_t > m_expectedTargetCellMeasId
The list of measurement identities being tested in the target cell.
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
LteUeMeasurementsPiecewiseTestCase1(std::string name, LteRrcSap::ReportConfigEutra config, std::vector< Time > expectedTime, std::vector< uint8_t > expectedRsrp)
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
uint8_t range
Value range used in RSRP/RSRQ threshold.
Definition: lte-rrc-sap.h:254
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:173
void SetPosition(const Vector &position)
Event A5: PCell becomes worse than absolute threshold1 AND Neighbour becomes better than another abso...
Definition: lte-rrc-sap.h:272
enum ns3::LteRrcSap::ReportConfigEutra::@72 triggerQuantity
The quantities used to evaluate the triggering condition for the event, see 3GPP TS 36...
int8_t a3Offset
Offset value for Event A3. An integer between -30 and 30. The actual value is (value * 0...
Definition: lte-rrc-sap.h:283
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
Fast test.
Definition: test.h:857
Helper class used to assign positions and mobility models to nodes.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
static uint8_t Dbm2RsrpRange(double dbm)
convert an RSRP value in dBm to the corresponding range as per 3GPP TS 36.133 section 9...
Definition: lte-common.cc:210
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Try and find the static routing protocol as either the main routing protocol or in the list of routin...
Event A3: Neighbour becomes amount of offset better than PCell.
Definition: lte-rrc-sap.h:270
LteUeMeasurementsTestCase(std::string name, double d1, double d2, double rsrpDbmUe1, double rsrpDbmUe2, double rsrqDbUe1, double rsrqDbUe2)
Helper class that adds ns3::Ipv4StaticRouting objects.
hold objects of type ns3::DataRate
enum ns3::LteRrcSap::ThresholdEutra::@68 choice
static void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::run method bef...
Definition: simulator.cc:165
Testing UE measurements in LTE with simulation of 1 eNodeB and 1 UE in piecewise configuration and 12...
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
Test suite for generating calls to UE measurements test case ns3::LteUeMeasurementsPiecewiseTestCase1...
#define NS_LOG_DEBUG(msg)
Definition: log.h:289
virtual void DoRun()
Setup the simulation with the intended UE measurement reporting configuration, run it...
enum ns3::LteRrcSap::ReportConfigEutra::@74 reportInterval
Indicates the interval between periodical reports.
std::vector< uint8_t >::iterator m_itExpectedRsrp
Pointer to the element of m_expectedRsrp which is expected to occur next in the simulation.
Event A4: Neighbour becomes better than absolute threshold.
Definition: lte-rrc-sap.h:271
std::vector< Time > m_expectedTime
The list of expected time when measurement reports are received by eNodeB.
std::string GetName(void) const
Definition: test.cc:242
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Reference Signal Received Power.
Definition: lte-rrc-sap.h:299
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void RecvMeasurementReport(uint64_t imsi, uint16_t cellId, uint16_t rnti, LteRrcSap::MeasurementReport meas)
Test suite for generating calls to UE measurements test case ns3::LteUeMeasurementsHandoverTestCase.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
static uint8_t Db2RsrqRange(double db)
convert an RSRQ value in dB to the corresponding range as per 3GPP TS 36.133 section 9...
Definition: lte-common.cc:226
Hold a floating point type.
Definition: double.h:41
uint16_t timeToTrigger
Time during which specific criteria for the event needs to be met in order to trigger a measurement r...
Definition: lte-rrc-sap.h:289
The eNodeB device implementation.
Ptr< T > GetObject(void) const
Definition: object.h:361
LteUeMeasurementsPiecewiseTestCase2(std::string name, LteRrcSap::ReportConfigEutra config, std::vector< Time > expectedTime, std::vector< uint8_t > expectedRsrp)
int64_t GetMilliSeconds(void) const
Definition: nstime.h:283
Qci
QoS Class Indicator.
Definition: eps-bearer.h:77
std::vector< uint8_t >::iterator m_itExpectedRsrp
Pointer to the element of m_expectedRsrp which is expected to occur next in the simulation.
The LtePhy models the physical layer of LTE.
Definition: lte-phy.h:52
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
virtual void DoTeardown()
Runs at the end of the simulation, verifying that all expected measurement reports have been examined...
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:137
static double RsrpRange2Dbm(uint8_t range)
converts an RSRP range to dBm as per 3GPP TS 36.133 section 9.1.4 RSRP Measurement Report Mapping ...
Definition: lte-common.cc:202
void ReportUeMeasurementsCallback(LteUeMeasurementsTestCase *testcase, std::string path, uint16_t rnti, uint16_t cellId, double rsrp, double rsrq, bool servingCell)
Event A1: Serving becomes better than absolute threshold.
Definition: lte-rrc-sap.h:268
ThresholdEutra threshold2
Threshold for event A5.
Definition: lte-rrc-sap.h:277
std::vector< Time > m_expectedTime
The list of expected time when measurement reports are received by eNodeB.
The LteUeNetDevice class implements the UE net device.
static LteUeMeasurementsPiecewiseTestSuite1 lteUeMeasurementsPiecewiseTestSuite1