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>
18 * (Based on lte-helper.cc)
19 */
20
21#include "lte-simple-helper.h"
22
24#include "lte-test-entities.h"
25
26#include "ns3/callback.h"
27#include "ns3/config.h"
28#include "ns3/error-model.h"
29#include "ns3/log.h"
30#include "ns3/simple-channel.h"
31
32namespace ns3
33{
34
35NS_LOG_COMPONENT_DEFINE("LteSimpleHelper");
36
37NS_OBJECT_ENSURE_REGISTERED(LteSimpleHelper);
38
40{
41 NS_LOG_FUNCTION(this);
44}
45
46void
48{
49 NS_LOG_FUNCTION(this);
50
51 m_phyChannel = CreateObject<SimpleChannel>();
52
54}
55
57{
58 NS_LOG_FUNCTION(this);
59}
60
63{
64 static TypeId tid = TypeId("ns3::LteSimpleHelper")
66 .AddConstructor<LteSimpleHelper>()
67 .AddAttribute("RlcEntity",
68 "Specify which type of RLC will be used. ",
70 MakeEnumAccessor<LteRlcEntityType_t>(
72 MakeEnumChecker(RLC_UM, "RlcUm", RLC_AM, "RlcAm"));
73 return tid;
74}
75
76void
78{
79 NS_LOG_FUNCTION(this);
80 m_phyChannel = nullptr;
81
83 m_enbMac = nullptr;
85 m_ueMac = nullptr;
86
88}
89
92{
93 NS_LOG_FUNCTION(this);
94 Initialize(); // will run DoInitialize () if necessary
95 NetDeviceContainer devices;
96 for (auto i = c.Begin(); i != c.End(); ++i)
97 {
98 Ptr<Node> node = *i;
100 devices.Add(device);
101 }
102 return devices;
103}
104
107{
108 NS_LOG_FUNCTION(this);
109 NetDeviceContainer devices;
110 for (auto i = c.Begin(); i != c.End(); ++i)
111 {
112 Ptr<Node> node = *i;
114 devices.Add(device);
115 }
116 return devices;
117}
118
121{
122 NS_LOG_FUNCTION(this);
123
124 m_enbRrc = CreateObject<LteTestRrc>();
125 m_enbPdcp = CreateObject<LtePdcp>();
126
128 {
129 m_enbRlc = CreateObject<LteRlcUm>();
130 }
131 else // m_lteRlcEntityType == RLC_AM
132 {
133 m_enbRlc = CreateObject<LteRlcAm>();
134 }
135
136 m_enbRlc->SetRnti(11);
137 m_enbRlc->SetLcId(12);
138
140 enbDev->SetAddress(Mac48Address::Allocate());
141 enbDev->SetChannel(m_phyChannel);
142
143 n->AddDevice(enbDev);
144
145 m_enbMac = CreateObject<LteTestMac>();
146 m_enbMac->SetDevice(enbDev);
147
148 m_enbRrc->SetDevice(enbDev);
149
150 enbDev->SetReceiveCallback(MakeCallback(&LteTestMac::Receive, m_enbMac));
151
152 // Connect SAPs: RRC <-> PDCP <-> RLC <-> MAC
153
154 m_enbRrc->SetLtePdcpSapProvider(m_enbPdcp->GetLtePdcpSapProvider());
155 m_enbPdcp->SetLtePdcpSapUser(m_enbRrc->GetLtePdcpSapUser());
156
157 m_enbPdcp->SetLteRlcSapProvider(m_enbRlc->GetLteRlcSapProvider());
158 m_enbRlc->SetLteRlcSapUser(m_enbPdcp->GetLteRlcSapUser());
159
162
163 return enbDev;
164}
165
168{
169 NS_LOG_FUNCTION(this);
170
171 m_ueRrc = CreateObject<LteTestRrc>();
172 m_uePdcp = CreateObject<LtePdcp>();
173
175 {
176 m_ueRlc = CreateObject<LteRlcUm>();
177 }
178 else // m_lteRlcEntityType == RLC_AM
179 {
180 m_ueRlc = CreateObject<LteRlcAm>();
181 }
182
183 m_ueRlc->SetRnti(21);
184 m_ueRlc->SetLcId(22);
185
187 ueDev->SetAddress(Mac48Address::Allocate());
188 ueDev->SetChannel(m_phyChannel);
189
190 n->AddDevice(ueDev);
191
192 m_ueMac = CreateObject<LteTestMac>();
193 m_ueMac->SetDevice(ueDev);
194
195 ueDev->SetReceiveCallback(MakeCallback(&LteTestMac::Receive, m_ueMac));
196
197 // Connect SAPs: RRC <-> PDCP <-> RLC <-> MAC
198
199 m_ueRrc->SetLtePdcpSapProvider(m_uePdcp->GetLtePdcpSapProvider());
200 m_uePdcp->SetLtePdcpSapUser(m_ueRrc->GetLtePdcpSapUser());
201
202 m_uePdcp->SetLteRlcSapProvider(m_ueRlc->GetLteRlcSapProvider());
203 m_ueRlc->SetLteRlcSapUser(m_uePdcp->GetLteRlcSapUser());
204
207
208 return ueDev;
209}
210
211void
213{
215
216 LogComponentEnable("Config", level);
217 LogComponentEnable("LteSimpleHelper", level);
218 LogComponentEnable("LteTestEntities", level);
219 LogComponentEnable("LtePdcp", level);
220 LogComponentEnable("LteRlc", level);
221 LogComponentEnable("LteRlcUm", level);
222 LogComponentEnable("LteRlcAm", level);
223 LogComponentEnable("LteSimpleNetDevice", level);
224 LogComponentEnable("SimpleNetDevice", level);
225 LogComponentEnable("SimpleChannel", level);
226}
227
228void
230{
231 // EnableMacTraces ();
234}
235
236void
238{
241}
242
252void
254 std::string path,
255 uint16_t rnti,
256 uint8_t lcid,
258{
259 NS_LOG_FUNCTION(rlcStats << path << rnti << (uint16_t)lcid << packetSize);
260 uint64_t imsi = 111;
261 uint16_t cellId = 222;
262 rlcStats->DlTxPdu(cellId, imsi, rnti, lcid, packetSize);
263}
264
275void
277 std::string path,
278 uint16_t rnti,
279 uint8_t lcid,
281 uint64_t delay)
282{
283 NS_LOG_FUNCTION(rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
284 uint64_t imsi = 333;
285 uint16_t cellId = 555;
286 rlcStats->DlRxPdu(cellId, imsi, rnti, lcid, packetSize, delay);
287}
288
289void
291{
293
294 // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/TxPDU",
295 // MakeBoundCallback (&LteSimpleHelperDlTxPduCallback, m_rlcStats));
296 // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/RxPDU",
297 // MakeBoundCallback (&LteSimpleHelperDlRxPduCallback, m_rlcStats));
298}
299
309void
311 std::string path,
312 uint16_t rnti,
313 uint8_t lcid,
315{
316 NS_LOG_FUNCTION(rlcStats << path << rnti << (uint16_t)lcid << packetSize);
317 uint64_t imsi = 1111;
318 uint16_t cellId = 555;
319 rlcStats->UlTxPdu(cellId, imsi, rnti, lcid, packetSize);
320}
321
332void
334 std::string path,
335 uint16_t rnti,
336 uint8_t lcid,
338 uint64_t delay)
339{
340 NS_LOG_FUNCTION(rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
341 uint64_t imsi = 444;
342 uint16_t cellId = 555;
343 rlcStats->UlRxPdu(cellId, imsi, rnti, lcid, packetSize, delay);
344}
345
346void
348{
350
351 // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/TxPDU",
352 // MakeBoundCallback (&LteSimpleHelperUlTxPduCallback, m_rlcStats));
353 // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/RxPDU",
354 // MakeBoundCallback (&LteSimpleHelperUlRxPduCallback, m_rlcStats));
355}
356
357void
359{
362}
363
364void
366{
368
369 // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/TxPDU",
370 // MakeBoundCallback (&LteSimpleHelperDlTxPduCallback, m_pdcpStats));
371 // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/RxPDU",
372 // MakeBoundCallback (&LteSimpleHelperDlRxPduCallback, m_pdcpStats));
373}
374
375void
377{
379
380 // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/TxPDU",
381 // MakeBoundCallback (&LteSimpleHelperUlTxPduCallback, m_pdcpStats));
382 // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/RxPDU",
383 // MakeBoundCallback (&LteSimpleHelperUlRxPduCallback, m_pdcpStats));
384}
385
386} // namespace ns3
Hold variables of type enum.
Definition: enum.h:62
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:214
virtual void DoInitialize()
Initialize() implementation.
Definition: object.cc:451
void Dispose()
Dispose of this Object.
Definition: object.cc:258
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:444
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#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.
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.h:189
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.
static const uint32_t packetSize
Packet size generated at the AP.