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>
30 #include <ns3/node-container.h>
31 #include <ns3/net-device-container.h>
32 #include <ns3/ipv4-interface-container.h>
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>
42 #include <ns3/data-rate.h>
43 #include <ns3/ipv4-static-routing.h>
44 #include <ns3/position-allocator.h>
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))
71 virtual void DoRun (
void);
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);
84 Time m_delayThreshold;
85 Time m_simulationDuration;
87 Time m_ueHandoverStart;
88 Time m_enbHandoverStart;
95 NS_LOG_INFO (
"-----test case: ideal RRC = " << m_useIdealRrc
96 <<
" handover time = " << m_handoverTime.
GetSeconds () <<
"-----");
100 lteHelper->SetEpcHelper (epcHelper);
101 lteHelper->SetAttribute (
"UseIdealRrc",
BooleanValue(m_useIdealRrc));
108 inetStackHelper.
Install (remoteHosts);
119 remoteHosts.
Get (0));
122 addrHelper.
SetBase (
"10.1.1.0",
"255.255.255.0");
124 inetIfs = addrHelper.
Assign (inetDevs);
131 remoteHostRouting->AddNetworkRouteTo (
Ipv4Address (
"7.0.0.0"),
151 posAlloc->Add (
Vector (0, 0, 0));
152 posAlloc->Add (
Vector (1000, 0, 0));
153 posAlloc->Add (
Vector (500, 0, 0));
158 mobilityHelper.
Install (enbNodes);
159 mobilityHelper.
Install (ueNodes);
165 enbDevs = lteHelper->InstallEnbDevice (enbNodes);
166 ueDevs = lteHelper->InstallUeDevice (ueNodes);
170 inetStackHelper.
Install(ueNodes);
172 ueIfs = epcHelper->AssignUeIpv4Address (ueDevs);
178 ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (),
184 MakeCallback (&LteHandoverDelayTestCase::UeHandoverStartCallback,
this));
186 MakeCallback (&LteHandoverDelayTestCase::UeHandoverEndOkCallback,
this));
189 MakeCallback (&LteHandoverDelayTestCase::EnbHandoverStartCallback,
this));
191 MakeCallback (&LteHandoverDelayTestCase::EnbHandoverEndOkCallback,
this));
195 lteHelper->AddX2Interface (enbNodes);
196 lteHelper->Attach (ueDevs.
Get(0), enbDevs.
Get(0));
197 lteHelper->HandoverRequest (m_handoverTime, ueDevs.
Get (0), enbDevs.
Get (0),
210 LteHandoverDelayTestCase::UeHandoverStartCallback (std::string context,
211 uint64_t imsi, uint16_t cellid, uint16_t rnti, uint16_t targetCellId)
218 LteHandoverDelayTestCase::UeHandoverEndOkCallback (std::string context,
219 uint64_t imsi, uint16_t cellid, uint16_t rnti)
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 () <<
")");
233 LteHandoverDelayTestCase::EnbHandoverStartCallback (std::string context,
234 uint64_t imsi, uint16_t cellid, uint16_t rnti, uint16_t targetCellId)
241 LteHandoverDelayTestCase::EnbHandoverEndOkCallback (std::string context,
242 uint64_t imsi, uint16_t cellid, uint16_t rnti)
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 () <<
")");
273 handoverTime +=
Seconds (0.001))
278 Seconds (0.200)), TestCase::QUICK);
283 for (
Time handoverTime = Seconds (0.100); handoverTime <
Seconds (0.110);
284 handoverTime +=
Seconds (0.001))
289 Seconds (0.200)), TestCase::QUICK);
292 } g_lteHandoverDelayTestSuite;
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
NetDeviceContainer Install(NodeContainer c)
a class to represent an Ipv4 address mask
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
aggregate IP/TCP/UDP functionality to existing Nodes.
Build a set of PointToPointNetDevice objects.
void Connect(std::string path, const CallbackBase &cb)
void SetDeviceAttribute(std::string name, const AttributeValue &value)
TestSuite(std::string name, Type type=UNIT)
Constuct a new test suite.
Class for representing data rates.
double GetSeconds(void) const
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
hold objects of type ns3::Time
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
TestCase(std::string name)
static void Destroy(void)
Access to the Ipv4 forwarding table, interfaces, and configuration.
keep track of a set of node pointers.
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())
virtual void DoRun(void)
Implementation to actually run this test case.
void Install(std::string nodeName) const
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Helper class used to assign positions and mobility models to nodes.
Ipv4 addresses are stored in host order in this class.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Helper class that adds ns3::Ipv4StaticRouting objects.
hold objects of type ns3::DataRate
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
#define NS_LOG_DEBUG(msg)
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Ptr< T > GetObject(void) const
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.