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  */
22 
23 #include <ns3/llc-snap-header.h>
24 #include <ns3/simulator.h>
25 #include <ns3/callback.h>
26 #include <ns3/node.h>
27 #include <ns3/packet.h>
28 #include <ns3/lte-net-device.h>
29 #include <ns3/packet-burst.h>
30 #include <ns3/uinteger.h>
31 #include <ns3/trace-source-accessor.h>
32 #include <ns3/pointer.h>
33 #include <ns3/enum.h>
34 #include <ns3/lte-amc.h>
35 #include <ns3/lte-enb-mac.h>
36 #include <ns3/lte-enb-net-device.h>
37 #include <ns3/lte-enb-rrc.h>
38 #include <ns3/lte-ue-net-device.h>
39 #include <ns3/lte-enb-phy.h>
40 #include <ns3/ff-mac-scheduler.h>
41 #include <ns3/lte-handover-algorithm.h>
42 #include <ns3/lte-anr.h>
43 #include <ns3/lte-ffr-algorithm.h>
44 #include <ns3/ipv4-l3-protocol.h>
45 #include <ns3/abort.h>
46 #include <ns3/log.h>
47 
48 namespace ns3 {
49 
50 NS_LOG_COMPONENT_DEFINE ("LteEnbNetDevice");
51 
52 NS_OBJECT_ENSURE_REGISTERED ( LteEnbNetDevice);
53 
55 {
56  static TypeId
57  tid =
58  TypeId ("ns3::LteEnbNetDevice")
60  .AddConstructor<LteEnbNetDevice> ()
61  .AddAttribute ("LteEnbRrc",
62  "The RRC associated to this EnbNetDevice",
63  PointerValue (),
65  MakePointerChecker <LteEnbRrc> ())
66  .AddAttribute ("LteHandoverAlgorithm",
67  "The handover algorithm associated to this EnbNetDevice",
68  PointerValue (),
70  MakePointerChecker <LteHandoverAlgorithm> ())
71  .AddAttribute ("LteAnr",
72  "The automatic neighbour relation function associated to this EnbNetDevice",
73  PointerValue (),
75  MakePointerChecker <LteAnr> ())
76  .AddAttribute ("LteFfrAlgorithm",
77  "The FFR algorithm associated to this EnbNetDevice",
78  PointerValue (),
80  MakePointerChecker <LteFfrAlgorithm> ())
81  .AddAttribute ("LteEnbMac",
82  "The MAC associated to this EnbNetDevice",
83  PointerValue (),
85  MakePointerChecker <LteEnbMac> ())
86  .AddAttribute ("FfMacScheduler",
87  "The scheduler associated to this EnbNetDevice",
88  PointerValue (),
90  MakePointerChecker <FfMacScheduler> ())
91  .AddAttribute ("LteEnbPhy",
92  "The PHY associated to this EnbNetDevice",
93  PointerValue (),
95  MakePointerChecker <LteEnbPhy> ())
96  .AddAttribute ("UlBandwidth",
97  "Uplink Transmission Bandwidth Configuration in number of Resource Blocks",
98  UintegerValue (25),
101  MakeUintegerChecker<uint8_t> ())
102  .AddAttribute ("DlBandwidth",
103  "Downlink Transmission Bandwidth Configuration in number of Resource Blocks",
104  UintegerValue (25),
107  MakeUintegerChecker<uint8_t> ())
108  .AddAttribute ("CellId",
109  "Cell Identifier",
110  UintegerValue (0),
112  MakeUintegerChecker<uint16_t> ())
113  .AddAttribute ("DlEarfcn",
114  "Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
115  "as per 3GPP 36.101 Section 5.7.3. ",
116  UintegerValue (100),
118  MakeUintegerChecker<uint16_t> (0, 6599))
119  .AddAttribute ("UlEarfcn",
120  "Uplink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
121  "as per 3GPP 36.101 Section 5.7.3. ",
122  UintegerValue (18100),
124  MakeUintegerChecker<uint16_t> (18000, 24599))
125  .AddAttribute ("CsgId",
126  "The Closed Subscriber Group (CSG) identity that this eNodeB belongs to",
127  UintegerValue (0),
130  MakeUintegerChecker<uint32_t> ())
131  .AddAttribute ("CsgIndication",
132  "If true, only UEs which are members of the CSG (i.e. same CSG ID) "
133  "can gain access to the eNodeB, therefore enforcing closed access mode. "
134  "Otherwise, the eNodeB operates as a non-CSG cell and implements open access mode.",
135  BooleanValue (false),
139  ;
140  return tid;
141 }
142 
144  : m_isConstructed (false),
145  m_isConfigured (false),
146  m_anr (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_mac->Dispose ();
162  m_mac = 0;
163 
164  m_scheduler->Dispose ();
165  m_scheduler = 0;
166 
167  m_rrc->Dispose ();
168  m_rrc = 0;
169 
170  m_handoverAlgorithm->Dispose ();
172 
173  if (m_anr != 0)
174  {
175  m_anr->Dispose ();
176  m_anr = 0;
177  }
178 
179  m_ffrAlgorithm->Dispose ();
180  m_ffrAlgorithm = 0;
181 
182  m_phy->Dispose ();
183  m_phy = 0;
184 
186 }
187 
188 
189 
192 {
193  return m_mac;
194 }
195 
198 {
199  return m_phy;
200 }
201 
204 {
205  return m_rrc;
206 }
207 
208 uint16_t
210 {
211  return m_cellId;
212 }
213 
214 uint8_t
216 {
217  return m_ulBandwidth;
218 }
219 
220 void
222 {
223  NS_LOG_FUNCTION (this << uint16_t (bw));
224  switch (bw)
225  {
226  case 6:
227  case 15:
228  case 25:
229  case 50:
230  case 75:
231  case 100:
232  m_ulBandwidth = bw;
233  break;
234 
235  default:
236  NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) bw);
237  break;
238  }
239 }
240 
241 uint8_t
243 {
244  return m_dlBandwidth;
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_dlBandwidth = bw;
260  break;
261 
262  default:
263  NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) bw);
264  break;
265  }
266 }
267 
268 uint16_t
270 {
271  return m_dlEarfcn;
272 }
273 
274 void
276 {
277  NS_LOG_FUNCTION (this << earfcn);
278  m_dlEarfcn = earfcn;
279 }
280 
281 uint16_t
283 {
284  return m_ulEarfcn;
285 }
286 
287 void
289 {
290  NS_LOG_FUNCTION (this << earfcn);
291  m_ulEarfcn = earfcn;
292 }
293 
294 uint32_t
296 {
297  return m_csgId;
298 }
299 
300 void
302 {
303  NS_LOG_FUNCTION (this << csgId);
304  m_csgId = csgId;
305  UpdateConfig (); // propagate the change to RRC level
306 }
307 
308 bool
310 {
311  return m_csgIndication;
312 }
313 
314 void
316 {
317  NS_LOG_FUNCTION (this << csgIndication);
318  m_csgIndication = csgIndication;
319  UpdateConfig (); // propagate the change to RRC level
320 }
321 
322 
323 void
325 {
326  NS_LOG_FUNCTION (this);
327  m_isConstructed = true;
328  UpdateConfig ();
329  m_phy->Initialize ();
330  m_mac->Initialize ();
331  m_rrc->Initialize ();
332  m_handoverAlgorithm->Initialize ();
333 
334  if (m_anr != 0)
335  {
336  m_anr->Initialize ();
337  }
338 
339  m_ffrAlgorithm->Initialize ();
340 }
341 
342 
343 bool
344 LteEnbNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
345 {
346  NS_LOG_FUNCTION (this << packet << dest << protocolNumber);
347  NS_ASSERT_MSG (protocolNumber == Ipv4L3Protocol::PROT_NUMBER, "unsupported protocol " << protocolNumber << ", only IPv4 is supported");
348  return m_rrc->SendData (packet);
349 }
350 
351 
352 void
354 {
355  NS_LOG_FUNCTION (this);
356 
357  if (m_isConstructed)
358  {
359  if (!m_isConfigured)
360  {
361  NS_LOG_LOGIC (this << " Configure cell " << m_cellId);
362  // we have to make sure that this function is called only once
364  m_isConfigured = true;
365  }
366 
367  NS_LOG_LOGIC (this << " Updating SIB1 of cell " << m_cellId
368  << " with CSG ID " << m_csgId
369  << " and CSG indication " << m_csgIndication);
370  m_rrc->SetCsgId (m_csgId, m_csgIndication);
371  }
372  else
373  {
374  /*
375  * Lower layers are not ready yet, so do nothing now and expect
376  * ``DoInitialize`` to re-invoke this function.
377  */
378  }
379 }
380 
381 
382 } // namespace ns3
uint16_t GetDlEarfcn() const
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:34
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
uint16_t GetCellId() const
virtual void DoDispose(void)
Destructor implementation.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
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:81
uint8_t m_dlBandwidth
downlink bandwidth in RBs
Ptr< LteEnbPhy > GetPhy(void) const
#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
uint16_t m_dlEarfcn
downlink carrier frequency
uint32_t GetCsgId() const
Returns the CSG ID of the eNodeB.
Ptr< LteEnbMac > m_mac
a polymophic address class
Definition: address.h:90
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
virtual void DoInitialize(void)
Initialize() implementation.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
static TypeId GetTypeId(void)
Ptr< LteEnbPhy > m_phy
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
Hold objects of type Ptr.
Definition: pointer.h:36
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
void SetDlEarfcn(uint16_t earfcn)
virtual void DoDispose(void)
Destructor implementation.
void SetCsgIndication(bool csgIndication)
Enable or disable the CSG indication flag.
uint16_t GetUlEarfcn() const
uint16_t m_ulEarfcn
uplink carrier frequency
#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 GetCsgIndication() const
Returns the CSG indication flag of the eNodeB.
Ptr< LteHandoverAlgorithm > m_handoverAlgorithm
uint16_t m_cellId
Cell Identifer.
uint8_t GetDlBandwidth() const
void SetCsgId(uint32_t csgId)
Associate the eNodeB device with a particular CSG.
uint8_t m_ulBandwidth
uplink bandwidth in RBs
Ptr< FfMacScheduler > m_scheduler
virtual ~LteEnbNetDevice(void)
void SetUlEarfcn(uint16_t earfcn)
LteNetDevice provides basic implementation for all LTE network devices.
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:904
static const uint16_t PROT_NUMBER
Protocol number (0x0800)