A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
93 NetDeviceContainer devices;
94 for (auto 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);
107 NetDeviceContainer devices;
108 for (auto 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{
213
214 LogComponentEnable("Config", level);
215 LogComponentEnable("LteSimpleHelper", level);
216 LogComponentEnable("LteTestEntities", level);
217 LogComponentEnable("LtePdcp", level);
218 LogComponentEnable("LteRlc", level);
219 LogComponentEnable("LteRlcUm", level);
220 LogComponentEnable("LteRlcAm", level);
221 LogComponentEnable("LteSimpleNetDevice", level);
222 LogComponentEnable("SimpleNetDevice", level);
223 LogComponentEnable("SimpleChannel", level);
224}
225
226void
228{
229 // EnableMacTraces ();
232}
233
234void
236{
239}
240
250void
252 std::string path,
253 uint16_t rnti,
254 uint8_t lcid,
256{
257 NS_LOG_FUNCTION(rlcStats << path << rnti << (uint16_t)lcid << packetSize);
258 uint64_t imsi = 111;
259 uint16_t cellId = 222;
260 rlcStats->DlTxPdu(cellId, imsi, rnti, lcid, packetSize);
261}
262
273void
275 std::string path,
276 uint16_t rnti,
277 uint8_t lcid,
279 uint64_t delay)
280{
281 NS_LOG_FUNCTION(rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
282 uint64_t imsi = 333;
283 uint16_t cellId = 555;
284 rlcStats->DlRxPdu(cellId, imsi, rnti, lcid, packetSize, delay);
285}
286
287void
289{
291
292 // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/TxPDU",
293 // MakeBoundCallback (&LteSimpleHelperDlTxPduCallback, m_rlcStats));
294 // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/RxPDU",
295 // MakeBoundCallback (&LteSimpleHelperDlRxPduCallback, m_rlcStats));
296}
297
307void
309 std::string path,
310 uint16_t rnti,
311 uint8_t lcid,
313{
314 NS_LOG_FUNCTION(rlcStats << path << rnti << (uint16_t)lcid << packetSize);
315 uint64_t imsi = 1111;
316 uint16_t cellId = 555;
317 rlcStats->UlTxPdu(cellId, imsi, rnti, lcid, packetSize);
318}
319
330void
332 std::string path,
333 uint16_t rnti,
334 uint8_t lcid,
336 uint64_t delay)
337{
338 NS_LOG_FUNCTION(rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
339 uint64_t imsi = 444;
340 uint16_t cellId = 555;
341 rlcStats->UlRxPdu(cellId, imsi, rnti, lcid, packetSize, delay);
342}
343
344void
346{
348
349 // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/TxPDU",
350 // MakeBoundCallback (&LteSimpleHelperUlTxPduCallback, m_rlcStats));
351 // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/RxPDU",
352 // MakeBoundCallback (&LteSimpleHelperUlRxPduCallback, m_rlcStats));
353}
354
355void
357{
360}
361
362void
364{
366
367 // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/TxPDU",
368 // MakeBoundCallback (&LteSimpleHelperDlTxPduCallback, m_pdcpStats));
369 // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/RxPDU",
370 // MakeBoundCallback (&LteSimpleHelperDlRxPduCallback, m_pdcpStats));
371}
372
373void
375{
377
378 // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/TxPDU",
379 // MakeBoundCallback (&LteSimpleHelperUlTxPduCallback, m_pdcpStats));
380 // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/RxPDU",
381 // MakeBoundCallback (&LteSimpleHelperUlRxPduCallback, m_pdcpStats));
382}
383
384} // namespace ns3
Hold variables of type enum.
Definition: enum.h:56
void SetLteRlcSapUser(LteRlcSapUser *s)
Definition: lte-rlc.cc:155
void SetRnti(uint16_t rnti)
Definition: lte-rlc.cc:134
void SetLteMacSapProvider(LteMacSapProvider *s)
Definition: lte-rlc.cc:169
LteMacSapUser * GetLteMacSapUser()
Definition: lte-rlc.cc:176
void SetLcId(uint8_t lcId)
Definition: lte-rlc.cc:141
LteRlcSapProvider * GetLteRlcSapProvider()
Definition: lte-rlc.cc:162
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.
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.
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:359
void Dispose()
Dispose of this Object.
Definition: object.cc:219
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:352
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:930
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:302
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:704
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.