A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-enb-net-device.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Giuseppe Piro <g.piro@poliba.it>
7 * Author: Marco Miozzo <mmiozzo@cttc.es> : Update to FF API Architecture
8 * Author: Nicola Baldo <nbaldo@cttc.es> : Integrated with new RRC and MAC architecture
9 * Author: Danilo Abrignani <danilo.abrignani@unibo.it> : Integrated with new architecture - GSoC
10 * 2015 - Carrier Aggregation
11 */
12
13#include "lte-enb-net-device.h"
14
16#include "lte-anr.h"
18#include "lte-enb-mac.h"
19#include "lte-enb-phy.h"
20#include "lte-enb-rrc.h"
21#include "lte-ffr-algorithm.h"
23#include "lte-net-device.h"
24
25#include <ns3/abort.h>
26#include <ns3/callback.h>
27#include <ns3/enum.h>
28#include <ns3/ipv4-l3-protocol.h>
29#include <ns3/ipv6-l3-protocol.h>
30#include <ns3/llc-snap-header.h>
31#include <ns3/log.h>
32#include <ns3/node.h>
33#include <ns3/object-factory.h>
34#include <ns3/object-map.h>
35#include <ns3/packet-burst.h>
36#include <ns3/packet.h>
37#include <ns3/pointer.h>
38#include <ns3/simulator.h>
39#include <ns3/trace-source-accessor.h>
40#include <ns3/uinteger.h>
41
42namespace ns3
43{
44
45NS_LOG_COMPONENT_DEFINE("LteEnbNetDevice");
46
47NS_OBJECT_ENSURE_REGISTERED(LteEnbNetDevice);
48
49TypeId
51{
52 static TypeId tid =
53 TypeId("ns3::LteEnbNetDevice")
55 .AddConstructor<LteEnbNetDevice>()
56 .AddAttribute("LteEnbRrc",
57 "The RRC associated to this EnbNetDevice",
61 .AddAttribute("LteHandoverAlgorithm",
62 "The handover algorithm associated to this EnbNetDevice",
66 .AddAttribute(
67 "LteAnr",
68 "The automatic neighbour relation function associated to this EnbNetDevice",
72 .AddAttribute("LteFfrAlgorithm",
73 "The FFR algorithm associated to this EnbNetDevice",
77 .AddAttribute("LteEnbComponentCarrierManager",
78 "The RRC associated to this EnbNetDevice",
82 .AddAttribute("ComponentCarrierMap",
83 "List of component carriers.",
87 .AddAttribute(
88 "UlBandwidth",
89 "Uplink Transmission Bandwidth Configuration in number of Resource Blocks",
90 UintegerValue(25),
94 .AddAttribute(
95 "DlBandwidth",
96 "Downlink Transmission Bandwidth Configuration in number of Resource Blocks",
97 UintegerValue(25),
101 .AddAttribute("CellId",
102 "Cell Identifier",
103 UintegerValue(0),
106 .AddAttribute("DlEarfcn",
107 "Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
108 "as per 3GPP 36.101 Section 5.7.3.",
109 UintegerValue(100),
112 .AddAttribute("UlEarfcn",
113 "Uplink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
114 "as per 3GPP 36.101 Section 5.7.3.",
115 UintegerValue(18100),
118 .AddAttribute(
119 "CsgId",
120 "The Closed Subscriber Group (CSG) identity that this eNodeB belongs to",
121 UintegerValue(0),
124 .AddAttribute(
125 "CsgIndication",
126 "If true, only UEs which are members of the CSG (i.e. same CSG ID) "
127 "can gain access to the eNodeB, therefore enforcing closed access mode. "
128 "Otherwise, the eNodeB operates as a non-CSG cell and implements open access mode.",
129 BooleanValue(false),
133 return tid;
134}
135
137 : m_isConstructed(false),
138 m_isConfigured(false),
139 m_anr(nullptr),
140 m_componentCarrierManager(nullptr)
141{
142 NS_LOG_FUNCTION(this);
143}
144
149
150void
152{
153 NS_LOG_FUNCTION(this);
154
155 m_rrc->Dispose();
156 m_rrc = nullptr;
157
158 m_handoverAlgorithm->Dispose();
159 m_handoverAlgorithm = nullptr;
160
161 if (m_anr)
162 {
163 m_anr->Dispose();
164 m_anr = nullptr;
165 }
166 m_componentCarrierManager->Dispose();
168 // ComponentCarrierEnb::DoDispose() will call DoDispose
169 // of its PHY, MAC, FFR and scheduler instance
170 for (uint32_t i = 0; i < m_ccMap.size(); i++)
171 {
172 m_ccMap.at(i)->Dispose();
173 m_ccMap.at(i) = nullptr;
174 }
175
177}
178
181{
182 return GetMac(0);
183}
184
187{
188 return GetPhy(0);
189}
190
192LteEnbNetDevice::GetMac(uint8_t index) const
193{
194 return DynamicCast<ComponentCarrierEnb>(m_ccMap.at(index))->GetMac();
195}
196
198LteEnbNetDevice::GetPhy(uint8_t index) const
199{
200 return DynamicCast<ComponentCarrierEnb>(m_ccMap.at(index))->GetPhy();
201}
202
205{
206 return m_rrc;
207}
208
214
215uint16_t
217{
218 return m_cellId;
219}
220
221std::vector<uint16_t>
223{
224 std::vector<uint16_t> cellIds;
225
226 cellIds.reserve(m_ccMap.size());
227 for (auto& it : m_ccMap)
228 {
229 cellIds.push_back(it.second->GetCellId());
230 }
231 return cellIds;
232}
233
234bool
235LteEnbNetDevice::HasCellId(uint16_t cellId) const
236{
237 return m_rrc->HasCellId(cellId);
238}
239
240uint16_t
242{
243 return m_ulBandwidth;
244}
245
246void
248{
249 NS_LOG_FUNCTION(this << bw);
250 switch (bw)
251 {
252 case 6:
253 case 15:
254 case 25:
255 case 50:
256 case 75:
257 case 100:
258 m_ulBandwidth = bw;
259 break;
260
261 default:
262 NS_FATAL_ERROR("invalid bandwidth value " << bw);
263 break;
264 }
265}
266
267uint16_t
269{
270 return m_dlBandwidth;
271}
272
273void
275{
276 NS_LOG_FUNCTION(this << uint16_t(bw));
277 switch (bw)
278 {
279 case 6:
280 case 15:
281 case 25:
282 case 50:
283 case 75:
284 case 100:
285 m_dlBandwidth = bw;
286 break;
287
288 default:
289 NS_FATAL_ERROR("invalid bandwidth value " << bw);
290 break;
291 }
292}
293
296{
297 return m_dlEarfcn;
298}
299
300void
302{
303 NS_LOG_FUNCTION(this << earfcn);
304 m_dlEarfcn = earfcn;
305}
306
309{
310 return m_ulEarfcn;
311}
312
313void
315{
316 NS_LOG_FUNCTION(this << earfcn);
317 m_ulEarfcn = earfcn;
318}
319
322{
323 return m_csgId;
324}
325
326void
328{
329 NS_LOG_FUNCTION(this << csgId);
330 m_csgId = csgId;
331 UpdateConfig(); // propagate the change to RRC level
332}
333
334bool
339
340void
342{
343 NS_LOG_FUNCTION(this << csgIndication);
344 m_csgIndication = csgIndication;
345 UpdateConfig(); // propagate the change to RRC level
346}
347
348std::map<uint8_t, Ptr<ComponentCarrierBaseStation>>
350{
351 return m_ccMap;
352}
353
354void
356{
357 NS_ASSERT_MSG(!m_isConfigured, "attempt to set CC map after configuration");
358 m_ccMap = ccm;
359}
360
361void
363{
364 NS_LOG_FUNCTION(this);
365 m_isConstructed = true;
366 UpdateConfig();
367 for (auto it = m_ccMap.begin(); it != m_ccMap.end(); ++it)
368 {
369 it->second->Initialize();
370 }
371 m_rrc->Initialize();
372 m_componentCarrierManager->Initialize();
373 m_handoverAlgorithm->Initialize();
374
375 if (m_anr)
376 {
377 m_anr->Initialize();
378 }
379
380 m_ffrAlgorithm->Initialize();
381}
382
383bool
384LteEnbNetDevice::Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
385{
386 NS_LOG_FUNCTION(this << packet << dest << protocolNumber);
388 protocolNumber != Ipv6L3Protocol::PROT_NUMBER,
389 "unsupported protocol " << protocolNumber
390 << ", only IPv4 and IPv6 are supported");
391 return m_rrc->SendData(packet);
392}
393
394void
396{
397 NS_LOG_FUNCTION(this);
398
399 if (m_isConstructed)
400 {
401 if (!m_isConfigured)
402 {
403 NS_LOG_LOGIC(this << " Configure cell " << m_cellId);
404 // we have to make sure that this function is called only once
405 NS_ASSERT(!m_ccMap.empty());
406 m_rrc->ConfigureCell(m_ccMap);
407 m_isConfigured = true;
408 }
409
410 NS_LOG_LOGIC(this << " Updating SIB1 of cell " << m_cellId << " with CSG ID " << m_csgId
411 << " and CSG indication " << m_csgIndication);
412 m_rrc->SetCsgId(m_csgId, m_csgIndication);
413 }
414 else
415 {
416 /*
417 * Lower layers are not ready yet, so do nothing now and expect
418 * ``DoInitialize`` to re-invoke this function.
419 */
420 }
421}
422
423} // namespace ns3
a polymophic address class
Definition address.h:90
AttributeValue implementation for Boolean.
Definition boolean.h:26
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
void SetUlEarfcn(uint32_t earfcn)
std::map< uint8_t, Ptr< ComponentCarrierBaseStation > > GetCcMap() const
bool HasCellId(uint16_t cellId) const
Ptr< LteAnr > m_anr
ANR.
void UpdateConfig()
Propagate attributes and configuration to sub-modules.
uint32_t m_dlEarfcn
DEPRECATE - It is maintained for backward compatibility after adding CA feature- downlink carrier fre...
void SetCsgId(uint32_t csgId)
Associate the eNodeB device with a particular CSG.
Ptr< LteHandoverAlgorithm > m_handoverAlgorithm
the handover algorithm
void SetDlEarfcn(uint32_t earfcn)
void SetCcMap(std::map< uint8_t, Ptr< ComponentCarrierBaseStation > > ccm)
Set the ComponentCarrier Map of the Enb.
bool m_isConfigured
is configured?
bool GetCsgIndication() const
Returns the CSG indication flag of the eNodeB.
void SetUlBandwidth(uint16_t bw)
uint16_t m_dlBandwidth
DEPRECATE - It is maintained for backward compatibility after adding CA feature- downlink bandwidth i...
bool m_isConstructed
is constructed?
uint32_t GetCsgId() const
Returns the CSG ID of the eNodeB.
uint16_t GetDlBandwidth() const
uint32_t GetUlEarfcn() const
uint32_t GetDlEarfcn() const
Ptr< LteEnbRrc > GetRrc() const
void SetCsgIndication(bool csgIndication)
Enable or disable the CSG indication flag.
Ptr< LteEnbRrc > m_rrc
the RRC
Ptr< LteEnbPhy > GetPhy() const
uint16_t m_cellId
Cell Identifier.
uint16_t GetUlBandwidth() const
void DoInitialize() override
Initialize() implementation.
std::vector< uint16_t > GetCellIds() const
Ptr< LteEnbComponentCarrierManager > GetComponentCarrierManager() const
bool m_csgIndication
CSG indication.
void SetDlBandwidth(uint16_t bw)
uint32_t m_ulEarfcn
DEPRECATE - It is maintained for backward compatibility after adding CA feature- uplink carrier frequ...
Ptr< LteFfrAlgorithm > m_ffrAlgorithm
DEPRECATED - It is maintained for backward compatibility after adding CA feature.
Ptr< LteEnbComponentCarrierManager > m_componentCarrierManager
the component carrier manager of this eNb
static TypeId GetTypeId()
Get the type ID.
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
Ptr< LteEnbMac > GetMac() const
std::map< uint8_t, Ptr< ComponentCarrierBaseStation > > m_ccMap
ComponentCarrier map.
uint16_t m_ulBandwidth
DEPRECATE - It is maintained for backward compatibility after adding CA feature- uplink bandwidth in ...
void DoDispose() override
Destructor implementation.
LteNetDevice provides basic implementation for all LTE network devices.
void DoDispose() override
Destructor implementation.
AttributeValue implementation for Pointer.
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
Hold an unsigned integer type.
Definition uinteger.h:34
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition boolean.cc:113
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition boolean.h:70
ObjectPtrContainerValue ObjectMapValue
ObjectMapValue is an alias for ObjectPtrContainerValue.
Definition object-map.h:29
Ptr< const AttributeAccessor > MakeObjectMapAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Definition object-map.h:65
Ptr< const AttributeChecker > MakeObjectMapChecker()
Definition object-map.h:110
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition pointer.h:248
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Definition pointer.h:269
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition uinteger.h:35
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition abort.h:97
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#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:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580