A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-test-aggregation-throughput-scale.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Alexander Krotov
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Alexander Krotov <krotov@iitp.ru>
7 *
8 */
9
11
12#include <ns3/application-container.h>
13#include <ns3/friis-spectrum-propagation-loss.h>
14#include <ns3/internet-stack-helper.h>
15#include <ns3/ipv4-address-helper.h>
16#include <ns3/ipv4-interface-container.h>
17#include <ns3/ipv4-static-routing-helper.h>
18#include <ns3/log.h>
19#include <ns3/lte-enb-net-device.h>
20#include <ns3/lte-helper.h>
21#include <ns3/lte-ue-net-device.h>
22#include <ns3/lte-ue-rrc.h>
23#include <ns3/mobility-helper.h>
24#include <ns3/net-device-container.h>
25#include <ns3/node-container.h>
26#include <ns3/packet-sink.h>
27#include <ns3/point-to-point-epc-helper.h>
28#include <ns3/point-to-point-helper.h>
29#include <ns3/simulator.h>
30#include <ns3/udp-client.h>
31
32#include <algorithm>
33#include <numeric>
34
35using namespace ns3;
36
37NS_LOG_COMPONENT_DEFINE("LteAggregationThroughputScaleTest");
38
40 : TestSuite("lte-aggregation-throughput-scale", Type::SYSTEM)
41{
42 AddTestCase(new LteAggregationThroughputScaleTestCase("Carrier aggregation throughput scale"),
43 TestCase::Duration::QUICK);
44}
45
46/**
47 * @ingroup lte-test
48 * Static variable for test initialization
49 */
51
57
62
63double
65{
66 NS_LOG_FUNCTION(this << GetName());
67
68 Config::SetDefault("ns3::LteEnbNetDevice::DlEarfcn", UintegerValue(100));
69 Config::SetDefault("ns3::LteEnbNetDevice::UlEarfcn", UintegerValue(100 + 18000));
70 Config::SetDefault("ns3::LteEnbNetDevice::DlBandwidth", UintegerValue(25));
71 Config::SetDefault("ns3::LteEnbNetDevice::UlBandwidth", UintegerValue(25));
72 Config::SetDefault("ns3::LteUeNetDevice::DlEarfcn", UintegerValue(100));
73
74 auto lteHelper = CreateObject<LteHelper>();
75 lteHelper->SetAttribute("PathlossModel",
77 lteHelper->SetAttribute("NumberOfComponentCarriers", UintegerValue(numberOfComponentCarriers));
78 lteHelper->SetAttribute("EnbComponentCarrierManager",
79 StringValue("ns3::RrComponentCarrierManager"));
80
81 auto epcHelper = CreateObject<PointToPointEpcHelper>();
82 lteHelper->SetEpcHelper(epcHelper);
83
84 auto enbNode = CreateObject<Node>();
85 auto ueNode = CreateObject<Node>();
86 auto pgwNode = epcHelper->GetPgwNode();
87
88 MobilityHelper mobility;
89 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
90 mobility.Install(enbNode);
91 mobility.Install(ueNode);
92
93 InternetStackHelper internet;
94 internet.Install(ueNode);
95
97 ipv4h.SetBase("1.0.0.0", "255.0.0.0");
98
99 Ipv4StaticRoutingHelper ipv4RoutingHelper;
100 auto ueStaticRouting = ipv4RoutingHelper.GetStaticRouting(ueNode->GetObject<Ipv4>());
101 ueStaticRouting->SetDefaultRoute(epcHelper->GetUeDefaultGatewayAddress(), 1);
102
103 auto enbDev = DynamicCast<LteEnbNetDevice>(lteHelper->InstallEnbDevice(enbNode).Get(0));
104 auto ueDevs = lteHelper->InstallUeDevice(ueNode);
105 auto ueDev = DynamicCast<LteUeNetDevice>(ueDevs.Get(0));
106
107 Ipv4InterfaceContainer ueIpIface = epcHelper->AssignUeIpv4Address(ueDevs);
108
109 // Attach to last CC as primary
110 std::map<uint8_t, Ptr<ComponentCarrierUe>> ueCcMap = ueDev->GetCcMap();
111 ueDev->SetDlEarfcn(ueCcMap.at(numberOfComponentCarriers - 1)->GetDlEarfcn());
112 lteHelper->Attach(ueDevs);
113 m_expectedCellId = enbDev->GetCcMap().at(numberOfComponentCarriers - 1)->GetCellId();
114
115 // Applications
116 const uint16_t port = 21;
117
119
121 sink->SetAttribute("Protocol", StringValue("ns3::UdpSocketFactory"));
122 sink->SetAttribute("Local", AddressValue(InetSocketAddress(ueIpIface.GetAddress(0), port)));
123 ueNode->AddApplication(sink);
124 apps.Add(sink);
125
126 auto client = CreateObject<UdpClient>();
127 client->SetAttribute("RemotePort", UintegerValue(port));
128 client->SetAttribute("MaxPackets", UintegerValue(1000000));
129 client->SetAttribute("Interval", TimeValue(Seconds(0.0001)));
130 client->SetAttribute("PacketSize", UintegerValue(1000));
131 client->SetAttribute("RemoteAddress", AddressValue(ueIpIface.GetAddress(0)));
132 pgwNode->AddApplication(client);
133
134 apps.Add(client);
135 apps.Start(Seconds(1));
136
139
140 m_actualCellId = ueDev->GetRrc()->GetCellId();
141
143 return 8e-6 * sink->GetTotalRx();
144}
145
146void
148{
149 std::vector<double> throughputs;
150 for (uint8_t i = 1; i <= 4; i++)
151 {
152 throughputs.push_back(GetThroughput(i) / i);
155 "UE has attached to an unexpected cell");
156 }
157 double average =
158 std::accumulate(begin(throughputs), end(throughputs), 0.0) / throughputs.size();
159 for (double throughput : throughputs)
160 {
162 average,
163 average * 0.01,
164 "Throughput does not scale with number of component carriers");
165 }
166}
Testing that UE throughput scales linearly with number of component carriers.
void DoRun() override
Setup the simulation, run it, and verify the result.
double GetThroughput(uint8_t numberOfComponentCarriers)
Get throughput function.
uint16_t m_expectedCellId
Cell ID UE is expected to attach to.
LteAggregationThroughputScaleTestCase(std::string name)
Creates an instance of the carrier aggregation throughput scaling test case.
Test suite for executing carrier aggregation throughput scaling test case.
AttributeValue implementation for Address.
Definition address.h:275
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
an Inet address class
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.
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition ipv4.h:69
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
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...
Helper class used to assign positions and mobility models to nodes.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
Hold variables of type string.
Definition string.h:45
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
std::string GetName() const
Definition test.cc:367
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
AttributeValue implementation for Time.
Definition nstime.h:1431
AttributeValue implementation for TypeId.
Definition type-id.h:617
Hold an unsigned integer type.
Definition uinteger.h:34
uint16_t port
Definition dsdv-manet.cc:33
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:883
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
static LteAggregationThroughputScaleTestSuite g_lteAggregationThroughputScaleTestSuite
Static variable for test initialization.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#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:134
#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:327
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1344
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580
std::ofstream throughput
Ptr< PacketSink > sink
Pointer to the packet sink application.
Definition wifi-tcp.cc:44