A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("LteRlcAmTransmitterTest");
31 
32 using namespace ns3;
33 
34 
40  : TestSuite ("lte-rlc-am-transmitter", SYSTEM)
41 {
42  // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
43  // LogComponentEnable ("LteRlcAmTransmitterTest", logLevel);
44 
45  AddTestCase (new LteRlcAmTransmitterOneSduTestCase ("One SDU, one PDU"), TestCase::QUICK);
46  AddTestCase (new LteRlcAmTransmitterSegmentationTestCase ("Segmentation"), TestCase::QUICK);
47  AddTestCase (new LteRlcAmTransmitterConcatenationTestCase ("Concatenation"), TestCase::QUICK);
48  AddTestCase (new LteRlcAmTransmitterReportBufferStatusTestCase ("ReportBufferStatus primitive"), TestCase::QUICK);
49 
50 }
51 
53 
54 
56  : TestCase (name)
57 {
58 }
59 
61 {
62 }
63 
64 void
66 {
67  // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
68  // LogComponentEnable ("LteRlcAmTransmitterTest", logLevel);
69  // LogComponentEnable ("LteTestEntities", logLevel);
70  // LogComponentEnable ("LteRlc", logLevel);
71  // LogComponentEnable ("LteRlcAm", logLevel);
72  // LogComponentEnable ("LteRlcHeader", logLevel);
73 
74  uint16_t rnti = 1111;
75  uint8_t lcid = 222;
76 
77  Packet::EnablePrinting ();
78 
79  // Create topology
80 
81  // Create transmission PDCP test entity
82  txPdcp = CreateObject<LteTestPdcp> ();
83 
84  // Create transmission RLC entity
85  txRlc = CreateObject<LteRlcAm> ();
86  txRlc->SetRnti (rnti);
87  txRlc->SetLcId (lcid);
88 
89  // Create transmission MAC test entity
90  txMac = CreateObject<LteTestMac> ();
91  txMac->SetRlcHeaderType (LteTestMac::AM_RLC_HEADER);
92 
93  // Connect SAPs: PDCP (TX) <-> RLC (Tx) <-> MAC (Tx)
94  txPdcp->SetLteRlcSapProvider (txRlc->GetLteRlcSapProvider ());
95  txRlc->SetLteRlcSapUser (txPdcp->GetLteRlcSapUser ());
96 
97  txRlc->SetLteMacSapProvider (txMac->GetLteMacSapProvider ());
98  txMac->SetLteMacSapUser (txRlc->GetLteMacSapUser ());
99 
100 }
101 
102 void
103 LteRlcAmTransmitterTestCase::CheckDataReceived (Time time, std::string shouldReceived, std::string assertMsg)
104 {
105  Simulator::Schedule (time, &LteRlcAmTransmitterTestCase::DoCheckDataReceived, this, shouldReceived, assertMsg);
106 }
107 
108 void
109 LteRlcAmTransmitterTestCase::DoCheckDataReceived (std::string shouldReceived, std::string assertMsg)
110 {
111  NS_TEST_ASSERT_MSG_EQ (shouldReceived, txMac->GetDataReceived (), assertMsg);
112 }
113 
114 
120 {
121 }
122 
124 {
125 }
126 
127 void
129 {
130  // Create topology
132 
133  //
134  // a) One SDU generates one PDU
135  //
136 
137  // PDCP entity sends data
138  txPdcp->SendData (Seconds (0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
139 
140  txMac->SendTxOpportunity (Seconds (0.150), 30);
141  CheckDataReceived (Seconds (0.200), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
142 
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::Run ();
186  Simulator::Destroy ();
187 }
188 
194 {
195 }
196 
198 {
199 }
200 
201 void
203 {
204  // Create topology
206 
207  //
208  // c) Concatenation: n SDUs generate one PDU
209  //
210 
211  // PDCP entity sends three data packets
212  txPdcp->SendData (Seconds (0.100), "ABCDEFGH");
213  txPdcp->SendData (Seconds (0.150), "IJKLMNOPQR");
214  txPdcp->SendData (Seconds (0.200), "STUVWXYZ");
215 
216  // MAC entity sends TxOpp to RLC entity generating only one concatenated PDU
217 
218  txMac->SendTxOpportunity (Seconds (0.250), 33);
219  CheckDataReceived (Seconds (0.300), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "Concatenation is not OK");
220 
221  Simulator::Run ();
222  Simulator::Destroy ();
223 }
224 
230 {
231 }
232 
234 {
235 }
236 
237 void
239 {
240  // Create topology
242 
243  //
244  // d) Test the parameters of the ReportBufferStatus primitive
245  //
246 
247 // txMac->SendTxOpportunity (Seconds (0.1), (2+2) + (10+6));
248 
249  // PDCP entity sends data
250  txPdcp->SendData (Seconds (0.100), "ABCDEFGHIJ"); // 10
251  txPdcp->SendData (Seconds (0.150), "KLMNOPQRS"); // 9
252  txPdcp->SendData (Seconds (0.200), "TUVWXYZ"); // 7
253 
254  txMac->SendTxOpportunity (Seconds (0.250), (4+2) + (10+6));
255  CheckDataReceived (Seconds (0.300), "ABCDEFGHIJKLMNOP", "SDU #1 is not OK");
256 
257  txPdcp->SendData (Seconds (0.350), "ABCDEFGH"); // 8
258  txPdcp->SendData (Seconds (0.400), "IJKLMNOPQRST"); // 12
259  txPdcp->SendData (Seconds (0.450), "UVWXYZ"); // 6
260 
261  txMac->SendTxOpportunity (Seconds (0.500), 4 + 3);
262  CheckDataReceived (Seconds (0.550), "QRS", "SDU #2 is not OK");
263 
264  txPdcp->SendData (Seconds (0.600), "ABCDEFGH"); // 8
265  txPdcp->SendData (Seconds (0.650), "IJKLMNOPQRST"); // 12
266  txPdcp->SendData (Seconds (0.700), "UVWXYZ"); // 6
267 
268  txPdcp->SendData (Seconds (0.750), "ABCDEFGHIJ"); // 10
269  txPdcp->SendData (Seconds (0.800), "KLMNOPQRST"); // 10
270  txPdcp->SendData (Seconds (0.850), "UVWXYZ"); // 6
271 
272  txMac->SendTxOpportunity (Seconds (0.900), 4 + 7);
273  CheckDataReceived (Seconds (0.950), "TUVWXYZ", "SDU #3 is not OK");
274 
275  txMac->SendTxOpportunity (Seconds (1.000), (4+2) + (8+2));
276  CheckDataReceived (Seconds (1.050), "ABCDEFGHIJ", "SDU #4 is not OK");
277 
278  txPdcp->SendData (Seconds (1.100), "ABCDEFGHIJ"); // 10
279  txPdcp->SendData (Seconds (1.150), "KLMNOPQRSTU"); // 11
280  txPdcp->SendData (Seconds (1.200), "VWXYZ"); // 5
281 
282  txMac->SendTxOpportunity (Seconds (1.250), 4 + 3);
283  CheckDataReceived (Seconds (1.300), "KLM", "SDU #5 is not OK");
284 
285  txMac->SendTxOpportunity (Seconds (1.350), 4 + 3);
286  CheckDataReceived (Seconds (1.400), "NOP", "SDU #6 is not OK");
287 
288  txMac->SendTxOpportunity (Seconds (1.450), 4 + 4);
289  CheckDataReceived (Seconds (1.500), "QRST", "SDU #7 is not OK");
290 
291  txMac->SendTxOpportunity (Seconds (1.550), (4+2+1+2+1+2+1) + (6+8+12+6+10+10+3));
292  CheckDataReceived (Seconds (1.600), "UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW", "SDU #8 is not OK");
293 
294  txMac->SendTxOpportunity (Seconds (1.650), (4+2+1+2) + (3+10+10+7));
295  CheckDataReceived (Seconds (1.700), "XYZABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU #9 is not OK");
296 
297  Simulator::Run ();
298  Simulator::Destroy ();
299 }
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
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:1105
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:170
encapsulates test code
Definition: test.h:929
void SetRnti(uint16_t rnti)
Definition: lte-rlc.cc:125
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.
#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:148
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.
TestSuite 4.1.1 RLC AM: Only transmitter.
void DoCheckDataReceived(std::string shouldReceived, std::string assertMsg)
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:184
std::string GetDataReceived(void)
void SendTxOpportunity(Time, uint32_t)
virtual void DoRun(void)
Implementation to actually run this TestCase.
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.