10#include <ns3/boolean.h>
11#include <ns3/callback.h>
12#include <ns3/config.h>
13#include <ns3/data-rate.h>
14#include <ns3/double.h>
15#include <ns3/internet-stack-helper.h>
16#include <ns3/ipv4-address-helper.h>
17#include <ns3/ipv4-interface-container.h>
18#include <ns3/ipv4-static-routing-helper.h>
19#include <ns3/ipv4-static-routing.h>
21#include <ns3/lte-enb-net-device.h>
22#include <ns3/lte-enb-phy.h>
23#include <ns3/lte-helper.h>
24#include <ns3/mobility-helper.h>
25#include <ns3/net-device-container.h>
26#include <ns3/node-container.h>
27#include <ns3/nstime.h>
28#include <ns3/point-to-point-epc-helper.h>
29#include <ns3/point-to-point-helper.h>
30#include <ns3/position-allocator.h>
31#include <ns3/simulator.h>
33#include <ns3/uinteger.h>
77 uint16_t sourceCellId,
78 uint16_t targetCellId,
79 std::string handoverAlgorithmType);
98 uint16_t sourceCellId,
100 uint16_t targetCellId);
113 void DoRun()
override;
138 uint16_t sourceCellId,
139 uint16_t targetCellId,
140 std::string handoverAlgorithmType)
142 m_uePosition(uePosition),
143 m_gridSizeX(gridSizeX),
144 m_gridSizeY(gridSizeY),
145 m_sourceCellId(sourceCellId),
146 m_targetCellId(targetCellId),
147 m_handoverAlgorithmType(handoverAlgorithmType),
148 m_sourceEnbDev(nullptr),
149 m_hasHandoverOccurred(false)
155 uint16_t nEnb = gridSizeX * gridSizeY;
157 if (sourceCellId > nEnb)
162 if (targetCellId > nEnb)
176 uint16_t sourceCellId,
178 uint16_t targetCellId)
180 NS_LOG_FUNCTION(
this << context << imsi << sourceCellId << rnti << targetCellId);
186 "Handover occurred but with wrong source cell");
189 "Handover occurred but with wrong target cell");
219 lteHelper->SetEpcHelper(epcHelper);
220 lteHelper->SetAttribute(
"PathlossModel",
StringValue(
"ns3::FriisSpectrumPropagationLossModel"));
221 lteHelper->SetAttribute(
"UseIdealRrc",
BooleanValue(
true));
225 lteHelper->SetHandoverAlgorithmType(
"ns3::A2A4RsrqHandoverAlgorithm");
226 lteHelper->SetHandoverAlgorithmAttribute(
"ServingCellThreshold",
UintegerValue(30));
227 lteHelper->SetHandoverAlgorithmAttribute(
"NeighbourCellOffset",
UintegerValue(1));
231 lteHelper->SetHandoverAlgorithmType(
"ns3::A3RsrpHandoverAlgorithm");
232 lteHelper->SetHandoverAlgorithmAttribute(
"Hysteresis",
DoubleValue(1.5));
293 remoteHostContainer.
Create(1);
296 internet.Install(remoteHostContainer);
305 ipv4h.
SetBase(
"1.0.0.0",
"255.0.0.0");
312 remoteHostStaticRouting->AddNetworkRouteTo(
Ipv4Address(
"7.0.0.0"),
Ipv4Mask(
"255.0.0.0"), 1);
317 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
318 ueDevs = lteHelper->InstallUeDevice(ueNodes);
321 internet.Install(ueNodes);
332 ueStaticRouting->SetDefaultRoute(epcHelper->GetUeDefaultGatewayAddress(), 1);
336 lteHelper->AddX2Interface(enbNodes);
349 lteHelper->Attach(ueDevs.
Get(0), sourceEnb);
404 "ns3::A2A4RsrqHandoverAlgorithm"),
405 TestCase::Duration::QUICK);
412 "ns3::A3RsrpHandoverAlgorithm"),
413 TestCase::Duration::QUICK);
427 "ns3::A2A4RsrqHandoverAlgorithm"),
428 TestCase::Duration::EXTENSIVE);
435 "ns3::A3RsrpHandoverAlgorithm"),
436 TestCase::Duration::EXTENSIVE);
Testing a handover algorithm, verifying that it selects the right target cell when more than one opti...
Ptr< LteEnbNetDevice > m_sourceEnbDev
source ENB device
uint8_t m_gridSizeY
Y grid size.
std::string m_handoverAlgorithmType
handover algorithm type
bool m_hasHandoverOccurred
has handover occurred?
~LteHandoverTargetTestCase() override
LteHandoverTargetTestCase(std::string name, Vector uePosition, uint8_t gridSizeX, uint8_t gridSizeY, uint16_t sourceCellId, uint16_t targetCellId, std::string handoverAlgorithmType)
Construct a new test case and providing input parameters for the simulation.
void DoTeardown() override
Called at the end of simulation and verifies that a handover has occurred in the simulation.
void CellShutdownCallback()
A trigger that can be scheduled to "shutdown" the cell pointed by m_sourceCellId by reducing its powe...
uint16_t m_sourceCellId
source cell ID
void HandoverStartCallback(std::string context, uint64_t imsi, uint16_t sourceCellId, uint16_t rnti, uint16_t targetCellId)
Triggers when an eNodeB starts a handover and then verifies that the handover has the right source an...
Vector m_uePosition
UE positions.
uint8_t m_gridSizeX
X grid size.
uint16_t m_targetCellId
target cell ID
void DoRun() override
Run a simulation of a micro-cell network using the parameters provided to the constructor function.
Test suite lte-handover-target, verifying that handover algorithms are able to select the right targe...
LteHandoverTargetTestSuite()
Class for representing data rates.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
Access to the IPv4 forwarding table, interfaces, and configuration.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
a class to represent an Ipv4 address mask
Helper class that adds ns3::Ipv4StaticRouting objects.
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...
The eNodeB device implementation.
Helper class used to assign positions and mobility models to nodes.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
void SetMobilityModel(std::string type, Ts &&... args)
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Build a set of PointToPointNetDevice objects.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
NetDeviceContainer Install(NodeContainer c)
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
std::string GetName() const
int64_t GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Hold an unsigned integer type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
void SetDefault(std::string name, const AttributeValue &value)
void Connect(std::string path, const CallbackBase &cb)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
static LteHandoverTargetTestSuite g_lteHandoverTargetTestSuiteInstance
Static variable for test initialization.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#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.
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...