A Discrete-Event Network Simulator
API
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
43 AddTestCase(new LteRlcAmTransmitterOneSduTestCase("One SDU, one PDU"), TestCase::QUICK);
44 AddTestCase(new LteRlcAmTransmitterSegmentationTestCase("Segmentation"), TestCase::QUICK);
45 AddTestCase(new LteRlcAmTransmitterConcatenationTestCase("Concatenation"), TestCase::QUICK);
46 AddTestCase(new LteRlcAmTransmitterReportBufferStatusTestCase("ReportBufferStatus primitive"),
47 TestCase::QUICK);
48}
49
51
53 : TestCase(name)
54{
55}
56
58{
59}
60
61void
63{
64 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
65 // LogComponentEnable ("LteRlcAmTransmitterTest", logLevel);
66 // LogComponentEnable ("LteTestEntities", logLevel);
67 // LogComponentEnable ("LteRlc", logLevel);
68 // LogComponentEnable ("LteRlcAm", logLevel);
69 // LogComponentEnable ("LteRlcHeader", logLevel);
70
71 uint16_t rnti = 1111;
72 uint8_t lcid = 222;
73
74 Packet::EnablePrinting();
75
76 // Create topology
77
78 // Create transmission PDCP test entity
79 txPdcp = CreateObject<LteTestPdcp>();
80
81 // Create transmission RLC entity
82 txRlc = CreateObject<LteRlcAm>();
83 txRlc->SetRnti(rnti);
84 txRlc->SetLcId(lcid);
85
86 // Create transmission MAC test entity
87 txMac = CreateObject<LteTestMac>();
88 txMac->SetRlcHeaderType(LteTestMac::AM_RLC_HEADER);
89
90 // Connect SAPs: PDCP (TX) <-> RLC (Tx) <-> MAC (Tx)
93
96}
97
98void
100 std::string shouldReceived,
101 std::string assertMsg)
102{
103 Simulator::Schedule(time,
105 this,
106 shouldReceived,
107 assertMsg);
108}
109
110void
111LteRlcAmTransmitterTestCase::DoCheckDataReceived(std::string shouldReceived, std::string assertMsg)
112{
113 NS_TEST_ASSERT_MSG_EQ(shouldReceived, txMac->GetDataReceived(), assertMsg);
114}
115
121{
122}
123
125{
126}
127
128void
130{
131 // Create topology
133
134 //
135 // a) One SDU generates one PDU
136 //
137
138 // PDCP entity sends data
139 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
140
141 txMac->SendTxOpportunity(Seconds(0.150), 30);
142 CheckDataReceived(Seconds(0.200), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
143
144 Simulator::Stop(Seconds(0.3));
145 Simulator::Run();
146 Simulator::Destroy();
147}
148
154{
155}
156
158{
159}
160
161void
163{
164 // Create topology
166
167 //
168 // b) Segmentation: one SDU generates n PDUs
169 //
170
171 // PDCP entity sends data
172 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZZ");
173
174 // MAC entity sends small TxOpp to RLC entity generating four segments
175 txMac->SendTxOpportunity(Seconds(0.150), 12);
176 CheckDataReceived(Seconds(0.200), "ABCDEFGH", "Segment #1 is not OK");
177
178 txMac->SendTxOpportunity(Seconds(0.250), 12);
179 CheckDataReceived(Seconds(0.300), "IJKLMNOP", "Segment #2 is not OK");
180
181 txMac->SendTxOpportunity(Seconds(0.350), 12);
182 CheckDataReceived(Seconds(0.400), "QRSTUVWX", "Segment #3 is not OK");
183
184 txMac->SendTxOpportunity(Seconds(0.450), 7);
185 CheckDataReceived(Seconds(0.500), "YZZ", "Segment #4 is not OK");
186
187 Simulator::Stop(Seconds(0.6));
188 Simulator::Run();
189 Simulator::Destroy();
190}
191
197{
198}
199
201{
202}
203
204void
206{
207 // Create topology
209
210 //
211 // c) Concatenation: n SDUs generate one PDU
212 //
213
214 // PDCP entity sends three data packets
215 txPdcp->SendData(Seconds(0.100), "ABCDEFGH");
216 txPdcp->SendData(Seconds(0.150), "IJKLMNOPQR");
217 txPdcp->SendData(Seconds(0.200), "STUVWXYZ");
218
219 // MAC entity sends TxOpp to RLC entity generating only one concatenated PDU
220
221 txMac->SendTxOpportunity(Seconds(0.250), 33);
222 CheckDataReceived(Seconds(0.300), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "Concatenation is not OK");
223
224 Simulator::Stop(Seconds(0.4));
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 // txMac->SendTxOpportunity (Seconds (0.1), (2+2) + (10+6));
253
254 // PDCP entity sends data
255 txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJ"); // 10
256 txPdcp->SendData(Seconds(0.150), "KLMNOPQRS"); // 9
257 txPdcp->SendData(Seconds(0.200), "TUVWXYZ"); // 7
258
259 txMac->SendTxOpportunity(Seconds(0.250), (4 + 2) + (10 + 6));
260 CheckDataReceived(Seconds(0.300), "ABCDEFGHIJKLMNOP", "SDU #1 is not OK");
261
262 txPdcp->SendData(Seconds(0.350), "ABCDEFGH"); // 8
263 txPdcp->SendData(Seconds(0.400), "IJKLMNOPQRST"); // 12
264 txPdcp->SendData(Seconds(0.450), "UVWXYZ"); // 6
265
266 txMac->SendTxOpportunity(Seconds(0.500), 4 + 3);
267 CheckDataReceived(Seconds(0.550), "QRS", "SDU #2 is not OK");
268
269 txPdcp->SendData(Seconds(0.600), "ABCDEFGH"); // 8
270 txPdcp->SendData(Seconds(0.650), "IJKLMNOPQRST"); // 12
271 txPdcp->SendData(Seconds(0.700), "UVWXYZ"); // 6
272
273 txPdcp->SendData(Seconds(0.750), "ABCDEFGHIJ"); // 10
274 txPdcp->SendData(Seconds(0.800), "KLMNOPQRST"); // 10
275 txPdcp->SendData(Seconds(0.850), "UVWXYZ"); // 6
276
277 txMac->SendTxOpportunity(Seconds(0.900), 4 + 7);
278 CheckDataReceived(Seconds(0.950), "TUVWXYZ", "SDU #3 is not OK");
279
280 txMac->SendTxOpportunity(Seconds(1.000), (4 + 2) + (8 + 2));
281 CheckDataReceived(Seconds(1.050), "ABCDEFGHIJ", "SDU #4 is not OK");
282
283 txPdcp->SendData(Seconds(1.100), "ABCDEFGHIJ"); // 10
284 txPdcp->SendData(Seconds(1.150), "KLMNOPQRSTU"); // 11
285 txPdcp->SendData(Seconds(1.200), "VWXYZ"); // 5
286
287 txMac->SendTxOpportunity(Seconds(1.250), 4 + 3);
288 CheckDataReceived(Seconds(1.300), "KLM", "SDU #5 is not OK");
289
290 txMac->SendTxOpportunity(Seconds(1.350), 4 + 3);
291 CheckDataReceived(Seconds(1.400), "NOP", "SDU #6 is not OK");
292
293 txMac->SendTxOpportunity(Seconds(1.450), 4 + 4);
294 CheckDataReceived(Seconds(1.500), "QRST", "SDU #7 is not OK");
295
297 (4 + 2 + 1 + 2 + 1 + 2 + 1) + (6 + 8 + 12 + 6 + 10 + 10 + 3));
299 "UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW",
300 "SDU #8 is not OK");
301
302 txMac->SendTxOpportunity(Seconds(1.650), (4 + 2 + 1 + 2) + (3 + 10 + 10 + 7));
303 CheckDataReceived(Seconds(1.700), "XYZABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU #9 is not OK");
304
305 Simulator::Stop(Seconds(2));
306 Simulator::Run();
307 Simulator::Destroy();
308}
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: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 LteRlcAmTransmitterTestSuite lteRlcAmTransmitterTestSuite
Every class exported by the ns3 library is enclosed in the ns3 namespace.