A Discrete-Event Network Simulator
API
lte-test-aggregation-throughput-scale.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2017 Alexander Krotov
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Alexander Krotov <krotov@iitp.ru>
19  *
20  */
21 
23 
24 #include <algorithm>
25 #include <numeric>
26 
27 #include <ns3/application-container.h>
28 #include <ns3/friis-spectrum-propagation-loss.h>
29 #include <ns3/internet-stack-helper.h>
30 #include <ns3/ipv4-address-helper.h>
31 #include <ns3/ipv4-interface-container.h>
32 #include <ns3/ipv4-static-routing-helper.h>
33 #include <ns3/log.h>
34 #include <ns3/lte-enb-net-device.h>
35 #include <ns3/lte-helper.h>
36 #include <ns3/lte-ue-net-device.h>
37 #include <ns3/lte-ue-rrc.h>
38 #include <ns3/mobility-helper.h>
39 #include <ns3/net-device-container.h>
40 #include <ns3/node-container.h>
41 #include <ns3/packet-sink.h>
42 #include <ns3/point-to-point-epc-helper.h>
43 #include <ns3/point-to-point-helper.h>
44 #include <ns3/simulator.h>
45 #include <ns3/udp-client.h>
46 
47 using namespace ns3;
48 
49 NS_LOG_COMPONENT_DEFINE ("LteAggregationThroughputScaleTest");
50 
52  : TestSuite ("lte-aggregation-throughput-scale", SYSTEM)
53 {
54  AddTestCase (new LteAggregationThroughputScaleTestCase ("Carrier aggregation throughput scale"), TestCase::QUICK);
55 }
56 
58 
60  : TestCase (name)
61 {
62  NS_LOG_FUNCTION (this << GetName ());
63 }
64 
65 
67 {
68  NS_LOG_FUNCTION (this << GetName ());
69 }
70 
71 double
72 LteAggregationThroughputScaleTestCase::GetThroughput (uint8_t numberOfComponentCarriers)
73 {
74  NS_LOG_FUNCTION (this << GetName ());
75 
76  Config::SetDefault ("ns3::LteEnbNetDevice::DlEarfcn", UintegerValue (100));
77  Config::SetDefault ("ns3::LteEnbNetDevice::UlEarfcn", UintegerValue (100 + 18000));
78  Config::SetDefault ("ns3::LteEnbNetDevice::DlBandwidth", UintegerValue (25));
79  Config::SetDefault ("ns3::LteEnbNetDevice::UlBandwidth", UintegerValue (25));
80  Config::SetDefault ("ns3::LteUeNetDevice::DlEarfcn", UintegerValue (100));
81 
82  auto lteHelper = CreateObject<LteHelper> ();
83  lteHelper->SetAttribute ("PathlossModel", TypeIdValue (ns3::FriisSpectrumPropagationLossModel::GetTypeId ()));
84  lteHelper->SetAttribute ("NumberOfComponentCarriers", UintegerValue (numberOfComponentCarriers));
85  lteHelper->SetAttribute ("EnbComponentCarrierManager", StringValue ("ns3::RrComponentCarrierManager"));
86 
87  auto epcHelper = CreateObject<PointToPointEpcHelper> ();
88  lteHelper->SetEpcHelper (epcHelper);
89 
90  auto enbNode = CreateObject<Node> ();
91  auto ueNode = CreateObject<Node> ();
92  auto pgwNode = epcHelper->GetPgwNode ();
93 
95  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
96  mobility.Install (enbNode);
97  mobility.Install (ueNode);
98 
99  InternetStackHelper internet;
100  internet.Install (ueNode);
101 
102  Ipv4AddressHelper ipv4h;
103  ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
104 
105  Ipv4StaticRoutingHelper ipv4RoutingHelper;
106  auto ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
107  ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
108 
109  auto enbDev = DynamicCast<LteEnbNetDevice> (lteHelper->InstallEnbDevice (enbNode).Get (0));
110  auto ueDevs = lteHelper->InstallUeDevice (ueNode);
111  auto ueDev = DynamicCast<LteUeNetDevice> (ueDevs.Get (0));
112 
113  Ipv4InterfaceContainer ueIpIface = epcHelper->AssignUeIpv4Address (ueDevs);
114 
115  // Attach to last CC as primary
116  std::map< uint8_t, Ptr<ComponentCarrierUe> > ueCcMap = ueDev->GetCcMap ();
117  ueDev->SetDlEarfcn (ueCcMap.at (numberOfComponentCarriers - 1)->GetDlEarfcn ());
118  lteHelper->Attach (ueDevs);
119  m_expectedCellId = enbDev->GetCcMap ().at (numberOfComponentCarriers - 1)->GetCellId ();
120 
121  // Applications
122  const uint16_t port = 21;
123 
125 
126  auto sink = CreateObject<PacketSink> ();
127  sink->SetAttribute ("Protocol", StringValue ("ns3::UdpSocketFactory"));
128  sink->SetAttribute ("Local", AddressValue (InetSocketAddress (ueIpIface.GetAddress (0), port)));
129  ueNode->AddApplication (sink);
130  apps.Add (sink);
131 
132  auto client = CreateObject<UdpClient> ();
133  client->SetAttribute ("RemotePort", UintegerValue (port));
134  client->SetAttribute ("MaxPackets", UintegerValue (1000000));
135  client->SetAttribute ("Interval", TimeValue (Seconds (0.0001)));
136  client->SetAttribute ("PacketSize", UintegerValue (1000));
137  client->SetAttribute ("RemoteAddress", AddressValue (ueIpIface.GetAddress (0)));
138  pgwNode->AddApplication (client);
139 
140  apps.Add (client);
141  apps.Start (Seconds (1.0));
142 
143  Simulator::Stop (Seconds (2.0));
144  Simulator::Run ();
145 
146  m_actualCellId = ueDev->GetRrc ()->GetCellId ();
147 
148  Simulator::Destroy ();
149  return 8e-6 * sink->GetTotalRx ();
150 }
151 
152 void
154 {
155  std::vector<double> throughputs;
156  for (uint8_t i = 1; i <= 4; i++)
157  {
158  throughputs.push_back (GetThroughput (i) / i);
159  NS_TEST_ASSERT_MSG_EQ (m_expectedCellId, m_actualCellId, "UE has attached to an unexpected cell");
160  }
161  double average = std::accumulate(begin (throughputs), end (throughputs), 0.0) / throughputs.size ();
162  for (double throughput: throughputs)
163  {
164  NS_TEST_ASSERT_MSG_EQ_TOL (throughput, average, average * 0.01, "Throughput does not scale with number of component carriers");
165  }
166 }
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::InetSocketAddress
an Inet address class
Definition: inet-socket-address.h:41
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
LteAggregationThroughputScaleTestSuite::LteAggregationThroughputScaleTestSuite
LteAggregationThroughputScaleTestSuite()
Definition: lte-test-aggregation-throughput-scale.cc:51
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
LteAggregationThroughputScaleTestCase::~LteAggregationThroughputScaleTestCase
virtual ~LteAggregationThroughputScaleTestCase()
Definition: lte-test-aggregation-throughput-scale.cc:66
ns3::Ipv4AddressHelper
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Definition: ipv4-address-helper.h:48
ns3::AddressValue
AttributeValue implementation for Address.
Definition: address.h:278
ns3::TestCase::GetName
std::string GetName(void) const
Definition: test.cc:370
g_lteAggregationThroughputScaleTestSuite
static LteAggregationThroughputScaleTestSuite g_lteAggregationThroughputScaleTestSuite
Definition: lte-test-aggregation-throughput-scale.cc:57
ns3::ObjectBase::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
LteAggregationThroughputScaleTestCase::LteAggregationThroughputScaleTestCase
LteAggregationThroughputScaleTestCase(std::string name)
Creates an instance of the carrier aggregation throughput scaling test case.
Definition: lte-test-aggregation-throughput-scale.cc:59
ns3::TestCase
encapsulates test code
Definition: test.h:1154
ns3::ApplicationContainer::Add
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
Definition: application-container.cc:67
ns3::Ipv4AddressHelper::SetBase
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Definition: ipv4-address-helper.cc:64
ns3::Ipv4
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:77
ns3::Ipv4StaticRoutingHelper
Helper class that adds ns3::Ipv4StaticRouting objects.
Definition: ipv4-static-routing-helper.h:43
ns3::TypeIdValue
AttributeValue implementation for TypeId.
Definition: type-id.h:595
LteAggregationThroughputScaleTestCase
Testing that UE throughput scales linearly with number of component carriers.
Definition: lte-test-aggregation-throughput-scale.h:48
ns3::Ipv4StaticRoutingHelper::GetStaticRouting
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...
Definition: ipv4-static-routing-helper.cc:58
ns3::FriisSpectrumPropagationLossModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition: friis-spectrum-propagation-loss.cc:41
ns3::InternetStackHelper::Install
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Definition: internet-stack-helper.cc:366
NS_TEST_ASSERT_MSG_EQ_TOL
#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:378
ns3::PacketSink::GetTotalRx
uint64_t GetTotalRx() const
Definition: packet-sink.cc:93
LteAggregationThroughputScaleTestCase::GetThroughput
double GetThroughput(uint8_t numberOfComponentCarriers)
Get throughput function.
Definition: lte-test-aggregation-throughput-scale.cc:72
ns3::Ipv4InterfaceContainer
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Definition: ipv4-interface-container.h:55
sink
Ptr< PacketSink > sink
Definition: wifi-tcp.cc:56
ns3::StringValue
Hold variables of type string.
Definition: string.h:41
LteAggregationThroughputScaleTestCase::m_expectedCellId
uint16_t m_expectedCellId
Cell ID UE is expected to attach to.
Definition: lte-test-aggregation-throughput-scale.h:72
ns3::TestSuite
A suite of tests to run.
Definition: test.h:1344
NS_TEST_ASSERT_MSG_EQ
#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:166
ns3::ApplicationContainer::Start
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
Definition: application-container.cc:87
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
ns3::ApplicationContainer
holds a vector of ns3::Application pointers.
Definition: application-container.h:43
LteAggregationThroughputScaleTestCase::m_actualCellId
uint16_t m_actualCellId
Cell ID UE has attached to.
Definition: lte-test-aggregation-throughput-scale.h:73
ns3::TimeValue
AttributeValue implementation for Time.
Definition: nstime.h:1353
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition: log-macros-enabled.h:244
ns3::Ipv4InterfaceContainer::GetAddress
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Definition: ipv4-interface-container.cc:59
ns3::UintegerValue
Hold an unsigned integer type.
Definition: uinteger.h:44
ns3::Config::SetDefault
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:849
ns3::InternetStackHelper
aggregate IP/TCP/UDP functionality to existing Nodes.
Definition: internet-stack-helper.h:88
LteAggregationThroughputScaleTestSuite
Test suite for executing carrier aggregation throughput scaling test case.
Definition: lte-test-aggregation-throughput-scale.h:35
ns3::MobilityHelper
Helper class used to assign positions and mobility models to nodes.
Definition: mobility-helper.h:43
lte-test-aggregation-throughput-scale.h
LteAggregationThroughputScaleTestCase::DoRun
virtual void DoRun()
Setup the simulation, run it, and verify the result.
Definition: lte-test-aggregation-throughput-scale.cc:153
third.mobility
mobility
Definition: third.py:108
port
uint16_t port
Definition: dsdv-manet.cc:45