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