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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Manuel Requena <manuel.requena@cttc.es>
18 */
19
21
22#include "lte-test-entities.h"
23
24#include "ns3/log.h"
25#include "ns3/lte-rlc-am.h"
26#include "ns3/lte-rlc-header.h"
27#include "ns3/simulator.h"
28
29using namespace ns3;
30
31NS_LOG_COMPONENT_DEFINE("LteRlcAmTransmitterTest");
32
33/**
34 * TestSuite 4.1.1 RLC AM: Only transmitter
35 */
36
38 : TestSuite("lte-rlc-am-transmitter", Type::SYSTEM)
39{
40 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
41 // LogComponentEnable ("LteRlcAmTransmitterTest", logLevel);
42
43 AddTestCase(new LteRlcAmTransmitterOneSduTestCase("One SDU, one PDU"),
44 TestCase::Duration::QUICK);
46 TestCase::Duration::QUICK);
48 TestCase::Duration::QUICK);
49 AddTestCase(new LteRlcAmTransmitterReportBufferStatusTestCase("ReportBufferStatus primitive"),
50 TestCase::Duration::QUICK);
51}
52
53/**
54 * \ingroup lte-test
55 * Static variable for test initialization
56 */
58
60 : TestCase(name)
61{
62}
63
65{
66}
67
68void
70{
71 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
72 // LogComponentEnable ("LteRlcAmTransmitterTest", logLevel);
73 // LogComponentEnable ("LteTestEntities", logLevel);
74 // LogComponentEnable ("LteRlc", logLevel);
75 // LogComponentEnable ("LteRlcAm", logLevel);
76 // LogComponentEnable ("LteRlcHeader", logLevel);
77
78 uint16_t rnti = 1111;
79 uint8_t lcid = 222;
80
82
83 // Create topology
84
85 // Create transmission PDCP test entity
86 txPdcp = CreateObject<LteTestPdcp>();
87
88 // Create transmission RLC entity
89 txRlc = CreateObject<LteRlcAm>();
90 txRlc->SetRnti(rnti);
91 txRlc->SetLcId(lcid);
92
93 // Create transmission MAC test entity
94 txMac = CreateObject<LteTestMac>();
96
97 // Connect SAPs: PDCP (TX) <-> RLC (Tx) <-> MAC (Tx)
100
103}
104
105void
107 std::string shouldReceived,
108 std::string assertMsg)
109{
112 this,
113 shouldReceived,
114 assertMsg);
115}
116
117void
118LteRlcAmTransmitterTestCase::DoCheckDataReceived(std::string shouldReceived, std::string assertMsg)
119{
120 NS_TEST_ASSERT_MSG_EQ(shouldReceived, txMac->GetDataReceived(), assertMsg);
121}
122
123/**
124 * Test 4.1.1.1 One SDU, One PDU
125 */
128{
129}
130
132{
133}
134
135void
137{
138 // Create topology
140
141 //
142 // a) One SDU generates one PDU
143 //
144
145 // PDCP entity sends data
146 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
147
148 txMac->SendTxOpportunity(Seconds(0.150), 30);
149 CheckDataReceived(Seconds(0.200), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
150
154}
155
156/**
157 * Test 4.1.1.2 Segmentation (One SDU => n PDUs)
158 */
161{
162}
163
165{
166}
167
168void
170{
171 // Create topology
173
174 //
175 // b) Segmentation: one SDU generates n PDUs
176 //
177
178 // PDCP entity sends data
179 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZZ");
180
181 // MAC entity sends small TxOpp to RLC entity generating four segments
182 txMac->SendTxOpportunity(Seconds(0.150), 12);
183 CheckDataReceived(Seconds(0.200), "ABCDEFGH", "Segment #1 is not OK");
184
185 txMac->SendTxOpportunity(Seconds(0.250), 12);
186 CheckDataReceived(Seconds(0.300), "IJKLMNOP", "Segment #2 is not OK");
187
188 txMac->SendTxOpportunity(Seconds(0.350), 12);
189 CheckDataReceived(Seconds(0.400), "QRSTUVWX", "Segment #3 is not OK");
190
191 txMac->SendTxOpportunity(Seconds(0.450), 7);
192 CheckDataReceived(Seconds(0.500), "YZZ", "Segment #4 is not OK");
193
197}
198
199/**
200 * Test 4.1.1.3 Concatenation (n SDUs => One PDU)
201 */
204{
205}
206
208{
209}
210
211void
213{
214 // Create topology
216
217 //
218 // c) Concatenation: n SDUs generate one PDU
219 //
220
221 // PDCP entity sends three data packets
222 txPdcp->SendData(Seconds(0.100), "ABCDEFGH");
223 txPdcp->SendData(Seconds(0.150), "IJKLMNOPQR");
224 txPdcp->SendData(Seconds(0.200), "STUVWXYZ");
225
226 // MAC entity sends TxOpp to RLC entity generating only one concatenated PDU
227
228 txMac->SendTxOpportunity(Seconds(0.250), 33);
229 CheckDataReceived(Seconds(0.300), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "Concatenation is not OK");
230
234}
235
236/**
237 * Test 4.1.1.4 Report Buffer Status (test primitive parameters)
238 */
240 std::string name)
242{
243}
244
246{
247}
248
249void
251{
252 // Create topology
254
255 //
256 // d) Test the parameters of the ReportBufferStatus primitive
257 //
258
259 // txMac->SendTxOpportunity (Seconds (0.1), (2+2) + (10+6));
260
261 // PDCP entity sends data
262 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJ"); // 10
263 txPdcp->SendData(Seconds(0.150), "KLMNOPQRS"); // 9
264 txPdcp->SendData(Seconds(0.200), "TUVWXYZ"); // 7
265
266 txMac->SendTxOpportunity(Seconds(0.250), (4 + 2) + (10 + 6));
267 CheckDataReceived(Seconds(0.300), "ABCDEFGHIJKLMNOP", "SDU #1 is not OK");
268
269 txPdcp->SendData(Seconds(0.350), "ABCDEFGH"); // 8
270 txPdcp->SendData(Seconds(0.400), "IJKLMNOPQRST"); // 12
271 txPdcp->SendData(Seconds(0.450), "UVWXYZ"); // 6
272
273 txMac->SendTxOpportunity(Seconds(0.500), 4 + 3);
274 CheckDataReceived(Seconds(0.550), "QRS", "SDU #2 is not OK");
275
276 txPdcp->SendData(Seconds(0.600), "ABCDEFGH"); // 8
277 txPdcp->SendData(Seconds(0.650), "IJKLMNOPQRST"); // 12
278 txPdcp->SendData(Seconds(0.700), "UVWXYZ"); // 6
279
280 txPdcp->SendData(Seconds(0.750), "ABCDEFGHIJ"); // 10
281 txPdcp->SendData(Seconds(0.800), "KLMNOPQRST"); // 10
282 txPdcp->SendData(Seconds(0.850), "UVWXYZ"); // 6
283
284 txMac->SendTxOpportunity(Seconds(0.900), 4 + 7);
285 CheckDataReceived(Seconds(0.950), "TUVWXYZ", "SDU #3 is not OK");
286
287 txMac->SendTxOpportunity(Seconds(1.000), (4 + 2) + (8 + 2));
288 CheckDataReceived(Seconds(1.050), "ABCDEFGHIJ", "SDU #4 is not OK");
289
290 txPdcp->SendData(Seconds(1.100), "ABCDEFGHIJ"); // 10
291 txPdcp->SendData(Seconds(1.150), "KLMNOPQRSTU"); // 11
292 txPdcp->SendData(Seconds(1.200), "VWXYZ"); // 5
293
294 txMac->SendTxOpportunity(Seconds(1.250), 4 + 3);
295 CheckDataReceived(Seconds(1.300), "KLM", "SDU #5 is not OK");
296
297 txMac->SendTxOpportunity(Seconds(1.350), 4 + 3);
298 CheckDataReceived(Seconds(1.400), "NOP", "SDU #6 is not OK");
299
300 txMac->SendTxOpportunity(Seconds(1.450), 4 + 4);
301 CheckDataReceived(Seconds(1.500), "QRST", "SDU #7 is not OK");
302
304 (4 + 2 + 1 + 2 + 1 + 2 + 1) + (6 + 8 + 12 + 6 + 10 + 10 + 3));
306 "UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW",
307 "SDU #8 is not OK");
308
309 txMac->SendTxOpportunity(Seconds(1.650), (4 + 2 + 1 + 2) + (3 + 10 + 10 + 7));
310 CheckDataReceived(Seconds(1.700), "XYZABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU #9 is not OK");
311
315}
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.
void SetLteRlcSapUser(LteRlcSapUser *s)
Definition: lte-rlc.cc:155
void SetRnti(uint16_t rnti)
Definition: lte-rlc.cc:134
void SetLteMacSapProvider(LteMacSapProvider *s)
Definition: lte-rlc.cc:169
LteMacSapUser * GetLteMacSapUser()
Definition: lte-rlc.cc:176
void SetLcId(uint8_t lcId)
Definition: lte-rlc.cc:141
LteRlcSapProvider * GetLteRlcSapProvider()
Definition: lte-rlc.cc:162
void SendTxOpportunity(Time time, uint32_t bytes)
Send transmit opportunity function.
void SetLteMacSapUser(LteMacSapUser *s)
Set the MAC SAP user.
LteMacSapProvider * GetLteMacSapProvider()
Get the MAC SAP provider.
std::string GetDataReceived()
Get data received function.
void SetRlcHeaderType(uint8_t rlcHeaderType)
Set RLC header type.
void SetLteRlcSapProvider(LteRlcSapProvider *s)
Set the RLC SAP provider.
LteRlcSapUser * GetLteRlcSapUser()
Get the RLC SAP user.
void SendData(Time time, std::string dataToSend)
Send data function.
static void EnablePrinting()
Enable printing packets metadata.
Definition: packet.cc:596
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
static LteRlcAmTransmitterTestSuite lteRlcAmTransmitterTestSuite
Static variable for test initialization.
#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:145
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
Every class exported by the ns3 library is enclosed in the ns3 namespace.