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
38 : TestSuite("lte-rlc-am-transmitter", SYSTEM)
39{
40 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
41 // LogComponentEnable ("LteRlcAmTransmitterTest", logLevel);
42
46 AddTestCase(new LteRlcAmTransmitterReportBufferStatusTestCase("ReportBufferStatus primitive"),
48}
49
55
57 : TestCase(name)
58{
59}
60
62{
63}
64
65void
67{
68 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
69 // LogComponentEnable ("LteRlcAmTransmitterTest", logLevel);
70 // LogComponentEnable ("LteTestEntities", logLevel);
71 // LogComponentEnable ("LteRlc", logLevel);
72 // LogComponentEnable ("LteRlcAm", logLevel);
73 // LogComponentEnable ("LteRlcHeader", logLevel);
74
75 uint16_t rnti = 1111;
76 uint8_t lcid = 222;
77
79
80 // Create topology
81
82 // Create transmission PDCP test entity
83 txPdcp = CreateObject<LteTestPdcp>();
84
85 // Create transmission RLC entity
86 txRlc = CreateObject<LteRlcAm>();
87 txRlc->SetRnti(rnti);
88 txRlc->SetLcId(lcid);
89
90 // Create transmission MAC test entity
91 txMac = CreateObject<LteTestMac>();
93
94 // Connect SAPs: PDCP (TX) <-> RLC (Tx) <-> MAC (Tx)
97
100}
101
102void
104 std::string shouldReceived,
105 std::string assertMsg)
106{
109 this,
110 shouldReceived,
111 assertMsg);
112}
113
114void
115LteRlcAmTransmitterTestCase::DoCheckDataReceived(std::string shouldReceived, std::string assertMsg)
116{
117 NS_TEST_ASSERT_MSG_EQ(shouldReceived, txMac->GetDataReceived(), assertMsg);
118}
119
125{
126}
127
129{
130}
131
132void
134{
135 // Create topology
137
138 //
139 // a) One SDU generates one PDU
140 //
141
142 // PDCP entity sends data
143 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
144
145 txMac->SendTxOpportunity(Seconds(0.150), 30);
146 CheckDataReceived(Seconds(0.200), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
147
151}
152
158{
159}
160
162{
163}
164
165void
167{
168 // Create topology
170
171 //
172 // b) Segmentation: one SDU generates n PDUs
173 //
174
175 // PDCP entity sends data
176 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZZ");
177
178 // MAC entity sends small TxOpp to RLC entity generating four segments
179 txMac->SendTxOpportunity(Seconds(0.150), 12);
180 CheckDataReceived(Seconds(0.200), "ABCDEFGH", "Segment #1 is not OK");
181
182 txMac->SendTxOpportunity(Seconds(0.250), 12);
183 CheckDataReceived(Seconds(0.300), "IJKLMNOP", "Segment #2 is not OK");
184
185 txMac->SendTxOpportunity(Seconds(0.350), 12);
186 CheckDataReceived(Seconds(0.400), "QRSTUVWX", "Segment #3 is not OK");
187
188 txMac->SendTxOpportunity(Seconds(0.450), 7);
189 CheckDataReceived(Seconds(0.500), "YZZ", "Segment #4 is not OK");
190
194}
195
201{
202}
203
205{
206}
207
208void
210{
211 // Create topology
213
214 //
215 // c) Concatenation: n SDUs generate one PDU
216 //
217
218 // PDCP entity sends three data packets
219 txPdcp->SendData(Seconds(0.100), "ABCDEFGH");
220 txPdcp->SendData(Seconds(0.150), "IJKLMNOPQR");
221 txPdcp->SendData(Seconds(0.200), "STUVWXYZ");
222
223 // MAC entity sends TxOpp to RLC entity generating only one concatenated PDU
224
225 txMac->SendTxOpportunity(Seconds(0.250), 33);
226 CheckDataReceived(Seconds(0.300), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "Concatenation is not OK");
227
231}
232
237 std::string name)
239{
240}
241
243{
244}
245
246void
248{
249 // Create topology
251
252 //
253 // d) Test the parameters of the ReportBufferStatus primitive
254 //
255
256 // txMac->SendTxOpportunity (Seconds (0.1), (2+2) + (10+6));
257
258 // PDCP entity sends data
259 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJ"); // 10
260 txPdcp->SendData(Seconds(0.150), "KLMNOPQRS"); // 9
261 txPdcp->SendData(Seconds(0.200), "TUVWXYZ"); // 7
262
263 txMac->SendTxOpportunity(Seconds(0.250), (4 + 2) + (10 + 6));
264 CheckDataReceived(Seconds(0.300), "ABCDEFGHIJKLMNOP", "SDU #1 is not OK");
265
266 txPdcp->SendData(Seconds(0.350), "ABCDEFGH"); // 8
267 txPdcp->SendData(Seconds(0.400), "IJKLMNOPQRST"); // 12
268 txPdcp->SendData(Seconds(0.450), "UVWXYZ"); // 6
269
270 txMac->SendTxOpportunity(Seconds(0.500), 4 + 3);
271 CheckDataReceived(Seconds(0.550), "QRS", "SDU #2 is not OK");
272
273 txPdcp->SendData(Seconds(0.600), "ABCDEFGH"); // 8
274 txPdcp->SendData(Seconds(0.650), "IJKLMNOPQRST"); // 12
275 txPdcp->SendData(Seconds(0.700), "UVWXYZ"); // 6
276
277 txPdcp->SendData(Seconds(0.750), "ABCDEFGHIJ"); // 10
278 txPdcp->SendData(Seconds(0.800), "KLMNOPQRST"); // 10
279 txPdcp->SendData(Seconds(0.850), "UVWXYZ"); // 6
280
281 txMac->SendTxOpportunity(Seconds(0.900), 4 + 7);
282 CheckDataReceived(Seconds(0.950), "TUVWXYZ", "SDU #3 is not OK");
283
284 txMac->SendTxOpportunity(Seconds(1.000), (4 + 2) + (8 + 2));
285 CheckDataReceived(Seconds(1.050), "ABCDEFGHIJ", "SDU #4 is not OK");
286
287 txPdcp->SendData(Seconds(1.100), "ABCDEFGHIJ"); // 10
288 txPdcp->SendData(Seconds(1.150), "KLMNOPQRSTU"); // 11
289 txPdcp->SendData(Seconds(1.200), "VWXYZ"); // 5
290
291 txMac->SendTxOpportunity(Seconds(1.250), 4 + 3);
292 CheckDataReceived(Seconds(1.300), "KLM", "SDU #5 is not OK");
293
294 txMac->SendTxOpportunity(Seconds(1.350), 4 + 3);
295 CheckDataReceived(Seconds(1.400), "NOP", "SDU #6 is not OK");
296
297 txMac->SendTxOpportunity(Seconds(1.450), 4 + 4);
298 CheckDataReceived(Seconds(1.500), "QRST", "SDU #7 is not OK");
299
301 (4 + 2 + 1 + 2 + 1 + 2 + 1) + (6 + 8 + 12 + 6 + 10 + 10 + 3));
303 "UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW",
304 "SDU #8 is not OK");
305
306 txMac->SendTxOpportunity(Seconds(1.650), (4 + 2 + 1 + 2) + (3 + 10 + 10 + 7));
307 CheckDataReceived(Seconds(1.700), "XYZABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU #9 is not OK");
308
312}
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:558
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:140
static void Run()
Run the simulation.
Definition: simulator.cc:176
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:184
encapsulates test code
Definition: test.h:1060
@ QUICK
Fast test.
Definition: test.h:1065
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1256
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:144
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1325
Every class exported by the ns3 library is enclosed in the ns3 namespace.