A Discrete-Event Network Simulator
API
lte-test-rlc-am-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 #include "ns3/config-store.h"
34 
35 #include "lte-test-rlc-am-e2e.h"
36 #include "lte-simple-helper.h"
37 #include "lte-test-entities.h"
38 
39 
40 using namespace ns3;
41 
42 NS_LOG_COMPONENT_DEFINE ("LteRlcAmE2eTest");
43 
53  : TestSuite ("lte-rlc-am-e2e", SYSTEM)
54 {
55  // NS_LOG_INFO ("Creating LteRlcAmE2eTestSuite");
56 
57  double losses[] = {0.0, 0.10, 0.25, 0.50, 0.75, 0.90, 0.95};
58  uint32_t seeds[] = {1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 10101};
59 
60  for ( uint32_t l = 0 ; l < (sizeof (losses) / sizeof (double)) ; l++ )
61  {
62  for ( uint32_t s = 0 ; s < (sizeof (seeds) / sizeof (uint32_t)) ; s++ )
63  {
64  std::ostringstream name;
65  name << " Losses = " << losses[l] * 100 << "%. Seed = " << seeds[s];
66  TestCase::TestDuration testDuration;
67  if (l == 1 && s == 0)
68  {
69  testDuration = TestCase::QUICK;
70  }
71  else
72  {
73  testDuration = TestCase::EXTENSIVE;
74  }
75  AddTestCase (new LteRlcAmE2eTestCase (name.str (), seeds[s], losses[l]), testDuration);
76  }
77  }
78 }
79 
81 
82 
87 LteRlcAmE2eTestCase::LteRlcAmE2eTestCase (std::string name, uint32_t seed, double losses)
88  : TestCase (name)
89 {
90  // NS_LOG_UNCOND ("Creating LteRlcAmTestingTestCase: " + name);
91 
92  m_seed = seed;
93  m_losses = losses;
94 
95  m_dlDrops = 0;
96  m_ulDrops = 0;
97 }
98 
100 {
101 }
102 
103 
104 void
106 {
107  // NS_LOG_FUNCTION (this);
108  m_dlDrops++;
109 }
110 
111 void
113 {
114  // NS_LOG_FUNCTION (this);
115  m_ulDrops++;
116 }
117 
118 void
120 {
121  uint16_t numberOfNodes = 1;
122 
123  // LogLevel level = (LogLevel) (LOG_LEVEL_ALL | LOG_PREFIX_TIME | LOG_PREFIX_NODE | LOG_PREFIX_FUNC);
124  // LogComponentEnable ("LteRlcAmE2eTest", level);
125  // LogComponentEnable ("ErrorModel", level);
126  // LogComponentEnable ("LteSimpleHelper", level);
127  // LogComponentEnable ("LteSimpleNetDevice", level);
128  // LogComponentEnable ("SimpleNetDevice", level);
129  // LogComponentEnable ("SimpleChannel", level);
130  // LogComponentEnable ("LteTestEntities", level);
131  // LogComponentEnable ("LtePdcp", level);
132  // LogComponentEnable ("LteRlc", level);
133  // LogComponentEnable ("LteRlcUm", level);
134  // LogComponentEnable ("LteRlcAm", level);
135 
136  RngSeedManager::SetSeed (m_seed);
137 
138  Ptr<LteSimpleHelper> lteSimpleHelper = CreateObject<LteSimpleHelper> ();
139  // lteSimpleHelper->EnableLogComponents ();
140  // lteSimpleHelper->EnableTraces ();
141 
142  lteSimpleHelper->SetAttribute ("RlcEntity", StringValue ("RlcAm"));
143 
144  // eNB and UE nodes
145  NodeContainer ueNodes;
146  NodeContainer enbNodes;
147  enbNodes.Create (numberOfNodes);
148  ueNodes.Create (numberOfNodes);
149 
150  // Install LTE Devices to the nodes
151  NetDeviceContainer enbLteDevs = lteSimpleHelper->InstallEnbDevice (enbNodes);
152  NetDeviceContainer ueLteDevs = lteSimpleHelper->InstallUeDevice (ueNodes);
153 
154  // Note: Just one eNB and UE is supported. Everything is done in InstallEnbDevice and InstallUeDevice
155 
156  // Attach one UE per eNodeB
157  // for (uint16_t i = 0; i < numberOfNodes; i++)
158  // {
159  // lteSimpleHelper->Attach (ueLteDevs.Get(i), enbLteDevs.Get(i));
160  // }
161 
162  // lteSimpleHelper->ActivateEpsBearer (ueLteDevs, EpsBearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT), EpcTft::Default ());
163 
164 
165  // Error models: downlink and uplink
166  Ptr<RateErrorModel> dlEm = CreateObject<RateErrorModel> ();
167  dlEm->SetAttribute ("ErrorRate", DoubleValue (m_losses));
168  dlEm->SetAttribute ("ErrorUnit", StringValue ("ERROR_UNIT_PACKET"));
169 
170 // Ptr<RateErrorModel> ueEm = CreateObjectWithAttributes<RateErrorModel> ("RanVar", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1.0]"));
171 // ueEm->SetAttribute ("ErrorRate", DoubleValue (m_losses));
172 // ueEm->SetAttribute ("ErrorUnit", StringValue ("ERROR_UNIT_PACKET"));
173 
174  // The below hooks will cause drops and receptions to be counted
175  ueLteDevs.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (dlEm));
176  ueLteDevs.Get (0)->TraceConnectWithoutContext ("PhyRxDrop", MakeCallback (&LteRlcAmE2eTestCase::DlDropEvent, this));
177 // enbLteDevs.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (enbEm));
178 // enbLteDevs.Get (0)->TraceConnectWithoutContext ("PhyRxDrop", MakeCallback (&LteRlcAmE2eTestCase::EnbDropEvent, this));
179 
180  // Sending packets from RRC layer
181  lteSimpleHelper->m_enbRrc->SetArrivalTime (Seconds (0.010));
182  lteSimpleHelper->m_enbRrc->SetPduSize (100);
183 
184  // MAC sends transmission opportunities (TxOpp)
185  lteSimpleHelper->m_enbMac->SetTxOppSize (150);
186  lteSimpleHelper->m_enbMac->SetTxOppTime (Seconds (0.005));
187  lteSimpleHelper->m_enbMac->SetTxOpportunityMode (LteTestMac::RANDOM_MODE);
188 
189  // MAC sends transmission opportunities (TxOpp)
190  lteSimpleHelper->m_ueMac->SetTxOppSize (140);
191  lteSimpleHelper->m_ueMac->SetTxOppTime (Seconds (0.015));
192  lteSimpleHelper->m_ueMac->SetTxOpportunityMode (LteTestMac::RANDOM_MODE);
193 
194  // Start/Stop pseudo-application at RRC layer
195  Simulator::Schedule (Seconds (0.100), &LteTestRrc::Start, lteSimpleHelper->m_enbRrc);
196  Simulator::Schedule (Seconds (10.100), &LteTestRrc::Stop, lteSimpleHelper->m_enbRrc);
197 
198 
199  Simulator::Stop (Seconds (100.000));
200  Simulator::Run ();
201 
202  uint32_t txEnbRrcPdus = lteSimpleHelper->m_enbRrc->GetTxPdus ();
203  uint32_t rxUeRrcPdus = lteSimpleHelper->m_ueRrc->GetRxPdus ();
204 
205  // NS_LOG_INFO ("Seed = " << m_seed);
206  // NS_LOG_INFO ("Losses (%) = " << uint32_t (m_losses * 100));
207 
208  // NS_LOG_INFO ("dl dev drops = " << m_dlDrops);
209  // NS_LOG_INFO ("ul dev drops = " << m_ulDrops);
210 
211  // NS_LOG_INFO ("eNB tx RRC count = " << txEnbRrcPdus);
212  // NS_LOG_INFO ("eNB rx RRC count = " << rxEnbRrcPdus);
213  // NS_LOG_INFO ("UE tx RRC count = " << txUeRrcPdus);
214  // NS_LOG_INFO ("UE rx RRC count = " << rxUeRrcPdus);
215 
216  NS_LOG_INFO (m_seed << "\t" << m_losses << "\t" << txEnbRrcPdus << "\t" << rxUeRrcPdus << "\t" << m_dlDrops);
217 
218  NS_TEST_ASSERT_MSG_EQ (txEnbRrcPdus, rxUeRrcPdus,
219  "TX PDUs (" << txEnbRrcPdus << ") != RX PDUs (" << rxUeRrcPdus << ")");
220 
221  Simulator::Destroy ();
222 }
Ptr< LteTestRrc > m_enbRrc
Hold variables of type string.
Definition: string.h:41
Test x.x.x RLC AM: End-to-end flow.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
A suite of tests to run.
Definition: test.h:1270
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
Ptr< LteTestRrc > m_ueRrc
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:244
void SetTxOpportunityMode(uint8_t mode)
Ptr< LteTestMac > m_ueMac
encapsulates test code
Definition: test.h:1102
TestDuration
How long the test takes to execute.
Definition: test.h:1109
Ptr< LteTestMac > m_enbMac
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:184
#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:152
Ptr< SampleEmitter > s
holds a vector of ns3::NetDevice pointers
NetDeviceContainer InstallEnbDevice(NodeContainer c)
create a set of eNB devices
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1290
void SetTxOppTime(Time txOppTime)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Hold objects of type Ptr.
Definition: pointer.h:36
NetDeviceContainer InstallUeDevice(NodeContainer c)
create a set of UE devices
static LteRlcAmE2eTestSuite lteRlcAmE2eTestSuite
void SetTxOppSize(uint32_t txOppSize)
virtual void DoRun(void)
Implementation to actually run this TestCase.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:859
void DlDropEvent(Ptr< const Packet > p)
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
LteRlcAmE2eTestSuite()
Test x.x.x RLC AM: 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
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:190
void UlDropEvent(Ptr< const Packet > p)