A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-test-rlc-um-e2e.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Manuel Requena <manuel.requena@cttc.es>
7 */
8
10
11#include "lte-simple-helper.h"
12#include "lte-test-entities.h"
13
14#include "ns3/config.h"
15#include "ns3/error-model.h"
16#include "ns3/log.h"
17#include "ns3/lte-rlc-header.h"
18#include "ns3/lte-rlc-um.h"
19#include "ns3/net-device-container.h"
20#include "ns3/node-container.h"
21#include "ns3/packet.h"
22#include "ns3/pointer.h"
23#include "ns3/radio-bearer-stats-calculator.h"
24#include "ns3/rng-seed-manager.h"
25#include "ns3/simulator.h"
26
27using namespace ns3;
28
29NS_LOG_COMPONENT_DEFINE("LteRlcUmE2eTest");
30
31/**
32 * Test x.x.x RLC UM: End-to-end flow
33 */
34
35/**
36 * TestSuite
37 */
38
40 : TestSuite("lte-rlc-um-e2e", Type::SYSTEM)
41{
42 // NS_LOG_INFO ("Creating LteRlcUmE2eTestSuite");
43
44 double losses[] = {0.0, 0.10, 0.25, 0.50, 0.75, 0.90, 1.00};
45 uint32_t seeds[] = {1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 10101};
46
47 for (uint32_t l = 0; l < (sizeof(losses) / sizeof(double)); l++)
48 {
49 for (uint32_t s = 0; s < (sizeof(seeds) / sizeof(uint32_t)); s++)
50 {
51 std::ostringstream name;
52 name << " Losses = " << losses[l] << "%. Seed = " << seeds[s];
53 TestCase::Duration testDuration;
54 if (l == 1 && s == 0)
55 {
56 testDuration = TestCase::Duration::QUICK;
57 }
58 else
59 {
60 testDuration = TestCase::Duration::EXTENSIVE;
61 }
62 AddTestCase(new LteRlcUmE2eTestCase(name.str(), seeds[s], losses[l]), testDuration);
63 }
64 }
65}
66
67/**
68 * \ingroup lte-test
69 * Static variable for test initialization
70 */
72
73/**
74 * TestCase
75 */
76
77LteRlcUmE2eTestCase::LteRlcUmE2eTestCase(std::string name, uint32_t seed, double losses)
78 : TestCase(name)
79{
80 // NS_LOG_UNCOND ("Creating LteRlcUmTestingTestCase: " + name);
81
82 m_seed = seed;
83 m_losses = losses;
84
85 m_dlDrops = 0;
86 m_ulDrops = 0;
87}
88
92
93void
95{
96 // NS_LOG_FUNCTION (this);
97 m_dlDrops++;
98}
99
100void
102{
103 // NS_LOG_FUNCTION (this);
104 m_ulDrops++;
105}
106
107void
109{
110 uint16_t numberOfNodes = 1;
111
112 // LogLevel level = (LogLevel) (LOG_LEVEL_ALL | LOG_PREFIX_TIME | LOG_PREFIX_NODE |
113 // LOG_PREFIX_FUNC); LogComponentEnable ("LteRlcUmE2eTest", level); LogComponentEnable
114 // ("ErrorModel", level); LogComponentEnable ("LteSimpleHelper", level); LogComponentEnable
115 // ("LteSimpleNetDevice", level); LogComponentEnable ("SimpleNetDevice", level);
116 // LogComponentEnable ("SimpleChannel", level);
117 // LogComponentEnable ("LteTestEntities", level);
118 // LogComponentEnable ("LtePdcp", level);
119 // LogComponentEnable ("LteRlc", level);
120 // LogComponentEnable ("LteRlcUm", level);
121 // LogComponentEnable ("LteRlcAm", level);
122
124
126 // lteSimpleHelper->EnableLogComponents ();
127 // lteSimpleHelper->EnableTraces ();
128
129 lteSimpleHelper->SetAttribute("RlcEntity", StringValue("RlcUm"));
130
131 // eNB and UE nodes
132 NodeContainer ueNodes;
133 NodeContainer enbNodes;
134 enbNodes.Create(numberOfNodes);
135 ueNodes.Create(numberOfNodes);
136
137 // Install LTE Devices to the nodes
138 NetDeviceContainer enbLteDevs = lteSimpleHelper->InstallEnbDevice(enbNodes);
139 NetDeviceContainer ueLteDevs = lteSimpleHelper->InstallUeDevice(ueNodes);
140
141 // Note: Just one eNB and UE are supported. Everything is done in InstallEnbDevice and
142 // InstallUeDevice
143
144 // Attach one UE per eNodeB
145 // for (uint16_t i = 0; i < numberOfNodes; i++)
146 // {
147 // lteSimpleHelper->Attach (ueLteDevs.Get(i), enbLteDevs.Get(i));
148 // }
149
150 // lteSimpleHelper->ActivateEpsBearer (ueLteDevs, EpsBearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT),
151 // EpcTft::Default ());
152
153 // Error models: downlink and uplink
155 dlEm->SetAttribute("ErrorRate", DoubleValue(m_losses));
156 dlEm->SetAttribute("ErrorUnit", StringValue("ERROR_UNIT_PACKET"));
157
159 ulEm->SetAttribute("ErrorRate", DoubleValue(m_losses));
160 ulEm->SetAttribute("ErrorUnit", StringValue("ERROR_UNIT_PACKET"));
161
162 // The below hooks will cause drops to be counted at simple phy layer
163 ueLteDevs.Get(0)->SetAttribute("ReceiveErrorModel", PointerValue(dlEm));
164 ueLteDevs.Get(0)->TraceConnectWithoutContext(
165 "PhyRxDrop",
167 enbLteDevs.Get(0)->SetAttribute("ReceiveErrorModel", PointerValue(ulEm));
168 enbLteDevs.Get(0)->TraceConnectWithoutContext(
169 "PhyRxDrop",
171
172 // Sending packets from eNB RRC layer (eNB -> UE)
173 lteSimpleHelper->m_enbRrc->SetArrivalTime(Seconds(0.010));
174 lteSimpleHelper->m_enbRrc->SetPduSize(100);
175
176 // MAC sends transmission opportunities (TxOpp)
177 lteSimpleHelper->m_enbMac->SetTxOppSize(150);
178 lteSimpleHelper->m_enbMac->SetTxOppTime(Seconds(0.005));
179 lteSimpleHelper->m_enbMac->SetTxOpportunityMode(LteTestMac::RANDOM_MODE);
180
181 // Sending packets from UE RRC layer (UE -> eNB)
182 lteSimpleHelper->m_ueRrc->SetArrivalTime(Seconds(0.010));
183 lteSimpleHelper->m_ueRrc->SetPduSize(100);
184
185 // MAC sends transmission opportunities (TxOpp)
186 lteSimpleHelper->m_ueMac->SetTxOppSize(150);
187 lteSimpleHelper->m_ueMac->SetTxOppTime(Seconds(0.005));
188 lteSimpleHelper->m_ueMac->SetTxOpportunityMode(LteTestMac::RANDOM_MODE);
189
190 // Start/Stop pseudo-application at eNB RRC
191 Simulator::Schedule(Seconds(0.100), &LteTestRrc::Start, lteSimpleHelper->m_enbRrc);
192 Simulator::Schedule(Seconds(10.100), &LteTestRrc::Stop, lteSimpleHelper->m_enbRrc);
193
194 // Start/Stop pseudo-application at UE RRC
195 Simulator::Schedule(Seconds(20.100), &LteTestRrc::Start, lteSimpleHelper->m_ueRrc);
196 Simulator::Schedule(Seconds(30.100), &LteTestRrc::Stop, lteSimpleHelper->m_ueRrc);
197
198 Simulator::Stop(Seconds(31.000));
200
201 uint32_t txEnbRrcPdus = lteSimpleHelper->m_enbRrc->GetTxPdus();
202 uint32_t rxUeRrcPdus = lteSimpleHelper->m_ueRrc->GetRxPdus();
203
204 uint32_t txUeRrcPdus = lteSimpleHelper->m_ueRrc->GetTxPdus();
205 uint32_t rxEnbRrcPdus = lteSimpleHelper->m_enbRrc->GetRxPdus();
206
207 // NS_LOG_INFO ("Seed = " << m_seed);
208 // NS_LOG_INFO ("Losses (%) = " << uint32_t (m_losses * 100));
209
210 // NS_LOG_INFO ("dl dev drops = " << m_dlDrops);
211 // NS_LOG_INFO ("ul dev drops = " << m_ulDrops);
212
213 // NS_LOG_INFO ("eNB tx RRC count = " << txEnbRrcPdus);
214 // NS_LOG_INFO ("eNB rx RRC count = " << rxEnbRrcPdus);
215 // NS_LOG_INFO ("UE tx RRC count = " << txUeRrcPdus);
216 // NS_LOG_INFO ("UE rx RRC count = " << rxUeRrcPdus);
217
218 NS_LOG_INFO(m_seed << "\t" << m_losses << "\t" << txEnbRrcPdus << "\t" << rxUeRrcPdus << "\t"
219 << m_dlDrops);
220 NS_LOG_INFO(m_seed << "\t" << m_losses << "\t" << txUeRrcPdus << "\t" << rxEnbRrcPdus << "\t"
221 << m_ulDrops);
222
223 NS_TEST_ASSERT_MSG_EQ(txEnbRrcPdus,
224 rxUeRrcPdus + m_dlDrops,
225 "Downlink: TX PDUs (" << txEnbRrcPdus << ") != RX PDUs (" << rxUeRrcPdus
226 << ") + DROPS (" << m_dlDrops << ")");
227 NS_TEST_ASSERT_MSG_EQ(txUeRrcPdus,
228 rxEnbRrcPdus + m_ulDrops,
229 "Uplink: TX PDUs (" << txUeRrcPdus << ") != RX PDUs (" << rxEnbRrcPdus
230 << ") + DROPS (" << m_ulDrops << ")");
231
233}
Test end-to-end flow when RLC UM is being used.
uint32_t m_dlDrops
number of Dl drops
double m_losses
error rate
void UlDropEvent(Ptr< const Packet > p)
UL drop event.
void DoRun() override
Implementation to actually run this TestCase.
void DlDropEvent(Ptr< const Packet > p)
DL drop event.
uint32_t m_seed
random number seed
uint32_t m_ulDrops
number of UL drops
Test suite for RlcUmE2eTestCase.
LteRlcUmE2eTestSuite()
Test x.x.x RLC UM: End-to-end flow.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
void Stop()
Stop function.
void Start()
Start function.
holds a vector of ns3::NetDevice pointers
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.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
static void SetSeed(uint32_t seed)
Set the seed.
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
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
Duration
How long the test takes to execute.
Definition test.h:1054
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
static LteRlcUmE2eTestSuite lteRlcUmE2eTestSuite
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
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition callback.h:684