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  ;
40 
42 {
43  NS_LOG_FUNCTION (this);
46 }
47 
48 void
50 {
51  NS_LOG_FUNCTION (this);
52 
53  m_phyChannel = CreateObject<SimpleChannel> ();
54 
56 }
57 
59 {
60  NS_LOG_FUNCTION (this);
61 }
62 
64 {
65  static TypeId
66  tid =
67  TypeId ("ns3::LteSimpleHelper")
68  .SetParent<Object> ()
69  .AddConstructor<LteSimpleHelper> ()
70  .AddAttribute ("RlcEntity",
71  "Specify which type of RLC will be used. ",
72  EnumValue (RLC_UM),
74  MakeEnumChecker (RLC_UM, "RlcUm",
75  RLC_AM, "RlcAm"))
76  ;
77  return tid;
78 }
79 
80 void
82 {
83  NS_LOG_FUNCTION (this);
84  m_phyChannel = 0;
85 
86  m_enbMac->Dispose ();
87  m_enbMac = 0;
88  m_ueMac->Dispose ();
89  m_ueMac = 0;
90 
92 }
93 
94 
97 {
98  NS_LOG_FUNCTION (this);
99  Initialize (); // will run DoInitialize () if necessary
101  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
102  {
103  Ptr<Node> node = *i;
104  Ptr<NetDevice> device = InstallSingleEnbDevice (node);
105  devices.Add (device);
106  }
107  return devices;
108 }
109 
112 {
113  NS_LOG_FUNCTION (this);
115  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
116  {
117  Ptr<Node> node = *i;
118  Ptr<NetDevice> device = InstallSingleUeDevice (node);
119  devices.Add (device);
120  }
121  return devices;
122 }
123 
124 
127 {
128  NS_LOG_FUNCTION (this);
129 
130  m_enbRrc = CreateObject<LteTestRrc> ();
131  m_enbPdcp = CreateObject<LtePdcp> ();
132 
133  if (m_lteRlcEntityType == RLC_UM)
134  {
135  m_enbRlc = CreateObject<LteRlcUm> ();
136  }
137  else // m_lteRlcEntityType == RLC_AM
138  {
139  m_enbRlc = CreateObject<LteRlcAm> ();
140  }
141 
142  m_enbRlc->SetRnti (11);
143  m_enbRlc->SetLcId (12);
144 
146  enbDev->SetAddress (Mac48Address::Allocate ());
147  enbDev->SetChannel (m_phyChannel);
148 
149  n->AddDevice (enbDev);
150 
151  m_enbMac = CreateObject<LteTestMac> ();
152  m_enbMac->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 
164  m_enbRlc->SetLteMacSapProvider (m_enbMac->GetLteMacSapProvider ());
165  m_enbMac->SetLteMacSapUser (m_enbRlc->GetLteMacSapUser ());
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 
209  m_ueRlc->SetLteMacSapProvider (m_ueMac->GetLteMacSapProvider ());
210  m_ueMac->SetLteMacSapUser (m_ueRlc->GetLteMacSapUser ());
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.
enum ns3::LteSimpleHelper::LteRlcEntityType_t m_lteRlcEntityType
Ptr< LteTestRrc > m_enbRrc
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
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
std::vector< Ptr< Node > >::const_iterator Iterator
virtual ~LteSimpleHelper(void)
Ptr< NetDevice > InstallSingleEnbDevice(Ptr< Node > n)
Ptr< NetDevice > InstallSingleUeDevice(Ptr< Node > n)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
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:336
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition: log.h:309
void EnableTraces(void)
Enables trace sinks for MAC, RLC and PDCP.
Ptr< LteTestMac > m_ueMac
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 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:1238
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.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
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.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
NetDeviceContainer InstallUeDevice(NodeContainer c)
create a set of UE devices
NS_LOG_COMPONENT_DEFINE("LteSimpleHelper")
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.
uint32_t AddDevice(Ptr< NetDevice > device)
Definition: node.cc:118
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:68
void Initialize(void)
This method calls the virtual DoInitialize method on all the objects aggregated to this object...
Definition: object.cc:180
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.
a base class which provides memory management and object aggregation
Definition: object.h:63
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:611
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:343
void LteSimpleHelperDlTxPduCallback(Ptr< RadioBearerStatsCalculator > rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
void LogComponentEnable(char const *name, enum LogLevel level)
Definition: log.cc:311
bool Receive(Ptr< NetDevice > nd, Ptr< const Packet > p, uint16_t protocol, const Address &addr)