A Discrete-Event Network Simulator
API
lte-test-rlc-um-e2e.cc
Go to the documentation of this file.
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2012 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/config.h"
22#include "ns3/simulator.h"
23#include "ns3/pointer.h"
24#include "ns3/log.h"
25#include "ns3/packet.h"
26#include "ns3/node-container.h"
27#include "ns3/net-device-container.h"
28#include "ns3/error-model.h"
29#include "ns3/rng-seed-manager.h"
30#include "ns3/radio-bearer-stats-calculator.h"
31#include "ns3/lte-rlc-header.h"
32#include "ns3/lte-rlc-um.h"
33
34#include "lte-simple-helper.h"
35#include "lte-test-entities.h"
36#include "lte-test-rlc-um-e2e.h"
37
38
39using namespace ns3;
40
41NS_LOG_COMPONENT_DEFINE ("LteRlcUmE2eTest");
42
52 : TestSuite ("lte-rlc-um-e2e", SYSTEM)
53{
54 // NS_LOG_INFO ("Creating LteRlcUmE2eTestSuite");
55
56 double losses[] = {0.0, 0.10, 0.25, 0.50, 0.75, 0.90, 1.00};
57 uint32_t seeds[] = {1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 10101};
58
59 for ( uint32_t l = 0 ; l < (sizeof (losses) / sizeof (double)) ; l++ )
60 {
61 for ( uint32_t s = 0 ; s < (sizeof (seeds) / sizeof (uint32_t)) ; s++ )
62 {
63 std::ostringstream name;
64 name << " Losses = " << losses[l] << "%. Seed = " << seeds[s];
65 TestCase::TestDuration testDuration;
66 if (l == 1 && s == 0)
67 {
68 testDuration = TestCase::QUICK;
69 }
70 else
71 {
72 testDuration = TestCase::EXTENSIVE;
73 }
74 AddTestCase (new LteRlcUmE2eTestCase (name.str (), seeds[s], losses[l]), testDuration);
75 }
76 }
77}
78
80
81
86LteRlcUmE2eTestCase::LteRlcUmE2eTestCase (std::string name, uint32_t seed, double losses)
87 : TestCase (name)
88{
89 // NS_LOG_UNCOND ("Creating LteRlcUmTestingTestCase: " + name);
90
91 m_seed = seed;
92 m_losses = losses;
93
94 m_dlDrops = 0;
95 m_ulDrops = 0;
96}
97
99{
100}
101
102
103void
105{
106 // NS_LOG_FUNCTION (this);
107 m_dlDrops++;
108}
109
110void
112{
113 // NS_LOG_FUNCTION (this);
114 m_ulDrops++;
115}
116
117void
119{
120 uint16_t numberOfNodes = 1;
121
122 // LogLevel level = (LogLevel) (LOG_LEVEL_ALL | LOG_PREFIX_TIME | LOG_PREFIX_NODE | LOG_PREFIX_FUNC);
123 // LogComponentEnable ("LteRlcUmE2eTest", level);
124 // LogComponentEnable ("ErrorModel", level);
125 // LogComponentEnable ("LteSimpleHelper", level);
126 // LogComponentEnable ("LteSimpleNetDevice", level);
127 // LogComponentEnable ("SimpleNetDevice", level);
128 // LogComponentEnable ("SimpleChannel", level);
129 // LogComponentEnable ("LteTestEntities", level);
130 // LogComponentEnable ("LtePdcp", level);
131 // LogComponentEnable ("LteRlc", level);
132 // LogComponentEnable ("LteRlcUm", level);
133 // LogComponentEnable ("LteRlcAm", level);
134
135 RngSeedManager::SetSeed (m_seed);
136
137 Ptr<LteSimpleHelper> lteSimpleHelper = CreateObject<LteSimpleHelper> ();
138 // lteSimpleHelper->EnableLogComponents ();
139 // lteSimpleHelper->EnableTraces ();
140
141 lteSimpleHelper->SetAttribute ("RlcEntity", StringValue ("RlcUm"));
142
143 // eNB and UE nodes
144 NodeContainer ueNodes;
145 NodeContainer enbNodes;
146 enbNodes.Create (numberOfNodes);
147 ueNodes.Create (numberOfNodes);
148
149 // Install LTE Devices to the nodes
150 NetDeviceContainer enbLteDevs = lteSimpleHelper->InstallEnbDevice (enbNodes);
151 NetDeviceContainer ueLteDevs = lteSimpleHelper->InstallUeDevice (ueNodes);
152
153 // Note: Just one eNB and UE are supported. Everything is done in InstallEnbDevice and InstallUeDevice
154
155 // Attach one UE per eNodeB
156 // for (uint16_t i = 0; i < numberOfNodes; i++)
157 // {
158 // lteSimpleHelper->Attach (ueLteDevs.Get(i), enbLteDevs.Get(i));
159 // }
160
161 // lteSimpleHelper->ActivateEpsBearer (ueLteDevs, EpsBearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT), EpcTft::Default ());
162
163 // Error models: downlink and uplink
164 Ptr<RateErrorModel> dlEm = CreateObject<RateErrorModel> ();
165 dlEm->SetAttribute ("ErrorRate", DoubleValue (m_losses));
166 dlEm->SetAttribute ("ErrorUnit", StringValue ("ERROR_UNIT_PACKET"));
167
168 Ptr<RateErrorModel> ulEm = CreateObject<RateErrorModel> ();
169 ulEm->SetAttribute ("ErrorRate", DoubleValue (m_losses));
170 ulEm->SetAttribute ("ErrorUnit", StringValue ("ERROR_UNIT_PACKET"));
171
172 // The below hooks will cause drops to be counted at simple phy layer
173 ueLteDevs.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (dlEm));
175 enbLteDevs.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (ulEm));
176 enbLteDevs.Get (0)->TraceConnectWithoutContext ("PhyRxDrop", MakeCallback (&LteRlcUmE2eTestCase::UlDropEvent, this));
177
178 // Sending packets from eNB RRC layer (eNB -> UE)
179 lteSimpleHelper->m_enbRrc->SetArrivalTime (Seconds (0.010));
180 lteSimpleHelper->m_enbRrc->SetPduSize (100);
181
182 // MAC sends transmission opportunities (TxOpp)
183 lteSimpleHelper->m_enbMac->SetTxOppSize (150);
184 lteSimpleHelper->m_enbMac->SetTxOppTime (Seconds (0.005));
185 lteSimpleHelper->m_enbMac->SetTxOpportunityMode (LteTestMac::RANDOM_MODE);
186
187 // Sending packets from UE RRC layer (UE -> eNB)
188 lteSimpleHelper->m_ueRrc->SetArrivalTime (Seconds (0.010));
189 lteSimpleHelper->m_ueRrc->SetPduSize (100);
190
191 // MAC sends transmission opportunities (TxOpp)
192 lteSimpleHelper->m_ueMac->SetTxOppSize (150);
193 lteSimpleHelper->m_ueMac->SetTxOppTime (Seconds (0.005));
194 lteSimpleHelper->m_ueMac->SetTxOpportunityMode (LteTestMac::RANDOM_MODE);
195
196 // Start/Stop pseudo-application at eNB RRC
197 Simulator::Schedule (Seconds (0.100), &LteTestRrc::Start, lteSimpleHelper->m_enbRrc);
198 Simulator::Schedule (Seconds (10.100), &LteTestRrc::Stop, lteSimpleHelper->m_enbRrc);
199
200 // Start/Stop pseudo-application at UE RRC
201 Simulator::Schedule (Seconds (20.100), &LteTestRrc::Start, lteSimpleHelper->m_ueRrc);
202 Simulator::Schedule (Seconds (30.100), &LteTestRrc::Stop, lteSimpleHelper->m_ueRrc);
203
204
205 Simulator::Stop (Seconds (31.000));
207
208 uint32_t txEnbRrcPdus = lteSimpleHelper->m_enbRrc->GetTxPdus ();
209 uint32_t rxUeRrcPdus = lteSimpleHelper->m_ueRrc->GetRxPdus ();
210
211 uint32_t txUeRrcPdus = lteSimpleHelper->m_ueRrc->GetTxPdus ();
212 uint32_t rxEnbRrcPdus = lteSimpleHelper->m_enbRrc->GetRxPdus ();
213
214 // NS_LOG_INFO ("Seed = " << m_seed);
215 // NS_LOG_INFO ("Losses (%) = " << uint32_t (m_losses * 100));
216
217 // NS_LOG_INFO ("dl dev drops = " << m_dlDrops);
218 // NS_LOG_INFO ("ul dev drops = " << m_ulDrops);
219
220 // NS_LOG_INFO ("eNB tx RRC count = " << txEnbRrcPdus);
221 // NS_LOG_INFO ("eNB rx RRC count = " << rxEnbRrcPdus);
222 // NS_LOG_INFO ("UE tx RRC count = " << txUeRrcPdus);
223 // NS_LOG_INFO ("UE rx RRC count = " << rxUeRrcPdus);
224
225 NS_LOG_INFO (m_seed << "\t" << m_losses << "\t" << txEnbRrcPdus << "\t" << rxUeRrcPdus << "\t" << m_dlDrops);
226 NS_LOG_INFO (m_seed << "\t" << m_losses << "\t" << txUeRrcPdus << "\t" << rxEnbRrcPdus << "\t" << m_ulDrops);
227
228 NS_TEST_ASSERT_MSG_EQ (txEnbRrcPdus, rxUeRrcPdus + m_dlDrops,
229 "Downlink: TX PDUs (" << txEnbRrcPdus << ") != RX PDUs (" << rxUeRrcPdus << ") + DROPS (" << m_dlDrops << ")");
230 NS_TEST_ASSERT_MSG_EQ (txUeRrcPdus, rxEnbRrcPdus + m_ulDrops,
231 "Uplink: TX PDUs (" << txUeRrcPdus << ") != RX PDUs (" << rxEnbRrcPdus << ") + DROPS (" << m_ulDrops << ")");
232
233 Simulator::Destroy ();
234}
void Run(ObjectFactory &factory, uint32_t pop, uint32_t total, uint32_t runs, Ptr< RandomVariableStream > eventStream, bool calRev)
Perform the runs for a single scheduler type.
Test end-to-end flow when RLC UM is being used.
uint32_t m_dlDrops
number of Dl drops
double m_losses
error rate
void UlDropEvent(Ptr< const Packet > p)
UL drop event.
void DlDropEvent(Ptr< const Packet > p)
DL drop event.
uint32_t m_seed
random number seed
uint32_t m_ulDrops
number of UL drops
virtual void DoRun(void)
Implementation to actually run this TestCase.
Test suite for RlcUmE2eTestCase.
LteRlcUmE2eTestSuite()
Test x.x.x RLC UM: End-to-end flow.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:364
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:256
Hold objects of type Ptr<T>.
Definition: pointer.h:37
Hold variables of type string.
Definition: string.h:41
encapsulates test code
Definition: test.h:994
TestDuration
How long the test takes to execute.
Definition: test.h:998
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
A suite of tests to run.
Definition: test.h:1188
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
#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:141
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1245
static LteRlcUmE2eTestSuite lteRlcUmE2eTestSuite
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:661