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
Hold variables of type enum.
Definition: enum.h:55
void SetLteRlcSapUser(LteRlcSapUser *s)
Definition: lte-rlc.cc:147
void SetRnti(uint16_t rnti)
Definition: lte-rlc.cc:133
void SetLteMacSapProvider(LteMacSapProvider *s)
Definition: lte-rlc.cc:161
LteMacSapUser * GetLteMacSapUser()
Definition: lte-rlc.cc:168
void SetLcId(uint8_t lcId)
Definition: lte-rlc.cc:140
LteRlcSapProvider * GetLteRlcSapProvider()
Definition: lte-rlc.cc:154
ObjectFactory m_ueDeviceFactory
UE device factory.
Ptr< NetDevice > InstallSingleEnbDevice(Ptr< Node > n)
Install single ENB device.
Ptr< LteTestRrc > m_ueRrc
UE RRC.
void EnableDlPdcpTraces(void)
Enable trace sinks for DL PDCP layer.
virtual ~LteSimpleHelper(void)
Ptr< LtePdcp > m_enbPdcp
ENB PDCP.
NetDeviceContainer InstallEnbDevice(NodeContainer c)
create a set of eNB devices
Ptr< NetDevice > InstallSingleUeDevice(Ptr< Node > n)
Install single UE device.
ObjectFactory m_enbDeviceFactory
ENB device factory.
Ptr< SimpleChannel > m_phyChannel
the physical channel
void EnableDlRlcTraces(void)
Enable trace sinks for DL RLC layer.
Ptr< LteTestRrc > m_enbRrc
ENB RRC.
void EnableLogComponents(void)
Enables logging for all components of the LENA architecture.
Ptr< LteTestMac > m_enbMac
ENB MAC.
Ptr< LteTestMac > m_ueMac
UE MAC.
Ptr< LteRlc > m_ueRlc
UE RLC.
NetDeviceContainer InstallUeDevice(NodeContainer c)
create a set of UE devices
static TypeId GetTypeId(void)
Get the type ID.
virtual void DoDispose(void)
Destructor implementation.
Ptr< LtePdcp > m_uePdcp
UE PDCP.
Ptr< LteRlc > m_enbRlc
ENB RLC.
void EnableUlRlcTraces(void)
Enable trace sinks for UL RLC layer.
void EnableRlcTraces(void)
Enable trace sinks for RLC layer.
enum ns3::LteSimpleHelper::LteRlcEntityType_t m_lteRlcEntityType
RLC entity type.
void EnableTraces(void)
Enables trace sinks for MAC, RLC and PDCP.
void EnablePdcpTraces(void)
Enable trace sinks for PDCP layer.
virtual void DoInitialize(void)
Initialize() implementation.
void EnableUlPdcpTraces(void)
Enable trace sinks for UL PDCP layer.
The LteSimpleNetDevice class implements the LTE simple net device.
static TypeId GetTypeId(void)
Get the type ID.
void SetLteMacSapUser(LteMacSapUser *s)
Set the MAC SAP user.
bool Receive(Ptr< NetDevice > nd, Ptr< const Packet > p, uint16_t protocol, const Address &addr)
the Receive function
void SetDevice(Ptr< NetDevice > device)
Set the device function.
LteMacSapProvider * GetLteMacSapProvider(void)
Get the MAC SAP provider.
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:130
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
A base class which provides memory management and object aggregation.
Definition: object.h:88
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:353
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
Definition: object.cc:183
void Dispose(void)
Dispose of this Object.
Definition: object.cc:214
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
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:205
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#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
devices
Definition: first.py:39
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LteSimpleHelperDlTxPduCallback(Ptr< RadioBearerStatsCalculator > rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
DL transmit PDU callback.
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.h:162
void LteSimpleHelperUlRxPduCallback(Ptr< RadioBearerStatsCalculator > rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
UL receive PDU callback.
LogLevel
Logging severity classes and levels.
Definition: log.h:94
@ LOG_LEVEL_ALL
Print everything.
Definition: log.h:116
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
Definition: log.h:118
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
Definition: log.h:119
@ LOG_PREFIX_NODE
Prefix all trace prints with simulation node.
Definition: log.h:120
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:361
void LteSimpleHelperUlTxPduCallback(Ptr< RadioBearerStatsCalculator > rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
UL transmit PDU callback.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1648
static const uint32_t packetSize