A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("LteSimpleHelper");
34 
35 namespace ns3 {
36 
37 
38 NS_OBJECT_ENSURE_REGISTERED (LteSimpleHelper);
39 
41 {
42  NS_LOG_FUNCTION (this);
45 }
46 
47 void
49 {
50  NS_LOG_FUNCTION (this);
51 
52  m_phyChannel = CreateObject<SimpleChannel> ();
53 
55 }
56 
58 {
59  NS_LOG_FUNCTION (this);
60 }
61 
63 {
64  static TypeId
65  tid =
66  TypeId ("ns3::LteSimpleHelper")
67  .SetParent<Object> ()
68  .AddConstructor<LteSimpleHelper> ()
69  .AddAttribute ("RlcEntity",
70  "Specify which type of RLC will be used. ",
71  EnumValue (RLC_UM),
73  MakeEnumChecker (RLC_UM, "RlcUm",
74  RLC_AM, "RlcAm"))
75  ;
76  return tid;
77 }
78 
79 void
81 {
82  NS_LOG_FUNCTION (this);
83  m_phyChannel = 0;
84 
85  m_enbMac->Dispose ();
86  m_enbMac = 0;
87  m_ueMac->Dispose ();
88  m_ueMac = 0;
89 
91 }
92 
93 
96 {
97  NS_LOG_FUNCTION (this);
98  Initialize (); // will run DoInitialize () if necessary
100  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
101  {
102  Ptr<Node> node = *i;
103  Ptr<NetDevice> device = InstallSingleEnbDevice (node);
104  devices.Add (device);
105  }
106  return devices;
107 }
108 
111 {
112  NS_LOG_FUNCTION (this);
114  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
115  {
116  Ptr<Node> node = *i;
117  Ptr<NetDevice> device = InstallSingleUeDevice (node);
118  devices.Add (device);
119  }
120  return devices;
121 }
122 
123 
126 {
127  NS_LOG_FUNCTION (this);
128 
129  m_enbRrc = CreateObject<LteTestRrc> ();
130  m_enbPdcp = CreateObject<LtePdcp> ();
131 
132  if (m_lteRlcEntityType == RLC_UM)
133  {
134  m_enbRlc = CreateObject<LteRlcUm> ();
135  }
136  else // m_lteRlcEntityType == RLC_AM
137  {
138  m_enbRlc = CreateObject<LteRlcAm> ();
139  }
140 
141  m_enbRlc->SetRnti (11);
142  m_enbRlc->SetLcId (12);
143 
145  enbDev->SetAddress (Mac48Address::Allocate ());
146  enbDev->SetChannel (m_phyChannel);
147 
148  n->AddDevice (enbDev);
149 
150  m_enbMac = CreateObject<LteTestMac> ();
151  m_enbMac->SetDevice (enbDev);
152 
153  enbDev->SetReceiveCallback (MakeCallback (&LteTestMac::Receive, m_enbMac));
154 
155  // Connect SAPs: RRC <-> PDCP <-> RLC <-> MAC
156 
157  m_enbRrc->SetLtePdcpSapProvider (m_enbPdcp->GetLtePdcpSapProvider ());
158  m_enbPdcp->SetLtePdcpSapUser (m_enbRrc->GetLtePdcpSapUser ());
159 
160  m_enbPdcp->SetLteRlcSapProvider (m_enbRlc->GetLteRlcSapProvider ());
161  m_enbRlc->SetLteRlcSapUser (m_enbPdcp->GetLteRlcSapUser ());
162 
165 
166  return enbDev;
167 }
168 
171 {
172  NS_LOG_FUNCTION (this);
173 
174  m_ueRrc = CreateObject<LteTestRrc> ();
175  m_uePdcp = CreateObject<LtePdcp> ();
176 
177  if (m_lteRlcEntityType == RLC_UM)
178  {
179  m_ueRlc = CreateObject<LteRlcUm> ();
180  }
181  else // m_lteRlcEntityType == RLC_AM
182  {
183  m_ueRlc = CreateObject<LteRlcAm> ();
184  }
185 
186  m_ueRlc->SetRnti (21);
187  m_ueRlc->SetLcId (22);
188 
190  ueDev->SetAddress (Mac48Address::Allocate ());
191  ueDev->SetChannel (m_phyChannel);
192 
193  n->AddDevice (ueDev);
194 
195  m_ueMac = CreateObject<LteTestMac> ();
196  m_ueMac->SetDevice (ueDev);
197 
198  ueDev->SetReceiveCallback (MakeCallback (&LteTestMac::Receive, m_ueMac));
199 
200  // Connect SAPs: RRC <-> PDCP <-> RLC <-> MAC
201 
202  m_ueRrc->SetLtePdcpSapProvider (m_uePdcp->GetLtePdcpSapProvider ());
203  m_uePdcp->SetLtePdcpSapUser (m_ueRrc->GetLtePdcpSapUser ());
204 
205  m_uePdcp->SetLteRlcSapProvider (m_ueRlc->GetLteRlcSapProvider ());
206  m_ueRlc->SetLteRlcSapUser (m_uePdcp->GetLteRlcSapUser ());
207 
210 
211  return ueDev;
212 }
213 
214 
215 void
217 {
219 
220  LogComponentEnable ("Config", level);
221  LogComponentEnable ("LteSimpleHelper", level);
222  LogComponentEnable ("LteTestEntities", level);
223  LogComponentEnable ("LtePdcp", level);
224  LogComponentEnable ("LteRlc", level);
225  LogComponentEnable ("LteRlcUm", level);
226  LogComponentEnable ("LteRlcAm", level);
227  LogComponentEnable ("LteSimpleNetDevice", level);
228  LogComponentEnable ("SimpleNetDevice", level);
229  LogComponentEnable ("SimpleChannel", level);
230 }
231 
232 void
234 {
235 // EnableMacTraces ();
236  EnableRlcTraces ();
237  EnablePdcpTraces ();
238 }
239 
240 void
242 {
245 }
246 
247 
248 void
250  uint16_t rnti, uint8_t lcid, uint32_t packetSize)
251 {
252  NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize);
253  uint64_t imsi = 111;
254  uint16_t cellId = 222;
255  rlcStats->DlTxPdu (cellId, imsi, rnti, lcid, packetSize);
256 }
257 
258 void
260  uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
261 {
262  NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
263  uint64_t imsi = 333;
264  uint16_t cellId = 555;
265  rlcStats->DlRxPdu (cellId, imsi, rnti, lcid, packetSize, delay);
266 }
267 
268 void
270 {
272 
273  // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/TxPDU",
274  // MakeBoundCallback (&LteSimpleHelperDlTxPduCallback, m_rlcStats));
275  // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/RxPDU",
276  // MakeBoundCallback (&LteSimpleHelperDlRxPduCallback, m_rlcStats));
277 }
278 
279 void
281  uint16_t rnti, uint8_t lcid, uint32_t packetSize)
282 {
283  NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize);
284  uint64_t imsi = 1111;
285  uint16_t cellId = 555;
286  rlcStats->UlTxPdu (cellId, imsi, rnti, lcid, packetSize);
287 }
288 
289 void
291  uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
292 {
293  NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
294  uint64_t imsi = 444;
295  uint16_t cellId = 555;
296  rlcStats->UlRxPdu (cellId, imsi, rnti, lcid, packetSize, delay);
297 }
298 
299 
300 void
302 {
304 
305  // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/TxPDU",
306  // MakeBoundCallback (&LteSimpleHelperUlTxPduCallback, m_rlcStats));
307  // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/RxPDU",
308  // MakeBoundCallback (&LteSimpleHelperUlRxPduCallback, m_rlcStats));
309 }
310 
311 
312 void
314 {
317 }
318 
319 void
321 {
323 
324  // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/TxPDU",
325  // MakeBoundCallback (&LteSimpleHelperDlTxPduCallback, m_pdcpStats));
326  // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/RxPDU",
327  // MakeBoundCallback (&LteSimpleHelperDlRxPduCallback, m_pdcpStats));
328 }
329 
330 void
332 {
334 
335  // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/TxPDU",
336  // MakeBoundCallback (&LteSimpleHelperUlTxPduCallback, m_pdcpStats));
337  // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/RxPDU",
338  // MakeBoundCallback (&LteSimpleHelperUlRxPduCallback, m_pdcpStats));
339 }
340 
341 
342 } // namespace ns3
void EnableRlcTraces(void)
Enable trace sinks for RLC layer.
enum ns3::LteSimpleHelper::LteRlcEntityType_t m_lteRlcEntityType
Ptr< LteTestRrc > m_enbRrc
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
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)
Definition: enum.cc:178
tuple devices
Definition: first.py:32
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
virtual ~LteSimpleHelper(void)
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:170
Ptr< LteTestRrc > m_ueRrc
void SetTypeId(TypeId tid)
static TypeId GetTypeId(void)
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: object.cc:335
#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:125
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)
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
hold variables of type 'enum'
Definition: enum.h:37
Ptr< Object > Create(void) const
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:1242
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:160
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
LteMacSapProvider * GetLteMacSapProvider(void)
Get the MAC SAP provider.
Ptr< SimpleChannel > m_phyChannel
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:139
prefix all trace prints with simulation time
Definition: log.h:96
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:95
NetDeviceContainer InstallUeDevice(NodeContainer c)
create a set of UE devices
void SetLcId(uint8_t lcId)
Definition: lte-rlc.cc:132
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.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition: enum.h:118
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.
prefix all trace prints with simulation node
Definition: log.h:97
uint32_t AddDevice(Ptr< NetDevice > device)
Definition: node.cc:120
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:71
void SetDevice(Ptr< NetDevice > device)
void Initialize(void)
This method calls the virtual DoInitialize method on all the objects aggregated to this object...
Definition: object.cc:179
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
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:146
a base class which provides memory management and object aggregation
Definition: object.h:64
The LteSimpleNetDevice class implements the LTE simple net device.
static TypeId GetTypeId(void)
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
void Dispose(void)
Run the DoDispose methods of this object and all the objects aggregated to it.
Definition: object.cc:204
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.
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
Definition: object.cc:342
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:153
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:318
bool Receive(Ptr< NetDevice > nd, Ptr< const Packet > p, uint16_t protocol, const Address &addr)