A Discrete-Event Network Simulator
API
epc-test-s1u-downlink.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
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: Nicola Baldo <nbaldo@cttc.es>
18 */
19
20#include "lte-test-entities.h"
21
22#include "ns3/boolean.h"
23#include "ns3/config.h"
24#include "ns3/csma-helper.h"
25#include "ns3/epc-enb-application.h"
26#include "ns3/eps-bearer.h"
27#include "ns3/inet-socket-address.h"
28#include "ns3/internet-stack-helper.h"
29#include "ns3/ipv4-address-helper.h"
30#include "ns3/log.h"
31#include "ns3/packet-sink-helper.h"
32#include "ns3/packet-sink.h"
33#include "ns3/point-to-point-epc-helper.h"
34#include "ns3/point-to-point-helper.h"
35#include "ns3/simulator.h"
36#include "ns3/test.h"
37#include "ns3/udp-echo-helper.h"
38#include "ns3/uinteger.h"
39#include <ns3/ipv4-static-routing-helper.h>
40#include <ns3/ipv4-static-routing.h>
41
42using namespace ns3;
43
44NS_LOG_COMPONENT_DEFINE("EpcTestS1uDownlink");
45
53{
61
64
67};
68
70 : numPkts(n),
71 pktSize(s)
72{
73}
74
83{
84 std::vector<UeDlTestData> ues;
85};
86
94{
95 public:
102 EpcS1uDlTestCase(std::string name, std::vector<EnbDlTestData> v);
103 ~EpcS1uDlTestCase() override;
104
105 private:
106 void DoRun() override;
107 std::vector<EnbDlTestData> m_enbDlTestData;
108};
109
110EpcS1uDlTestCase::EpcS1uDlTestCase(std::string name, std::vector<EnbDlTestData> v)
111 : TestCase(name),
112 m_enbDlTestData(v)
113{
114}
115
117{
118}
119
120void
122{
123 Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper>();
124 Ptr<Node> pgw = epcHelper->GetPgwNode();
125
126 // allow jumbo packets
127 Config::SetDefault("ns3::CsmaNetDevice::Mtu", UintegerValue(30000));
128 Config::SetDefault("ns3::PointToPointNetDevice::Mtu", UintegerValue(30000));
129 epcHelper->SetAttribute("S1uLinkMtu", UintegerValue(30000));
130
131 // Create a single RemoteHost
132 NodeContainer remoteHostContainer;
133 remoteHostContainer.Create(1);
134 Ptr<Node> remoteHost = remoteHostContainer.Get(0);
135 InternetStackHelper internet;
136 internet.Install(remoteHostContainer);
137
138 // Create the internet
140 p2ph.SetDeviceAttribute("DataRate", DataRateValue(DataRate("100Gb/s")));
141 NetDeviceContainer internetDevices = p2ph.Install(pgw, remoteHost);
142 Ipv4AddressHelper ipv4h;
143 ipv4h.SetBase("1.0.0.0", "255.0.0.0");
144 ipv4h.Assign(internetDevices);
145
146 // setup default gateway for the remote hosts
147 Ipv4StaticRoutingHelper ipv4RoutingHelper;
148 Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
149 ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
150
151 // hardcoded UE addresses for now
152 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address("7.0.0.0"),
153 Ipv4Mask("255.255.255.0"),
154 1);
155
156 NodeContainer enbs;
157 uint16_t cellIdCounter = 0;
158 uint64_t imsiCounter = 0;
159
160 for (std::vector<EnbDlTestData>::iterator enbit = m_enbDlTestData.begin();
161 enbit < m_enbDlTestData.end();
162 ++enbit)
163 {
164 Ptr<Node> enb = CreateObject<Node>();
165 enbs.Add(enb);
166
167 // we test EPC without LTE, hence we use:
168 // 1) a CSMA network to simulate the cell
169 // 2) a raw socket opened on the CSMA device to simulate the LTE socket
170
171 uint16_t cellId = ++cellIdCounter;
172
173 NodeContainer ues;
174 ues.Create(enbit->ues.size());
175
176 NodeContainer cell;
177 cell.Add(ues);
178 cell.Add(enb);
179
180 CsmaHelper csmaCell;
181 NetDeviceContainer cellDevices = csmaCell.Install(cell);
182
183 // the eNB's CSMA NetDevice acting as an LTE NetDevice.
184 Ptr<NetDevice> enbDevice = cellDevices.Get(cellDevices.GetN() - 1);
185
186 // Note that the EpcEnbApplication won't care of the actual NetDevice type
187 std::vector<uint16_t> cellIds;
188 cellIds.push_back(cellId);
189 epcHelper->AddEnb(enb, enbDevice, cellIds);
190
191 // Plug test RRC entity
193 NS_ASSERT_MSG(enbApp, "cannot retrieve EpcEnbApplication");
194 Ptr<EpcTestRrc> rrc = CreateObject<EpcTestRrc>();
195 enb->AggregateObject(rrc);
196 rrc->SetS1SapProvider(enbApp->GetS1SapProvider());
197 enbApp->SetS1SapUser(rrc->GetS1SapUser());
198
199 // we install the IP stack on UEs only
200 InternetStackHelper internet;
201 internet.Install(ues);
202
203 // assign IP address to UEs, and install applications
204 for (uint32_t u = 0; u < ues.GetN(); ++u)
205 {
206 Ptr<NetDevice> ueLteDevice = cellDevices.Get(u);
207 Ipv4InterfaceContainer ueIpIface =
208 epcHelper->AssignUeIpv4Address(NetDeviceContainer(ueLteDevice));
209
210 Ptr<Node> ue = ues.Get(u);
211
212 // disable IP Forwarding on the UE. This is because we use
213 // CSMA broadcast MAC addresses for this test. The problem
214 // won't happen with a LteUeNetDevice.
215 ue->GetObject<Ipv4>()->SetAttribute("IpForward", BooleanValue(false));
216
217 uint16_t port = 1234;
218 PacketSinkHelper packetSinkHelper("ns3::UdpSocketFactory",
219 InetSocketAddress(Ipv4Address::GetAny(), port));
220 ApplicationContainer apps = packetSinkHelper.Install(ue);
221 apps.Start(Seconds(1.0));
222 apps.Stop(Seconds(10.0));
223 enbit->ues[u].serverApp = apps.Get(0)->GetObject<PacketSink>();
224
225 Time interPacketInterval = Seconds(0.01);
226 UdpEchoClientHelper client(ueIpIface.GetAddress(0), port);
227 client.SetAttribute("MaxPackets", UintegerValue(enbit->ues[u].numPkts));
228 client.SetAttribute("Interval", TimeValue(interPacketInterval));
229 client.SetAttribute("PacketSize", UintegerValue(enbit->ues[u].pktSize));
230 apps = client.Install(remoteHost);
231 apps.Start(Seconds(2.0));
232 apps.Stop(Seconds(10.0));
233 enbit->ues[u].clientApp = apps.Get(0);
234
235 uint64_t imsi = ++imsiCounter;
236 epcHelper->AddUe(ueLteDevice, imsi);
237 epcHelper->ActivateEpsBearer(ueLteDevice,
238 imsi,
239 EpcTft::Default(),
240 EpsBearer(EpsBearer::NGBR_VIDEO_TCP_DEFAULT));
241 Simulator::Schedule(MilliSeconds(10),
242 &EpcEnbS1SapProvider::InitialUeMessage,
243 enbApp->GetS1SapProvider(),
244 imsi,
245 (uint16_t)imsi);
246 }
247 }
248
249 Simulator::Run();
250
251 for (std::vector<EnbDlTestData>::iterator enbit = m_enbDlTestData.begin();
252 enbit < m_enbDlTestData.end();
253 ++enbit)
254 {
255 for (std::vector<UeDlTestData>::iterator ueit = enbit->ues.begin(); ueit < enbit->ues.end();
256 ++ueit)
257 {
258 NS_TEST_ASSERT_MSG_EQ(ueit->serverApp->GetTotalRx(),
259 (ueit->numPkts) * (ueit->pktSize),
260 "wrong total received bytes");
261 }
262 }
263
264 Simulator::Destroy();
265}
266
271{
272 public:
274
276
278 : TestSuite("epc-s1u-downlink", SYSTEM)
279{
280 std::vector<EnbDlTestData> v1;
281 EnbDlTestData e1;
282 UeDlTestData f1(1, 100);
283 e1.ues.push_back(f1);
284 v1.push_back(e1);
285 AddTestCase(new EpcS1uDlTestCase("1 eNB, 1UE", v1), TestCase::QUICK);
286
287 std::vector<EnbDlTestData> v2;
288 EnbDlTestData e2;
289 UeDlTestData f2_1(1, 100);
290 e2.ues.push_back(f2_1);
291 UeDlTestData f2_2(2, 200);
292 e2.ues.push_back(f2_2);
293 v2.push_back(e2);
294 AddTestCase(new EpcS1uDlTestCase("1 eNB, 2UEs", v2), TestCase::QUICK);
295
296 std::vector<EnbDlTestData> v3;
297 v3.push_back(e1);
298 v3.push_back(e2);
299 AddTestCase(new EpcS1uDlTestCase("2 eNBs", v3), TestCase::QUICK);
300
301 EnbDlTestData e3;
302 UeDlTestData f3_1(3, 50);
303 e3.ues.push_back(f3_1);
304 UeDlTestData f3_2(5, 1472);
305 e3.ues.push_back(f3_2);
306 UeDlTestData f3_3(1, 1);
307 e3.ues.push_back(f3_2);
308 std::vector<EnbDlTestData> v4;
309 v4.push_back(e3);
310 v4.push_back(e1);
311 v4.push_back(e2);
312 AddTestCase(new EpcS1uDlTestCase("3 eNBs", v4), TestCase::QUICK);
313
314 std::vector<EnbDlTestData> v5;
315 EnbDlTestData e5;
316 UeDlTestData f5(10, 3000);
317 e5.ues.push_back(f5);
318 v5.push_back(e5);
319 AddTestCase(new EpcS1uDlTestCase("1 eNB, 10 pkts 3000 bytes each", v5), TestCase::QUICK);
320
321 std::vector<EnbDlTestData> v6;
322 EnbDlTestData e6;
323 UeDlTestData f6(50, 3000);
324 e6.ues.push_back(f6);
325 v6.push_back(e6);
326 AddTestCase(new EpcS1uDlTestCase("1 eNB, 50 pkts 3000 bytes each", v6), TestCase::QUICK);
327
328 std::vector<EnbDlTestData> v7;
329 EnbDlTestData e7;
330 UeDlTestData f7(10, 15000);
331 e7.ues.push_back(f7);
332 v7.push_back(e7);
333 AddTestCase(new EpcS1uDlTestCase("1 eNB, 10 pkts 15000 bytes each", v7), TestCase::QUICK);
334
335 std::vector<EnbDlTestData> v8;
336 EnbDlTestData e8;
337 UeDlTestData f8(100, 15000);
338 e8.ues.push_back(f8);
339 v8.push_back(e8);
340 AddTestCase(new EpcS1uDlTestCase("1 eNB, 100 pkts 15000 bytes each", v8), TestCase::QUICK);
341}
EpcS1uDlTestCase class.
std::vector< EnbDlTestData > m_enbDlTestData
ENB DL test data.
EpcS1uDlTestCase(std::string name, std::vector< EnbDlTestData > v)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
Test that the S1-U interface implementation works correctly.
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.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
AttributeValue implementation for Boolean.
Definition: boolean.h:37
build a set of CsmaNetDevice objects
Definition: csma-helper.h:48
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttri...
Definition: csma-helper.cc:226
AttributeValue implementation for DataRate.
This application is installed inside eNBs and provides the bridge functionality for user data plane p...
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
an Inet address class
aggregate IP/TCP/UDP functionality to existing Nodes.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
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.
Definition: ipv4-address.h:43
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:79
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
Definition: ipv4-address.h:258
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...
holds a vector of ns3::NetDevice pointers
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in this container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
void AddUe(Ptr< NetDevice > ueLteDevice, uint64_t imsi) override
Notify the EPC of the existence of a new UE which might attach at a later time.
uint8_t ActivateEpsBearer(Ptr< NetDevice > ueLteDevice, uint64_t imsi, Ptr< EpcTft > tft, EpsBearer bearer) override
Activate an EPS bearer, setting up the corresponding S1-U tunnel.
Ptr< Node > GetPgwNode() const override
Get the PGW node.
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.
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Ptr< Application > GetApplication(uint32_t index) const
Retrieve the index-th Application associated to this node.
Definition: node.cc:180
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:258
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:259
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.
Definition: packet-sink.h:74
void AddEnb(Ptr< Node > enbNode, Ptr< NetDevice > lteEnbNetDevice, std::vector< uint16_t > cellIds) override
Add an eNB to the EPC.
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.
NetDeviceContainer Install(NodeContainer c)
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:305
A suite of tests to run.
Definition: test.h:1256
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
AttributeValue implementation for Time.
Definition: nstime.h:1425
Create an application which sends a UDP packet and waits for an echo of this packet.
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
ApplicationContainer Install(Ptr< Node > node) const
Create a udp echo client application on the specified node.
Hold an unsigned integer type.
Definition: uinteger.h:45
uint16_t port
Definition: dsdv-manet.cc:45
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:891
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Definition: data-rate.h:328
#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:144
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1338
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1350
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Custom structure for testing eNodeB downlink data, contains the list of data structures for UEs.
std::vector< UeDlTestData > ues
list of data structure for different UEs
Custom structure for testing UE downlink data.
uint32_t pktSize
packet size
UeDlTestData(uint32_t n, uint32_t s)
Constructor.
uint32_t numPkts
number of packets
Ptr< Application > clientApp
Client application.
Ptr< PacketSink > serverApp
Server application.
uint32_t pktSize
packet size used for the simulation (in bytes)