A Discrete-Event Network Simulator
API
lte-simple-helper.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> (Based on lte-helper.cc)
19  */
20 
21 
22 #include "ns3/log.h"
23 #include "ns3/callback.h"
24 #include "ns3/config.h"
25 #include "ns3/simple-channel.h"
26 #include "ns3/error-model.h"
27 
28 #include "lte-simple-helper.h"
29 #include "lte-simple-net-device.h"
30 #include "lte-test-entities.h"
31 
32 
33 namespace ns3 {
34 
35 NS_LOG_COMPONENT_DEFINE ("LteSimpleHelper");
36 
37 NS_OBJECT_ENSURE_REGISTERED (LteSimpleHelper);
38 
40 {
41  NS_LOG_FUNCTION (this);
44 }
45 
46 void
48 {
49  NS_LOG_FUNCTION (this);
50 
51  m_phyChannel = CreateObject<SimpleChannel> ();
52 
54 }
55 
57 {
58  NS_LOG_FUNCTION (this);
59 }
60 
62 {
63  static TypeId
64  tid =
65  TypeId ("ns3::LteSimpleHelper")
66  .SetParent<Object> ()
67  .AddConstructor<LteSimpleHelper> ()
68  .AddAttribute ("RlcEntity",
69  "Specify which type of RLC will be used. ",
70  EnumValue (RLC_UM),
72  MakeEnumChecker (RLC_UM, "RlcUm",
73  RLC_AM, "RlcAm"))
74  ;
75  return tid;
76 }
77 
78 void
80 {
81  NS_LOG_FUNCTION (this);
82  m_phyChannel = 0;
83 
84  m_enbMac->Dispose ();
85  m_enbMac = 0;
86  m_ueMac->Dispose ();
87  m_ueMac = 0;
88 
90 }
91 
92 
95 {
96  NS_LOG_FUNCTION (this);
97  Initialize (); // will run DoInitialize () if necessary
99  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
100  {
101  Ptr<Node> node = *i;
102  Ptr<NetDevice> device = InstallSingleEnbDevice (node);
103  devices.Add (device);
104  }
105  return devices;
106 }
107 
110 {
111  NS_LOG_FUNCTION (this);
113  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
114  {
115  Ptr<Node> node = *i;
116  Ptr<NetDevice> device = InstallSingleUeDevice (node);
117  devices.Add (device);
118  }
119  return devices;
120 }
121 
122 
125 {
126  NS_LOG_FUNCTION (this);
127 
128  m_enbRrc = CreateObject<LteTestRrc> ();
129  m_enbPdcp = CreateObject<LtePdcp> ();
130 
131  if (m_lteRlcEntityType == RLC_UM)
132  {
133  m_enbRlc = CreateObject<LteRlcUm> ();
134  }
135  else // m_lteRlcEntityType == RLC_AM
136  {
137  m_enbRlc = CreateObject<LteRlcAm> ();
138  }
139 
140  m_enbRlc->SetRnti (11);
141  m_enbRlc->SetLcId (12);
142 
144  enbDev->SetAddress (Mac48Address::Allocate ());
145  enbDev->SetChannel (m_phyChannel);
146 
147  n->AddDevice (enbDev);
148 
149  m_enbMac = CreateObject<LteTestMac> ();
150  m_enbMac->SetDevice (enbDev);
151 
152  m_enbRrc->SetDevice (enbDev);
153 
154  enbDev->SetReceiveCallback (MakeCallback (&LteTestMac::Receive, m_enbMac));
155 
156  // Connect SAPs: RRC <-> PDCP <-> RLC <-> MAC
157 
158  m_enbRrc->SetLtePdcpSapProvider (m_enbPdcp->GetLtePdcpSapProvider ());
159  m_enbPdcp->SetLtePdcpSapUser (m_enbRrc->GetLtePdcpSapUser ());
160 
161  m_enbPdcp->SetLteRlcSapProvider (m_enbRlc->GetLteRlcSapProvider ());
162  m_enbRlc->SetLteRlcSapUser (m_enbPdcp->GetLteRlcSapUser ());
163 
166 
167  return enbDev;
168 }
169 
172 {
173  NS_LOG_FUNCTION (this);
174 
175  m_ueRrc = CreateObject<LteTestRrc> ();
176  m_uePdcp = CreateObject<LtePdcp> ();
177 
178  if (m_lteRlcEntityType == RLC_UM)
179  {
180  m_ueRlc = CreateObject<LteRlcUm> ();
181  }
182  else // m_lteRlcEntityType == RLC_AM
183  {
184  m_ueRlc = CreateObject<LteRlcAm> ();
185  }
186 
187  m_ueRlc->SetRnti (21);
188  m_ueRlc->SetLcId (22);
189 
191  ueDev->SetAddress (Mac48Address::Allocate ());
192  ueDev->SetChannel (m_phyChannel);
193 
194  n->AddDevice (ueDev);
195 
196  m_ueMac = CreateObject<LteTestMac> ();
197  m_ueMac->SetDevice (ueDev);
198 
199  ueDev->SetReceiveCallback (MakeCallback (&LteTestMac::Receive, m_ueMac));
200 
201  // Connect SAPs: RRC <-> PDCP <-> RLC <-> MAC
202 
203  m_ueRrc->SetLtePdcpSapProvider (m_uePdcp->GetLtePdcpSapProvider ());
204  m_uePdcp->SetLtePdcpSapUser (m_ueRrc->GetLtePdcpSapUser ());
205 
206  m_uePdcp->SetLteRlcSapProvider (m_ueRlc->GetLteRlcSapProvider ());
207  m_ueRlc->SetLteRlcSapUser (m_uePdcp->GetLteRlcSapUser ());
208 
211 
212  return ueDev;
213 }
214 
215 
216 void
218 {
220 
221  LogComponentEnable ("Config", level);
222  LogComponentEnable ("LteSimpleHelper", level);
223  LogComponentEnable ("LteTestEntities", level);
224  LogComponentEnable ("LtePdcp", level);
225  LogComponentEnable ("LteRlc", level);
226  LogComponentEnable ("LteRlcUm", level);
227  LogComponentEnable ("LteRlcAm", level);
228  LogComponentEnable ("LteSimpleNetDevice", level);
229  LogComponentEnable ("SimpleNetDevice", level);
230  LogComponentEnable ("SimpleChannel", level);
231 }
232 
233 void
235 {
236 // EnableMacTraces ();
237  EnableRlcTraces ();
238  EnablePdcpTraces ();
239 }
240 
241 void
243 {
246 }
247 
248 
258 void
260  uint16_t rnti, uint8_t lcid, uint32_t packetSize)
261 {
262  NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize);
263  uint64_t imsi = 111;
264  uint16_t cellId = 222;
265  rlcStats->DlTxPdu (cellId, imsi, rnti, lcid, packetSize);
266 }
267 
278 void
280  uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
281 {
282  NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
283  uint64_t imsi = 333;
284  uint16_t cellId = 555;
285  rlcStats->DlRxPdu (cellId, imsi, rnti, lcid, packetSize, delay);
286 }
287 
288 void
290 {
292 
293  // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/TxPDU",
294  // MakeBoundCallback (&LteSimpleHelperDlTxPduCallback, m_rlcStats));
295  // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/RxPDU",
296  // MakeBoundCallback (&LteSimpleHelperDlRxPduCallback, m_rlcStats));
297 }
298 
308 void
310  uint16_t rnti, uint8_t lcid, uint32_t packetSize)
311 {
312  NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize);
313  uint64_t imsi = 1111;
314  uint16_t cellId = 555;
315  rlcStats->UlTxPdu (cellId, imsi, rnti, lcid, packetSize);
316 }
317 
328 void
330  uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
331 {
332  NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
333  uint64_t imsi = 444;
334  uint16_t cellId = 555;
335  rlcStats->UlRxPdu (cellId, imsi, rnti, lcid, packetSize, delay);
336 }
337 
338 
339 void
341 {
343 
344  // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/TxPDU",
345  // MakeBoundCallback (&LteSimpleHelperUlTxPduCallback, m_rlcStats));
346  // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/RxPDU",
347  // MakeBoundCallback (&LteSimpleHelperUlRxPduCallback, m_rlcStats));
348 }
349 
350 
351 void
353 {
356 }
357 
358 void
360 {
362 
363  // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/TxPDU",
364  // MakeBoundCallback (&LteSimpleHelperDlTxPduCallback, m_pdcpStats));
365  // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/RxPDU",
366  // MakeBoundCallback (&LteSimpleHelperDlRxPduCallback, m_pdcpStats));
367 }
368 
369 void
371 {
373 
374  // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/TxPDU",
375  // MakeBoundCallback (&LteSimpleHelperUlTxPduCallback, m_pdcpStats));
376  // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/RxPDU",
377  // MakeBoundCallback (&LteSimpleHelperUlRxPduCallback, m_pdcpStats));
378 }
379 
380 
381 } // namespace ns3
void EnableRlcTraces(void)
Enable trace sinks for RLC layer.
void Dispose(void)
Dispose of this Object.
Definition: object.cc:214
enum ns3::LteSimpleHelper::LteRlcEntityType_t m_lteRlcEntityType
RLC entity type.
Ptr< LteTestRrc > m_enbRrc
ENB RRC.
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:353
Prefix all trace prints with simulation node.
Definition: log.h:120
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
static const uint32_t packetSize
virtual ~LteSimpleHelper(void)
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: enum.h:209
Ptr< NetDevice > InstallSingleEnbDevice(Ptr< Node > n)
Install single ENB device.
Ptr< NetDevice > InstallSingleUeDevice(Ptr< Node > n)
Install single UE device.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
Ptr< LteTestRrc > m_ueRrc
UE RRC.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
static TypeId GetTypeId(void)
Get the type ID.
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
void EnableTraces(void)
Enables trace sinks for MAC, RLC and PDCP.
Ptr< LteTestMac > m_ueMac
UE MAC.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
void SetRnti(uint16_t rnti)
Definition: lte-rlc.cc:130
Ptr< LteTestMac > m_enbMac
ENB MAC.
void LteSimpleHelperUlTxPduCallback(Ptr< RadioBearerStatsCalculator > rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
UL transmit PDU callback.
Ptr< LtePdcp > m_enbPdcp
ENB PDCP.
void SetLteMacSapUser(LteMacSapUser *s)
Set the MAC SAP user.
void LteSimpleHelperDlRxPduCallback(Ptr< RadioBearerStatsCalculator > rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
DL receive PDU callback.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:370
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
Hold variables of type enum.
Definition: enum.h:54
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void LteSimpleHelperUlRxPduCallback(Ptr< RadioBearerStatsCalculator > rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
UL receive PDU callback.
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:1610
void UlTxPdu(uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
Notifies the stats calculator that an uplink transmission has occurred.
LteMacSapUser * GetLteMacSapUser()
Definition: lte-rlc.cc:165
virtual void DoDispose(void)
Destructor implementation.
Prefix all trace prints with simulation time.
Definition: log.h:119
LteMacSapProvider * GetLteMacSapProvider(void)
Get the MAC SAP provider.
Ptr< SimpleChannel > m_phyChannel
the physical channel
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ObjectFactory m_ueDeviceFactory
UE device factory.
keep track of a set of node pointers.
void EnableLogComponents(void)
Enables logging for all components of the LENA architecture.
void SetLteRlcSapUser(LteRlcSapUser *s)
Definition: lte-rlc.cc:144
NetDeviceContainer InstallUeDevice(NodeContainer c)
create a set of UE devices
void SetLcId(uint8_t lcId)
Definition: lte-rlc.cc:137
void DlTxPdu(uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
Notifies the stats calculator that an downlink transmission has occurred.
void EnableDlRlcTraces(void)
Enable trace sinks for DL RLC layer.
void UlRxPdu(uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
Notifies the stats calculator that an uplink reception has occurred.
LogLevel
Logging severity classes and levels.
Definition: log.h:93
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.cc:184
Prefix all trace prints with function.
Definition: log.h:118
void EnableUlPdcpTraces(void)
Enable trace sinks for UL PDCP layer.
void EnableDlPdcpTraces(void)
Enable trace sinks for DL PDCP layer.
ObjectFactory m_enbDeviceFactory
ENB device factory.
void SetDevice(Ptr< NetDevice > device)
Set the device function.
virtual void DoInitialize(void)
Initialize() implementation.
Print everything.
Definition: log.h:116
Ptr< LtePdcp > m_uePdcp
UE PDCP.
void EnableUlRlcTraces(void)
Enable trace sinks for UL RLC layer.
void EnablePdcpTraces(void)
Enable trace sinks for PDCP layer.
LteRlcSapProvider * GetLteRlcSapProvider()
Definition: lte-rlc.cc:151
A base class which provides memory management and object aggregation.
Definition: object.h:87
devices
Definition: first.py:39
Ptr< LteRlc > m_ueRlc
UE RLC.
The LteSimpleNetDevice class implements the LTE simple net device.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< LteRlc > m_enbRlc
ENB RLC.
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
void DlRxPdu(uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
Notifies the stats calculator that an downlink reception has occurred.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
Definition: object.cc:183
void LteSimpleHelperDlTxPduCallback(Ptr< RadioBearerStatsCalculator > rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
DL transmit PDU callback.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
void SetLteMacSapProvider(LteMacSapProvider *s)
Definition: lte-rlc.cc:158
bool Receive(Ptr< NetDevice > nd, Ptr< const Packet > p, uint16_t protocol, const Address &addr)
the Receive function