A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 */
8
9#include "lte-test-entities.h"
10
11#include "ns3/boolean.h"
12#include "ns3/config.h"
13#include "ns3/csma-helper.h"
14#include "ns3/epc-enb-application.h"
15#include "ns3/eps-bearer.h"
16#include "ns3/inet-socket-address.h"
17#include "ns3/internet-stack-helper.h"
18#include "ns3/ipv4-address-helper.h"
19#include "ns3/log.h"
20#include "ns3/packet-sink-helper.h"
21#include "ns3/packet-sink.h"
22#include "ns3/point-to-point-epc-helper.h"
23#include "ns3/point-to-point-helper.h"
24#include "ns3/simulator.h"
25#include "ns3/test.h"
26#include "ns3/udp-echo-helper.h"
27#include "ns3/uinteger.h"
28#include <ns3/ipv4-static-routing-helper.h>
29#include <ns3/ipv4-static-routing.h>
30
31using namespace ns3;
32
33NS_LOG_COMPONENT_DEFINE("EpcTestS1uDownlink");
34
35/**
36 * \ingroup lte-test
37 *
38 * \brief Custom structure for testing UE downlink data
39 */
41{
42 /**
43 * Constructor
44 *
45 * \param n number of packets
46 * \param s packet size
47 */
49
50 uint32_t numPkts; ///< number of packets
51 uint32_t pktSize; ///< packet size
52
53 Ptr<PacketSink> serverApp; ///< Server application
54 Ptr<Application> clientApp; ///< Client application
55};
56
58 : numPkts(n),
59 pktSize(s)
60{
61}
62
63/**
64 * \ingroup lte-test
65 *
66 * \brief Custom structure for testing eNodeB downlink data, contains
67 * the list of data structures for UEs
68 */
70{
71 std::vector<UeDlTestData> ues; ///< list of data structure for different UEs
72};
73
74/**
75 * \ingroup lte-test
76 *
77 * \brief EpcS1uDlTestCase class
78 */
80{
81 public:
82 /**
83 * Constructor
84 *
85 * \param name the name of the test case instance
86 * \param v list of eNodeB downlink test data information
87 */
88 EpcS1uDlTestCase(std::string name, std::vector<EnbDlTestData> v);
89 ~EpcS1uDlTestCase() override;
90
91 private:
92 void DoRun() override;
93 std::vector<EnbDlTestData> m_enbDlTestData; ///< ENB DL test data
94};
95
96EpcS1uDlTestCase::EpcS1uDlTestCase(std::string name, std::vector<EnbDlTestData> v)
97 : TestCase(name),
98 m_enbDlTestData(v)
99{
100}
101
105
106void
108{
110 Ptr<Node> pgw = epcHelper->GetPgwNode();
111
112 // allow jumbo packets
113 Config::SetDefault("ns3::CsmaNetDevice::Mtu", UintegerValue(30000));
114 Config::SetDefault("ns3::PointToPointNetDevice::Mtu", UintegerValue(30000));
115 epcHelper->SetAttribute("S1uLinkMtu", UintegerValue(30000));
116
117 // Create a single RemoteHost
118 NodeContainer remoteHostContainer;
119 remoteHostContainer.Create(1);
120 Ptr<Node> remoteHost = remoteHostContainer.Get(0);
121 InternetStackHelper internet;
122 internet.Install(remoteHostContainer);
123
124 // Create the internet
126 p2ph.SetDeviceAttribute("DataRate", DataRateValue(DataRate("100Gb/s")));
127 NetDeviceContainer internetDevices = p2ph.Install(pgw, remoteHost);
128 Ipv4AddressHelper ipv4h;
129 ipv4h.SetBase("1.0.0.0", "255.0.0.0");
130 ipv4h.Assign(internetDevices);
131
132 // setup default gateway for the remote hosts
133 Ipv4StaticRoutingHelper ipv4RoutingHelper;
134 Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
135 ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
136
137 // hardcoded UE addresses for now
138 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address("7.0.0.0"),
139 Ipv4Mask("255.255.255.0"),
140 1);
141
142 NodeContainer enbs;
143 uint16_t cellIdCounter = 0;
144 uint64_t imsiCounter = 0;
145
146 for (auto enbit = m_enbDlTestData.begin(); enbit < m_enbDlTestData.end(); ++enbit)
147 {
149 enbs.Add(enb);
150
151 // we test EPC without LTE, hence we use:
152 // 1) a CSMA network to simulate the cell
153 // 2) a raw socket opened on the CSMA device to simulate the LTE socket
154
155 uint16_t cellId = ++cellIdCounter;
156
157 NodeContainer ues;
158 ues.Create(enbit->ues.size());
159
160 NodeContainer cell;
161 cell.Add(ues);
162 cell.Add(enb);
163
164 CsmaHelper csmaCell;
165 NetDeviceContainer cellDevices = csmaCell.Install(cell);
166
167 // the eNB's CSMA NetDevice acting as an LTE NetDevice.
168 Ptr<NetDevice> enbDevice = cellDevices.Get(cellDevices.GetN() - 1);
169
170 // Note that the EpcEnbApplication won't care of the actual NetDevice type
171 std::vector<uint16_t> cellIds;
172 cellIds.push_back(cellId);
173 epcHelper->AddEnb(enb, enbDevice, cellIds);
174
175 // Plug test RRC entity
176 Ptr<EpcEnbApplication> enbApp = enb->GetApplication(0)->GetObject<EpcEnbApplication>();
177 NS_ASSERT_MSG(enbApp, "cannot retrieve EpcEnbApplication");
179 enb->AggregateObject(rrc);
180 rrc->SetS1SapProvider(enbApp->GetS1SapProvider());
181 enbApp->SetS1SapUser(rrc->GetS1SapUser());
182
183 // we install the IP stack on UEs only
184 InternetStackHelper internet;
185 internet.Install(ues);
186
187 // assign IP address to UEs, and install applications
188 for (uint32_t u = 0; u < ues.GetN(); ++u)
189 {
190 Ptr<NetDevice> ueLteDevice = cellDevices.Get(u);
191 Ipv4InterfaceContainer ueIpIface =
192 epcHelper->AssignUeIpv4Address(NetDeviceContainer(ueLteDevice));
193
194 Ptr<Node> ue = ues.Get(u);
195
196 // disable IP Forwarding on the UE. This is because we use
197 // CSMA broadcast MAC addresses for this test. The problem
198 // won't happen with a LteUeNetDevice.
199 ue->GetObject<Ipv4>()->SetAttribute("IpForward", BooleanValue(false));
200
201 uint16_t port = 1234;
202 PacketSinkHelper packetSinkHelper("ns3::UdpSocketFactory",
204 ApplicationContainer apps = packetSinkHelper.Install(ue);
205 apps.Start(Seconds(1.0));
206 apps.Stop(Seconds(10.0));
207 enbit->ues[u].serverApp = apps.Get(0)->GetObject<PacketSink>();
208
209 Time interPacketInterval = Seconds(0.01);
210 UdpEchoClientHelper client(ueIpIface.GetAddress(0), port);
211 client.SetAttribute("MaxPackets", UintegerValue(enbit->ues[u].numPkts));
212 client.SetAttribute("Interval", TimeValue(interPacketInterval));
213 client.SetAttribute("PacketSize", UintegerValue(enbit->ues[u].pktSize));
214 apps = client.Install(remoteHost);
215 apps.Start(Seconds(2.0));
216 apps.Stop(Seconds(10.0));
217 enbit->ues[u].clientApp = apps.Get(0);
218
219 uint64_t imsi = ++imsiCounter;
220 epcHelper->AddUe(ueLteDevice, imsi);
221 epcHelper->ActivateEpsBearer(ueLteDevice,
222 imsi,
227 enbApp->GetS1SapProvider(),
228 imsi,
229 (uint16_t)imsi);
230 }
231 }
232
234
235 for (auto enbit = m_enbDlTestData.begin(); enbit < m_enbDlTestData.end(); ++enbit)
236 {
237 for (auto ueit = enbit->ues.begin(); ueit < enbit->ues.end(); ++ueit)
238 {
239 NS_TEST_ASSERT_MSG_EQ(ueit->serverApp->GetTotalRx(),
240 (ueit->numPkts) * (ueit->pktSize),
241 "wrong total received bytes");
242 }
243 }
244
246}
247
248/**
249 * Test that the S1-U interface implementation works correctly
250 */
257
259 : TestSuite("epc-s1u-downlink", Type::SYSTEM)
260{
261 std::vector<EnbDlTestData> v1;
262 EnbDlTestData e1;
263 UeDlTestData f1(1, 100);
264 e1.ues.push_back(f1);
265 v1.push_back(e1);
266 AddTestCase(new EpcS1uDlTestCase("1 eNB, 1UE", v1), TestCase::Duration::QUICK);
267
268 std::vector<EnbDlTestData> v2;
269 EnbDlTestData e2;
270 UeDlTestData f2_1(1, 100);
271 e2.ues.push_back(f2_1);
272 UeDlTestData f2_2(2, 200);
273 e2.ues.push_back(f2_2);
274 v2.push_back(e2);
275 AddTestCase(new EpcS1uDlTestCase("1 eNB, 2UEs", v2), TestCase::Duration::QUICK);
276
277 std::vector<EnbDlTestData> v3;
278 v3.push_back(e1);
279 v3.push_back(e2);
280 AddTestCase(new EpcS1uDlTestCase("2 eNBs", v3), TestCase::Duration::QUICK);
281
282 EnbDlTestData e3;
283 UeDlTestData f3_1(3, 50);
284 e3.ues.push_back(f3_1);
285 UeDlTestData f3_2(5, 1472);
286 e3.ues.push_back(f3_2);
287 UeDlTestData f3_3(1, 1);
288 e3.ues.push_back(f3_2);
289 std::vector<EnbDlTestData> v4;
290 v4.push_back(e3);
291 v4.push_back(e1);
292 v4.push_back(e2);
293 AddTestCase(new EpcS1uDlTestCase("3 eNBs", v4), TestCase::Duration::QUICK);
294
295 std::vector<EnbDlTestData> v5;
296 EnbDlTestData e5;
297 UeDlTestData f5(10, 3000);
298 e5.ues.push_back(f5);
299 v5.push_back(e5);
300 AddTestCase(new EpcS1uDlTestCase("1 eNB, 10 pkts 3000 bytes each", v5),
301 TestCase::Duration::QUICK);
302
303 std::vector<EnbDlTestData> v6;
304 EnbDlTestData e6;
305 UeDlTestData f6(50, 3000);
306 e6.ues.push_back(f6);
307 v6.push_back(e6);
308 AddTestCase(new EpcS1uDlTestCase("1 eNB, 50 pkts 3000 bytes each", v6),
309 TestCase::Duration::QUICK);
310
311 std::vector<EnbDlTestData> v7;
312 EnbDlTestData e7;
313 UeDlTestData f7(10, 15000);
314 e7.ues.push_back(f7);
315 v7.push_back(e7);
316 AddTestCase(new EpcS1uDlTestCase("1 eNB, 10 pkts 15000 bytes each", v7),
317 TestCase::Duration::QUICK);
318
319 std::vector<EnbDlTestData> v8;
320 EnbDlTestData e8;
321 UeDlTestData f8(100, 15000);
322 e8.ues.push_back(f8);
323 v8.push_back(e8);
324 AddTestCase(new EpcS1uDlTestCase("1 eNB, 100 pkts 15000 bytes each", v8),
325 TestCase::Duration::QUICK);
326}
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.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
build a set of CsmaNetDevice objects
Definition csma-helper.h:37
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttri...
Class for representing data rates.
Definition data-rate.h:78
This application is installed inside eNBs and provides the bridge functionality for user data plane p...
virtual void InitialUeMessage(uint64_t imsi, uint16_t rnti)=0
Initial UE message.
static Ptr< EpcTft > Default()
creates a TFT matching any traffic
Definition epc-tft.cc:218
This class contains the specification of EPS Bearers.
Definition eps-bearer.h:80
@ NGBR_VIDEO_TCP_DEFAULT
Non-GBR TCP-based Video (Buffered Streaming, e.g., www, e-mail...)
Definition eps-bearer.h:115
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.
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.
static Ipv4Address GetAny()
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
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...
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.
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.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Receive and consume traffic generated to an IP address and port.
Definition packet-sink.h:64
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)
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
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
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Create an application which sends a UDP packet and waits for an echo of this packet.
Hold an unsigned integer type.
Definition uinteger.h:34
uint16_t port
Definition dsdv-manet.cc:33
#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:75
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
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
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1320
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)