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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Manuel Requena <manuel.requena@cttc.es>
7 * (Based on lte-helper.cc)
8 */
9
10#include "lte-simple-helper.h"
11
13#include "lte-test-entities.h"
14
15#include "ns3/callback.h"
16#include "ns3/config.h"
17#include "ns3/error-model.h"
18#include "ns3/log.h"
19#include "ns3/simple-channel.h"
20
21namespace ns3
22{
23
24NS_LOG_COMPONENT_DEFINE("LteSimpleHelper");
25
26NS_OBJECT_ENSURE_REGISTERED(LteSimpleHelper);
27
34
35void
44
49
52{
53 static TypeId tid = TypeId("ns3::LteSimpleHelper")
55 .AddConstructor<LteSimpleHelper>()
56 .AddAttribute("RlcEntity",
57 "Specify which type of RLC will be used. ",
61 MakeEnumChecker(RLC_UM, "RlcUm", RLC_AM, "RlcAm"));
62 return tid;
63}
64
65void
67{
68 NS_LOG_FUNCTION(this);
69 m_phyChannel = nullptr;
70
71 m_enbMac->Dispose();
72 m_enbMac = nullptr;
73 m_ueMac->Dispose();
74 m_ueMac = nullptr;
75
77}
78
81{
82 NS_LOG_FUNCTION(this);
83 Initialize(); // will run DoInitialize () if necessary
84 NetDeviceContainer devices;
85 for (auto i = c.Begin(); i != c.End(); ++i)
86 {
87 Ptr<Node> node = *i;
89 devices.Add(device);
90 }
91 return devices;
92}
93
96{
97 NS_LOG_FUNCTION(this);
98 NetDeviceContainer devices;
99 for (auto i = c.Begin(); i != c.End(); ++i)
100 {
101 Ptr<Node> node = *i;
103 devices.Add(device);
104 }
105 return devices;
106}
107
110{
111 NS_LOG_FUNCTION(this);
112
115
117 {
119 }
120 else // m_lteRlcEntityType == RLC_AM
121 {
123 }
124
125 m_enbRlc->SetRnti(11);
126 m_enbRlc->SetLcId(12);
127
129 enbDev->SetAddress(Mac48Address::Allocate());
130 enbDev->SetChannel(m_phyChannel);
131
132 n->AddDevice(enbDev);
133
135 m_enbMac->SetDevice(enbDev);
136
137 m_enbRrc->SetDevice(enbDev);
138
139 enbDev->SetReceiveCallback(MakeCallback(&LteTestMac::Receive, m_enbMac));
140
141 // Connect SAPs: RRC <-> PDCP <-> RLC <-> MAC
142
143 m_enbRrc->SetLtePdcpSapProvider(m_enbPdcp->GetLtePdcpSapProvider());
144 m_enbPdcp->SetLtePdcpSapUser(m_enbRrc->GetLtePdcpSapUser());
145
146 m_enbPdcp->SetLteRlcSapProvider(m_enbRlc->GetLteRlcSapProvider());
147 m_enbRlc->SetLteRlcSapUser(m_enbPdcp->GetLteRlcSapUser());
148
149 m_enbRlc->SetLteMacSapProvider(m_enbMac->GetLteMacSapProvider());
150 m_enbMac->SetLteMacSapUser(m_enbRlc->GetLteMacSapUser());
151
152 return enbDev;
153}
154
157{
158 NS_LOG_FUNCTION(this);
159
162
164 {
166 }
167 else // m_lteRlcEntityType == RLC_AM
168 {
170 }
171
172 m_ueRlc->SetRnti(21);
173 m_ueRlc->SetLcId(22);
174
176 ueDev->SetAddress(Mac48Address::Allocate());
177 ueDev->SetChannel(m_phyChannel);
178
179 n->AddDevice(ueDev);
180
182 m_ueMac->SetDevice(ueDev);
183
184 ueDev->SetReceiveCallback(MakeCallback(&LteTestMac::Receive, m_ueMac));
185
186 // Connect SAPs: RRC <-> PDCP <-> RLC <-> MAC
187
188 m_ueRrc->SetLtePdcpSapProvider(m_uePdcp->GetLtePdcpSapProvider());
189 m_uePdcp->SetLtePdcpSapUser(m_ueRrc->GetLtePdcpSapUser());
190
191 m_uePdcp->SetLteRlcSapProvider(m_ueRlc->GetLteRlcSapProvider());
192 m_ueRlc->SetLteRlcSapUser(m_uePdcp->GetLteRlcSapUser());
193
194 m_ueRlc->SetLteMacSapProvider(m_ueMac->GetLteMacSapProvider());
195 m_ueMac->SetLteMacSapUser(m_ueRlc->GetLteMacSapUser());
196
197 return ueDev;
198}
199
200void
202{
204
205 LogComponentEnable("Config", level);
206 LogComponentEnable("LteSimpleHelper", level);
207 LogComponentEnable("LteTestEntities", level);
208 LogComponentEnable("LtePdcp", level);
209 LogComponentEnable("LteRlc", level);
210 LogComponentEnable("LteRlcUm", level);
211 LogComponentEnable("LteRlcAm", level);
212 LogComponentEnable("LteSimpleNetDevice", level);
213 LogComponentEnable("SimpleNetDevice", level);
214 LogComponentEnable("SimpleChannel", level);
215}
216
217void
219{
220 // EnableMacTraces ();
223}
224
225void
231
232/**
233 * DL transmit PDU callback
234 *
235 * \param rlcStats the stats calculator
236 * \param path
237 * \param rnti the RNTI
238 * \param lcid the LCID
239 * \param packetSize the packet size
240 */
241void
243 std::string path,
244 uint16_t rnti,
245 uint8_t lcid,
247{
248 NS_LOG_FUNCTION(rlcStats << path << rnti << (uint16_t)lcid << packetSize);
249 uint64_t imsi = 111;
250 uint16_t cellId = 222;
251 rlcStats->DlTxPdu(cellId, imsi, rnti, lcid, packetSize);
252}
253
254/**
255 * DL receive PDU callback
256 *
257 * \param rlcStats the stats calculator
258 * \param path
259 * \param rnti the RNTI
260 * \param lcid the LCID
261 * \param packetSize the packet size
262 * \param delay the delay
263 */
264void
266 std::string path,
267 uint16_t rnti,
268 uint8_t lcid,
270 uint64_t delay)
271{
272 NS_LOG_FUNCTION(rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
273 uint64_t imsi = 333;
274 uint16_t cellId = 555;
275 rlcStats->DlRxPdu(cellId, imsi, rnti, lcid, packetSize, delay);
276}
277
278void
280{
282
283 // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/TxPDU",
284 // MakeBoundCallback (&LteSimpleHelperDlTxPduCallback, m_rlcStats));
285 // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/RxPDU",
286 // MakeBoundCallback (&LteSimpleHelperDlRxPduCallback, m_rlcStats));
287}
288
289/**
290 * UL transmit PDU callback
291 *
292 * \param rlcStats the stats calculator
293 * \param path
294 * \param rnti the RNTI
295 * \param lcid the LCID
296 * \param packetSize the packet size
297 */
298void
300 std::string path,
301 uint16_t rnti,
302 uint8_t lcid,
304{
305 NS_LOG_FUNCTION(rlcStats << path << rnti << (uint16_t)lcid << packetSize);
306 uint64_t imsi = 1111;
307 uint16_t cellId = 555;
308 rlcStats->UlTxPdu(cellId, imsi, rnti, lcid, packetSize);
309}
310
311/**
312 * UL receive PDU callback
313 *
314 * \param rlcStats the stats calculator
315 * \param path
316 * \param rnti the RNTI
317 * \param lcid the LCID
318 * \param packetSize the packet size
319 * \param delay the delay
320 */
321void
323 std::string path,
324 uint16_t rnti,
325 uint8_t lcid,
327 uint64_t delay)
328{
329 NS_LOG_FUNCTION(rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
330 uint64_t imsi = 444;
331 uint16_t cellId = 555;
332 rlcStats->UlRxPdu(cellId, imsi, rnti, lcid, packetSize, delay);
333}
334
335void
337{
339
340 // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/TxPDU",
341 // MakeBoundCallback (&LteSimpleHelperUlTxPduCallback, m_rlcStats));
342 // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/RxPDU",
343 // MakeBoundCallback (&LteSimpleHelperUlRxPduCallback, m_rlcStats));
344}
345
346void
352
353void
355{
357
358 // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/TxPDU",
359 // MakeBoundCallback (&LteSimpleHelperDlTxPduCallback, m_pdcpStats));
360 // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/RxPDU",
361 // MakeBoundCallback (&LteSimpleHelperDlRxPduCallback, m_pdcpStats));
362}
363
364void
366{
368
369 // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/TxPDU",
370 // MakeBoundCallback (&LteSimpleHelperUlTxPduCallback, m_pdcpStats));
371 // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/RxPDU",
372 // MakeBoundCallback (&LteSimpleHelperUlRxPduCallback, m_pdcpStats));
373}
374
375} // namespace ns3
Hold variables of type enum.
Definition enum.h:52
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.
bool Receive(Ptr< NetDevice > nd, Ptr< const Packet > p, uint16_t protocol, const Address &addr)
the Receive 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:78
void Initialize()
Invoke DoInitialize on all Objects aggregated to this one.
Definition object.cc:203
virtual void DoInitialize()
Initialize() implementation.
Definition object.cc:440
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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 ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
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:291
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:684
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:179
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:83
@ LOG_LEVEL_ALL
Print everything.
Definition log.h:105
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
Definition log.h:107
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
Definition log.h:108
@ LOG_PREFIX_NODE
Prefix all trace prints with simulation node.
Definition log.h:109
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 AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition enum.h:221
static const uint32_t packetSize
Packet size generated at the AP.