A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-test-rlc-um-transmitter.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: Manuel Requena <manuel.requena@cttc.es>
7 */
8
10
11#include "lte-test-entities.h"
12
13#include "ns3/log.h"
14#include "ns3/lte-rlc-header.h"
15#include "ns3/lte-rlc-um.h"
16#include "ns3/simulator.h"
17
18using namespace ns3;
19
20NS_LOG_COMPONENT_DEFINE("LteRlcUmTransmitterTest");
21
22/**
23 * TestSuite 4.1.1 RLC UM: Only transmitter
24 */
25
27 : TestSuite("lte-rlc-um-transmitter", Type::SYSTEM)
28{
29 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
30 // LogComponentEnable ("LteRlcUmTransmitterTest", logLevel);
31
32 // NS_LOG_INFO ("Creating LteRlcUmTransmitterTestSuite");
33
34 AddTestCase(new LteRlcUmTransmitterOneSduTestCase("One SDU, one PDU"),
35 TestCase::Duration::QUICK);
37 TestCase::Duration::QUICK);
39 TestCase::Duration::QUICK);
40 AddTestCase(new LteRlcUmTransmitterReportBufferStatusTestCase("ReportBufferStatus primitive"),
41 TestCase::Duration::QUICK);
42}
43
44/**
45 * @ingroup lte-test
46 * Static variable for test initialization
47 */
49
51 : TestCase(name)
52{
53 // NS_LOG_UNCOND ("Creating LteRlcUmTransmitterTestCase: " + name);
54}
55
59
60void
62{
63 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
64 // LogComponentEnable ("LteRlcUmTransmitterTest", logLevel);
65 // LogComponentEnable ("LteTestEntities", logLevel);
66 // LogComponentEnable ("LteRlc", logLevel);
67 // LogComponentEnable ("LteRlcUm", logLevel);
68 // LogComponentEnable ("LteRlcHeader", logLevel);
69
70 uint16_t rnti = 1111;
71 uint8_t lcid = 222;
72
74
75 // Create topology
76
77 // Create transmission PDCP test entity
79
80 // Create transmission RLC entity
82 txRlc->SetRnti(rnti);
83 txRlc->SetLcId(lcid);
84
85 // Create transmission MAC test entity
87 txMac->SetRlcHeaderType(LteTestMac::UM_RLC_HEADER);
88
89 // Connect SAPs: PDCP (TX) <-> RLC (Tx) <-> MAC (Tx)
90 txPdcp->SetLteRlcSapProvider(txRlc->GetLteRlcSapProvider());
91 txRlc->SetLteRlcSapUser(txPdcp->GetLteRlcSapUser());
92
93 txRlc->SetLteMacSapProvider(txMac->GetLteMacSapProvider());
94 txMac->SetLteMacSapUser(txRlc->GetLteMacSapUser());
95}
96
97void
99 std::string shouldReceived,
100 std::string assertMsg)
101{
104 this,
105 shouldReceived,
106 assertMsg);
107}
108
109void
110LteRlcUmTransmitterTestCase::DoCheckDataReceived(std::string shouldReceived, std::string assertMsg)
111{
112 NS_TEST_ASSERT_MSG_EQ(shouldReceived, txMac->GetDataReceived(), assertMsg);
113}
114
115/**
116 * Test 4.1.1.1 One SDU, One PDU
117 */
122
126
127void
129{
130 // Create topology
132
133 //
134 // a) One SDU generates one PDU
135 //
136
137 // PDCP entity sends data
138 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
139
140 // MAC entity sends TxOpp to RLC entity
141 txMac->SendTxOpportunity(Seconds(0.150), 28);
142 CheckDataReceived(Seconds(0.200), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
143
146}
147
148/**
149 * Test 4.1.1.2 Segmentation (One SDU => n PDUs)
150 */
155
159
160void
162{
163 // Create topology
165
166 //
167 // b) Segmentation: one SDU generates n PDUs
168 //
169
170 // PDCP entity sends data
171 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
172
173 // MAC entity sends small TxOpp to RLC entity generating four segments
174 txMac->SendTxOpportunity(Seconds(0.150), 10);
175 CheckDataReceived(Seconds(0.200), "ABCDEFGH", "Segment #1 is not OK");
176
177 txMac->SendTxOpportunity(Seconds(0.200), 10);
178 CheckDataReceived(Seconds(0.250), "IJKLMNOP", "Segment #2 is not OK");
179
180 txMac->SendTxOpportunity(Seconds(0.300), 10);
181 CheckDataReceived(Seconds(0.350), "QRSTUVWX", "Segment #3 is not OK");
182
183 txMac->SendTxOpportunity(Seconds(0.400), 4);
184 CheckDataReceived(Seconds(0.450), "YZ", "Segment #4 is not OK");
185
188}
189
190/**
191 * Test 4.1.1.3 Concatenation (n SDUs => One PDU)
192 */
197
201
202void
204{
205 // Create topology
207
208 //
209 // c) Concatenation: n SDUs generate one PDU
210 //
211
212 // PDCP entity sends three data packets
213 txPdcp->SendData(Seconds(0.100), "ABCDEFGH");
214 txPdcp->SendData(Seconds(0.150), "IJKLMNOPQR");
215 txPdcp->SendData(Seconds(0.200), "STUVWXYZ");
216
217 // MAC entity sends TxOpp to RLC entity generating only one concatenated PDU
218 txMac->SendTxOpportunity(Seconds(0.250), 31);
219 CheckDataReceived(Seconds(0.300), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "Concatenation is not OK");
220
223}
224
225/**
226 * Test 4.1.1.4 Report Buffer Status (test primitive parameters)
227 */
233
237
238void
240{
241 // Create topology
243
244 //
245 // d) Test the parameters of the ReportBufferStatus primitive
246 //
247
248 // PDCP entity sends data
249 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJ"); // 10
250 txPdcp->SendData(Seconds(0.150), "KLMNOPQRS"); // 9
251 txPdcp->SendData(Seconds(0.200), "TUVWXYZ"); // 7
252
253 txMac->SendTxOpportunity(Seconds(0.250), (2 + 2) + (10 + 6));
254 CheckDataReceived(Seconds(0.300), "ABCDEFGHIJKLMNOP", "SDU is not OK");
255
256 txPdcp->SendData(Seconds(0.350), "ABCDEFGH"); // 8
257 txPdcp->SendData(Seconds(0.400), "IJKLMNOPQRST"); // 12
258 txPdcp->SendData(Seconds(0.450), "UVWXYZ"); // 6
259
260 txMac->SendTxOpportunity(Seconds(0.500), 2 + 3);
261 CheckDataReceived(Seconds(0.550), "QRS", "SDU is not OK");
262
263 txPdcp->SendData(Seconds(0.600), "ABCDEFGH"); // 8
264 txPdcp->SendData(Seconds(0.650), "IJKLMNOPQRST"); // 12
265 txPdcp->SendData(Seconds(0.700), "UVWXYZ"); // 6
266
267 txPdcp->SendData(Seconds(0.750), "ABCDEFGHIJ"); // 10
268 txPdcp->SendData(Seconds(0.800), "KLMNOPQRST"); // 10
269 txPdcp->SendData(Seconds(0.850), "UVWXYZ"); // 6
270
271 txMac->SendTxOpportunity(Seconds(0.900), 2 + 7);
272 CheckDataReceived(Seconds(0.950), "TUVWXYZ", "SDU is not OK");
273
274 txMac->SendTxOpportunity(Seconds(1.000), (2 + 2) + (8 + 2));
275 CheckDataReceived(Seconds(1.050), "ABCDEFGHIJ", "SDU is not OK");
276
277 txPdcp->SendData(Seconds(1.100), "ABCDEFGHIJ"); // 10
278 txPdcp->SendData(Seconds(1.150), "KLMNOPQRST"); // 10
279 txPdcp->SendData(Seconds(1.200), "UVWXYZ"); // 6
280
281 txMac->SendTxOpportunity(Seconds(1.250), 2 + 2);
282 CheckDataReceived(Seconds(1.300), "KL", "SDU is not OK");
283
284 txMac->SendTxOpportunity(Seconds(1.350), 2 + 3);
285 CheckDataReceived(Seconds(1.400), "MNO", "SDU is not OK");
286
287 txMac->SendTxOpportunity(Seconds(1.450), 2 + 5);
288 CheckDataReceived(Seconds(1.500), "PQRST", "SDU is not OK");
289
290 txMac->SendTxOpportunity(Seconds(1.550),
291 (2 + 2 + 1 + 2 + 1 + 2 + 1) + (6 + 8 + 12 + 6 + 10 + 10 + 3));
293 "UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW",
294 "SDU is not OK");
295
296 txMac->SendTxOpportunity(Seconds(1.650), (2 + 2 + 1 + 2) + (3 + 10 + 10 + 6));
297 CheckDataReceived(Seconds(1.700), "XYZABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
298
301}
Test 4.1.1.3 Concatenation (n SDUs => One PDU)
void DoRun() override
Implementation to actually run this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
Test 4.1.1.4 Report Buffer Status (test primitive parameters)
void DoRun() override
Implementation to actually run this TestCase.
Test 4.1.1.2 Segmentation (One SDU => n PDUs)
void DoRun() override
Implementation to actually run this TestCase.
Test case used by LteRlcUmTransmitterOneSduTestCase to create topology and to implement functionaliti...
void DoRun() override
Implementation to actually run this TestCase.
Ptr< LteTestPdcp > txPdcp
the transmit PDCP
void CheckDataReceived(Time time, std::string shouldReceived, std::string assertMsg)
Check data received function.
void DoCheckDataReceived(std::string shouldReceived, std::string assertMsg)
Check data received function.
TestSuite 4.1.1 for RLC UM: Only transmitter part.
LteRlcUmTransmitterTestSuite()
TestSuite 4.1.1 RLC UM: Only transmitter.
static void EnablePrinting()
Enable printing packets metadata.
Definition packet.cc:585
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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
static LteRlcUmTransmitterTestSuite lteRlcUmTransmitterTestSuite
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:1344
Every class exported by the ns3 library is enclosed in the ns3 namespace.