A Discrete-Event Network Simulator
API
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 using namespace ns3;
31 
32 NS_LOG_COMPONENT_DEFINE ("LteRlcUmTransmitterTest");
33 
39  : TestSuite ("lte-rlc-um-transmitter", SYSTEM)
40 {
41  // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
42  // LogComponentEnable ("LteRlcUmTransmitterTest", logLevel);
43 
44  // NS_LOG_INFO ("Creating LteRlcUmTransmitterTestSuite");
45 
46  AddTestCase (new LteRlcUmTransmitterOneSduTestCase ("One SDU, one PDU"), TestCase::QUICK);
47  AddTestCase (new LteRlcUmTransmitterSegmentationTestCase ("Segmentation"), TestCase::QUICK);
48  AddTestCase (new LteRlcUmTransmitterConcatenationTestCase ("Concatenation"), TestCase::QUICK);
49  AddTestCase (new LteRlcUmTransmitterReportBufferStatusTestCase ("ReportBufferStatus primitive"), TestCase::QUICK);
50 
51 }
52 
54 
55 
57  : TestCase (name)
58 {
59  // NS_LOG_UNCOND ("Creating LteRlcUmTransmitterTestCase: " + name);
60 }
61 
63 {
64 }
65 
66 void
68 {
69  // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
70  // LogComponentEnable ("LteRlcUmTransmitterTest", logLevel);
71  // LogComponentEnable ("LteTestEntities", logLevel);
72  // LogComponentEnable ("LteRlc", logLevel);
73  // LogComponentEnable ("LteRlcUm", logLevel);
74  // LogComponentEnable ("LteRlcHeader", logLevel);
75 
76  uint16_t rnti = 1111;
77  uint8_t lcid = 222;
78 
79  Packet::EnablePrinting ();
80 
81  // Create topology
82 
83  // Create transmission PDCP test entity
84  txPdcp = CreateObject<LteTestPdcp> ();
85 
86  // Create transmission RLC entity
87  txRlc = CreateObject<LteRlcUm> ();
88  txRlc->SetRnti (rnti);
89  txRlc->SetLcId (lcid);
90 
91  // Create transmission MAC test entity
92  txMac = CreateObject<LteTestMac> ();
93  txMac->SetRlcHeaderType (LteTestMac::UM_RLC_HEADER);
94 
95  // Connect SAPs: PDCP (TX) <-> RLC (Tx) <-> MAC (Tx)
98 
101 
102 }
103 
104 void
105 LteRlcUmTransmitterTestCase::CheckDataReceived (Time time, std::string shouldReceived, std::string assertMsg)
106 {
107  Simulator::Schedule (time, &LteRlcUmTransmitterTestCase::DoCheckDataReceived, this, shouldReceived, assertMsg);
108 }
109 
110 void
111 LteRlcUmTransmitterTestCase::DoCheckDataReceived (std::string shouldReceived, std::string assertMsg)
112 {
113  NS_TEST_ASSERT_MSG_EQ (shouldReceived, txMac->GetDataReceived (), assertMsg);
114 }
115 
116 
122 {
123 }
124 
126 {
127 }
128 
129 void
131 {
132  // Create topology
134 
135  //
136  // a) One SDU generates one PDU
137  //
138 
139  // PDCP entity sends data
140  txPdcp->SendData (Seconds (0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
141 
142  // MAC entity sends TxOpp to RLC entity
143  txMac->SendTxOpportunity (Seconds (0.150), 28);
144  CheckDataReceived (Seconds (0.200), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
145 
146  Simulator::Run ();
147  Simulator::Destroy ();
148 }
149 
155 {
156 }
157 
159 {
160 }
161 
162 void
164 {
165  // Create topology
167 
168  //
169  // b) Segmentation: one SDU generates n PDUs
170  //
171 
172  // PDCP entity sends data
173  txPdcp->SendData (Seconds (0.100), "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
174 
175  // MAC entity sends small TxOpp to RLC entity generating four segments
176  txMac->SendTxOpportunity (Seconds (0.150), 10);
177  CheckDataReceived (Seconds (0.200), "ABCDEFGH", "Segment #1 is not OK");
178 
179  txMac->SendTxOpportunity (Seconds (0.200), 10);
180  CheckDataReceived (Seconds (0.250), "IJKLMNOP", "Segment #2 is not OK");
181 
182  txMac->SendTxOpportunity (Seconds (0.300), 10);
183  CheckDataReceived (Seconds (0.350), "QRSTUVWX", "Segment #3 is not OK");
184 
185  txMac->SendTxOpportunity (Seconds (0.400), 4);
186  CheckDataReceived (Seconds (0.450), "YZ", "Segment #4 is not OK");
187 
188  Simulator::Run ();
189  Simulator::Destroy ();
190 }
191 
197 {
198 }
199 
201 {
202 }
203 
204 void
206 {
207  // Create topology
209 
210  //
211  // c) Concatenation: n SDUs generate one PDU
212  //
213 
214  // PDCP entity sends three data packets
215  txPdcp->SendData (Seconds (0.100), "ABCDEFGH");
216  txPdcp->SendData (Seconds (0.150), "IJKLMNOPQR");
217  txPdcp->SendData (Seconds (0.200), "STUVWXYZ");
218 
219  // MAC entity sends TxOpp to RLC entity generating only one concatenated PDU
220  txMac->SendTxOpportunity (Seconds (0.250), 31);
221  CheckDataReceived (Seconds (0.300), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "Concatenation is not OK");
222 
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  // 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), (2+2) + (10+6));
255  CheckDataReceived (Seconds (0.300), "ABCDEFGHIJKLMNOP", "SDU 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), 2 + 3);
262  CheckDataReceived (Seconds (0.550), "QRS", "SDU 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), 2 + 7);
273  CheckDataReceived (Seconds (0.950), "TUVWXYZ", "SDU is not OK");
274 
275  txMac->SendTxOpportunity (Seconds (1.000), (2+2) + (8+2));
276  CheckDataReceived (Seconds (1.050), "ABCDEFGHIJ", "SDU is not OK");
277 
278  txPdcp->SendData (Seconds (1.100), "ABCDEFGHIJ"); // 10
279  txPdcp->SendData (Seconds (1.150), "KLMNOPQRST"); // 10
280  txPdcp->SendData (Seconds (1.200), "UVWXYZ"); // 6
281 
282  txMac->SendTxOpportunity (Seconds (1.250), 2 + 2);
283  CheckDataReceived (Seconds (1.300), "KL", "SDU is not OK");
284 
285  txMac->SendTxOpportunity (Seconds (1.350), 2 + 3);
286  CheckDataReceived (Seconds (1.400), "MNO", "SDU is not OK");
287 
288  txMac->SendTxOpportunity (Seconds (1.450), 2 + 5);
289  CheckDataReceived (Seconds (1.500), "PQRST", "SDU is not OK");
290 
291  txMac->SendTxOpportunity (Seconds (1.550), (2+2+1+2+1+2+1) + (6+8+12+6+10+10+3));
292  CheckDataReceived (Seconds (1.600), "UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW", "SDU is not OK");
293 
294  txMac->SendTxOpportunity (Seconds (1.650), (2+2+1+2) + (3+10+10+6));
295  CheckDataReceived (Seconds (1.700), "XYZABCDEFGHIJKLMNOPQRSTUVWXYZ", "SDU is not OK");
296 
297  Simulator::Run ();
298  Simulator::Destroy ();
299 }
virtual void DoRun(void)
Implementation to actually run this TestCase.
Test 4.1.1.4 Report Buffer Status (test primitive parameters)
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
static LteRlcUmTransmitterTestSuite lteRlcUmTransmitterTestSuite
Test case used by LteRlcUmTransmitterOneSduTestCase to create topology and to implement functionaliti...
A suite of tests to run.
Definition: test.h:1342
Test 4.1.1.2 Segmentation (One SDU => n PDUs)
#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.3 Concatenation (n SDUs => One PDU)
void SendTxOpportunity(Time time, uint32_t bytes)
Send transmit opportunity function.
void SetLteMacSapUser(LteMacSapUser *s)
Set the MAC SAP user.
void DoCheckDataReceived(std::string shouldReceived, std::string assertMsg)
Check data received function.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
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:168
void SetLteRlcSapProvider(LteRlcSapProvider *s)
Set the RLC SAP provider.
void CheckDataReceived(Time time, std::string shouldReceived, std::string assertMsg)
Check data received function.
LteMacSapUser * GetLteMacSapUser()
Definition: lte-rlc.cc:166
LteRlcUmTransmitterTestSuite()
TestSuite 4.1.1 RLC UM: Only transmitter.
LteMacSapProvider * GetLteMacSapProvider(void)
Get the MAC SAP provider.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetLteRlcSapUser(LteRlcSapUser *s)
Definition: lte-rlc.cc:145
Ptr< LteTestPdcp > txPdcp
the transmit PDCP
virtual void DoRun(void)
Implementation to actually run this TestCase.
TestSuite 4.1.1 for RLC UM: Only transmitter part.
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
void SendData(Time time, std::string dataToSend)
Send data function.
LteRlcSapProvider * GetLteRlcSapProvider()
Definition: lte-rlc.cc:152
void SetLteMacSapProvider(LteMacSapProvider *s)
Definition: lte-rlc.cc:159
void SetRlcHeaderType(uint8_t rlcHeaderType)
Set RLC header type.
LteRlcSapUser * GetLteRlcSapUser(void)
Get the RLC SAP user.