A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
lte-test-rlc-um-transmitter.cc
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-um.h"
26 
27 #include "lte-test-rlc-um-transmitter.h"
28 #include "lte-test-entities.h"
29 
30 NS_LOG_COMPONENT_DEFINE ("LteRlcUmTransmitterTest");
31 
32 namespace ns3 {
33 
34 
40  : TestSuite ("lte-rlc-um-transmitter", SYSTEM)
41 {
42  // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
43  // LogComponentEnable ("LteRlcUmTransmitterTest", logLevel);
44 
45  // NS_LOG_INFO ("Creating LteRlcUmTransmitterTestSuite");
46 
47  AddTestCase (new LteRlcUmTransmitterOneSduTestCase ("One SDU, one PDU"), TestCase::QUICK);
48  AddTestCase (new LteRlcUmTransmitterSegmentationTestCase ("Segmentation"), TestCase::QUICK);
49  AddTestCase (new LteRlcUmTransmitterConcatenationTestCase ("Concatenation"), TestCase::QUICK);
50  AddTestCase (new LteRlcUmTransmitterReportBufferStatusTestCase ("ReportBufferStatus primitive"), TestCase::QUICK);
51 
52 }
53 
54 static LteRlcUmTransmitterTestSuite lteRlcUmTransmitterTestSuite;
55 
56 
57 LteRlcUmTransmitterTestCase::LteRlcUmTransmitterTestCase (std::string name)
58  : TestCase (name)
59 {
60  // NS_LOG_UNCOND ("Creating LteRlcUmTransmitterTestCase: " + name);
61 }
62 
63 LteRlcUmTransmitterTestCase::~LteRlcUmTransmitterTestCase ()
64 {
65 }
66 
67 void
69 {
70  // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
71  // LogComponentEnable ("LteRlcUmTransmitterTest", logLevel);
72  // LogComponentEnable ("LteTestEntities", logLevel);
73  // LogComponentEnable ("LteRlc", logLevel);
74  // LogComponentEnable ("LteRlcUm", logLevel);
75  // LogComponentEnable ("LteRlcHeader", logLevel);
76 
77  uint16_t rnti = 1111;
78  uint8_t lcid = 222;
79 
81 
82  // Create topology
83 
84  // Create transmission PDCP test entity
85  txPdcp = CreateObject<LteTestPdcp> ();
86 
87  // Create transmission RLC entity
88  txRlc = CreateObject<LteRlcUm> ();
89  txRlc->SetRnti (rnti);
90  txRlc->SetLcId (lcid);
91 
92  // Create transmission MAC test entity
93  txMac = CreateObject<LteTestMac> ();
94  txMac->SetRlcHeaderType (LteTestMac::UM_RLC_HEADER);
95 
96  // Connect SAPs: PDCP (TX) <-> RLC (Tx) <-> MAC (Tx)
97  txPdcp->SetLteRlcSapProvider (txRlc->GetLteRlcSapProvider ());
98  txRlc->SetLteRlcSapUser (txPdcp->GetLteRlcSapUser ());
99 
100  txRlc->SetLteMacSapProvider (txMac->GetLteMacSapProvider ());
101  txMac->SetLteMacSapUser (txRlc->GetLteMacSapUser ());
102 
103 }
104 
105 void
106 LteRlcUmTransmitterTestCase::CheckDataReceived (Time time, std::string shouldReceived, std::string assertMsg)
107 {
108  Simulator::Schedule (time, &LteRlcUmTransmitterTestCase::DoCheckDataReceived, this, shouldReceived, assertMsg);
109 }
110 
111 void
112 LteRlcUmTransmitterTestCase::DoCheckDataReceived (std::string shouldReceived, std::string assertMsg)
113 {
114  NS_TEST_ASSERT_MSG_EQ (shouldReceived, txMac->GetDataReceived (), assertMsg);
115 }
116 
117 
121 LteRlcUmTransmitterOneSduTestCase::LteRlcUmTransmitterOneSduTestCase (std::string name)
123 {
124 }
125 
126 LteRlcUmTransmitterOneSduTestCase::~LteRlcUmTransmitterOneSduTestCase ()
127 {
128 }
129 
130 void
132 {
133  // Create topology
135 
136  //
137  // a) One SDU generates one PDU
138  //
139 
140  // PDCP entity sends data
141  txPdcp->SendData (Seconds (0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
142 
143  // MAC entity sends TxOpp to RLC entity
144  txMac->SendTxOpportunity (Seconds (0.150), 28);
145  CheckDataReceived (Seconds (0.200), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
146 
147  Simulator::Run ();
149 }
150 
154 LteRlcUmTransmitterSegmentationTestCase::LteRlcUmTransmitterSegmentationTestCase (std::string name)
156 {
157 }
158 
159 LteRlcUmTransmitterSegmentationTestCase::~LteRlcUmTransmitterSegmentationTestCase ()
160 {
161 }
162 
163 void
165 {
166  // Create topology
168 
169  //
170  // b) Segmentation: one SDU generates n PDUs
171  //
172 
173  // PDCP entity sends data
174  txPdcp->SendData (Seconds (0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
175 
176  // MAC entity sends small TxOpp to RLC entity generating four segments
177  txMac->SendTxOpportunity (Seconds (0.150), 10);
178  CheckDataReceived (Seconds (0.200), "ABCDEFGH", "Segment #1 is not OK");
179 
180  txMac->SendTxOpportunity (Seconds (0.200), 10);
181  CheckDataReceived (Seconds (0.250), "IJKLMNOP", "Segment #2 is not OK");
182 
183  txMac->SendTxOpportunity (Seconds (0.300), 10);
184  CheckDataReceived (Seconds (0.350), "QRSTUVWX", "Segment #3 is not OK");
185 
186  txMac->SendTxOpportunity (Seconds (0.400), 4);
187  CheckDataReceived (Seconds (0.450), "YZ", "Segment #4 is not OK");
188 
189  Simulator::Run ();
191 }
192 
196 LteRlcUmTransmitterConcatenationTestCase::LteRlcUmTransmitterConcatenationTestCase (std::string name)
198 {
199 }
200 
201 LteRlcUmTransmitterConcatenationTestCase::~LteRlcUmTransmitterConcatenationTestCase ()
202 {
203 }
204 
205 void
207 {
208  // Create topology
210 
211  //
212  // c) Concatenation: n SDUs generate one PDU
213  //
214 
215  // PDCP entity sends three data packets
216  txPdcp->SendData (Seconds (0.100), "ABCDEFGH");
217  txPdcp->SendData (Seconds (0.150), "IJKLMNOPQR");
218  txPdcp->SendData (Seconds (0.200), "STUVWXYZ");
219 
220  // MAC entity sends TxOpp to RLC entity generating only one concatenated PDU
221  txMac->SendTxOpportunity (Seconds (0.250), 31);
222  CheckDataReceived (Seconds (0.300), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "Concatenation is not OK");
223 
224  Simulator::Run ();
226 }
227 
231 LteRlcUmTransmitterReportBufferStatusTestCase::LteRlcUmTransmitterReportBufferStatusTestCase (std::string name)
233 {
234 }
235 
236 LteRlcUmTransmitterReportBufferStatusTestCase::~LteRlcUmTransmitterReportBufferStatusTestCase ()
237 {
238 }
239 
240 void
242 {
243  // Create topology
245 
246  //
247  // d) Test the parameters of the ReportBufferStatus primitive
248  //
249 
250  // PDCP entity sends data
251  txPdcp->SendData (Seconds (0.100), "ABCDEFGHIJ"); // 10
252  txPdcp->SendData (Seconds (0.150), "KLMNOPQRS"); // 9
253  txPdcp->SendData (Seconds (0.200), "TUVWXYZ"); // 7
254 
255  txMac->SendTxOpportunity (Seconds (0.250), (2+2) + (10+6));
256  CheckDataReceived (Seconds (0.300), "ABCDEFGHIJKLMNOP", "SDU is not OK");
257 
258  txPdcp->SendData (Seconds (0.350), "ABCDEFGH"); // 8
259  txPdcp->SendData (Seconds (0.400), "IJKLMNOPQRST"); // 12
260  txPdcp->SendData (Seconds (0.450), "UVWXYZ"); // 6
261 
262  txMac->SendTxOpportunity (Seconds (0.500), 2 + 3);
263  CheckDataReceived (Seconds (0.550), "QRS", "SDU is not OK");
264 
265  txPdcp->SendData (Seconds (0.600), "ABCDEFGH"); // 8
266  txPdcp->SendData (Seconds (0.650), "IJKLMNOPQRST"); // 12
267  txPdcp->SendData (Seconds (0.700), "UVWXYZ"); // 6
268 
269  txPdcp->SendData (Seconds (0.750), "ABCDEFGHIJ"); // 10
270  txPdcp->SendData (Seconds (0.800), "KLMNOPQRST"); // 10
271  txPdcp->SendData (Seconds (0.850), "UVWXYZ"); // 6
272 
273  txMac->SendTxOpportunity (Seconds (0.900), 2 + 7);
274  CheckDataReceived (Seconds (0.950), "TUVWXYZ", "SDU is not OK");
275 
276  txMac->SendTxOpportunity (Seconds (1.000), (2+2) + (8+2));
277  CheckDataReceived (Seconds (1.050), "ABCDEFGHIJ", "SDU is not OK");
278 
279  txPdcp->SendData (Seconds (1.100), "ABCDEFGHIJ"); // 10
280  txPdcp->SendData (Seconds (1.150), "KLMNOPQRST"); // 10
281  txPdcp->SendData (Seconds (1.200), "UVWXYZ"); // 6
282 
283  txMac->SendTxOpportunity (Seconds (1.250), 2 + 2);
284  CheckDataReceived (Seconds (1.300), "KL", "SDU is not OK");
285 
286  txMac->SendTxOpportunity (Seconds (1.350), 2 + 3);
287  CheckDataReceived (Seconds (1.400), "MNO", "SDU is not OK");
288 
289  txMac->SendTxOpportunity (Seconds (1.450), 2 + 5);
290  CheckDataReceived (Seconds (1.500), "PQRST", "SDU is not OK");
291 
292  txMac->SendTxOpportunity (Seconds (1.550), (2+2+1+2+1+2+1) + (6+8+12+6+10+10+3));
293  CheckDataReceived (Seconds (1.600), "UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW", "SDU is not OK");
294 
295  txMac->SendTxOpportunity (Seconds (1.650), (2+2+1+2) + (3+10+10+6));
296  CheckDataReceived (Seconds (1.700), "XYZABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
297 
298  Simulator::Run ();
300 }
301 
302 } // namespace ns3
303 
304 
keep track of time unit.
Definition: nstime.h:149
A suite of tests to run.
Definition: test.h:962
virtual void DoRun(void)
Implementation to actually run this test case.
static void Run(void)
Definition: simulator.cc:157
virtual void DoRun(void)
Implementation to actually run this test case.
#define NS_LOG_COMPONENT_DEFINE(name)
Definition: log.h:122
encapsulates test code
Definition: test.h:834
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Definition: simulator.h:820
static void EnablePrinting(void)
Definition: packet.cc:575
static void Destroy(void)
Definition: simulator.cc:121
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
Definition: test.cc:172
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Definition: nstime.h:586
virtual void DoRun(void)
Implementation to actually run this test case.
virtual void DoRun(void)
Implementation to actually run this test case.
virtual void DoRun(void)
Implementation to actually run this test case.