A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-test-rlc-am-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-am.h"
15#include "ns3/lte-rlc-header.h"
16#include "ns3/simulator.h"
17
18using namespace ns3;
19
20NS_LOG_COMPONENT_DEFINE("LteRlcAmTransmitterTest");
21
22/**
23 * TestSuite 4.1.1 RLC AM: Only transmitter
24 */
25
27 : TestSuite("lte-rlc-am-transmitter", Type::SYSTEM)
28{
29 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
30 // LogComponentEnable ("LteRlcAmTransmitterTest", logLevel);
31
32 AddTestCase(new LteRlcAmTransmitterOneSduTestCase("One SDU, one PDU"),
33 TestCase::Duration::QUICK);
35 TestCase::Duration::QUICK);
37 TestCase::Duration::QUICK);
38 AddTestCase(new LteRlcAmTransmitterReportBufferStatusTestCase("ReportBufferStatus primitive"),
39 TestCase::Duration::QUICK);
40}
41
42/**
43 * @ingroup lte-test
44 * Static variable for test initialization
45 */
47
52
56
57void
59{
60 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
61 // LogComponentEnable ("LteRlcAmTransmitterTest", logLevel);
62 // LogComponentEnable ("LteTestEntities", logLevel);
63 // LogComponentEnable ("LteRlc", logLevel);
64 // LogComponentEnable ("LteRlcAm", logLevel);
65 // LogComponentEnable ("LteRlcHeader", logLevel);
66
67 uint16_t rnti = 1111;
68 uint8_t lcid = 222;
69
71
72 // Create topology
73
74 // Create transmission PDCP test entity
76
77 // Create transmission RLC entity
79 txRlc->SetRnti(rnti);
80 txRlc->SetLcId(lcid);
81
82 // Create transmission MAC test entity
84 txMac->SetRlcHeaderType(LteTestMac::AM_RLC_HEADER);
85
86 // Connect SAPs: PDCP (TX) <-> RLC (Tx) <-> MAC (Tx)
87 txPdcp->SetLteRlcSapProvider(txRlc->GetLteRlcSapProvider());
88 txRlc->SetLteRlcSapUser(txPdcp->GetLteRlcSapUser());
89
90 txRlc->SetLteMacSapProvider(txMac->GetLteMacSapProvider());
91 txMac->SetLteMacSapUser(txRlc->GetLteMacSapUser());
92}
93
94void
96 std::string shouldReceived,
97 std::string assertMsg)
98{
101 this,
102 shouldReceived,
103 assertMsg);
104}
105
106void
107LteRlcAmTransmitterTestCase::DoCheckDataReceived(std::string shouldReceived, std::string assertMsg)
108{
109 NS_TEST_ASSERT_MSG_EQ(shouldReceived, txMac->GetDataReceived(), assertMsg);
110}
111
112/**
113 * Test 4.1.1.1 One SDU, One PDU
114 */
119
123
124void
126{
127 // Create topology
129
130 //
131 // a) One SDU generates one PDU
132 //
133
134 // PDCP entity sends data
135 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
136
137 txMac->SendTxOpportunity(Seconds(0.150), 30);
138 CheckDataReceived(Seconds(0.200), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
139
143}
144
145/**
146 * Test 4.1.1.2 Segmentation (One SDU => n PDUs)
147 */
152
156
157void
159{
160 // Create topology
162
163 //
164 // b) Segmentation: one SDU generates n PDUs
165 //
166
167 // PDCP entity sends data
168 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZZ");
169
170 // MAC entity sends small TxOpp to RLC entity generating four segments
171 txMac->SendTxOpportunity(Seconds(0.150), 12);
172 CheckDataReceived(Seconds(0.200), "ABCDEFGH", "Segment #1 is not OK");
173
174 txMac->SendTxOpportunity(Seconds(0.250), 12);
175 CheckDataReceived(Seconds(0.300), "IJKLMNOP", "Segment #2 is not OK");
176
177 txMac->SendTxOpportunity(Seconds(0.350), 12);
178 CheckDataReceived(Seconds(0.400), "QRSTUVWX", "Segment #3 is not OK");
179
180 txMac->SendTxOpportunity(Seconds(0.450), 7);
181 CheckDataReceived(Seconds(0.500), "YZZ", "Segment #4 is not OK");
182
186}
187
188/**
189 * Test 4.1.1.3 Concatenation (n SDUs => One PDU)
190 */
195
199
200void
202{
203 // Create topology
205
206 //
207 // c) Concatenation: n SDUs generate one PDU
208 //
209
210 // PDCP entity sends three data packets
211 txPdcp->SendData(Seconds(0.100), "ABCDEFGH");
212 txPdcp->SendData(Seconds(0.150), "IJKLMNOPQR");
213 txPdcp->SendData(Seconds(0.200), "STUVWXYZ");
214
215 // MAC entity sends TxOpp to RLC entity generating only one concatenated PDU
216
217 txMac->SendTxOpportunity(Seconds(0.250), 33);
218 CheckDataReceived(Seconds(0.300), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "Concatenation is not OK");
219
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 // txMac->SendTxOpportunity (Seconds (0.1), (2+2) + (10+6));
249
250 // PDCP entity sends data
251 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJ"); // 10
252 txPdcp->SendData(Seconds(0.150), "KLMNOPQRS"); // 9
253 txPdcp->SendData(Seconds(0.200), "TUVWXYZ"); // 7
254
255 txMac->SendTxOpportunity(Seconds(0.250), (4 + 2) + (10 + 6));
256 CheckDataReceived(Seconds(0.300), "ABCDEFGHIJKLMNOP", "SDU #1 is not OK");
257
258 txPdcp->SendData(Seconds(0.350), "ABCDEFGH"); // 8
259 txPdcp->SendData(Seconds(0.400), "IJKLMNOPQRST"); // 12
260 txPdcp->SendData(Seconds(0.450), "UVWXYZ"); // 6
261
262 txMac->SendTxOpportunity(Seconds(0.500), 4 + 3);
263 CheckDataReceived(Seconds(0.550), "QRS", "SDU #2 is not OK");
264
265 txPdcp->SendData(Seconds(0.600), "ABCDEFGH"); // 8
266 txPdcp->SendData(Seconds(0.650), "IJKLMNOPQRST"); // 12
267 txPdcp->SendData(Seconds(0.700), "UVWXYZ"); // 6
268
269 txPdcp->SendData(Seconds(0.750), "ABCDEFGHIJ"); // 10
270 txPdcp->SendData(Seconds(0.800), "KLMNOPQRST"); // 10
271 txPdcp->SendData(Seconds(0.850), "UVWXYZ"); // 6
272
273 txMac->SendTxOpportunity(Seconds(0.900), 4 + 7);
274 CheckDataReceived(Seconds(0.950), "TUVWXYZ", "SDU #3 is not OK");
275
276 txMac->SendTxOpportunity(Seconds(1.000), (4 + 2) + (8 + 2));
277 CheckDataReceived(Seconds(1.050), "ABCDEFGHIJ", "SDU #4 is not OK");
278
279 txPdcp->SendData(Seconds(1.100), "ABCDEFGHIJ"); // 10
280 txPdcp->SendData(Seconds(1.150), "KLMNOPQRSTU"); // 11
281 txPdcp->SendData(Seconds(1.200), "VWXYZ"); // 5
282
283 txMac->SendTxOpportunity(Seconds(1.250), 4 + 3);
284 CheckDataReceived(Seconds(1.300), "KLM", "SDU #5 is not OK");
285
286 txMac->SendTxOpportunity(Seconds(1.350), 4 + 3);
287 CheckDataReceived(Seconds(1.400), "NOP", "SDU #6 is not OK");
288
289 txMac->SendTxOpportunity(Seconds(1.450), 4 + 4);
290 CheckDataReceived(Seconds(1.500), "QRST", "SDU #7 is not OK");
291
292 txMac->SendTxOpportunity(Seconds(1.550),
293 (4 + 2 + 1 + 2 + 1 + 2 + 1) + (6 + 8 + 12 + 6 + 10 + 10 + 3));
295 "UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW",
296 "SDU #8 is not OK");
297
298 txMac->SendTxOpportunity(Seconds(1.650), (4 + 2 + 1 + 2) + (3 + 10 + 10 + 7));
299 CheckDataReceived(Seconds(1.700), "XYZABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU #9 is not OK");
300
304}
Test 4.1.1.3 Test that concatenation functionality works properly.
void DoRun() override
Implementation to actually run this TestCase.
Test 4.1.1.1 Test that SDU transmitted at PDCP corresponds to PDU received by MAC.
void DoRun() override
Implementation to actually run this TestCase.
Test 4.1.1.4 Test checks functionality of Report Buffer Status by testing primitive parameters.
void DoRun() override
Implementation to actually run this TestCase.
Test 4.1.1.2 Test the correct functionality of the Segmentation.
void DoRun() override
Implementation to actually run this TestCase.
Test case used by LteRlcAmTransmitterOneSduTestCase to create topology and to implement functionaliti...
Ptr< LteTestPdcp > txPdcp
the transmit PDCP
void CheckDataReceived(Time time, std::string shouldReceived, std::string assertMsg)
Check data received function.
void DoRun() override
Implementation to actually run this TestCase.
void DoCheckDataReceived(std::string shouldReceived, std::string assertMsg)
Check data received function.
TestSuite 4.1.1 RLC AM: Only transmitter functionality.
LteRlcAmTransmitterTestSuite()
TestSuite 4.1.1 RLC AM: 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
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
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 LteRlcAmTransmitterTestSuite lteRlcAmTransmitterTestSuite
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.