A Discrete-Event Network Simulator
API
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", 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"), TestCase::QUICK);
46 AddTestCase(new LteRlcUmTransmitterSegmentationTestCase("Segmentation"), TestCase::QUICK);
47 AddTestCase(new LteRlcUmTransmitterConcatenationTestCase("Concatenation"), TestCase::QUICK);
48 AddTestCase(new LteRlcUmTransmitterReportBufferStatusTestCase("ReportBufferStatus primitive"),
49 TestCase::QUICK);
50}
51
53
55 : TestCase(name)
56{
57 // NS_LOG_UNCOND ("Creating LteRlcUmTransmitterTestCase: " + name);
58}
59
61{
62}
63
64void
66{
67 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
68 // LogComponentEnable ("LteRlcUmTransmitterTest", logLevel);
69 // LogComponentEnable ("LteTestEntities", logLevel);
70 // LogComponentEnable ("LteRlc", logLevel);
71 // LogComponentEnable ("LteRlcUm", logLevel);
72 // LogComponentEnable ("LteRlcHeader", logLevel);
73
74 uint16_t rnti = 1111;
75 uint8_t lcid = 222;
76
77 Packet::EnablePrinting();
78
79 // Create topology
80
81 // Create transmission PDCP test entity
82 txPdcp = CreateObject<LteTestPdcp>();
83
84 // Create transmission RLC entity
85 txRlc = CreateObject<LteRlcUm>();
86 txRlc->SetRnti(rnti);
87 txRlc->SetLcId(lcid);
88
89 // Create transmission MAC test entity
90 txMac = CreateObject<LteTestMac>();
91 txMac->SetRlcHeaderType(LteTestMac::UM_RLC_HEADER);
92
93 // Connect SAPs: PDCP (TX) <-> RLC (Tx) <-> MAC (Tx)
96
99}
100
101void
103 std::string shouldReceived,
104 std::string assertMsg)
105{
106 Simulator::Schedule(time,
108 this,
109 shouldReceived,
110 assertMsg);
111}
112
113void
114LteRlcUmTransmitterTestCase::DoCheckDataReceived(std::string shouldReceived, std::string assertMsg)
115{
116 NS_TEST_ASSERT_MSG_EQ(shouldReceived, txMac->GetDataReceived(), assertMsg);
117}
118
124{
125}
126
128{
129}
130
131void
133{
134 // Create topology
136
137 //
138 // a) One SDU generates one PDU
139 //
140
141 // PDCP entity sends data
142 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
143
144 // MAC entity sends TxOpp to RLC entity
145 txMac->SendTxOpportunity(Seconds(0.150), 28);
146 CheckDataReceived(Seconds(0.200), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
147
148 Simulator::Run();
149 Simulator::Destroy();
150}
151
157{
158}
159
161{
162}
163
164void
166{
167 // Create topology
169
170 //
171 // b) Segmentation: one SDU generates n PDUs
172 //
173
174 // PDCP entity sends data
175 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
176
177 // MAC entity sends small TxOpp to RLC entity generating four segments
178 txMac->SendTxOpportunity(Seconds(0.150), 10);
179 CheckDataReceived(Seconds(0.200), "ABCDEFGH", "Segment #1 is not OK");
180
181 txMac->SendTxOpportunity(Seconds(0.200), 10);
182 CheckDataReceived(Seconds(0.250), "IJKLMNOP", "Segment #2 is not OK");
183
184 txMac->SendTxOpportunity(Seconds(0.300), 10);
185 CheckDataReceived(Seconds(0.350), "QRSTUVWX", "Segment #3 is not OK");
186
187 txMac->SendTxOpportunity(Seconds(0.400), 4);
188 CheckDataReceived(Seconds(0.450), "YZ", "Segment #4 is not OK");
189
190 Simulator::Run();
191 Simulator::Destroy();
192}
193
199{
200}
201
203{
204}
205
206void
208{
209 // Create topology
211
212 //
213 // c) Concatenation: n SDUs generate one PDU
214 //
215
216 // PDCP entity sends three data packets
217 txPdcp->SendData(Seconds(0.100), "ABCDEFGH");
218 txPdcp->SendData(Seconds(0.150), "IJKLMNOPQR");
219 txPdcp->SendData(Seconds(0.200), "STUVWXYZ");
220
221 // MAC entity sends TxOpp to RLC entity generating only one concatenated PDU
222 txMac->SendTxOpportunity(Seconds(0.250), 31);
223 CheckDataReceived(Seconds(0.300), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "Concatenation is not OK");
224
225 Simulator::Run();
226 Simulator::Destroy();
227}
228
233 std::string name)
235{
236}
237
239{
240}
241
242void
244{
245 // Create topology
247
248 //
249 // d) Test the parameters of the ReportBufferStatus primitive
250 //
251
252 // PDCP entity sends data
253 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJ"); // 10
254 txPdcp->SendData(Seconds(0.150), "KLMNOPQRS"); // 9
255 txPdcp->SendData(Seconds(0.200), "TUVWXYZ"); // 7
256
257 txMac->SendTxOpportunity(Seconds(0.250), (2 + 2) + (10 + 6));
258 CheckDataReceived(Seconds(0.300), "ABCDEFGHIJKLMNOP", "SDU is not OK");
259
260 txPdcp->SendData(Seconds(0.350), "ABCDEFGH"); // 8
261 txPdcp->SendData(Seconds(0.400), "IJKLMNOPQRST"); // 12
262 txPdcp->SendData(Seconds(0.450), "UVWXYZ"); // 6
263
264 txMac->SendTxOpportunity(Seconds(0.500), 2 + 3);
265 CheckDataReceived(Seconds(0.550), "QRS", "SDU is not OK");
266
267 txPdcp->SendData(Seconds(0.600), "ABCDEFGH"); // 8
268 txPdcp->SendData(Seconds(0.650), "IJKLMNOPQRST"); // 12
269 txPdcp->SendData(Seconds(0.700), "UVWXYZ"); // 6
270
271 txPdcp->SendData(Seconds(0.750), "ABCDEFGHIJ"); // 10
272 txPdcp->SendData(Seconds(0.800), "KLMNOPQRST"); // 10
273 txPdcp->SendData(Seconds(0.850), "UVWXYZ"); // 6
274
275 txMac->SendTxOpportunity(Seconds(0.900), 2 + 7);
276 CheckDataReceived(Seconds(0.950), "TUVWXYZ", "SDU is not OK");
277
278 txMac->SendTxOpportunity(Seconds(1.000), (2 + 2) + (8 + 2));
279 CheckDataReceived(Seconds(1.050), "ABCDEFGHIJ", "SDU is not OK");
280
281 txPdcp->SendData(Seconds(1.100), "ABCDEFGHIJ"); // 10
282 txPdcp->SendData(Seconds(1.150), "KLMNOPQRST"); // 10
283 txPdcp->SendData(Seconds(1.200), "UVWXYZ"); // 6
284
285 txMac->SendTxOpportunity(Seconds(1.250), 2 + 2);
286 CheckDataReceived(Seconds(1.300), "KL", "SDU is not OK");
287
288 txMac->SendTxOpportunity(Seconds(1.350), 2 + 3);
289 CheckDataReceived(Seconds(1.400), "MNO", "SDU is not OK");
290
291 txMac->SendTxOpportunity(Seconds(1.450), 2 + 5);
292 CheckDataReceived(Seconds(1.500), "PQRST", "SDU is not OK");
293
295 (2 + 2 + 1 + 2 + 1 + 2 + 1) + (6 + 8 + 12 + 6 + 10 + 10 + 3));
297 "UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW",
298 "SDU is not OK");
299
300 txMac->SendTxOpportunity(Seconds(1.650), (2 + 2 + 1 + 2) + (3 + 10 + 10 + 6));
301 CheckDataReceived(Seconds(1.700), "XYZABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
302
303 Simulator::Run();
304 Simulator::Destroy();
305}
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:148
void SetRnti(uint16_t rnti)
Definition: lte-rlc.cc:134
void SetLteMacSapProvider(LteMacSapProvider *s)
Definition: lte-rlc.cc:162
LteMacSapUser * GetLteMacSapUser()
Definition: lte-rlc.cc:169
void SetLcId(uint8_t lcId)
Definition: lte-rlc.cc:141
LteRlcSapProvider * GetLteRlcSapProvider()
Definition: lte-rlc.cc:155
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.
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:305
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
#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:1338
static LteRlcUmTransmitterTestSuite lteRlcUmTransmitterTestSuite
Every class exported by the ns3 library is enclosed in the ns3 namespace.