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 
249 void
251  uint16_t rnti, uint8_t lcid, uint32_t packetSize)
252 {
253  NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize);
254  uint64_t imsi = 111;
255  uint16_t cellId = 222;
256  rlcStats->DlTxPdu (cellId, imsi, rnti, lcid, packetSize);
257 }
258 
259 void
261  uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
262 {
263  NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
264  uint64_t imsi = 333;
265  uint16_t cellId = 555;
266  rlcStats->DlRxPdu (cellId, imsi, rnti, lcid, packetSize, delay);
267 }
268 
269 void
271 {
273 
274  // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/TxPDU",
275  // MakeBoundCallback (&LteSimpleHelperDlTxPduCallback, m_rlcStats));
276  // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/RxPDU",
277  // MakeBoundCallback (&LteSimpleHelperDlRxPduCallback, m_rlcStats));
278 }
279 
280 void
282  uint16_t rnti, uint8_t lcid, uint32_t packetSize)
283 {
284  NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize);
285  uint64_t imsi = 1111;
286  uint16_t cellId = 555;
287  rlcStats->UlTxPdu (cellId, imsi, rnti, lcid, packetSize);
288 }
289 
290 void
292  uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
293 {
294  NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
295  uint64_t imsi = 444;
296  uint16_t cellId = 555;
297  rlcStats->UlRxPdu (cellId, imsi, rnti, lcid, packetSize, delay);
298 }
299 
300 
301 void
303 {
305 
306  // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/TxPDU",
307  // MakeBoundCallback (&LteSimpleHelperUlTxPduCallback, m_rlcStats));
308  // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/RxPDU",
309  // MakeBoundCallback (&LteSimpleHelperUlRxPduCallback, m_rlcStats));
310 }
311 
312 
313 void
315 {
318 }
319 
320 void
322 {
324 
325  // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/TxPDU",
326  // MakeBoundCallback (&LteSimpleHelperDlTxPduCallback, m_pdcpStats));
327  // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/RxPDU",
328  // MakeBoundCallback (&LteSimpleHelperDlRxPduCallback, m_pdcpStats));
329 }
330 
331 void
333 {
335 
336  // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/TxPDU",
337  // MakeBoundCallback (&LteSimpleHelperUlTxPduCallback, m_pdcpStats));
338  // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/RxPDU",
339  // MakeBoundCallback (&LteSimpleHelperUlRxPduCallback, m_pdcpStats));
340 }
341 
342 
343 } // 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
Ptr< LteTestRrc > m_enbRrc
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:353
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
tuple devices
Definition: first.py:32
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
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)
Ptr< NetDevice > InstallSingleUeDevice(Ptr< Node > n)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
Ptr< LteTestRrc > m_ueRrc
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
static TypeId GetTypeId(void)
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
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
void SetRnti(uint16_t rnti)
Definition: lte-rlc.cc:127
Ptr< LteTestMac > m_enbMac
void LteSimpleHelperUlTxPduCallback(Ptr< RadioBearerStatsCalculator > rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
Ptr< LtePdcp > m_enbPdcp
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)
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:351
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 Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
void LteSimpleHelperUlRxPduCallback(Ptr< RadioBearerStatsCalculator > rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
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:1489
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:162
virtual void DoDispose(void)
Destructor implementation.
LteMacSapProvider * GetLteMacSapProvider(void)
Get the MAC SAP provider.
Ptr< SimpleChannel > m_phyChannel
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ObjectFactory m_ueDeviceFactory
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:141
Prefix all trace prints with simulation time.
Definition: log.h:115
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
Prefix all trace prints with function.
Definition: log.h:114
NetDeviceContainer InstallUeDevice(NodeContainer c)
create a set of UE devices
void SetLcId(uint8_t lcId)
Definition: lte-rlc.cc:134
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.
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 simulation node.
Definition: log.h:116
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:128
void EnableUlPdcpTraces(void)
Enable trace sinks for UL PDCP layer.
void EnableDlPdcpTraces(void)
Enable trace sinks for DL PDCP layer.
ObjectFactory m_enbDeviceFactory
LogLevel
Logging severity classes and levels.
Definition: log.h:90
void SetDevice(Ptr< NetDevice > device)
virtual void DoInitialize(void)
Initialize() implementation.
Print everything.
Definition: log.h:112
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:148
static const uint32_t packetSize
A base class which provides memory management and object aggregation.
Definition: object.h:87
The LteSimpleNetDevice class implements the LTE simple net device.
static TypeId GetTypeId(void)
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
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)
void SetLteMacSapProvider(LteMacSapProvider *s)
Definition: lte-rlc.cc:155
bool Receive(Ptr< NetDevice > nd, Ptr< const Packet > p, uint16_t protocol, const Address &addr)