20 #include <ns3/core-module.h>
21 #include <ns3/internet-module.h>
22 #include <ns3/lte-module.h>
23 #include <ns3/mobility-module.h>
24 #include <ns3/network-module.h>
25 #include <ns3/packet-sink-helper.h>
26 #include <ns3/packet-sink.h>
27 #include <ns3/point-to-point-module.h>
28 #include <ns3/udp-client-server-helper.h>
68 uint32_t nDedicatedBearers,
69 std::list<HandoverEvent> handoverEventList,
70 std::string handoverEventListName,
71 std::string schedulerType,
86 static std::string BuildNameString(uint32_t nUes,
87 uint32_t nDedicatedBearers,
88 std::string handoverEventListName,
89 std::string schedulerType,
92 void DoRun()
override;
104 void TeleportUeToMiddle(
Ptr<Node> ueNode);
153 void SaveStatsAfterHandover(uint32_t ueIndex);
158 void CheckStatsAWhileAfterHandover(uint32_t ueIndex);
170 uint32_t nDedicatedBearers,
171 std::string handoverEventListName,
172 std::string schedulerType,
176 std::ostringstream oss;
177 oss <<
" nUes=" << nUes <<
" nDedicatedBearers=" << nDedicatedBearers <<
" " << schedulerType
178 <<
" admitHo=" << admitHo <<
" hoList: " << handoverEventListName;
181 oss <<
", ideal RRC";
191 uint32_t nDedicatedBearers,
192 std::list<HandoverEvent> handoverEventList,
193 std::string handoverEventListName,
194 std::string schedulerType,
199 handoverEventListName,
204 m_nDedicatedBearers(nDedicatedBearers),
205 m_handoverEventList(handoverEventList),
206 m_handoverEventListName(handoverEventListName),
208 m_schedulerType(schedulerType),
210 m_useIdealRrc(useIdealRrc),
213 m_udpClientInterval(
Seconds(0.01)),
214 m_udpClientPktSize(100)
229 uint32_t previousSeed = RngSeedManager::GetSeed();
230 uint64_t previousRun = RngSeedManager::GetRun();
233 RngSeedManager::SetSeed(1);
234 RngSeedManager::SetRun(3);
246 StringValue(
"ns3::FriisSpectrumPropagationLossModel"));
249 "ns3::NoOpHandoverAlgorithm");
259 m_epcHelper = CreateObject<PointToPointEpcHelper>();
264 positionAlloc->Add(Vector(-3000, 0, 0));
265 positionAlloc->Add(Vector(3000, 0, 0));
266 for (uint32_t i = 0; i <
m_nUes; i++)
268 positionAlloc->Add(Vector(-3000, 100, 0));
271 mobility.SetPositionAllocator(positionAlloc);
272 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
279 for (
auto it = enbDevices.
Begin(); it != enbDevices.
End(); ++it)
297 remoteHostContainer.
Create(1);
298 remoteHost = remoteHostContainer.
Get(0);
300 internet.Install(remoteHostContainer);
310 ipv4h.
SetBase(
"1.0.0.0",
"255.0.0.0");
313 remoteHostAddr = internetIpIfaces.
GetAddress(1);
318 remoteHostStaticRouting->AddNetworkRouteTo(
Ipv4Address(
"7.0.0.0"),
338 uint16_t dlPort = 10000;
339 uint16_t ulPort = 20000;
349 for (uint32_t u = 0; u < ueNodes.
GetN(); ++u)
373 "ns3::UdpSocketFactory",
384 "ns3::UdpSocketFactory",
409 EpsBearer bearer(EpsBearer::NGBR_VIDEO_TCP_DEFAULT);
412 double d = startTimeSeconds->
GetValue();
427 for (uint32_t u = 0; u < ueDevices.
GetN(); ++u)
442 const Time maxRrcConnectionEstablishmentDuration =
Seconds(0.080);
443 for (
auto it = ueDevices.
Begin(); it != ueDevices.
End(); ++it)
445 Simulator::Schedule(maxRrcConnectionEstablishmentDuration,
459 Simulator::Schedule(hoEventIt->startTime -
MilliSeconds(10),
462 ueNodes.
Get(hoEventIt->ueDeviceIndex));
464 Simulator::Schedule(hoEventIt->startTime,
467 ueDevices.
Get(hoEventIt->ueDeviceIndex),
468 enbDevices.
Get(hoEventIt->sourceEnbDeviceIndex));
471 ueDevices.
Get(hoEventIt->ueDeviceIndex),
472 enbDevices.
Get(hoEventIt->sourceEnbDeviceIndex),
473 enbDevices.
Get(hoEventIt->targetEnbDeviceIndex));
476 Simulator::Schedule(hoEventIt->startTime +
MilliSeconds(40),
479 ueNodes.
Get(hoEventIt->ueDeviceIndex),
480 enbNodes.
Get(
m_admitHo ? hoEventIt->targetEnbDeviceIndex
481 : hoEventIt->sourceEnbDeviceIndex));
484 Simulator::Schedule(hoEndTime,
487 ueDevices.
Get(hoEventIt->ueDeviceIndex),
488 enbDevices.
Get(
m_admitHo ? hoEventIt->targetEnbDeviceIndex
489 : hoEventIt->sourceEnbDeviceIndex));
490 Simulator::Schedule(hoEndTime,
493 hoEventIt->ueDeviceIndex);
496 Simulator::Schedule(checkStatsAfterHoTime,
499 hoEventIt->ueDeviceIndex);
500 if (
stopTime <= checkStatsAfterHoTime)
513 Simulator::Destroy();
518 RngSeedManager::SetSeed(previousSeed);
519 RngSeedManager::SetRun(previousRun);
531 uint16_t rnti = ueRrc->GetRnti();
537 NS_ASSERT_MSG(ueManagerState == UeManager::CONNECTED_NORMALLY,
"Wrong UeManager state!");
539 uint16_t ueCellId = ueRrc->GetCellId();
540 uint16_t enbCellId = enbLteDevice->
GetCellId();
541 uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth();
543 uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth();
545 uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn();
547 uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn();
549 uint64_t ueImsi = ueLteDevice->GetImsi();
550 uint64_t enbImsi = ueManager->GetImsi();
560 ueManager->GetAttribute(
"DataRadioBearerMap", enbDataRadioBearerMapValue);
563 "wrong num bearers at eNB");
566 ueRrc->GetAttribute(
"DataRadioBearerMap", ueDataRadioBearerMapValue);
569 "wrong num bearers at UE");
571 auto enbBearerIt = enbDataRadioBearerMapValue.
Begin();
572 auto ueBearerIt = ueDataRadioBearerMapValue.
Begin();
573 while (enbBearerIt != enbDataRadioBearerMapValue.
End() &&
574 ueBearerIt != ueDataRadioBearerMapValue.
End())
583 (uint32_t)ueDrbInfo->m_epsBearerIdentity,
584 "epsBearerIdentity differs");
586 (uint32_t)ueDrbInfo->m_drbIdentity,
587 "drbIdentity differs");
591 (uint32_t)ueDrbInfo->m_logicalChannelIdentity,
592 "logicalChannelIdentity differs");
599 NS_ASSERT_MSG(enbBearerIt == enbDataRadioBearerMapValue.
End(),
"too many bearers at eNB");
600 NS_ASSERT_MSG(ueBearerIt == ueDataRadioBearerMapValue.
End(),
"too many bearers at UE");
617 ueMobility->
SetPosition(pos + Vector(0.0, 100.0, 0.0));
627 it->dlOldTotalRx = it->dlSink->GetTotalRx();
628 it->ulOldTotalRx = it->ulSink->GetTotalRx();
640 uint32_t dlRx = it->dlSink->GetTotalRx() - it->dlOldTotalRx;
641 uint32_t ulRx = it->ulSink->GetTotalRx() - it->ulOldTotalRx;
642 uint32_t expectedBytes =
647 "too few RX bytes in DL, ue=" << ueIndex <<
", b=" << b);
650 "too few RX bytes in UL, ue=" << ueIndex <<
", b=" << b);
712 std::string handoverEventList0name(
"none");
713 std::list<HandoverEvent> handoverEventList0;
715 std::string handoverEventList1name(
"1 fwd");
716 const std::list<HandoverEvent> handoverEventList1{
720 std::string handoverEventList2name(
"1 fwd & bwd");
721 const std::list<HandoverEvent> handoverEventList2{
726 std::string handoverEventList3name(
"1 fwd & bwd & fwd");
727 const std::list<HandoverEvent> handoverEventList3{
733 std::string handoverEventList4name(
"1+2 fwd");
734 const std::list<HandoverEvent> handoverEventList4{
739 std::string handoverEventList5name(
"1+2 fwd & bwd");
740 const std::list<HandoverEvent> handoverEventList5{
758 std::vector<std::string> schedulers{
759 "ns3::RrFfMacScheduler",
760 "ns3::PfFfMacScheduler",
763 for (
auto schedIt = schedulers.begin(); schedIt != schedulers.end(); ++schedIt)
765 for (
auto useIdealRrc : {
true,
false})
771 handoverEventList0name,
775 TestCase::EXTENSIVE);
779 handoverEventList0name,
783 TestCase::EXTENSIVE);
787 handoverEventList0name,
791 TestCase::EXTENSIVE);
795 handoverEventList0name,
799 TestCase::EXTENSIVE);
803 handoverEventList1name,
807 TestCase::EXTENSIVE);
811 handoverEventList1name,
815 TestCase::EXTENSIVE);
819 handoverEventList1name,
823 TestCase::EXTENSIVE);
827 handoverEventList1name,
831 TestCase::EXTENSIVE);
835 handoverEventList1name,
839 TestCase::EXTENSIVE);
843 handoverEventList1name,
847 TestCase::EXTENSIVE);
851 handoverEventList1name,
855 TestCase::EXTENSIVE);
859 handoverEventList1name,
863 TestCase::EXTENSIVE);
867 handoverEventList1name,
871 TestCase::EXTENSIVE);
875 handoverEventList1name,
879 TestCase::EXTENSIVE);
883 handoverEventList1name,
887 TestCase::EXTENSIVE);
891 handoverEventList1name,
895 TestCase::EXTENSIVE);
899 handoverEventList2name,
903 TestCase::EXTENSIVE);
907 handoverEventList2name,
911 TestCase::EXTENSIVE);
915 handoverEventList2name,
919 TestCase::EXTENSIVE);
923 handoverEventList3name,
927 TestCase::EXTENSIVE);
931 handoverEventList3name,
935 TestCase::EXTENSIVE);
939 handoverEventList3name,
943 TestCase::EXTENSIVE);
947 handoverEventList3name,
951 TestCase::EXTENSIVE);
955 handoverEventList3name,
959 TestCase::EXTENSIVE);
963 handoverEventList3name,
971 handoverEventList4name,
975 TestCase::EXTENSIVE);
979 handoverEventList4name,
983 TestCase::EXTENSIVE);
987 handoverEventList4name,
991 TestCase::EXTENSIVE);
995 handoverEventList5name,
999 TestCase::EXTENSIVE);
1003 handoverEventList5name,
1007 TestCase::EXTENSIVE);
1011 handoverEventList5name,
1015 TestCase::EXTENSIVE);
1019 handoverEventList3name,
1023 TestCase::EXTENSIVE);
1027 handoverEventList3name,
1031 TestCase::EXTENSIVE);
1035 handoverEventList3name,
1039 TestCase::EXTENSIVE);
1043 handoverEventList4name,
1047 TestCase::EXTENSIVE);
1051 handoverEventList4name,
1055 TestCase::EXTENSIVE);
1059 handoverEventList4name,
1063 TestCase::EXTENSIVE);
1067 handoverEventList5name,
1071 TestCase::EXTENSIVE);
1075 handoverEventList5name,
1079 TestCase::EXTENSIVE);
1083 handoverEventList5name,
static std::string BuildNameString(uint32_t nUes, uint32_t nDedicatedBearers, std::string handoverEventListName, std::string schedulerType, bool admitHo, bool useIdealRrc)
Build name string.
void DoRun() override
Implementation to actually run this TestCase.
Ptr< PointToPointEpcHelper > m_epcHelper
EPC helper.
uint32_t m_nUes
number of UEs in the test
std::string m_handoverEventListName
handover event list name
std::string m_schedulerType
scheduler type
const uint32_t m_udpClientPktSize
UDP client packet size.
bool m_useIdealRrc
whether to use the ideal RRC
const Time m_statsDuration
stats duration
std::vector< UeData > m_ueDataVector
UE data vector.
void CheckConnected(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
Check connected function.
LteX2HandoverTestCase(uint32_t nUes, uint32_t nDedicatedBearers, std::list< HandoverEvent > handoverEventList, std::string handoverEventListName, std::string schedulerType, bool admitHo, bool useIdealRrc)
void TeleportUeNearTargetEnb(Ptr< Node > ueNode, Ptr< Node > enbNode)
Teleport UE near the target eNB of the handover.
bool m_admitHo
whether to admit the handover request
bool m_epc
whether to use EPC
void SaveStatsAfterHandover(uint32_t ueIndex)
Save stats after handover function.
const Time m_maxHoDuration
maximum HO duration
std::list< HandoverEvent > m_handoverEventList
handover event list
void CheckStatsAWhileAfterHandover(uint32_t ueIndex)
Check stats a while after handover function.
uint32_t m_nDedicatedBearers
number of UEs in the test
const Time m_udpClientInterval
UDP client interval.
void TeleportUeToMiddle(Ptr< Node > ueNode)
Teleport UE between both eNBs of the test.
Ptr< LteHelper > m_lteHelper
LTE helper.
LTE X2 Handover Test Suite.
holds a vector of ns3::Application pointers.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
This class contains the specification of EPS Bearers.
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.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
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...
store information on active data radio bearer instance
The eNodeB device implementation.
uint16_t GetDlBandwidth() const
uint32_t GetUlEarfcn() const
uint32_t GetDlEarfcn() const
Ptr< LteEnbRrc > GetRrc() const
uint16_t GetUlBandwidth() const
uint16_t GetCellId() const
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 ...
void HandoverRequest(Time hoTime, Ptr< NetDevice > ueDev, Ptr< NetDevice > sourceEnbDev, Ptr< NetDevice > targetEnbDev)
Manually trigger an X2-based handover.
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
void SetHandoverAlgorithmType(std::string type)
Set the type of handover algorithm to be used by eNodeB devices.
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
void AddX2Interface(NodeContainer enbNodes)
Create an X2 interface between all the eNBs in a given set.
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used.
uint8_t ActivateDedicatedEpsBearer(NetDeviceContainer ueDevices, EpsBearer bearer, Ptr< EpcTft > tft)
Activate a dedicated EPS bearer on a given set of UE devices.
The LteUeNetDevice class implements the UE net device.
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
Vector GetPosition() const
void SetPosition(const Vector &position)
holds a vector of ns3::NetDevice pointers
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in this container.
Iterator Begin() const
Get an iterator which refers to the first NetDevice in the container.
Iterator End() const
Get an iterator which indicates past-the-last NetDevice in the container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Ptr< Node > GetPgwNode() const override
Get the PGW node.
Ipv4Address GetUeDefaultGatewayAddress() override
Ipv4InterfaceContainer AssignUeIpv4Address(NetDeviceContainer ueDevices) override
Assign IPv4 addresses to UE devices.
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.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Container for a set of ns3::Object pointers.
std::size_t GetN() const
Get the number of Objects.
Iterator End() const
Get an iterator to the past-the-end Object.
Iterator Begin() const
Get an iterator to the first Object.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
Receive and consume traffic generated to an IP address and port.
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.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
ApplicationContainer Install(NodeContainer c)
State
The state of the UeManager at the eNB RRC.
Hold an unsigned integer type.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void Reset()
Reset the initial value of every attribute as well as the value of every global to what they were bef...
void SetDefault(std::string name, const AttributeValue &value)
#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 ",...
static LteX2HandoverTestSuite g_lteX2HandoverTestSuiteInstance
Static variable for test initialization.
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
#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_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal 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.
uint32_t ueDeviceIndex
UE device index.
uint32_t targetEnbDeviceIndex
target ENB device index
uint32_t sourceEnbDeviceIndex
source ENB device index
uint32_t dlOldTotalRx
DL old total receive.
uint32_t ulOldTotalRx
UL old total receive.
Ptr< PacketSink > dlSink
DL sink.
Ptr< PacketSink > ulSink
UL sink.
std::list< BearerData > bearerDataList
bearer ID list
Implement the data structure representing a TrafficFlowTemplate Packet Filter.
uint16_t localPortEnd
end of the port number range of the UE
uint16_t remotePortEnd
end of the port number range of the remote host
uint16_t remotePortStart
start of the port number range of the remote host
uint16_t localPortStart
start of the port number range of the UE