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/abort.h>
47 #include <ns3/log.h>
48 #include <ns3/lte-enb-component-carrier-manager.h>
49 #include <ns3/object-map.h>
50 #include <ns3/object-factory.h>
51 
52 namespace ns3 {
53 
54 NS_LOG_COMPONENT_DEFINE ("LteEnbNetDevice");
55 
56 NS_OBJECT_ENSURE_REGISTERED ( LteEnbNetDevice);
57 
59 {
60  static TypeId
61  tid =
62  TypeId ("ns3::LteEnbNetDevice")
64  .AddConstructor<LteEnbNetDevice> ()
65  .AddAttribute ("LteEnbRrc",
66  "The RRC associated to this EnbNetDevice",
67  PointerValue (),
69  MakePointerChecker <LteEnbRrc> ())
70  .AddAttribute ("LteHandoverAlgorithm",
71  "The handover algorithm associated to this EnbNetDevice",
72  PointerValue (),
74  MakePointerChecker <LteHandoverAlgorithm> ())
75  .AddAttribute ("LteAnr",
76  "The automatic neighbour relation function associated to this EnbNetDevice",
77  PointerValue (),
79  MakePointerChecker <LteAnr> ())
80  .AddAttribute ("LteFfrAlgorithm",
81  "The FFR algorithm associated to this EnbNetDevice",
82  PointerValue (),
84  MakePointerChecker <LteFfrAlgorithm> ())
85  .AddAttribute ("LteEnbComponentCarrierManager",
86  "The RRC associated to this EnbNetDevice",
87  PointerValue (),
89  MakePointerChecker <LteEnbComponentCarrierManager> ())
90  .AddAttribute ("ComponentCarrierMap", "List of component carriers.",
91  ObjectMapValue (),
93  MakeObjectMapChecker<ComponentCarrierEnb> ())
94  .AddAttribute ("UlBandwidth",
95  "Uplink Transmission Bandwidth Configuration in number of Resource Blocks",
96  UintegerValue (25),
99  MakeUintegerChecker<uint8_t> ())
100  .AddAttribute ("DlBandwidth",
101  "Downlink Transmission Bandwidth Configuration in number of Resource Blocks",
102  UintegerValue (25),
105  MakeUintegerChecker<uint8_t> ())
106  .AddAttribute ("CellId",
107  "Cell Identifier",
108  UintegerValue (0),
110  MakeUintegerChecker<uint16_t> ())
111  .AddAttribute ("DlEarfcn",
112  "Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
113  "as per 3GPP 36.101 Section 5.7.3. ",
114  UintegerValue (100),
116  MakeUintegerChecker<uint32_t> (0, 262143))
117  .AddAttribute ("UlEarfcn",
118  "Uplink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
119  "as per 3GPP 36.101 Section 5.7.3. ",
120  UintegerValue (18100),
122  MakeUintegerChecker<uint32_t> (0, 262143))
123  .AddAttribute ("CsgId",
124  "The Closed Subscriber Group (CSG) identity that this eNodeB belongs to",
125  UintegerValue (0),
128  MakeUintegerChecker<uint32_t> ())
129  .AddAttribute ("CsgIndication",
130  "If true, only UEs which are members of the CSG (i.e. same CSG ID) "
131  "can gain access to the eNodeB, therefore enforcing closed access mode. "
132  "Otherwise, the eNodeB operates as a non-CSG cell and implements open access mode.",
133  BooleanValue (false),
137  ;
138  return tid;
139 }
140 
142  : m_isConstructed (false),
143  m_isConfigured (false),
144  m_anr (0),
145  m_componentCarrierManager(0)
146 {
147  NS_LOG_FUNCTION (this);
148 }
149 
151 {
152  NS_LOG_FUNCTION (this);
153 }
154 
155 void
157 {
158  NS_LOG_FUNCTION (this);
159 
160  m_rrc->Dispose ();
161  m_rrc = 0;
162 
163  m_handoverAlgorithm->Dispose ();
165 
166  if (m_anr != 0)
167  {
168  m_anr->Dispose ();
169  m_anr = 0;
170  }
171  m_componentCarrierManager->Dispose();
173  // ComponentCarrierEnb::DoDispose() will call DoDispose
174  // of its PHY, MAC, FFR and scheduler instance
175  for (uint32_t i = 0; i < m_ccMap.size (); i++)
176  {
177  m_ccMap.at (i)->Dispose ();
178  m_ccMap.at (i) = 0;
179  }
180 
182 }
183 
184 
185 
188 {
189  return m_ccMap.at (0)->GetMac ();
190 }
191 
194 {
195  return m_ccMap.at (0)->GetPhy ();
196 }
197 
199 LteEnbNetDevice::GetMac (uint8_t index)
200 {
201  return m_ccMap.at (index)->GetMac ();
202 }
203 
205 LteEnbNetDevice::GetPhy(uint8_t index)
206 {
207  return m_ccMap.at (index)->GetPhy ();
208 }
209 
212 {
213  return m_rrc;
214 }
215 
218 {
220 }
221 
222 uint16_t
224 {
225  return m_cellId;
226 }
227 
228 bool
229 LteEnbNetDevice::HasCellId (uint16_t cellId) const
230 {
231  for (auto &it: m_ccMap)
232  {
233  if (it.second->GetCellId () == cellId)
234  {
235  return true;
236  }
237  }
238  return false;
239 }
240 
241 uint8_t
243 {
244  return m_ulBandwidth;
245 }
246 
247 void
249 {
250  NS_LOG_FUNCTION (this << uint16_t (bw));
251  switch (bw)
252  {
253  case 6:
254  case 15:
255  case 25:
256  case 50:
257  case 75:
258  case 100:
259  m_ulBandwidth = bw;
260  break;
261 
262  default:
263  NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) bw);
264  break;
265  }
266 }
267 
268 uint8_t
270 {
271  return m_dlBandwidth;
272 }
273 
274 void
276 {
277  NS_LOG_FUNCTION (this << uint16_t (bw));
278  switch (bw)
279  {
280  case 6:
281  case 15:
282  case 25:
283  case 50:
284  case 75:
285  case 100:
286  m_dlBandwidth = bw;
287  break;
288 
289  default:
290  NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) bw);
291  break;
292  }
293 }
294 
295 uint32_t
297 {
298  return m_dlEarfcn;
299 }
300 
301 void
303 {
304  NS_LOG_FUNCTION (this << earfcn);
305  m_dlEarfcn = earfcn;
306 }
307 
308 uint32_t
310 {
311  return m_ulEarfcn;
312 }
313 
314 void
316 {
317  NS_LOG_FUNCTION (this << earfcn);
318  m_ulEarfcn = earfcn;
319 }
320 
321 uint32_t
323 {
324  return m_csgId;
325 }
326 
327 void
329 {
330  NS_LOG_FUNCTION (this << csgId);
331  m_csgId = csgId;
332  UpdateConfig (); // propagate the change to RRC level
333 }
334 
335 bool
337 {
338  return m_csgIndication;
339 }
340 
341 void
343 {
344  NS_LOG_FUNCTION (this << csgIndication);
345  m_csgIndication = csgIndication;
346  UpdateConfig (); // propagate the change to RRC level
347 }
348 
349 std::map < uint8_t, Ptr<ComponentCarrierEnb> >
351 {
352  return m_ccMap;
353 }
354 
355 void
357 {
358  NS_ASSERT_MSG (!m_isConfigured, "attempt to set CC map after configuration");
359  m_ccMap = ccm;
360 }
361 
362 void
364 {
365  NS_LOG_FUNCTION (this);
366  m_isConstructed = true;
367  UpdateConfig ();
368  std::map< uint8_t, Ptr<ComponentCarrierEnb> >::iterator it;
369  for (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);
390  NS_ASSERT_MSG (protocolNumber == Ipv4L3Protocol::PROT_NUMBER, "unsupported protocol " << protocolNumber << ", only IPv4 is supported");
391  return m_rrc->SendData (packet);
392 }
393 
394 
395 void
397 {
398  NS_LOG_FUNCTION (this);
399 
400  if (m_isConstructed)
401  {
402  if (!m_isConfigured)
403  {
404  NS_LOG_LOGIC (this << " Configure cell " << m_cellId);
405  // we have to make sure that this function is called only once
406  NS_ASSERT (!m_ccMap.empty ());
407  m_rrc->ConfigureCell (m_ccMap);
408  m_isConfigured = true;
409  }
410 
411  NS_LOG_LOGIC (this << " Updating SIB1 of cell " << m_cellId
412  << " with CSG ID " << m_csgId
413  << " and CSG indication " << m_csgIndication);
414  m_rrc->SetCsgId (m_csgId, m_csgIndication);
415  }
416  else
417  {
418  /*
419  * Lower layers are not ready yet, so do nothing now and expect
420  * ``DoInitialize`` to re-invoke this function.
421  */
422  }
423 }
424 
425 
426 } // namespace ns3
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
AttributeValue implementation for Boolean.
Definition: boolean.h:36
void SetUlEarfcn(uint32_t earfcn)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
uint16_t GetCellId() const
virtual void DoDispose(void)
Destructor implementation.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Ptr< LteAnr > m_anr
ANR.
uint8_t GetUlBandwidth() const
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:84
uint8_t m_dlBandwidth
DEPRECATE - It is maintained for backward compatibility after adding CA feature- downlink bandwidth i...
Ptr< LteEnbPhy > GetPhy(void) const
uint32_t m_dlEarfcn
DEPRECATE - It is maintained for backward compatibility after adding CA feature- downlink carrier fre...
#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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
std::map< uint8_t, Ptr< ComponentCarrierEnb > > m_ccMap
ComponentCarrier map.
uint32_t GetCsgId() const
Returns the CSG ID of the eNodeB.
Ptr< LteEnbComponentCarrierManager > m_componentCarrierManager
the component carrier manager of this eNb
bool m_isConstructed
is constructed?
uint16_t m_csgId
CSG ID.
a polymophic address class
Definition: address.h:90
uint32_t GetUlEarfcn() const
void UpdateConfig()
Propagate attributes and configuration to sub-modules.
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:220
Hold an unsigned integer type.
Definition: uinteger.h:44
void SetUlBandwidth(uint8_t bw)
Ptr< LteEnbRrc > m_rrc
the RRC
virtual void DoInitialize(void)
Initialize() implementation.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< LteEnbRrc > GetRrc() const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetDlBandwidth(uint8_t bw)
Ptr< LteFfrAlgorithm > m_ffrAlgorithm
DEPRECATED - It is maintained for backward compatibility after adding CA feature. ...
uint32_t GetDlEarfcn() const
Hold objects of type Ptr.
Definition: pointer.h:36
void SetDlEarfcn(uint32_t earfcn)
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
virtual void DoDispose(void)
Destructor implementation.
void SetCsgIndication(bool csgIndication)
Enable or disable the CSG indication flag.
uint32_t m_ulEarfcn
DEPRECATE - It is maintained for backward compatibility after adding CA feature- uplink carrier frequ...
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
void SetCcMap(std::map< uint8_t, Ptr< ComponentCarrierEnb > > ccm)
Set the ComponentCarrier Map of the Enb.
#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:90
bool m_csgIndication
CSG indication.
bool GetCsgIndication() const
Returns the CSG indication flag of the eNodeB.
Ptr< LteEnbComponentCarrierManager > GetComponentCarrierManager() const
bool m_isConfigured
is configured?
bool HasCellId(uint16_t cellId) const
Ptr< LteHandoverAlgorithm > m_handoverAlgorithm
the handover algorithm
uint16_t m_cellId
Cell Identifer.
uint8_t GetDlBandwidth() const
Ptr< const AttributeAccessor > MakeObjectMapAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Definition: object-map.h:80
void SetCsgId(uint32_t csgId)
Associate the eNodeB device with a particular CSG.
uint8_t m_ulBandwidth
DEPRECATE - It is maintained for backward compatibility after adding CA feature- uplink bandwidth in ...
virtual ~LteEnbNetDevice(void)
Container for a set of ns3::Object pointers.
LteNetDevice provides basic implementation for all LTE network devices.
std::map< uint8_t, Ptr< ComponentCarrierEnb > > GetCcMap(void)
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
a unique identifier for an interface.
Definition: type-id.h:58
Ptr< LteEnbMac > GetMac(void) const
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:914
static const uint16_t PROT_NUMBER
Protocol number (0x0800)