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)
93  txPdcp->SetLteRlcSapProvider (txRlc->GetLteRlcSapProvider ());
94  txRlc->SetLteRlcSapUser (txPdcp->GetLteRlcSapUser ());
95 
96  txRlc->SetLteMacSapProvider (txMac->GetLteMacSapProvider ());
97  txMac->SetLteMacSapUser (txRlc->GetLteMacSapUser ());
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::Run ();
143  Simulator::Destroy ();
144 }
145 
151 {
152 }
153 
155 {
156 }
157 
158 void
160 {
161  // Create topology
163 
164  //
165  // b) Segmentation: one SDU generates n PDUs
166  //
167 
168  // PDCP entity sends data
169  txPdcp->SendData (Seconds (0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZZ");
170 
171  // MAC entity sends small TxOpp to RLC entity generating four segments
172  txMac->SendTxOpportunity (Seconds (0.150), 12);
173  CheckDataReceived (Seconds (0.200), "ABCDEFGH", "Segment #1 is not OK");
174 
175  txMac->SendTxOpportunity (Seconds (0.250), 12);
176  CheckDataReceived (Seconds (0.300), "IJKLMNOP", "Segment #2 is not OK");
177 
178  txMac->SendTxOpportunity (Seconds (0.350), 12);
179  CheckDataReceived (Seconds (0.400), "QRSTUVWX", "Segment #3 is not OK");
180 
181  txMac->SendTxOpportunity (Seconds (0.450), 7);
182  CheckDataReceived (Seconds (0.500), "YZZ", "Segment #4 is not OK");
183 
184  Simulator::Run ();
185  Simulator::Destroy ();
186 }
187 
193 {
194 }
195 
197 {
198 }
199 
200 void
202 {
203  // Create topology
205 
206  //
207  // c) Concatenation: n SDUs generate one PDU
208  //
209 
210  // PDCP entity sends three data packets
211  txPdcp->SendData (Seconds (0.100), "ABCDEFGH");
212  txPdcp->SendData (Seconds (0.150), "IJKLMNOPQR");
213  txPdcp->SendData (Seconds (0.200), "STUVWXYZ");
214 
215  // MAC entity sends TxOpp to RLC entity generating only one concatenated PDU
216 
217  txMac->SendTxOpportunity (Seconds (0.250), 33);
218  CheckDataReceived (Seconds (0.300), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "Concatenation is not OK");
219 
220  Simulator::Run ();
221  Simulator::Destroy ();
222 }
223 
229 {
230 }
231 
233 {
234 }
235 
236 void
238 {
239  // Create topology
241 
242  //
243  // d) Test the parameters of the ReportBufferStatus primitive
244  //
245 
246 // txMac->SendTxOpportunity (Seconds (0.1), (2+2) + (10+6));
247 
248  // PDCP entity sends data
249  txPdcp->SendData (Seconds (0.100), "ABCDEFGHIJ"); // 10
250  txPdcp->SendData (Seconds (0.150), "KLMNOPQRS"); // 9
251  txPdcp->SendData (Seconds (0.200), "TUVWXYZ"); // 7
252 
253  txMac->SendTxOpportunity (Seconds (0.250), (4+2) + (10+6));
254  CheckDataReceived (Seconds (0.300), "ABCDEFGHIJKLMNOP", "SDU #1 is not OK");
255 
256  txPdcp->SendData (Seconds (0.350), "ABCDEFGH"); // 8
257  txPdcp->SendData (Seconds (0.400), "IJKLMNOPQRST"); // 12
258  txPdcp->SendData (Seconds (0.450), "UVWXYZ"); // 6
259 
260  txMac->SendTxOpportunity (Seconds (0.500), 4 + 3);
261  CheckDataReceived (Seconds (0.550), "QRS", "SDU #2 is not OK");
262 
263  txPdcp->SendData (Seconds (0.600), "ABCDEFGH"); // 8
264  txPdcp->SendData (Seconds (0.650), "IJKLMNOPQRST"); // 12
265  txPdcp->SendData (Seconds (0.700), "UVWXYZ"); // 6
266 
267  txPdcp->SendData (Seconds (0.750), "ABCDEFGHIJ"); // 10
268  txPdcp->SendData (Seconds (0.800), "KLMNOPQRST"); // 10
269  txPdcp->SendData (Seconds (0.850), "UVWXYZ"); // 6
270 
271  txMac->SendTxOpportunity (Seconds (0.900), 4 + 7);
272  CheckDataReceived (Seconds (0.950), "TUVWXYZ", "SDU #3 is not OK");
273 
274  txMac->SendTxOpportunity (Seconds (1.000), (4+2) + (8+2));
275  CheckDataReceived (Seconds (1.050), "ABCDEFGHIJ", "SDU #4 is not OK");
276 
277  txPdcp->SendData (Seconds (1.100), "ABCDEFGHIJ"); // 10
278  txPdcp->SendData (Seconds (1.150), "KLMNOPQRSTU"); // 11
279  txPdcp->SendData (Seconds (1.200), "VWXYZ"); // 5
280 
281  txMac->SendTxOpportunity (Seconds (1.250), 4 + 3);
282  CheckDataReceived (Seconds (1.300), "KLM", "SDU #5 is not OK");
283 
284  txMac->SendTxOpportunity (Seconds (1.350), 4 + 3);
285  CheckDataReceived (Seconds (1.400), "NOP", "SDU #6 is not OK");
286 
287  txMac->SendTxOpportunity (Seconds (1.450), 4 + 4);
288  CheckDataReceived (Seconds (1.500), "QRST", "SDU #7 is not OK");
289 
290  txMac->SendTxOpportunity (Seconds (1.550), (4+2+1+2+1+2+1) + (6+8+12+6+10+10+3));
291  CheckDataReceived (Seconds (1.600), "UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW", "SDU #8 is not OK");
292 
293  txMac->SendTxOpportunity (Seconds (1.650), (4+2+1+2) + (3+10+10+7));
294  CheckDataReceived (Seconds (1.700), "XYZABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU #9 is not OK");
295 
296  Simulator::Run ();
297  Simulator::Destroy ();
298 }
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
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:1270
void CheckDataReceived(Time time, std::string shouldReceived, std::string assertMsg)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
encapsulates test code
Definition: test.h:1102
void SetRnti(uint16_t rnti)
Definition: lte-rlc.cc:126
Test 4.1.1.4 Report Buffer Status (test primitive parameters)
Test 4.1.1.2 Segmentation (One SDU => n PDUs)
void SetLteMacSapUser(LteMacSapUser *s)
Set the MAC SAP user.
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:184
#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:152
void SetLteRlcSapProvider(LteRlcSapProvider *s)
Set the RLC SAP provider.
Test 4.1.1.3 Concatenation (n SDUs => One PDU)
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.
void DoCheckDataReceived(std::string shouldReceived, std::string assertMsg)
std::string GetDataReceived(void)
void SendTxOpportunity(Time, uint32_t)
virtual void DoRun(void)
Implementation to actually run this TestCase.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:859
static LteRlcAmTransmitterTestSuite lteRlcAmTransmitterTestSuite
void SendData(Time time, std::string dataToSend)
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void SetRlcHeaderType(uint8_t rlcHeaderType)
virtual void DoRun(void)
Implementation to actually run this TestCase.
LteRlcSapUser * GetLteRlcSapUser(void)
Get the RLC SAP user.