A Discrete-Event Network Simulator
API
lte-enb-net-device.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Giuseppe Piro <g.piro@poliba.it>
19  * Author: Marco Miozzo <mmiozzo@cttc.es> : Update to FF API Architecture
20  * Author: Nicola Baldo <nbaldo@cttc.es> : Integrated with new RRC and MAC architecture
21  * Author: Danilo Abrignani <danilo.abrignani@unibo.it> : Integrated with new architecture - GSoC 2015 - Carrier Aggregation
22  */
23 
24 #include <ns3/llc-snap-header.h>
25 #include <ns3/simulator.h>
26 #include <ns3/callback.h>
27 #include <ns3/node.h>
28 #include <ns3/packet.h>
29 #include <ns3/lte-net-device.h>
30 #include <ns3/packet-burst.h>
31 #include <ns3/uinteger.h>
32 #include <ns3/trace-source-accessor.h>
33 #include <ns3/pointer.h>
34 #include <ns3/enum.h>
35 #include <ns3/lte-amc.h>
36 #include <ns3/lte-enb-mac.h>
37 #include <ns3/lte-enb-net-device.h>
38 #include <ns3/lte-enb-rrc.h>
39 #include <ns3/lte-ue-net-device.h>
40 #include <ns3/lte-enb-phy.h>
41 #include <ns3/ff-mac-scheduler.h>
42 #include <ns3/lte-handover-algorithm.h>
43 #include <ns3/lte-anr.h>
44 #include <ns3/lte-ffr-algorithm.h>
45 #include <ns3/ipv4-l3-protocol.h>
46 #include <ns3/ipv6-l3-protocol.h>
47 #include <ns3/abort.h>
48 #include <ns3/log.h>
49 #include <ns3/lte-enb-component-carrier-manager.h>
50 #include <ns3/object-map.h>
51 #include <ns3/object-factory.h>
52 
53 namespace ns3 {
54 
55 NS_LOG_COMPONENT_DEFINE ("LteEnbNetDevice");
56 
57 NS_OBJECT_ENSURE_REGISTERED ( LteEnbNetDevice);
58 
60 {
61  static TypeId
62  tid =
63  TypeId ("ns3::LteEnbNetDevice")
65  .AddConstructor<LteEnbNetDevice> ()
66  .AddAttribute ("LteEnbRrc",
67  "The RRC associated to this EnbNetDevice",
68  PointerValue (),
70  MakePointerChecker <LteEnbRrc> ())
71  .AddAttribute ("LteHandoverAlgorithm",
72  "The handover algorithm associated to this EnbNetDevice",
73  PointerValue (),
75  MakePointerChecker <LteHandoverAlgorithm> ())
76  .AddAttribute ("LteAnr",
77  "The automatic neighbour relation function associated to this EnbNetDevice",
78  PointerValue (),
80  MakePointerChecker <LteAnr> ())
81  .AddAttribute ("LteFfrAlgorithm",
82  "The FFR algorithm associated to this EnbNetDevice",
83  PointerValue (),
85  MakePointerChecker <LteFfrAlgorithm> ())
86  .AddAttribute ("LteEnbComponentCarrierManager",
87  "The RRC associated to this EnbNetDevice",
88  PointerValue (),
90  MakePointerChecker <LteEnbComponentCarrierManager> ())
91  .AddAttribute ("ComponentCarrierMap", "List of component carriers.",
92  ObjectMapValue (),
94  MakeObjectMapChecker<ComponentCarrierEnb> ())
95  .AddAttribute ("UlBandwidth",
96  "Uplink Transmission Bandwidth Configuration in number of Resource Blocks",
97  UintegerValue (25),
100  MakeUintegerChecker<uint8_t> ())
101  .AddAttribute ("DlBandwidth",
102  "Downlink Transmission Bandwidth Configuration in number of Resource Blocks",
103  UintegerValue (25),
106  MakeUintegerChecker<uint8_t> ())
107  .AddAttribute ("CellId",
108  "Cell Identifier",
109  UintegerValue (0),
111  MakeUintegerChecker<uint16_t> ())
112  .AddAttribute ("DlEarfcn",
113  "Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
114  "as per 3GPP 36.101 Section 5.7.3. ",
115  UintegerValue (100),
117  MakeUintegerChecker<uint32_t> (0, 262143))
118  .AddAttribute ("UlEarfcn",
119  "Uplink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
120  "as per 3GPP 36.101 Section 5.7.3. ",
121  UintegerValue (18100),
123  MakeUintegerChecker<uint32_t> (0, 262143))
124  .AddAttribute ("CsgId",
125  "The Closed Subscriber Group (CSG) identity that this eNodeB belongs to",
126  UintegerValue (0),
129  MakeUintegerChecker<uint32_t> ())
130  .AddAttribute ("CsgIndication",
131  "If true, only UEs which are members of the CSG (i.e. same CSG ID) "
132  "can gain access to the eNodeB, therefore enforcing closed access mode. "
133  "Otherwise, the eNodeB operates as a non-CSG cell and implements open access mode.",
134  BooleanValue (false),
138  ;
139  return tid;
140 }
141 
143  : m_isConstructed (false),
144  m_isConfigured (false),
145  m_anr (0),
146  m_componentCarrierManager(0)
147 {
148  NS_LOG_FUNCTION (this);
149 }
150 
152 {
153  NS_LOG_FUNCTION (this);
154 }
155 
156 void
158 {
159  NS_LOG_FUNCTION (this);
160 
161  m_rrc->Dispose ();
162  m_rrc = 0;
163 
164  m_handoverAlgorithm->Dispose ();
166 
167  if (m_anr != 0)
168  {
169  m_anr->Dispose ();
170  m_anr = 0;
171  }
172  m_componentCarrierManager->Dispose();
174  // ComponentCarrierEnb::DoDispose() will call DoDispose
175  // of its PHY, MAC, FFR and scheduler instance
176  for (uint32_t i = 0; i < m_ccMap.size (); i++)
177  {
178  m_ccMap.at (i)->Dispose ();
179  m_ccMap.at (i) = 0;
180  }
181 
183 }
184 
185 
186 
189 {
190  return GetMac (0);
191 }
192 
195 {
196  return GetPhy (0);
197 }
198 
200 LteEnbNetDevice::GetMac (uint8_t index) const
201 {
202  return DynamicCast<ComponentCarrierEnb> (m_ccMap.at (index))->GetMac ();
203 }
204 
206 LteEnbNetDevice::GetPhy(uint8_t index) const
207 {
208  return DynamicCast<ComponentCarrierEnb> (m_ccMap.at (index))->GetPhy ();
209 }
210 
213 {
214  return m_rrc;
215 }
216 
219 {
221 }
222 
223 uint16_t
225 {
226  return m_cellId;
227 }
228 
229 bool
230 LteEnbNetDevice::HasCellId (uint16_t cellId) const
231 {
232  for (auto &it: m_ccMap)
233  {
234  if (it.second->GetCellId () == cellId)
235  {
236  return true;
237  }
238  }
239  return false;
240 }
241 
242 uint16_t
244 {
245  return m_ulBandwidth;
246 }
247 
248 void
250 {
251  NS_LOG_FUNCTION (this << bw);
252  switch (bw)
253  {
254  case 6:
255  case 15:
256  case 25:
257  case 50:
258  case 75:
259  case 100:
260  m_ulBandwidth = bw;
261  break;
262 
263  default:
264  NS_FATAL_ERROR ("invalid bandwidth value " << bw);
265  break;
266  }
267 }
268 
269 uint16_t
271 {
272  return m_dlBandwidth;
273 }
274 
275 void
277 {
278  NS_LOG_FUNCTION (this << uint16_t (bw));
279  switch (bw)
280  {
281  case 6:
282  case 15:
283  case 25:
284  case 50:
285  case 75:
286  case 100:
287  m_dlBandwidth = bw;
288  break;
289 
290  default:
291  NS_FATAL_ERROR ("invalid bandwidth value " << bw);
292  break;
293  }
294 }
295 
296 uint32_t
298 {
299  return m_dlEarfcn;
300 }
301 
302 void
304 {
305  NS_LOG_FUNCTION (this << earfcn);
306  m_dlEarfcn = earfcn;
307 }
308 
309 uint32_t
311 {
312  return m_ulEarfcn;
313 }
314 
315 void
317 {
318  NS_LOG_FUNCTION (this << earfcn);
319  m_ulEarfcn = earfcn;
320 }
321 
322 uint32_t
324 {
325  return m_csgId;
326 }
327 
328 void
330 {
331  NS_LOG_FUNCTION (this << csgId);
332  m_csgId = csgId;
333  UpdateConfig (); // propagate the change to RRC level
334 }
335 
336 bool
338 {
339  return m_csgIndication;
340 }
341 
342 void
344 {
345  NS_LOG_FUNCTION (this << csgIndication);
346  m_csgIndication = csgIndication;
347  UpdateConfig (); // propagate the change to RRC level
348 }
349 
350 std::map < uint8_t, Ptr<ComponentCarrierBaseStation> >
352 {
353  return m_ccMap;
354 }
355 
356 void
358 {
359  NS_ASSERT_MSG (!m_isConfigured, "attempt to set CC map after configuration");
360  m_ccMap = ccm;
361 }
362 
363 void
365 {
366  NS_LOG_FUNCTION (this);
367  m_isConstructed = true;
368  UpdateConfig ();
369  for (auto it = m_ccMap.begin (); it != m_ccMap.end (); ++it)
370  {
371  it->second->Initialize ();
372  }
373  m_rrc->Initialize ();
374  m_componentCarrierManager->Initialize();
375  m_handoverAlgorithm->Initialize ();
376 
377  if (m_anr != 0)
378  {
379  m_anr->Initialize ();
380  }
381 
382  m_ffrAlgorithm->Initialize ();
383 }
384 
385 
386 bool
387 LteEnbNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
388 {
389  NS_LOG_FUNCTION (this << packet << dest << protocolNumber);
391  && protocolNumber != Ipv6L3Protocol::PROT_NUMBER,
392  "unsupported protocol " << protocolNumber << ", only IPv4 and IPv6 are supported");
393  return m_rrc->SendData (packet);
394 }
395 
396 
397 void
399 {
400  NS_LOG_FUNCTION (this);
401 
402  if (m_isConstructed)
403  {
404  if (!m_isConfigured)
405  {
406  NS_LOG_LOGIC (this << " Configure cell " << m_cellId);
407  // we have to make sure that this function is called only once
408  NS_ASSERT (!m_ccMap.empty ());
409  m_rrc->ConfigureCell (m_ccMap);
410  m_isConfigured = true;
411  }
412 
413  NS_LOG_LOGIC (this << " Updating SIB1 of cell " << m_cellId
414  << " with CSG ID " << m_csgId
415  << " and CSG indication " << m_csgIndication);
416  m_rrc->SetCsgId (m_csgId, m_csgIndication);
417  }
418  else
419  {
420  /*
421  * Lower layers are not ready yet, so do nothing now and expect
422  * ``DoInitialize`` to re-invoke this function.
423  */
424  }
425 }
426 
427 
428 } // namespace ns3
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::LteEnbNetDevice::GetComponentCarrierManager
Ptr< LteEnbComponentCarrierManager > GetComponentCarrierManager() const
Definition: lte-enb-net-device.cc:218
ns3::LteEnbNetDevice::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: lte-enb-net-device.cc:157
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
ns3::LteEnbNetDevice::m_csgIndication
bool m_csgIndication
CSG indication.
Definition: lte-enb-net-device.h:254
ns3::BooleanValue
AttributeValue implementation for Boolean.
Definition: boolean.h:37
ns3::LteEnbNetDevice::m_ulEarfcn
uint32_t m_ulEarfcn
DEPRECATE - It is maintained for backward compatibility after adding CA feature- uplink carrier frequ...
Definition: lte-enb-net-device.h:251
ns3::LteEnbNetDevice::GetCellId
uint16_t GetCellId() const
Definition: lte-enb-net-device.cc:224
ns3::LteEnbNetDevice::GetCsgIndication
bool GetCsgIndication() const
Returns the CSG indication flag of the eNodeB.
Definition: lte-enb-net-device.cc:337
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::LteEnbNetDevice::SetCsgIndication
void SetCsgIndication(bool csgIndication)
Enable or disable the CSG indication flag.
Definition: lte-enb-net-device.cc:343
ns3::MakeObjectMapAccessor
Ptr< const AttributeAccessor > MakeObjectMapAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Definition: object-map.h:80
ns3::LteNetDevice::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: lte-net-device.cc:78
ns3::LteEnbNetDevice::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: lte-enb-net-device.cc:59
ns3::LteEnbNetDevice::m_ccMap
std::map< uint8_t, Ptr< ComponentCarrierBaseStation > > m_ccMap
ComponentCarrier map.
Definition: lte-enb-net-device.h:256
ns3::PointerValue
Hold objects of type Ptr<T>.
Definition: pointer.h:37
ns3::ObjectPtrContainerValue
Container for a set of ns3::Object pointers.
Definition: object-ptr-container.h:46
ns3::LteEnbNetDevice::GetMac
Ptr< LteEnbMac > GetMac(void) const
Definition: lte-enb-net-device.cc:188
ns3::LteEnbNetDevice::m_dlBandwidth
uint16_t m_dlBandwidth
DEPRECATE - It is maintained for backward compatibility after adding CA feature- downlink bandwidth i...
Definition: lte-enb-net-device.h:247
ns3::LteEnbNetDevice::GetCcMap
std::map< uint8_t, Ptr< ComponentCarrierBaseStation > > GetCcMap(void) const
Definition: lte-enb-net-device.cc:351
ns3::MakeBooleanAccessor
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:85
ns3::LteEnbNetDevice::m_csgId
uint16_t m_csgId
CSG ID.
Definition: lte-enb-net-device.h:253
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::LteEnbNetDevice::GetPhy
Ptr< LteEnbPhy > GetPhy(void) const
Definition: lte-enb-net-device.cc:194
ns3::LteEnbNetDevice::GetRrc
Ptr< LteEnbRrc > GetRrc() const
Definition: lte-enb-net-device.cc:212
ns3::LteEnbNetDevice::m_dlEarfcn
uint32_t m_dlEarfcn
DEPRECATE - It is maintained for backward compatibility after adding CA feature- downlink carrier fre...
Definition: lte-enb-net-device.h:250
ns3::LteEnbNetDevice::m_isConstructed
bool m_isConstructed
is constructed?
Definition: lte-enb-net-device.h:222
ns3::LteEnbNetDevice::Send
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Definition: lte-enb-net-device.cc:387
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
ns3::LteEnbNetDevice::GetUlEarfcn
uint32_t GetUlEarfcn() const
Definition: lte-enb-net-device.cc:310
ns3::LteEnbNetDevice::m_isConfigured
bool m_isConfigured
is configured?
Definition: lte-enb-net-device.h:223
ns3::LteEnbNetDevice::SetCsgId
void SetCsgId(uint32_t csgId)
Associate the eNodeB device with a particular CSG.
Definition: lte-enb-net-device.cc:329
ns3::LteEnbNetDevice::m_ffrAlgorithm
Ptr< LteFfrAlgorithm > m_ffrAlgorithm
DEPRECATED - It is maintained for backward compatibility after adding CA feature.
Definition: lte-enb-net-device.h:243
ns3::Address
a polymophic address class
Definition: address.h:91
ns3::MakeBooleanChecker
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
ns3::LteEnbNetDevice::m_componentCarrierManager
Ptr< LteEnbComponentCarrierManager > m_componentCarrierManager
the component carrier manager of this eNb
Definition: lte-enb-net-device.h:258
ns3::LteEnbNetDevice::m_ulBandwidth
uint16_t m_ulBandwidth
DEPRECATE - It is maintained for backward compatibility after adding CA feature- uplink bandwidth in ...
Definition: lte-enb-net-device.h:248
NS_ABORT_MSG_IF
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
ns3::LteEnbNetDevice::GetDlEarfcn
uint32_t GetDlEarfcn() const
Definition: lte-enb-net-device.cc:297
NS_ASSERT_MSG
#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:88
ns3::Ipv6L3Protocol::PROT_NUMBER
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
Definition: ipv6-l3-protocol.h:74
ns3::LteEnbNetDevice::GetCsgId
uint32_t GetCsgId() const
Returns the CSG ID of the eNodeB.
Definition: lte-enb-net-device.cc:323
ns3::LteEnbNetDevice::SetUlBandwidth
void SetUlBandwidth(uint16_t bw)
Definition: lte-enb-net-device.cc:249
ns3::LteEnbNetDevice::LteEnbNetDevice
LteEnbNetDevice()
Definition: lte-enb-net-device.cc:142
ns3::Ipv4L3Protocol::PROT_NUMBER
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
Definition: ipv4-l3-protocol.h:88
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
ns3::MakePointerAccessor
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:227
ns3::LteEnbNetDevice::m_rrc
Ptr< LteEnbRrc > m_rrc
the RRC
Definition: lte-enb-net-device.h:237
ns3::LteEnbNetDevice::UpdateConfig
void UpdateConfig()
Propagate attributes and configuration to sub-modules.
Definition: lte-enb-net-device.cc:398
ns3::LteEnbNetDevice::SetUlEarfcn
void SetUlEarfcn(uint32_t earfcn)
Definition: lte-enb-net-device.cc:316
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition: log-macros-enabled.h:244
ns3::LteEnbNetDevice::SetDlEarfcn
void SetDlEarfcn(uint32_t earfcn)
Definition: lte-enb-net-device.cc:303
ns3::LteNetDevice
LteNetDevice provides basic implementation for all LTE network devices.
Definition: lte-net-device.h:49
ns3::LteEnbNetDevice::DoInitialize
virtual void DoInitialize(void)
Initialize() implementation.
Definition: lte-enb-net-device.cc:364
ns3::UintegerValue
Hold an unsigned integer type.
Definition: uinteger.h:44
ns3::MakeUintegerAccessor
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:45
ns3::LteEnbNetDevice::m_cellId
uint16_t m_cellId
Cell Identifier.
Definition: lte-enb-net-device.h:245
ns3::LteEnbNetDevice::HasCellId
bool HasCellId(uint16_t cellId) const
Definition: lte-enb-net-device.cc:230
ns3::LteEnbNetDevice::GetUlBandwidth
uint16_t GetUlBandwidth() const
Definition: lte-enb-net-device.cc:243
ns3::LteEnbNetDevice::m_handoverAlgorithm
Ptr< LteHandoverAlgorithm > m_handoverAlgorithm
the handover algorithm
Definition: lte-enb-net-device.h:239
ns3::LteEnbNetDevice::~LteEnbNetDevice
virtual ~LteEnbNetDevice(void)
Definition: lte-enb-net-device.cc:151
ns3::LteEnbNetDevice::GetDlBandwidth
uint16_t GetDlBandwidth() const
Definition: lte-enb-net-device.cc:270
ns3::LteEnbNetDevice::SetDlBandwidth
void SetDlBandwidth(uint16_t bw)
Definition: lte-enb-net-device.cc:276
ns3::LteEnbNetDevice::SetCcMap
void SetCcMap(std::map< uint8_t, Ptr< ComponentCarrierBaseStation > > ccm)
Set the ComponentCarrier Map of the Enb.
Definition: lte-enb-net-device.cc:357
ns3::LteEnbNetDevice::m_anr
Ptr< LteAnr > m_anr
ANR.
Definition: lte-enb-net-device.h:241