A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-test-rlc-am-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 * Nicola Baldo <nbaldo@cttc.es>
8 */
9
10#include "lte-test-rlc-am-e2e.h"
11
12#include "lte-simple-helper.h"
13#include "lte-test-entities.h"
14
15#include "ns3/config.h"
16#include "ns3/error-model.h"
17#include "ns3/log.h"
18#include "ns3/lte-rlc-header.h"
19#include "ns3/lte-rlc-um.h"
20#include "ns3/net-device-container.h"
21#include "ns3/node-container.h"
22#include "ns3/packet.h"
23#include "ns3/pointer.h"
24#include "ns3/radio-bearer-stats-calculator.h"
25#include "ns3/rng-seed-manager.h"
26#include "ns3/simulator.h"
27
28using namespace ns3;
29
30NS_LOG_COMPONENT_DEFINE("LteRlcAmE2eTest");
31
33 : TestSuite("lte-rlc-am-e2e", Type::SYSTEM)
34{
35 // NS_LOG_INFO ("Creating LteRlcAmE2eTestSuite");
36
37 double losses[] = {0.0, 0.05, 0.10, 0.15, 0.25, 0.50, 0.75, 0.90, 0.95};
38 uint32_t runs[] = {
39 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 11110,
40 12221, 13332, 14443, 15554, 16665, 17776, 18887, 19998, 21109, 22220,
41 23331, 24442, 25553, 26664, 27775, 28886, 29997, 31108, 32219, 33330,
42 };
43
44 for (uint32_t l = 0; l < (sizeof(losses) / sizeof(double)); l++)
45 {
46 for (uint32_t s = 0; s < (sizeof(runs) / sizeof(uint32_t)); s++)
47 {
48 for (uint32_t sduArrivalType = 0; sduArrivalType <= 1; ++sduArrivalType)
49 {
50 std::ostringstream name;
51 name << " losses = " << losses[l] * 100 << "%; run = " << runs[s];
52
53 bool bulkSduArrival;
54 switch (sduArrivalType)
55 {
56 case 0:
57 bulkSduArrival = false;
58 name << "; continuous SDU arrival";
59 break;
60 case 1:
61 bulkSduArrival = true;
62 name << "; bulk SDU arrival";
63 break;
64 default:
65 NS_FATAL_ERROR("unsupported option");
66 break;
67 }
68
69 TestCase::Duration testDuration;
70 if (l == 1 && s == 0)
71 {
72 testDuration = TestCase::Duration::QUICK;
73 }
74 else if (s <= 4)
75 {
76 testDuration = TestCase::Duration::EXTENSIVE;
77 }
78 else
79 {
80 testDuration = TestCase::Duration::TAKES_FOREVER;
81 }
82 AddTestCase(new LteRlcAmE2eTestCase(name.str(), runs[s], losses[l], bulkSduArrival),
83 testDuration);
84 }
85 }
86 }
87}
88
89/**
90 * \ingroup lte-test
91 * Static variable for test initialization
92 */
94
96 uint32_t run,
97 double losses,
98 bool bulkSduArrival)
99 : TestCase(name),
100 m_run(run),
101 m_losses(losses),
102 m_bulkSduArrival(bulkSduArrival),
103 m_dlDrops(0),
104 m_ulDrops(0)
105{
106 NS_LOG_INFO("Creating LteRlcAmTestingTestCase: " + name);
107}
108
112
113void
115{
116 // NS_LOG_FUNCTION (this);
117 m_dlDrops++;
118}
119
120void
122{
123 // NS_LOG_FUNCTION (this);
124 m_ulDrops++;
125}
126
127void
129{
130 uint16_t numberOfNodes = 1;
131
132 // LogLevel level = (LogLevel) (LOG_LEVEL_ALL | LOG_PREFIX_TIME | LOG_PREFIX_NODE |
133 // LOG_PREFIX_FUNC); LogComponentEnable ("LteRlcAmE2eTest", level); LogComponentEnable
134 // ("ErrorModel", level); LogComponentEnable ("LteSimpleHelper", level); LogComponentEnable
135 // ("LteSimpleNetDevice", level); LogComponentEnable ("SimpleNetDevice", level);
136 // LogComponentEnable ("SimpleChannel", level);
137 // LogComponentEnable ("LteTestEntities", level);
138 // LogComponentEnable ("LtePdcp", level);
139 // LogComponentEnable ("LteRlc", level);
140 // LogComponentEnable ("LteRlcUm", level);
141 // LogComponentEnable ("LteRlcAm", level);
142
144 Config::SetDefault("ns3::LteRlcAm::PollRetransmitTimer", TimeValue(MilliSeconds(20)));
145 Config::SetDefault("ns3::LteRlcAm::ReorderingTimer", TimeValue(MilliSeconds(10)));
146 Config::SetDefault("ns3::LteRlcAm::StatusProhibitTimer", TimeValue(MilliSeconds(40)));
147 // This test was written for an unlimited transmit buffer (special value of 0)
148 Config::SetDefault("ns3::LteRlcAm::MaxTxBufferSize", UintegerValue(0));
149
151 // lteSimpleHelper->EnableLogComponents ();
152 // lteSimpleHelper->EnableTraces ();
153
154 lteSimpleHelper->SetAttribute("RlcEntity", StringValue("RlcAm"));
155
156 // eNB and UE nodes
157 NodeContainer ueNodes;
158 NodeContainer enbNodes;
159 enbNodes.Create(numberOfNodes);
160 ueNodes.Create(numberOfNodes);
161
162 // Install LTE Devices to the nodes
163 NetDeviceContainer enbLteDevs = lteSimpleHelper->InstallEnbDevice(enbNodes);
164 NetDeviceContainer ueLteDevs = lteSimpleHelper->InstallUeDevice(ueNodes);
165
166 // Note: Just one eNB and UE is supported. Everything is done in InstallEnbDevice and
167 // InstallUeDevice
168
169 // Attach one UE per eNodeB
170 // for (uint16_t i = 0; i < numberOfNodes; i++)
171 // {
172 // lteSimpleHelper->Attach (ueLteDevs.Get(i), enbLteDevs.Get(i));
173 // }
174
175 // lteSimpleHelper->ActivateEpsBearer (ueLteDevs, EpsBearer
176 // (EpsBearer::NGBR_VIDEO_TCP_DEFAULT), EpcTft::Default ());
177
178 // Error models: downlink and uplink
180 // fix the stream so that subsequent test cases get a number from the same stream
181 // if RngRun is different, the number shall then be different
182 dlEm->AssignStreams(3);
183 dlEm->SetAttribute("ErrorRate", DoubleValue(m_losses));
184 dlEm->SetAttribute("ErrorUnit", StringValue("ERROR_UNIT_PACKET"));
185
186 // Ptr<RateErrorModel> ueEm = CreateObjectWithAttributes<RateErrorModel> ("RanVar",
187 // StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1.0]")); ueEm->SetAttribute
188 // ("ErrorRate", DoubleValue (m_losses)); ueEm->SetAttribute ("ErrorUnit", StringValue
189 // ("ERROR_UNIT_PACKET"));
190
191 // The below hooks will cause drops and receptions to be counted
192 ueLteDevs.Get(0)->SetAttribute("ReceiveErrorModel", PointerValue(dlEm));
193 ueLteDevs.Get(0)->TraceConnectWithoutContext(
194 "PhyRxDrop",
196 // enbLteDevs.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (enbEm));
197 // enbLteDevs.Get (0)->TraceConnectWithoutContext ("PhyRxDrop", MakeCallback
198 // (&LteRlcAmE2eTestCase::EnbDropEvent, this));
199
200 uint32_t sduSizeBytes = 100;
201 uint32_t numSdu = 1000;
202 double sduStartTimeSeconds = 0.100;
203 double sduStopTimeSeconds;
204 double sduArrivalTimeSeconds;
205 uint32_t dlTxOppSizeBytes = 150;
206 double dlTxOpprTimeSeconds = 0.003;
207 uint32_t ulTxOppSizeBytes = 140;
208 double ulTxOpprTimeSeconds = 0.003;
209
211 {
212 sduStopTimeSeconds = sduStartTimeSeconds + 0.010;
213 }
214 else
215 {
216 sduStopTimeSeconds = sduStartTimeSeconds + 10;
217 }
218 sduArrivalTimeSeconds = (sduStopTimeSeconds - sduStartTimeSeconds) / numSdu;
219
220 // Sending packets from RRC layer
221 lteSimpleHelper->m_enbRrc->SetArrivalTime(Seconds(sduArrivalTimeSeconds));
222 lteSimpleHelper->m_enbRrc->SetPduSize(sduSizeBytes);
223
224 // MAC sends transmission opportunities (TxOpp)
225 lteSimpleHelper->m_enbMac->SetTxOppSize(dlTxOppSizeBytes);
226 lteSimpleHelper->m_enbMac->SetTxOppTime(Seconds(dlTxOpprTimeSeconds));
227 lteSimpleHelper->m_enbMac->SetTxOpportunityMode(LteTestMac::AUTOMATIC_MODE);
228
229 // MAC sends transmission opportunities (TxOpp)
230 lteSimpleHelper->m_ueMac->SetTxOppSize(ulTxOppSizeBytes);
231 lteSimpleHelper->m_ueMac->SetTxOppTime(Seconds(ulTxOpprTimeSeconds));
232 lteSimpleHelper->m_ueMac->SetTxOpportunityMode(LteTestMac::AUTOMATIC_MODE);
233
234 // Start/Stop pseudo-application at RRC layer
235 Simulator::Schedule(Seconds(sduStartTimeSeconds),
237 lteSimpleHelper->m_enbRrc);
238 Simulator::Schedule(Seconds(sduStopTimeSeconds), &LteTestRrc::Stop, lteSimpleHelper->m_enbRrc);
239
240 double maxDlThroughput = (dlTxOppSizeBytes / (dlTxOppSizeBytes + 4.0)) *
241 (dlTxOppSizeBytes / dlTxOpprTimeSeconds) * (1.0 - m_losses);
242 const double statusProhibitSeconds = 0.020;
243 double pollFrequency = (1.0 / dlTxOpprTimeSeconds) * (1 - m_losses);
244 double statusFrequency = std::min(pollFrequency, 1.0 / statusProhibitSeconds);
245 const uint32_t numNackSnPerStatusPdu = (ulTxOppSizeBytes * 8 - 14) / 10;
246 double maxRetxThroughput =
247 ((double)numNackSnPerStatusPdu * (double)dlTxOppSizeBytes) * statusFrequency;
248 double throughput = std::min(maxDlThroughput, maxRetxThroughput);
249 double totBytes =
250 ((sduSizeBytes) * (sduStopTimeSeconds - sduStartTimeSeconds) / sduArrivalTimeSeconds);
251
252 // note: the throughput estimation is valid only for the full buffer
253 // case. However, the test sends a finite number of SDUs. Hence, the
254 // estimated throughput will only be effective at the beginning of
255 // the test. Towards the end of the test, two issues are present:
256 // 1) no new data is transmitted, hence less feedback is sent,
257 // hence the transmission rate for the last PDUs to be
258 // retransmitted is much lower. This effect can be best noteed
259 // at very high loss rates, and can be adjusted by timers and
260 // params.
261 // 2) throughput is not meaningful, you need to evaluate the time
262 // it takes for all PDUs to be (re)transmitted successfully,
263 // i.e., how long it takes for the TX and reTX queues to deplete.
264
265 // Estimating correctly this effect would require a complex stateful
266 // model (e.g., a Markov chain model) so to avoid the hassle we just
267 // use a margin here which we empirically determine as something we
268 // think reasonable based on the PDU loss rate
269 Time margin;
270 if (m_losses < 0.07)
271 {
272 margin = Seconds(0.500);
273 }
274 else if (m_losses < 0.20)
275 {
276 margin = Seconds(1);
277 }
278 else if (m_losses < 0.50)
279 {
280 margin = Seconds(2);
281 }
282 else if (m_losses < 0.70)
283 {
284 margin = Seconds(10);
285 }
286 else if (m_losses < 0.91)
287 {
288 margin = Seconds(20);
289 }
290 else // 0.95
291 {
292 margin = Seconds(30);
293 }
294 Time stopTime =
295 Seconds(std::max(sduStartTimeSeconds + totBytes / throughput, sduStopTimeSeconds)) + margin;
296
297 NS_LOG_INFO("statusFrequency=" << statusFrequency << ", maxDlThroughput=" << maxDlThroughput
298 << ", maxRetxThroughput=" << maxRetxThroughput << ", totBytes="
299 << totBytes << ", stopTime=" << stopTime.As(Time::S));
300
303
304 uint32_t txEnbRrcPdus = lteSimpleHelper->m_enbRrc->GetTxPdus();
305 uint32_t rxUeRrcPdus = lteSimpleHelper->m_ueRrc->GetRxPdus();
306
307 uint32_t txEnbRlcPdus = lteSimpleHelper->m_enbMac->GetTxPdus();
308 uint32_t rxUeRlcPdus = lteSimpleHelper->m_ueMac->GetRxPdus();
309
310 NS_LOG_INFO("Run = " << m_run);
311 NS_LOG_INFO("Loss rate (%) = " << uint32_t(m_losses * 100));
312
313 NS_LOG_INFO("RLC PDUs TX: " << txEnbRlcPdus << " RX: " << rxUeRlcPdus
314 << " LOST: " << m_dlDrops << " ("
315 << (100.0 * (double)m_dlDrops) / txEnbRlcPdus << "%)");
316
317 NS_TEST_ASSERT_MSG_EQ(txEnbRlcPdus,
318 rxUeRlcPdus + m_dlDrops,
319 "lost RLC PDUs don't match TX + RX");
320
321 NS_LOG_INFO("eNB tx RRC count = " << txEnbRrcPdus);
322 NS_LOG_INFO("UE rx RRC count = " << rxUeRrcPdus);
323
324 NS_TEST_ASSERT_MSG_EQ(txEnbRrcPdus,
325 rxUeRrcPdus,
326 "TX PDUs (" << txEnbRrcPdus << ") != RX PDUs (" << rxUeRrcPdus << ")");
327
329}
Test cases used for the test suite lte-rlc-am-e2e.
void DlDropEvent(Ptr< const Packet > p)
DL drop event.
uint32_t m_ulDrops
number of UL drops
bool m_bulkSduArrival
bulk SDU arrival
void DoRun() override
Implementation to actually run this TestCase.
void UlDropEvent(Ptr< const Packet > p)
UL drop event.
uint32_t m_dlDrops
number of Dl drops
double m_losses
error rate
Test suite for RlcAmE2e test case.
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 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
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition time.cc:404
@ S
second
Definition nstime.h:105
Hold an unsigned integer type.
Definition uinteger.h:34
Time stopTime
void SetGlobal(std::string name, const AttributeValue &value)
Definition config.cc:929
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:883
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#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 LteRlcAmE2eTestSuite lteRlcAmE2eTestSuite
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
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.
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
std::ofstream throughput