A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lte-test-rlc-um-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-um.h"
26 
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 
50  AddTestCase (new LteRlcUmTransmitterReportBufferStatusTestCase ("ReportBufferStatus primitive"), TestCase::QUICK);
51 
52 }
53 
55 
56 
58  : TestCase (name)
59 {
60  // NS_LOG_UNCOND ("Creating LteRlcUmTransmitterTestCase: " + name);
61 }
62 
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 
123 {
124 }
125 
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 
156 {
157 }
158 
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 
198 {
199 }
200 
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 
233 {
234 }
235 
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 values and allow control of global simulation resolution
Definition: nstime.h:81
A suite of tests to run.
Definition: test.h:1025
virtual void DoRun(void)
Implementation to actually run this TestCase.
static void Run(void)
Run the simulation until one of:
Definition: simulator.cc:157
virtual void DoRun(void)
Implementation to actually run this TestCase.
LteRlcUmTransmitterTestSuite()
TestSuite 4.1.1 RLC UM: Only transmitter.
encapsulates test code
Definition: test.h:849
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Definition: simulator.h:824
Test 4.1.1.4 Report Buffer Status (test primitive parameters)
void CheckDataReceived(Time time, std::string shouldReceived, std::string assertMsg)
static void EnablePrinting(void)
By default, packets do not keep around enough metadata to perform the operations requested by the Pri...
Definition: packet.cc:552
TestSuite 4.1.1 RLC UM: Only transmitter.
static void Destroy(void)
Every event scheduled by the Simulator::insertAtDestroy method is invoked.
Definition: simulator.cc:121
Test 4.1.1.3 Concatenation (n SDUs => One PDU)
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:173
Fast test.
Definition: test.h:857
NS_LOG_COMPONENT_DEFINE("LteRlcUmTransmitterTest")
static LteRlcUmTransmitterTestSuite lteRlcUmTransmitterTestSuite
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Test 4.1.1.2 Segmentation (One SDU => n PDUs)
void DoCheckDataReceived(std::string shouldReceived, std::string assertMsg)
virtual void DoRun(void)
Implementation to actually run this TestCase.
#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:137