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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Alexander Krotov <krotov@iitp.ru>
18 *
19 */
20
22
23#include <ns3/application-container.h>
24#include <ns3/friis-spectrum-propagation-loss.h>
25#include <ns3/internet-stack-helper.h>
26#include <ns3/ipv4-address-helper.h>
27#include <ns3/ipv4-interface-container.h>
28#include <ns3/ipv4-static-routing-helper.h>
29#include <ns3/log.h>
30#include <ns3/lte-enb-net-device.h>
31#include <ns3/lte-helper.h>
32#include <ns3/lte-ue-net-device.h>
33#include <ns3/lte-ue-rrc.h>
34#include <ns3/mobility-helper.h>
35#include <ns3/net-device-container.h>
36#include <ns3/node-container.h>
37#include <ns3/packet-sink.h>
38#include <ns3/point-to-point-epc-helper.h>
39#include <ns3/point-to-point-helper.h>
40#include <ns3/simulator.h>
41#include <ns3/udp-client.h>
42
43#include <algorithm>
44#include <numeric>
45
46using namespace ns3;
47
48NS_LOG_COMPONENT_DEFINE("LteAggregationThroughputScaleTest");
49
51 : TestSuite("lte-aggregation-throughput-scale", Type::SYSTEM)
52{
53 AddTestCase(new LteAggregationThroughputScaleTestCase("Carrier aggregation throughput scale"),
54 TestCase::Duration::QUICK);
55}
56
62
64 : TestCase(name)
65{
66 NS_LOG_FUNCTION(this << GetName());
67}
68
70{
71 NS_LOG_FUNCTION(this << GetName());
72}
73
74double
76{
77 NS_LOG_FUNCTION(this << GetName());
78
79 Config::SetDefault("ns3::LteEnbNetDevice::DlEarfcn", UintegerValue(100));
80 Config::SetDefault("ns3::LteEnbNetDevice::UlEarfcn", UintegerValue(100 + 18000));
81 Config::SetDefault("ns3::LteEnbNetDevice::DlBandwidth", UintegerValue(25));
82 Config::SetDefault("ns3::LteEnbNetDevice::UlBandwidth", UintegerValue(25));
83 Config::SetDefault("ns3::LteUeNetDevice::DlEarfcn", UintegerValue(100));
84
85 auto lteHelper = CreateObject<LteHelper>();
86 lteHelper->SetAttribute("PathlossModel",
88 lteHelper->SetAttribute("NumberOfComponentCarriers", UintegerValue(numberOfComponentCarriers));
89 lteHelper->SetAttribute("EnbComponentCarrierManager",
90 StringValue("ns3::RrComponentCarrierManager"));
91
92 auto epcHelper = CreateObject<PointToPointEpcHelper>();
93 lteHelper->SetEpcHelper(epcHelper);
94
95 auto enbNode = CreateObject<Node>();
96 auto ueNode = CreateObject<Node>();
97 auto pgwNode = epcHelper->GetPgwNode();
98
99 MobilityHelper mobility;
100 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
101 mobility.Install(enbNode);
102 mobility.Install(ueNode);
103
104 InternetStackHelper internet;
105 internet.Install(ueNode);
106
107 Ipv4AddressHelper ipv4h;
108 ipv4h.SetBase("1.0.0.0", "255.0.0.0");
109
110 Ipv4StaticRoutingHelper ipv4RoutingHelper;
111 auto ueStaticRouting = ipv4RoutingHelper.GetStaticRouting(ueNode->GetObject<Ipv4>());
112 ueStaticRouting->SetDefaultRoute(epcHelper->GetUeDefaultGatewayAddress(), 1);
113
114 auto enbDev = DynamicCast<LteEnbNetDevice>(lteHelper->InstallEnbDevice(enbNode).Get(0));
115 auto ueDevs = lteHelper->InstallUeDevice(ueNode);
116 auto ueDev = DynamicCast<LteUeNetDevice>(ueDevs.Get(0));
117
118 Ipv4InterfaceContainer ueIpIface = epcHelper->AssignUeIpv4Address(ueDevs);
119
120 // Attach to last CC as primary
121 std::map<uint8_t, Ptr<ComponentCarrierUe>> ueCcMap = ueDev->GetCcMap();
122 ueDev->SetDlEarfcn(ueCcMap.at(numberOfComponentCarriers - 1)->GetDlEarfcn());
123 lteHelper->Attach(ueDevs);
124 m_expectedCellId = enbDev->GetCcMap().at(numberOfComponentCarriers - 1)->GetCellId();
125
126 // Applications
127 const uint16_t port = 21;
128
130
131 auto sink = CreateObject<PacketSink>();
132 sink->SetAttribute("Protocol", StringValue("ns3::UdpSocketFactory"));
134 ueNode->AddApplication(sink);
135 apps.Add(sink);
136
137 auto client = CreateObject<UdpClient>();
138 client->SetAttribute("RemotePort", UintegerValue(port));
139 client->SetAttribute("MaxPackets", UintegerValue(1000000));
140 client->SetAttribute("Interval", TimeValue(Seconds(0.0001)));
141 client->SetAttribute("PacketSize", UintegerValue(1000));
142 client->SetAttribute("RemoteAddress", AddressValue(ueIpIface.GetAddress(0)));
143 pgwNode->AddApplication(client);
144
145 apps.Add(client);
146 apps.Start(Seconds(1.0));
147
150
151 m_actualCellId = ueDev->GetRrc()->GetCellId();
152
154 return 8e-6 * sink->GetTotalRx();
155}
156
157void
159{
160 std::vector<double> throughputs;
161 for (uint8_t i = 1; i <= 4; i++)
162 {
163 throughputs.push_back(GetThroughput(i) / i);
166 "UE has attached to an unexpected cell");
167 }
168 double average =
169 std::accumulate(begin(throughputs), end(throughputs), 0.0) / throughputs.size();
170 for (double throughput : throughputs)
171 {
173 average,
174 average * 0.01,
175 "Throughput does not scale with number of component carriers");
176 }
177}
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:286
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:80
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.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:211
uint64_t GetTotalRx() const
Definition: packet-sink.cc:96
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
Hold variables of type string.
Definition: string.h:56
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
std::string GetName() const
Definition: test.cc:373
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
AttributeValue implementation for Time.
Definition: nstime.h:1413
AttributeValue implementation for TypeId.
Definition: type-id.h:598
Hold an unsigned integer type.
Definition: uinteger.h:45
uint16_t port
Definition: dsdv-manet.cc:44
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:894
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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.
#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:145
#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:338
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ofstream throughput
Ptr< PacketSink > sink
Pointer to the packet sink application.
Definition: wifi-tcp.cc:55