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 
29 using namespace ns3;
30 
31 NS_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 
57 
59  : TestCase(name)
60 {
61  // NS_LOG_UNCOND ("Creating LteRlcUmTransmitterTestCase: " + name);
62 }
63 
65 {
66 }
67 
68 void
70 {
71  // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
72  // LogComponentEnable ("LteRlcUmTransmitterTest", logLevel);
73  // LogComponentEnable ("LteTestEntities", logLevel);
74  // LogComponentEnable ("LteRlc", logLevel);
75  // LogComponentEnable ("LteRlcUm", logLevel);
76  // LogComponentEnable ("LteRlcHeader", logLevel);
77 
78  uint16_t rnti = 1111;
79  uint8_t lcid = 222;
80 
81  Packet::EnablePrinting();
82 
83  // Create topology
84 
85  // Create transmission PDCP test entity
86  txPdcp = CreateObject<LteTestPdcp>();
87 
88  // Create transmission RLC entity
89  txRlc = CreateObject<LteRlcUm>();
90  txRlc->SetRnti(rnti);
91  txRlc->SetLcId(lcid);
92 
93  // Create transmission MAC test entity
94  txMac = CreateObject<LteTestMac>();
95  txMac->SetRlcHeaderType(LteTestMac::UM_RLC_HEADER);
96 
97  // Connect SAPs: PDCP (TX) <-> RLC (Tx) <-> MAC (Tx)
100 
103 }
104 
105 void
107  std::string shouldReceived,
108  std::string assertMsg)
109 {
110  Simulator::Schedule(time,
112  this,
113  shouldReceived,
114  assertMsg);
115 }
116 
117 void
118 LteRlcUmTransmitterTestCase::DoCheckDataReceived(std::string shouldReceived, std::string assertMsg)
119 {
120  NS_TEST_ASSERT_MSG_EQ(shouldReceived, txMac->GetDataReceived(), assertMsg);
121 }
122 
128 {
129 }
130 
132 {
133 }
134 
135 void
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  // MAC entity sends TxOpp to RLC entity
149  txMac->SendTxOpportunity(Seconds(0.150), 28);
150  CheckDataReceived(Seconds(0.200), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
151 
152  Simulator::Run();
153  Simulator::Destroy();
154 }
155 
161 {
162 }
163 
165 {
166 }
167 
168 void
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), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
180 
181  // MAC entity sends small TxOpp to RLC entity generating four segments
182  txMac->SendTxOpportunity(Seconds(0.150), 10);
183  CheckDataReceived(Seconds(0.200), "ABCDEFGH", "Segment #1 is not OK");
184 
185  txMac->SendTxOpportunity(Seconds(0.200), 10);
186  CheckDataReceived(Seconds(0.250), "IJKLMNOP", "Segment #2 is not OK");
187 
188  txMac->SendTxOpportunity(Seconds(0.300), 10);
189  CheckDataReceived(Seconds(0.350), "QRSTUVWX", "Segment #3 is not OK");
190 
191  txMac->SendTxOpportunity(Seconds(0.400), 4);
192  CheckDataReceived(Seconds(0.450), "YZ", "Segment #4 is not OK");
193 
194  Simulator::Run();
195  Simulator::Destroy();
196 }
197 
203 {
204 }
205 
207 {
208 }
209 
210 void
212 {
213  // Create topology
215 
216  //
217  // c) Concatenation: n SDUs generate one PDU
218  //
219 
220  // PDCP entity sends three data packets
221  txPdcp->SendData(Seconds(0.100), "ABCDEFGH");
222  txPdcp->SendData(Seconds(0.150), "IJKLMNOPQR");
223  txPdcp->SendData(Seconds(0.200), "STUVWXYZ");
224 
225  // MAC entity sends TxOpp to RLC entity generating only one concatenated PDU
226  txMac->SendTxOpportunity(Seconds(0.250), 31);
227  CheckDataReceived(Seconds(0.300), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "Concatenation is not OK");
228 
229  Simulator::Run();
230  Simulator::Destroy();
231 }
232 
237  std::string name)
239 {
240 }
241 
243 {
244 }
245 
246 void
248 {
249  // Create topology
251 
252  //
253  // d) Test the parameters of the ReportBufferStatus primitive
254  //
255 
256  // PDCP entity sends data
257  txPdcp->SendData(Seconds(0.100), "ABCDEFGHIJ"); // 10
258  txPdcp->SendData(Seconds(0.150), "KLMNOPQRS"); // 9
259  txPdcp->SendData(Seconds(0.200), "TUVWXYZ"); // 7
260 
261  txMac->SendTxOpportunity(Seconds(0.250), (2 + 2) + (10 + 6));
262  CheckDataReceived(Seconds(0.300), "ABCDEFGHIJKLMNOP", "SDU is not OK");
263 
264  txPdcp->SendData(Seconds(0.350), "ABCDEFGH"); // 8
265  txPdcp->SendData(Seconds(0.400), "IJKLMNOPQRST"); // 12
266  txPdcp->SendData(Seconds(0.450), "UVWXYZ"); // 6
267 
268  txMac->SendTxOpportunity(Seconds(0.500), 2 + 3);
269  CheckDataReceived(Seconds(0.550), "QRS", "SDU is not OK");
270 
271  txPdcp->SendData(Seconds(0.600), "ABCDEFGH"); // 8
272  txPdcp->SendData(Seconds(0.650), "IJKLMNOPQRST"); // 12
273  txPdcp->SendData(Seconds(0.700), "UVWXYZ"); // 6
274 
275  txPdcp->SendData(Seconds(0.750), "ABCDEFGHIJ"); // 10
276  txPdcp->SendData(Seconds(0.800), "KLMNOPQRST"); // 10
277  txPdcp->SendData(Seconds(0.850), "UVWXYZ"); // 6
278 
279  txMac->SendTxOpportunity(Seconds(0.900), 2 + 7);
280  CheckDataReceived(Seconds(0.950), "TUVWXYZ", "SDU is not OK");
281 
282  txMac->SendTxOpportunity(Seconds(1.000), (2 + 2) + (8 + 2));
283  CheckDataReceived(Seconds(1.050), "ABCDEFGHIJ", "SDU is not OK");
284 
285  txPdcp->SendData(Seconds(1.100), "ABCDEFGHIJ"); // 10
286  txPdcp->SendData(Seconds(1.150), "KLMNOPQRST"); // 10
287  txPdcp->SendData(Seconds(1.200), "UVWXYZ"); // 6
288 
289  txMac->SendTxOpportunity(Seconds(1.250), 2 + 2);
290  CheckDataReceived(Seconds(1.300), "KL", "SDU is not OK");
291 
292  txMac->SendTxOpportunity(Seconds(1.350), 2 + 3);
293  CheckDataReceived(Seconds(1.400), "MNO", "SDU is not OK");
294 
295  txMac->SendTxOpportunity(Seconds(1.450), 2 + 5);
296  CheckDataReceived(Seconds(1.500), "PQRST", "SDU is not OK");
297 
299  (2 + 2 + 1 + 2 + 1 + 2 + 1) + (6 + 8 + 12 + 6 + 10 + 10 + 3));
300  CheckDataReceived(Seconds(1.600),
301  "UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW",
302  "SDU is not OK");
303 
304  txMac->SendTxOpportunity(Seconds(1.650), (2 + 2 + 1 + 2) + (3 + 10 + 10 + 6));
305  CheckDataReceived(Seconds(1.700), "XYZABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
306 
307  Simulator::Run();
308  Simulator::Destroy();
309 }
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.
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: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 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:144
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.