A Discrete-Event Network Simulator
API
lte-test-rlc-am-transmitter.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Manuel Requena <manuel.requena@cttc.es>
19  */
20 
21 #include "ns3/simulator.h"
22 #include "ns3/log.h"
23 
24 #include "ns3/lte-rlc-header.h"
25 #include "ns3/lte-rlc-am.h"
26 
28 #include "lte-test-entities.h"
29 
30 using namespace ns3;
31 
32 NS_LOG_COMPONENT_DEFINE ("LteRlcAmTransmitterTest");
33 
39  : TestSuite ("lte-rlc-am-transmitter", SYSTEM)
40 {
41  // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
42  // LogComponentEnable ("LteRlcAmTransmitterTest", logLevel);
43 
44  AddTestCase (new LteRlcAmTransmitterOneSduTestCase ("One SDU, one PDU"), TestCase::QUICK);
45  AddTestCase (new LteRlcAmTransmitterSegmentationTestCase ("Segmentation"), TestCase::QUICK);
46  AddTestCase (new LteRlcAmTransmitterConcatenationTestCase ("Concatenation"), TestCase::QUICK);
47  AddTestCase (new LteRlcAmTransmitterReportBufferStatusTestCase ("ReportBufferStatus primitive"), TestCase::QUICK);
48 
49 }
50 
52 
53 
55  : TestCase (name)
56 {
57 }
58 
60 {
61 }
62 
63 void
65 {
66  // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
67  // LogComponentEnable ("LteRlcAmTransmitterTest", logLevel);
68  // LogComponentEnable ("LteTestEntities", logLevel);
69  // LogComponentEnable ("LteRlc", logLevel);
70  // LogComponentEnable ("LteRlcAm", logLevel);
71  // LogComponentEnable ("LteRlcHeader", logLevel);
72 
73  uint16_t rnti = 1111;
74  uint8_t lcid = 222;
75 
76  Packet::EnablePrinting ();
77 
78  // Create topology
79 
80  // Create transmission PDCP test entity
81  txPdcp = CreateObject<LteTestPdcp> ();
82 
83  // Create transmission RLC entity
84  txRlc = CreateObject<LteRlcAm> ();
85  txRlc->SetRnti (rnti);
86  txRlc->SetLcId (lcid);
87 
88  // Create transmission MAC test entity
89  txMac = CreateObject<LteTestMac> ();
90  txMac->SetRlcHeaderType (LteTestMac::AM_RLC_HEADER);
91 
92  // Connect SAPs: PDCP (TX) <-> RLC (Tx) <-> MAC (Tx)
95 
98 
99 }
100 
101 void
102 LteRlcAmTransmitterTestCase::CheckDataReceived (Time time, std::string shouldReceived, std::string assertMsg)
103 {
104  Simulator::Schedule (time, &LteRlcAmTransmitterTestCase::DoCheckDataReceived, this, shouldReceived, assertMsg);
105 }
106 
107 void
108 LteRlcAmTransmitterTestCase::DoCheckDataReceived (std::string shouldReceived, std::string assertMsg)
109 {
110  NS_TEST_ASSERT_MSG_EQ (shouldReceived, txMac->GetDataReceived (), assertMsg);
111 }
112 
113 
119 {
120 }
121 
123 {
124 }
125 
126 void
128 {
129  // Create topology
131 
132  //
133  // a) One SDU generates one PDU
134  //
135 
136  // PDCP entity sends data
137  txPdcp->SendData (Seconds (0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
138 
139  txMac->SendTxOpportunity (Seconds (0.150), 30);
140  CheckDataReceived (Seconds (0.200), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
141 
142  Simulator::Stop (Seconds (0.3));
143  Simulator::Run ();
144  Simulator::Destroy ();
145 }
146 
152 {
153 }
154 
156 {
157 }
158 
159 void
161 {
162  // Create topology
164 
165  //
166  // b) Segmentation: one SDU generates n PDUs
167  //
168 
169  // PDCP entity sends data
170  txPdcp->SendData (Seconds (0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZZ");
171 
172  // MAC entity sends small TxOpp to RLC entity generating four segments
173  txMac->SendTxOpportunity (Seconds (0.150), 12);
174  CheckDataReceived (Seconds (0.200), "ABCDEFGH", "Segment #1 is not OK");
175 
176  txMac->SendTxOpportunity (Seconds (0.250), 12);
177  CheckDataReceived (Seconds (0.300), "IJKLMNOP", "Segment #2 is not OK");
178 
179  txMac->SendTxOpportunity (Seconds (0.350), 12);
180  CheckDataReceived (Seconds (0.400), "QRSTUVWX", "Segment #3 is not OK");
181 
182  txMac->SendTxOpportunity (Seconds (0.450), 7);
183  CheckDataReceived (Seconds (0.500), "YZZ", "Segment #4 is not OK");
184 
185  Simulator::Stop (Seconds (0.6));
186  Simulator::Run ();
187  Simulator::Destroy ();
188 }
189 
195 {
196 }
197 
199 {
200 }
201 
202 void
204 {
205  // Create topology
207 
208  //
209  // c) Concatenation: n SDUs generate one PDU
210  //
211 
212  // PDCP entity sends three data packets
213  txPdcp->SendData (Seconds (0.100), "ABCDEFGH");
214  txPdcp->SendData (Seconds (0.150), "IJKLMNOPQR");
215  txPdcp->SendData (Seconds (0.200), "STUVWXYZ");
216 
217  // MAC entity sends TxOpp to RLC entity generating only one concatenated PDU
218 
219  txMac->SendTxOpportunity (Seconds (0.250), 33);
220  CheckDataReceived (Seconds (0.300), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "Concatenation is not OK");
221 
222  Simulator::Stop (Seconds (0.4));
223  Simulator::Run ();
224  Simulator::Destroy ();
225 }
226 
232 {
233 }
234 
236 {
237 }
238 
239 void
241 {
242  // Create topology
244 
245  //
246  // d) Test the parameters of the ReportBufferStatus primitive
247  //
248 
249 // txMac->SendTxOpportunity (Seconds (0.1), (2+2) + (10+6));
250 
251  // PDCP entity sends data
252  txPdcp->SendData (Seconds (0.100), "ABCDEFGHIJ"); // 10
253  txPdcp->SendData (Seconds (0.150), "KLMNOPQRS"); // 9
254  txPdcp->SendData (Seconds (0.200), "TUVWXYZ"); // 7
255 
256  txMac->SendTxOpportunity (Seconds (0.250), (4+2) + (10+6));
257  CheckDataReceived (Seconds (0.300), "ABCDEFGHIJKLMNOP", "SDU #1 is not OK");
258 
259  txPdcp->SendData (Seconds (0.350), "ABCDEFGH"); // 8
260  txPdcp->SendData (Seconds (0.400), "IJKLMNOPQRST"); // 12
261  txPdcp->SendData (Seconds (0.450), "UVWXYZ"); // 6
262 
263  txMac->SendTxOpportunity (Seconds (0.500), 4 + 3);
264  CheckDataReceived (Seconds (0.550), "QRS", "SDU #2 is not OK");
265 
266  txPdcp->SendData (Seconds (0.600), "ABCDEFGH"); // 8
267  txPdcp->SendData (Seconds (0.650), "IJKLMNOPQRST"); // 12
268  txPdcp->SendData (Seconds (0.700), "UVWXYZ"); // 6
269 
270  txPdcp->SendData (Seconds (0.750), "ABCDEFGHIJ"); // 10
271  txPdcp->SendData (Seconds (0.800), "KLMNOPQRST"); // 10
272  txPdcp->SendData (Seconds (0.850), "UVWXYZ"); // 6
273 
274  txMac->SendTxOpportunity (Seconds (0.900), 4 + 7);
275  CheckDataReceived (Seconds (0.950), "TUVWXYZ", "SDU #3 is not OK");
276 
277  txMac->SendTxOpportunity (Seconds (1.000), (4+2) + (8+2));
278  CheckDataReceived (Seconds (1.050), "ABCDEFGHIJ", "SDU #4 is not OK");
279 
280  txPdcp->SendData (Seconds (1.100), "ABCDEFGHIJ"); // 10
281  txPdcp->SendData (Seconds (1.150), "KLMNOPQRSTU"); // 11
282  txPdcp->SendData (Seconds (1.200), "VWXYZ"); // 5
283 
284  txMac->SendTxOpportunity (Seconds (1.250), 4 + 3);
285  CheckDataReceived (Seconds (1.300), "KLM", "SDU #5 is not OK");
286 
287  txMac->SendTxOpportunity (Seconds (1.350), 4 + 3);
288  CheckDataReceived (Seconds (1.400), "NOP", "SDU #6 is not OK");
289 
290  txMac->SendTxOpportunity (Seconds (1.450), 4 + 4);
291  CheckDataReceived (Seconds (1.500), "QRST", "SDU #7 is not OK");
292 
293  txMac->SendTxOpportunity (Seconds (1.550), (4+2+1+2+1+2+1) + (6+8+12+6+10+10+3));
294  CheckDataReceived (Seconds (1.600), "UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW", "SDU #8 is not OK");
295 
296  txMac->SendTxOpportunity (Seconds (1.650), (4+2+1+2) + (3+10+10+7));
297  CheckDataReceived (Seconds (1.700), "XYZABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU #9 is not OK");
298 
299  Simulator::Stop (Seconds (2));
300  Simulator::Run ();
301  Simulator::Destroy ();
302 }
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
LteRlcAmTransmitterTestSuite()
TestSuite 4.1.1 RLC AM: Only transmitter.
virtual void DoRun(void)
Implementation to actually run this TestCase.
A suite of tests to run.
Definition: test.h:1342
void CheckDataReceived(Time time, std::string shouldReceived, std::string assertMsg)
Check data received function.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
encapsulates test code
Definition: test.h:1155
void SetRnti(uint16_t rnti)
Definition: lte-rlc.cc:131
Test 4.1.1.4 Test checks functionality of Report Buffer Status by testing primitive parameters...
Test case used by LteRlcAmTransmitterOneSduTestCase to create topology and to implement functionaliti...
Test 4.1.1.2 Test the correct functionality of the Segmentation.
void SendTxOpportunity(Time time, uint32_t bytes)
Send transmit opportunity function.
Ptr< LteTestPdcp > txPdcp
the transmit PDCP
void SetLteMacSapUser(LteMacSapUser *s)
Set the MAC SAP user.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
#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:168
void SetLteRlcSapProvider(LteRlcSapProvider *s)
Set the RLC SAP provider.
Test 4.1.1.1 Test that SDU transmitted at PDCP corresponds to PDU received by MAC.
Test 4.1.1.3 Test that concatenation functionality works properly.
LteMacSapUser * GetLteMacSapUser()
Definition: lte-rlc.cc:166
LteMacSapProvider * GetLteMacSapProvider(void)
Get the MAC SAP provider.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TestSuite 4.1.1 RLC AM: Only transmitter functionality.
void SetLteRlcSapUser(LteRlcSapUser *s)
Definition: lte-rlc.cc:145
void DoCheckDataReceived(std::string shouldReceived, std::string assertMsg)
Check data received function.
void SetLcId(uint8_t lcId)
Definition: lte-rlc.cc:138
std::string GetDataReceived(void)
Get data received function.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1014
static LteRlcAmTransmitterTestSuite lteRlcAmTransmitterTestSuite
void SendData(Time time, std::string dataToSend)
Send data function.
LteRlcSapProvider * GetLteRlcSapProvider()
Definition: lte-rlc.cc:152
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void SetLteMacSapProvider(LteMacSapProvider *s)
Definition: lte-rlc.cc:159
void SetRlcHeaderType(uint8_t rlcHeaderType)
Set RLC header type.
virtual void DoRun(void)
Implementation to actually run this TestCase.
LteRlcSapUser * GetLteRlcSapUser(void)
Get the RLC SAP user.