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