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 * 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-header.h"
26#include "ns3/lte-rlc-um.h"
27#include "ns3/simulator.h"
28
29using namespace ns3;
30
31NS_LOG_COMPONENT_DEFINE("LteRlcUmTransmitterTest");
32
38 : TestSuite("lte-rlc-um-transmitter", Type::SYSTEM)
39{
40 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
41 // LogComponentEnable ("LteRlcUmTransmitterTest", logLevel);
42
43 // NS_LOG_INFO ("Creating LteRlcUmTransmitterTestSuite");
44
45 AddTestCase(new LteRlcUmTransmitterOneSduTestCase("One SDU, one PDU"),
46 TestCase::Duration::QUICK);
48 TestCase::Duration::QUICK);
50 TestCase::Duration::QUICK);
51 AddTestCase(new LteRlcUmTransmitterReportBufferStatusTestCase("ReportBufferStatus primitive"),
52 TestCase::Duration::QUICK);
53}
54
60
62 : TestCase(name)
63{
64 // NS_LOG_UNCOND ("Creating LteRlcUmTransmitterTestCase: " + name);
65}
66
68{
69}
70
71void
73{
74 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
75 // LogComponentEnable ("LteRlcUmTransmitterTest", logLevel);
76 // LogComponentEnable ("LteTestEntities", logLevel);
77 // LogComponentEnable ("LteRlc", logLevel);
78 // LogComponentEnable ("LteRlcUm", logLevel);
79 // LogComponentEnable ("LteRlcHeader", logLevel);
80
81 uint16_t rnti = 1111;
82 uint8_t lcid = 222;
83
85
86 // Create topology
87
88 // Create transmission PDCP test entity
89 txPdcp = CreateObject<LteTestPdcp>();
90
91 // Create transmission RLC entity
92 txRlc = CreateObject<LteRlcUm>();
93 txRlc->SetRnti(rnti);
94 txRlc->SetLcId(lcid);
95
96 // Create transmission MAC test entity
97 txMac = CreateObject<LteTestMac>();
99
100 // Connect SAPs: PDCP (TX) <-> RLC (Tx) <-> MAC (Tx)
103
106}
107
108void
110 std::string shouldReceived,
111 std::string assertMsg)
112{
115 this,
116 shouldReceived,
117 assertMsg);
118}
119
120void
121LteRlcUmTransmitterTestCase::DoCheckDataReceived(std::string shouldReceived, std::string assertMsg)
122{
123 NS_TEST_ASSERT_MSG_EQ(shouldReceived, txMac->GetDataReceived(), assertMsg);
124}
125
131{
132}
133
135{
136}
137
138void
140{
141 // Create topology
143
144 //
145 // a) One SDU generates one PDU
146 //
147
148 // PDCP entity sends data
149 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
150
151 // MAC entity sends TxOpp to RLC entity
152 txMac->SendTxOpportunity(Seconds(0.150), 28);
153 CheckDataReceived(Seconds(0.200), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
154
157}
158
164{
165}
166
168{
169}
170
171void
173{
174 // Create topology
176
177 //
178 // b) Segmentation: one SDU generates n PDUs
179 //
180
181 // PDCP entity sends data
182 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
183
184 // MAC entity sends small TxOpp to RLC entity generating four segments
185 txMac->SendTxOpportunity(Seconds(0.150), 10);
186 CheckDataReceived(Seconds(0.200), "ABCDEFGH", "Segment #1 is not OK");
187
188 txMac->SendTxOpportunity(Seconds(0.200), 10);
189 CheckDataReceived(Seconds(0.250), "IJKLMNOP", "Segment #2 is not OK");
190
191 txMac->SendTxOpportunity(Seconds(0.300), 10);
192 CheckDataReceived(Seconds(0.350), "QRSTUVWX", "Segment #3 is not OK");
193
194 txMac->SendTxOpportunity(Seconds(0.400), 4);
195 CheckDataReceived(Seconds(0.450), "YZ", "Segment #4 is not OK");
196
199}
200
206{
207}
208
210{
211}
212
213void
215{
216 // Create topology
218
219 //
220 // c) Concatenation: n SDUs generate one PDU
221 //
222
223 // PDCP entity sends three data packets
224 txPdcp->SendData(Seconds(0.100), "ABCDEFGH");
225 txPdcp->SendData(Seconds(0.150), "IJKLMNOPQR");
226 txPdcp->SendData(Seconds(0.200), "STUVWXYZ");
227
228 // MAC entity sends TxOpp to RLC entity generating only one concatenated PDU
229 txMac->SendTxOpportunity(Seconds(0.250), 31);
230 CheckDataReceived(Seconds(0.300), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "Concatenation is not OK");
231
234}
235
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 // PDCP entity sends data
260 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJ"); // 10
261 txPdcp->SendData(Seconds(0.150), "KLMNOPQRS"); // 9
262 txPdcp->SendData(Seconds(0.200), "TUVWXYZ"); // 7
263
264 txMac->SendTxOpportunity(Seconds(0.250), (2 + 2) + (10 + 6));
265 CheckDataReceived(Seconds(0.300), "ABCDEFGHIJKLMNOP", "SDU is not OK");
266
267 txPdcp->SendData(Seconds(0.350), "ABCDEFGH"); // 8
268 txPdcp->SendData(Seconds(0.400), "IJKLMNOPQRST"); // 12
269 txPdcp->SendData(Seconds(0.450), "UVWXYZ"); // 6
270
271 txMac->SendTxOpportunity(Seconds(0.500), 2 + 3);
272 CheckDataReceived(Seconds(0.550), "QRS", "SDU is not OK");
273
274 txPdcp->SendData(Seconds(0.600), "ABCDEFGH"); // 8
275 txPdcp->SendData(Seconds(0.650), "IJKLMNOPQRST"); // 12
276 txPdcp->SendData(Seconds(0.700), "UVWXYZ"); // 6
277
278 txPdcp->SendData(Seconds(0.750), "ABCDEFGHIJ"); // 10
279 txPdcp->SendData(Seconds(0.800), "KLMNOPQRST"); // 10
280 txPdcp->SendData(Seconds(0.850), "UVWXYZ"); // 6
281
282 txMac->SendTxOpportunity(Seconds(0.900), 2 + 7);
283 CheckDataReceived(Seconds(0.950), "TUVWXYZ", "SDU is not OK");
284
285 txMac->SendTxOpportunity(Seconds(1.000), (2 + 2) + (8 + 2));
286 CheckDataReceived(Seconds(1.050), "ABCDEFGHIJ", "SDU is not OK");
287
288 txPdcp->SendData(Seconds(1.100), "ABCDEFGHIJ"); // 10
289 txPdcp->SendData(Seconds(1.150), "KLMNOPQRST"); // 10
290 txPdcp->SendData(Seconds(1.200), "UVWXYZ"); // 6
291
292 txMac->SendTxOpportunity(Seconds(1.250), 2 + 2);
293 CheckDataReceived(Seconds(1.300), "KL", "SDU is not OK");
294
295 txMac->SendTxOpportunity(Seconds(1.350), 2 + 3);
296 CheckDataReceived(Seconds(1.400), "MNO", "SDU is not OK");
297
298 txMac->SendTxOpportunity(Seconds(1.450), 2 + 5);
299 CheckDataReceived(Seconds(1.500), "PQRST", "SDU is not OK");
300
302 (2 + 2 + 1 + 2 + 1 + 2 + 1) + (6 + 8 + 12 + 6 + 10 + 10 + 3));
304 "UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW",
305 "SDU is not OK");
306
307 txMac->SendTxOpportunity(Seconds(1.650), (2 + 2 + 1 + 2) + (3 + 10 + 10 + 6));
308 CheckDataReceived(Seconds(1.700), "XYZABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
309
312}
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.
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
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 LteRlcUmTransmitterTestSuite lteRlcUmTransmitterTestSuite
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:1326
Every class exported by the ns3 library is enclosed in the ns3 namespace.