View | Details | Raw Unified | Return to bug 1660
Collapse All | Expand All

(-)a/src/lte/doc/source/lte-design.rst (-1 / +2 lines)
 Lines 2035-2040    Link Here 
2035
   for the handover case
2035
   for the handover case
2036
2036
2037
2037
2038
.. _sec-rrc-protocol-models:
2039
2038
RRC protocol models
2040
RRC protocol models
2039
+++++++++++++++++++
2041
+++++++++++++++++++
2040
2042
 Lines 2043-2049    Link Here 
2043
and *Real*. Each of them is described in one of the following
2045
and *Real*. Each of them is described in one of the following
2044
subsections.
2046
subsections.
2045
2047
2046
2047
Ideal RRC protocol model
2048
Ideal RRC protocol model
2048
------------------------
2049
------------------------
2049
2050
(-)a/src/lte/doc/source/lte-testing.rst (+47 lines)
 Lines 893-895    Link Here 
893
 - for each Data Radio Bearer, the following identifiers match between
893
 - for each Data Radio Bearer, the following identifiers match between
894
   the UE and the eNB: EPS bearer id, DRB id, LCID
894
   the UE and the eNB: EPS bearer id, DRB id, LCID
895
895
896
897
Handover delays
898
---------------
899
900
Handover procedure consists of several message exchanges between UE, source
901
eNodeB, and target eNodeB over both RRC protocol and X2 interface. Test suite
902
``lte-handover-delay`` verifies that this procedure consistently spends the
903
same amount of time.
904
905
The test suite will run several handover test cases. Eact test case is an
906
individual simulation featuring a handover at a specified time in simulation.
907
For example, the handover in the first test case is invoked at time +0.100s,
908
while in the second test case it is at +0.101s. There are 10 test cases, each
909
testing a different subframe in LTE. Thus the last test case has the handover
910
at +0.109s.
911
912
The simulation scenario in the test cases is as follow:
913
914
 - EPC is enabled
915
 - 2 eNodeBs with circular (isotropic) antenna, separated by 1000 meters
916
 - 1 static UE positioned exactly in the center between the eNodeBs
917
 - no application installed
918
 - no channel fading
919
 - default path loss model (Friis)
920
 - 0.300s simulation duration
921
922
The test case runs as follow. At the beginning of the simulation, the UE is
923
attached to the first eNodeB. Then at the time specified by the test case input
924
argument, a handover request will be explicitly issued to the second eNodeB.
925
The test case will then record the starting time, wait until the handover is
926
completed, and then record the completion time. If the difference between the
927
completion time and starting time is less than a predefined threshold, then the
928
test passes.
929
930
A typical handover in the current ns-3 implementation takes 4.2141 ms when using
931
Ideal RRC protocol model, and 19.9283 ms when using Real RRC protocol model.
932
Accordingly, the test cases use 5 ms and 20 ms as the maximum threshold values.
933
The test suite runs 10 test cases with Ideal RRC protocol model and 10 test
934
cases with Real RRC protocol model. More information regarding these models can
935
be found in Section :ref:`sec-rrc-protocol-models`.
936
937
The motivation behind using subframes as the main test parameters is the fact
938
that subframe index is one of the factors for calculating RA-RNTI, which is used
939
by Random Access during the handover procedure. The test cases verify this
940
computation, utilizing the fact that the handover will be delayed when this
941
computation is broken. In the default simulation configuration, the handover
942
delay observed because of a broken RA-RNTI computation is typically 6 ms.
(-)a/src/lte/model/lte-enb-mac.cc (-1 / +9 lines)
 Lines 1042-1048    Link Here 
1042
  Ptr<RarLteControlMessage> rarMsg = Create<RarLteControlMessage> ();
1042
  Ptr<RarLteControlMessage> rarMsg = Create<RarLteControlMessage> ();
1043
  // see TS 36.321 5.1.4;  preambles were sent two frames ago
1043
  // see TS 36.321 5.1.4;  preambles were sent two frames ago
1044
  // (plus 3GPP counts subframes from 0, not 1)
1044
  // (plus 3GPP counts subframes from 0, not 1)
1045
  uint16_t raRnti = m_subframeNo - 3;
1045
  uint16_t raRnti;
1046
  if (m_subframeNo < 3)
1047
    {
1048
      raRnti = m_subframeNo + 7; // equivalent to +10-3
1049
    }
1050
  else
1051
    {
1052
      raRnti = m_subframeNo - 3;
1053
    }
1046
  rarMsg->SetRaRnti (raRnti);
1054
  rarMsg->SetRaRnti (raRnti);
1047
  for (unsigned int i = 0; i < ind.m_buildRarList.size (); i++)
1055
  for (unsigned int i = 0; i < ind.m_buildRarList.size (); i++)
1048
    {
1056
    {
(-)da5e3a6c4029 (+296 lines)
Added Link Here 
1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2013 Magister Solutions
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: Budiarto Herman <budiarto.herman@magister.fi>
19
 */
20
21
#include <ns3/test.h>
22
23
#include <ns3/log.h>
24
#include <ns3/nstime.h>
25
#include <ns3/callback.h>
26
#include <ns3/config.h>
27
#include <ns3/boolean.h>
28
#include <ns3/simulator.h>
29
30
#include <ns3/node-container.h>
31
#include <ns3/net-device-container.h>
32
#include <ns3/ipv4-interface-container.h>
33
34
#include <ns3/lte-helper.h>
35
#include <ns3/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
#include <ns3/mobility-helper.h>
41
42
#include <ns3/data-rate.h>
43
#include <ns3/ipv4-static-routing.h>
44
#include <ns3/position-allocator.h>
45
46
47
NS_LOG_COMPONENT_DEFINE("LteHandoverDelayTest");
48
49
namespace ns3 {
50
51
52
/*
53
 * HANDOVER DELAY TEST CASE
54
 */
55
56
class LteHandoverDelayTestCase : public TestCase
57
{
58
public:
59
  LteHandoverDelayTestCase (bool useIdealRrc, Time handoverTime,
60
      Time delayThreshold, Time simulationDuration)
61
      : TestCase ("Verifying that the time needed for handover is under a specified threshold"),
62
        m_useIdealRrc (useIdealRrc),
63
        m_handoverTime (handoverTime),
64
        m_delayThreshold (delayThreshold),
65
        m_simulationDuration (simulationDuration),
66
        m_ueHandoverStart (Seconds (0)),
67
        m_enbHandoverStart (Seconds (0))
68
  {
69
  }
70
private:
71
  virtual void DoRun (void);
72
73
  void UeHandoverStartCallback (std::string context, uint64_t imsi,
74
      uint16_t cellid, uint16_t rnti, uint16_t targetCellId);
75
  void UeHandoverEndOkCallback (std::string context, uint64_t imsi,
76
      uint16_t cellid, uint16_t rnti);
77
  void EnbHandoverStartCallback (std::string context, uint64_t imsi,
78
      uint16_t cellid, uint16_t rnti, uint16_t targetCellId);
79
  void EnbHandoverEndOkCallback (std::string context, uint64_t imsi,
80
      uint16_t cellid, uint16_t rnti);
81
82
  bool m_useIdealRrc;
83
  Time m_handoverTime;
84
  Time m_delayThreshold;
85
  Time m_simulationDuration;
86
87
  Time m_ueHandoverStart;
88
  Time m_enbHandoverStart;
89
};
90
91
92
void
93
LteHandoverDelayTestCase::DoRun ()
94
{
95
  NS_LOG_INFO ("-----test case: ideal RRC = " << m_useIdealRrc
96
      << " handover time = " << m_handoverTime.GetSeconds () << "-----");
97
98
  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
99
  Ptr<EpcHelper> epcHelper = CreateObject<EpcHelper> ();
100
  lteHelper->SetEpcHelper (epcHelper);
101
  lteHelper->SetAttribute ("UseIdealRrc", BooleanValue(m_useIdealRrc));
102
103
  // SETUP A REMOTE HOST
104
105
  NodeContainer remoteHosts;
106
  remoteHosts.Create (1);
107
  InternetStackHelper inetStackHelper;
108
  inetStackHelper.Install (remoteHosts);
109
110
  // SETUP POINT-TO-POINT CONNECTION BETWEEN REMOTE HOST AND EPC
111
112
  PointToPointHelper p2pHelper;
113
  p2pHelper.SetDeviceAttribute ("DataRate",
114
      DataRateValue (DataRate ("100Gb/s")));
115
  p2pHelper.SetDeviceAttribute ("Mtu", UintegerValue (1500));
116
  p2pHelper.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
117
118
  NetDeviceContainer inetDevs = p2pHelper.Install (epcHelper->GetPgwNode (),
119
      remoteHosts.Get (0));
120
121
  Ipv4AddressHelper addrHelper;
122
  addrHelper.SetBase ("10.1.1.0", "255.255.255.0");
123
  Ipv4InterfaceContainer inetIfs;
124
  inetIfs = addrHelper.Assign (inetDevs);
125
126
  // SETUP ROUTING
127
128
  Ipv4StaticRoutingHelper ipRoutingHelper;
129
  Ptr<Ipv4StaticRouting> remoteHostRouting =
130
      ipRoutingHelper.GetStaticRouting (remoteHosts.Get (0)->GetObject<Ipv4> ());
131
  remoteHostRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"),
132
      Ipv4Mask ("255.0.0.0"), 1);
133
134
  // CREATE NODES
135
136
  NodeContainer enbNodes;
137
  NodeContainer ueNodes;
138
  enbNodes.Create (2);
139
  ueNodes.Create (1);
140
141
  /**
142
   * eNodeB 0                    UE                      eNodeB 1
143
   *
144
   *    x ----------------------- x ----------------------- x
145
   *              500 m                      500 m
146
   */
147
148
  // SETUP MOBILITY
149
150
  Ptr<ListPositionAllocator> posAlloc = CreateObject<ListPositionAllocator> ();
151
  posAlloc->Add (Vector (0, 0, 0));
152
  posAlloc->Add (Vector (1000, 0, 0));
153
  posAlloc->Add (Vector (500, 0, 0));
154
155
  MobilityHelper mobilityHelper;
156
  mobilityHelper.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
157
  mobilityHelper.SetPositionAllocator (posAlloc);
158
  mobilityHelper.Install (enbNodes);
159
  mobilityHelper.Install (ueNodes);
160
161
  // SETUP LTE DEVICES
162
163
  NetDeviceContainer enbDevs;
164
  NetDeviceContainer ueDevs;
165
  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
166
  ueDevs = lteHelper->InstallUeDevice (ueNodes);
167
168
  // SETUP INTERNET IN UE
169
170
  inetStackHelper.Install(ueNodes);
171
  Ipv4InterfaceContainer ueIfs;
172
  ueIfs = epcHelper->AssignUeIpv4Address (ueDevs);
173
174
  // SETUP DEFAULT GATEWAY FOR UE
175
176
  Ptr<Ipv4StaticRouting> ueStaticRouting =
177
      ipRoutingHelper.GetStaticRouting (ueNodes.Get (0)->GetObject<Ipv4> ());
178
  ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (),
179
      1);
180
181
  // INSTALLING TRACES
182
183
  Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/HandoverStart",
184
      MakeCallback (&LteHandoverDelayTestCase::UeHandoverStartCallback, this));
185
  Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/HandoverEndOk",
186
      MakeCallback (&LteHandoverDelayTestCase::UeHandoverEndOkCallback, this));
187
188
  Config::Connect ("/NodeList/*/DeviceList/*/LteEnbRrc/HandoverStart",
189
      MakeCallback (&LteHandoverDelayTestCase::EnbHandoverStartCallback, this));
190
  Config::Connect ("/NodeList/*/DeviceList/*/LteEnbRrc/HandoverEndOk",
191
      MakeCallback (&LteHandoverDelayTestCase::EnbHandoverEndOkCallback, this));
192
193
  // SIMULATION
194
195
  lteHelper->AddX2Interface (enbNodes);
196
  lteHelper->Attach (ueDevs.Get(0), enbDevs.Get(0));
197
  lteHelper->HandoverRequest (m_handoverTime, ueDevs.Get (0), enbDevs.Get (0),
198
      enbDevs.Get (1));
199
  // disable error model in dl ctrl channel
200
  //Config::Set ("/NodeList/*/DeviceList/*/LteUePhy/DlSpectrumPhy/CtrlErrorModelEnabled",
201
  //    BooleanValue (false));
202
  Simulator::Stop (m_simulationDuration);
203
  Simulator::Run ();
204
  Simulator::Destroy ();
205
206
} // end of void LteHandoverDelayTestCase::DoRun ()
207
208
209
void
210
LteHandoverDelayTestCase::UeHandoverStartCallback (std::string context,
211
    uint64_t imsi, uint16_t cellid, uint16_t rnti, uint16_t targetCellId)
212
{
213
  NS_LOG_FUNCTION (this << context);
214
  m_ueHandoverStart = Simulator::Now ();
215
}
216
217
void
218
LteHandoverDelayTestCase::UeHandoverEndOkCallback (std::string context,
219
    uint64_t imsi, uint16_t cellid, uint16_t rnti)
220
{
221
  NS_LOG_FUNCTION (this << context);
222
  NS_ASSERT (m_ueHandoverStart > Seconds (0));
223
  Time delay = Simulator::Now () - m_ueHandoverStart;
224
  NS_LOG_DEBUG (this << " UE delay = " << delay.GetSeconds ());
225
  NS_TEST_ASSERT_MSG_LT (delay.GetSeconds (), m_delayThreshold.GetSeconds (),
226
      "UE handover delay is higher than the allowed threshold "
227
      << "(ideal RRC = " << m_useIdealRrc
228
      << " handover time = " << m_handoverTime.GetSeconds () << ")");
229
}
230
231
232
void
233
LteHandoverDelayTestCase::EnbHandoverStartCallback (std::string context,
234
    uint64_t imsi, uint16_t cellid, uint16_t rnti, uint16_t targetCellId)
235
{
236
  NS_LOG_FUNCTION (this << context);
237
  m_enbHandoverStart = Simulator::Now ();
238
}
239
240
void
241
LteHandoverDelayTestCase::EnbHandoverEndOkCallback (std::string context,
242
    uint64_t imsi, uint16_t cellid, uint16_t rnti)
243
{
244
  NS_LOG_FUNCTION (this << context);
245
  NS_ASSERT (m_enbHandoverStart > Seconds (0));
246
  Time delay = Simulator::Now () - m_enbHandoverStart;
247
  NS_LOG_DEBUG (this << " eNodeB delay = " << delay.GetSeconds ());
248
  NS_TEST_ASSERT_MSG_LT (delay.GetSeconds (), m_delayThreshold.GetSeconds (),
249
      "eNodeB handover delay is higher than the allowed threshold "
250
      << "(ideal RRC = " << m_useIdealRrc
251
      << " handover time = " << m_handoverTime.GetSeconds () << ")");
252
}
253
254
255
256
/*
257
 * TEST SUITE
258
 */
259
260
static class LteHandoverDelayTestSuite : public TestSuite
261
{
262
public:
263
  LteHandoverDelayTestSuite ()
264
      : TestSuite ("lte-handover-delay", TestSuite::SYSTEM)
265
  {
266
    //LogComponentEnable ("LteHandoverDelayTest", LOG_PREFIX_TIME);
267
    //LogComponentEnable ("LteHandoverDelayTest", LOG_DEBUG);
268
    //LogComponentEnable ("LteHandoverDelayTest", LOG_INFO);
269
270
    // HANDOVER DELAY TEST CASES WITH IDEAL RRC (THRESHOLD = 0.005 sec)
271
272
    for (Time handoverTime = Seconds (0.100); handoverTime < Seconds (0.110);
273
        handoverTime += Seconds (0.001))
274
      {
275
        // arguments: useIdealRrc, handoverTime, delayThreshold, simulationDuration
276
        AddTestCase (
277
            new LteHandoverDelayTestCase (true, handoverTime, Seconds (0.005),
278
                Seconds (0.200)), TestCase::QUICK);
279
      }
280
281
    // HANDOVER DELAY TEST CASES WITH REAL RRC (THRESHOLD = 0.020 sec)
282
283
    for (Time handoverTime = Seconds (0.100); handoverTime < Seconds (0.110);
284
        handoverTime += Seconds (0.001))
285
      {
286
        // arguments: useIdealRrc, handoverTime, delayThreshold, simulationDuration
287
        AddTestCase (
288
            new LteHandoverDelayTestCase (false, handoverTime, Seconds (0.020),
289
                Seconds (0.200)), TestCase::QUICK);
290
      }
291
  }
292
} g_lteHandoverDelayTestSuite;
293
294
295
296
} // end of namespace ns3
(-)a/src/lte/wscript (+1 lines)
 Lines 140-145    Link Here 
140
        'test/test-lte-rrc.cc',
140
        'test/test-lte-rrc.cc',
141
        'test/test-lte-x2-handover.cc',
141
        'test/test-lte-x2-handover.cc',
142
        'test/test-asn1-encoding.cc',
142
        'test/test-asn1-encoding.cc',
143
        'test/test-lte-handover-delay.cc',
143
        ]
144
        ]
144
145
145
    headers = bld(features='ns3header')
146
    headers = bld(features='ns3header')

Return to bug 1660