A Discrete-Event Network Simulator
API
lte-simple-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Manuel Requena <manuel.requena@cttc.es> (Based on lte-helper.cc)
18 */
19
20#include "lte-simple-helper.h"
21
23#include "lte-test-entities.h"
24
25#include "ns3/callback.h"
26#include "ns3/config.h"
27#include "ns3/error-model.h"
28#include "ns3/log.h"
29#include "ns3/simple-channel.h"
30
31namespace ns3
32{
33
34NS_LOG_COMPONENT_DEFINE("LteSimpleHelper");
35
36NS_OBJECT_ENSURE_REGISTERED(LteSimpleHelper);
37
39{
40 NS_LOG_FUNCTION(this);
43}
44
45void
47{
48 NS_LOG_FUNCTION(this);
49
50 m_phyChannel = CreateObject<SimpleChannel>();
51
53}
54
56{
57 NS_LOG_FUNCTION(this);
58}
59
62{
63 static TypeId tid = TypeId("ns3::LteSimpleHelper")
65 .AddConstructor<LteSimpleHelper>()
66 .AddAttribute("RlcEntity",
67 "Specify which type of RLC will be used. ",
70 MakeEnumChecker(RLC_UM, "RlcUm", RLC_AM, "RlcAm"));
71 return tid;
72}
73
74void
76{
77 NS_LOG_FUNCTION(this);
78 m_phyChannel = nullptr;
79
81 m_enbMac = nullptr;
83 m_ueMac = nullptr;
84
86}
87
90{
91 NS_LOG_FUNCTION(this);
92 Initialize(); // will run DoInitialize () if necessary
94 for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i)
95 {
96 Ptr<Node> node = *i;
98 devices.Add(device);
99 }
100 return devices;
101}
102
105{
106 NS_LOG_FUNCTION(this);
108 for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i)
109 {
110 Ptr<Node> node = *i;
112 devices.Add(device);
113 }
114 return devices;
115}
116
119{
120 NS_LOG_FUNCTION(this);
121
122 m_enbRrc = CreateObject<LteTestRrc>();
123 m_enbPdcp = CreateObject<LtePdcp>();
124
126 {
127 m_enbRlc = CreateObject<LteRlcUm>();
128 }
129 else // m_lteRlcEntityType == RLC_AM
130 {
131 m_enbRlc = CreateObject<LteRlcAm>();
132 }
133
134 m_enbRlc->SetRnti(11);
135 m_enbRlc->SetLcId(12);
136
138 enbDev->SetAddress(Mac48Address::Allocate());
139 enbDev->SetChannel(m_phyChannel);
140
141 n->AddDevice(enbDev);
142
143 m_enbMac = CreateObject<LteTestMac>();
144 m_enbMac->SetDevice(enbDev);
145
146 m_enbRrc->SetDevice(enbDev);
147
148 enbDev->SetReceiveCallback(MakeCallback(&LteTestMac::Receive, m_enbMac));
149
150 // Connect SAPs: RRC <-> PDCP <-> RLC <-> MAC
151
152 m_enbRrc->SetLtePdcpSapProvider(m_enbPdcp->GetLtePdcpSapProvider());
153 m_enbPdcp->SetLtePdcpSapUser(m_enbRrc->GetLtePdcpSapUser());
154
155 m_enbPdcp->SetLteRlcSapProvider(m_enbRlc->GetLteRlcSapProvider());
156 m_enbRlc->SetLteRlcSapUser(m_enbPdcp->GetLteRlcSapUser());
157
160
161 return enbDev;
162}
163
166{
167 NS_LOG_FUNCTION(this);
168
169 m_ueRrc = CreateObject<LteTestRrc>();
170 m_uePdcp = CreateObject<LtePdcp>();
171
173 {
174 m_ueRlc = CreateObject<LteRlcUm>();
175 }
176 else // m_lteRlcEntityType == RLC_AM
177 {
178 m_ueRlc = CreateObject<LteRlcAm>();
179 }
180
181 m_ueRlc->SetRnti(21);
182 m_ueRlc->SetLcId(22);
183
185 ueDev->SetAddress(Mac48Address::Allocate());
186 ueDev->SetChannel(m_phyChannel);
187
188 n->AddDevice(ueDev);
189
190 m_ueMac = CreateObject<LteTestMac>();
191 m_ueMac->SetDevice(ueDev);
192
193 ueDev->SetReceiveCallback(MakeCallback(&LteTestMac::Receive, m_ueMac));
194
195 // Connect SAPs: RRC <-> PDCP <-> RLC <-> MAC
196
197 m_ueRrc->SetLtePdcpSapProvider(m_uePdcp->GetLtePdcpSapProvider());
198 m_uePdcp->SetLtePdcpSapUser(m_ueRrc->GetLtePdcpSapUser());
199
200 m_uePdcp->SetLteRlcSapProvider(m_ueRlc->GetLteRlcSapProvider());
201 m_ueRlc->SetLteRlcSapUser(m_uePdcp->GetLteRlcSapUser());
202
205
206 return ueDev;
207}
208
209void
211{
212 LogLevel level =
214
215 LogComponentEnable("Config", level);
216 LogComponentEnable("LteSimpleHelper", level);
217 LogComponentEnable("LteTestEntities", level);
218 LogComponentEnable("LtePdcp", level);
219 LogComponentEnable("LteRlc", level);
220 LogComponentEnable("LteRlcUm", level);
221 LogComponentEnable("LteRlcAm", level);
222 LogComponentEnable("LteSimpleNetDevice", level);
223 LogComponentEnable("SimpleNetDevice", level);
224 LogComponentEnable("SimpleChannel", level);
225}
226
227void
229{
230 // EnableMacTraces ();
233}
234
235void
237{
240}
241
251void
253 std::string path,
254 uint16_t rnti,
255 uint8_t lcid,
257{
258 NS_LOG_FUNCTION(rlcStats << path << rnti << (uint16_t)lcid << packetSize);
259 uint64_t imsi = 111;
260 uint16_t cellId = 222;
261 rlcStats->DlTxPdu(cellId, imsi, rnti, lcid, packetSize);
262}
263
274void
276 std::string path,
277 uint16_t rnti,
278 uint8_t lcid,
280 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
288void
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
308void
310 std::string path,
311 uint16_t rnti,
312 uint8_t lcid,
314{
315 NS_LOG_FUNCTION(rlcStats << path << rnti << (uint16_t)lcid << packetSize);
316 uint64_t imsi = 1111;
317 uint16_t cellId = 555;
318 rlcStats->UlTxPdu(cellId, imsi, rnti, lcid, packetSize);
319}
320
331void
333 std::string path,
334 uint16_t rnti,
335 uint8_t lcid,
337 uint64_t delay)
338{
339 NS_LOG_FUNCTION(rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
340 uint64_t imsi = 444;
341 uint16_t cellId = 555;
342 rlcStats->UlRxPdu(cellId, imsi, rnti, lcid, packetSize, delay);
343}
344
345void
347{
349
350 // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/TxPDU",
351 // MakeBoundCallback (&LteSimpleHelperUlTxPduCallback, m_rlcStats));
352 // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/RxPDU",
353 // MakeBoundCallback (&LteSimpleHelperUlRxPduCallback, m_rlcStats));
354}
355
356void
358{
361}
362
363void
365{
367
368 // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/TxPDU",
369 // MakeBoundCallback (&LteSimpleHelperDlTxPduCallback, m_pdcpStats));
370 // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/RxPDU",
371 // MakeBoundCallback (&LteSimpleHelperDlRxPduCallback, m_pdcpStats));
372}
373
374void
376{
378
379 // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/TxPDU",
380 // MakeBoundCallback (&LteSimpleHelperUlTxPduCallback, m_pdcpStats));
381 // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/RxPDU",
382 // MakeBoundCallback (&LteSimpleHelperUlRxPduCallback, m_pdcpStats));
383}
384
385} // namespace ns3
Hold variables of type enum.
Definition: enum.h:56
void SetLteRlcSapUser(LteRlcSapUser *s)
Definition: lte-rlc.cc:148
void SetRnti(uint16_t rnti)
Definition: lte-rlc.cc:134
void SetLteMacSapProvider(LteMacSapProvider *s)
Definition: lte-rlc.cc:162
LteMacSapUser * GetLteMacSapUser()
Definition: lte-rlc.cc:169
void SetLcId(uint8_t lcId)
Definition: lte-rlc.cc:141
LteRlcSapProvider * GetLteRlcSapProvider()
Definition: lte-rlc.cc:155
ObjectFactory m_ueDeviceFactory
UE device factory.
Ptr< NetDevice > InstallSingleEnbDevice(Ptr< Node > n)
Install single ENB device.
Ptr< LteTestRrc > m_ueRrc
UE RRC.
static TypeId GetTypeId()
Get the type ID.
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.
void EnableDlPdcpTraces()
Enable trace sinks for DL PDCP layer.
ObjectFactory m_enbDeviceFactory
ENB device factory.
Ptr< SimpleChannel > m_phyChannel
the physical channel
void EnableRlcTraces()
Enable trace sinks for RLC layer.
void DoDispose() override
Destructor implementation.
void EnableUlRlcTraces()
Enable trace sinks for UL RLC layer.
Ptr< LteTestRrc > m_enbRrc
ENB RRC.
void EnableDlRlcTraces()
Enable trace sinks for DL RLC layer.
Ptr< LteTestMac > m_enbMac
ENB MAC.
Ptr< LteTestMac > m_ueMac
UE MAC.
void EnableTraces()
Enables trace sinks for MAC, RLC and PDCP.
Ptr< LteRlc > m_ueRlc
UE RLC.
NetDeviceContainer InstallUeDevice(NodeContainer c)
create a set of UE devices
void DoInitialize() override
Initialize() implementation.
Ptr< LtePdcp > m_uePdcp
UE PDCP.
Ptr< LteRlc > m_enbRlc
ENB RLC.
enum ns3::LteSimpleHelper::LteRlcEntityType_t m_lteRlcEntityType
RLC entity type.
void EnableLogComponents()
Enables logging for all components of the LENA architecture.
void EnablePdcpTraces()
Enable trace sinks for PDCP layer.
void EnableUlPdcpTraces()
Enable trace sinks for UL PDCP layer.
The LteSimpleNetDevice class implements the LTE simple net device.
static TypeId GetTypeId()
Get the type ID.
void SetLteMacSapUser(LteMacSapUser *s)
Set the MAC SAP user.
LteMacSapProvider * GetLteMacSapProvider()
Get the MAC SAP provider.
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.
static Mac48Address Allocate()
Allocate a new Mac48Address.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:138
Ptr< Object > Create() 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:89
void Initialize()
Invoke DoInitialize on all Objects aggregated to this one.
Definition: object.cc:186
virtual void DoInitialize()
Initialize() implementation.
Definition: object.cc:360
void Dispose()
Dispose of this Object.
Definition: object.cc:219
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:353
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition: enum.h:205
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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:46
devices
Definition: first.py:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:691
void LogComponentEnable(const char *name, LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:296
void LteSimpleHelperDlTxPduCallback(Ptr< RadioBearerStatsCalculator > rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
DL transmit PDU callback.
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 LteSimpleHelperUlTxPduCallback(Ptr< RadioBearerStatsCalculator > rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
UL 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:163
static const uint32_t packetSize
Packet size generated at the AP.