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