A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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/ipv4-l3-protocol.h>
44 #include <ns3/abort.h>
45 #include <ns3/log.h>
46 
47 NS_LOG_COMPONENT_DEFINE ("LteEnbNetDevice");
48 
49 namespace ns3 {
50 
51 NS_OBJECT_ENSURE_REGISTERED ( LteEnbNetDevice);
52 
54 {
55  static TypeId
56  tid =
57  TypeId ("ns3::LteEnbNetDevice")
59  .AddConstructor<LteEnbNetDevice> ()
60  .AddAttribute ("LteEnbRrc",
61  "The RRC associated to this EnbNetDevice",
62  PointerValue (),
63  MakePointerAccessor (&LteEnbNetDevice::m_rrc),
64  MakePointerChecker <LteEnbRrc> ())
65  .AddAttribute ("LteHandoverAlgorithm",
66  "The handover algorithm associated to this EnbNetDevice",
67  PointerValue (),
68  MakePointerAccessor (&LteEnbNetDevice::m_handoverAlgorithm),
69  MakePointerChecker <LteHandoverAlgorithm> ())
70  .AddAttribute ("LteAnr",
71  "The automatic neighbour relation function associated to this EnbNetDevice",
72  PointerValue (),
73  MakePointerAccessor (&LteEnbNetDevice::m_anr),
74  MakePointerChecker <LteAnr> ())
75  .AddAttribute ("LteEnbMac",
76  "The MAC associated to this EnbNetDevice",
77  PointerValue (),
78  MakePointerAccessor (&LteEnbNetDevice::m_mac),
79  MakePointerChecker <LteEnbMac> ())
80  .AddAttribute ("FfMacScheduler",
81  "The scheduler associated to this EnbNetDevice",
82  PointerValue (),
83  MakePointerAccessor (&LteEnbNetDevice::m_scheduler),
84  MakePointerChecker <FfMacScheduler> ())
85  .AddAttribute ("LteEnbPhy",
86  "The PHY associated to this EnbNetDevice",
87  PointerValue (),
88  MakePointerAccessor (&LteEnbNetDevice::m_phy),
89  MakePointerChecker <LteEnbPhy> ())
90  .AddAttribute ("UlBandwidth",
91  "Uplink Transmission Bandwidth Configuration in number of Resource Blocks",
92  UintegerValue (25),
93  MakeUintegerAccessor (&LteEnbNetDevice::SetUlBandwidth,
95  MakeUintegerChecker<uint8_t> ())
96  .AddAttribute ("DlBandwidth",
97  "Downlink Transmission Bandwidth Configuration in number of Resource Blocks",
98  UintegerValue (25),
99  MakeUintegerAccessor (&LteEnbNetDevice::SetDlBandwidth,
101  MakeUintegerChecker<uint8_t> ())
102  .AddAttribute ("CellId",
103  "Cell Identifier",
104  UintegerValue (0),
105  MakeUintegerAccessor (&LteEnbNetDevice::m_cellId),
106  MakeUintegerChecker<uint16_t> ())
107  .AddAttribute ("DlEarfcn",
108  "Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
109  "as per 3GPP 36.101 Section 5.7.3. ",
110  UintegerValue (100),
111  MakeUintegerAccessor (&LteEnbNetDevice::m_dlEarfcn),
112  MakeUintegerChecker<uint16_t> (0, 6599))
113  .AddAttribute ("UlEarfcn",
114  "Uplink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
115  "as per 3GPP 36.101 Section 5.7.3. ",
116  UintegerValue (18100),
117  MakeUintegerAccessor (&LteEnbNetDevice::m_ulEarfcn),
118  MakeUintegerChecker<uint16_t> (18000, 24599))
119  .AddAttribute ("CsgId",
120  "The Closed Subscriber Group (CSG) identity that this eNodeB belongs to",
121  UintegerValue (0),
122  MakeUintegerAccessor (&LteEnbNetDevice::SetCsgId,
124  MakeUintegerChecker<uint32_t> ())
125  .AddAttribute ("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),
130  MakeBooleanAccessor (&LteEnbNetDevice::SetCsgIndication,
132  MakeBooleanChecker ())
133  ;
134  return tid;
135 }
136 
138  : m_isConstructed (false),
139  m_isConfigured (false),
140  m_anr (0)
141 {
142  NS_LOG_FUNCTION (this);
143 }
144 
146 {
147  NS_LOG_FUNCTION (this);
148 }
149 
150 void
152 {
153  NS_LOG_FUNCTION (this);
154 
155  m_mac->Dispose ();
156  m_mac = 0;
157 
158  m_scheduler->Dispose ();
159  m_scheduler = 0;
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 
173  m_phy->Dispose ();
174  m_phy = 0;
175 
177 }
178 
179 
180 
183 {
184  return m_mac;
185 }
186 
189 {
190  return m_phy;
191 }
192 
195 {
196  return m_rrc;
197 }
198 
199 uint16_t
201 {
202  return m_cellId;
203 }
204 
205 uint8_t
207 {
208  return m_ulBandwidth;
209 }
210 
211 void
213 {
214  NS_LOG_FUNCTION (this << uint16_t (bw));
215  switch (bw)
216  {
217  case 6:
218  case 15:
219  case 25:
220  case 50:
221  case 75:
222  case 100:
223  m_ulBandwidth = bw;
224  break;
225 
226  default:
227  NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) bw);
228  break;
229  }
230 }
231 
232 uint8_t
234 {
235  return m_dlBandwidth;
236 }
237 
238 void
240 {
241  NS_LOG_FUNCTION (this << uint16_t (bw));
242  switch (bw)
243  {
244  case 6:
245  case 15:
246  case 25:
247  case 50:
248  case 75:
249  case 100:
250  m_dlBandwidth = bw;
251  break;
252 
253  default:
254  NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) bw);
255  break;
256  }
257 }
258 
259 uint16_t
261 {
262  return m_dlEarfcn;
263 }
264 
265 void
267 {
268  NS_LOG_FUNCTION (this << earfcn);
269  m_dlEarfcn = earfcn;
270 }
271 
272 uint16_t
274 {
275  return m_ulEarfcn;
276 }
277 
278 void
280 {
281  NS_LOG_FUNCTION (this << earfcn);
282  m_ulEarfcn = earfcn;
283 }
284 
285 uint32_t
287 {
288  return m_csgId;
289 }
290 
291 void
293 {
294  NS_LOG_FUNCTION (this << csgId);
295  m_csgId = csgId;
296  UpdateConfig (); // propagate the change to RRC level
297 }
298 
299 bool
301 {
302  return m_csgIndication;
303 }
304 
305 void
307 {
308  NS_LOG_FUNCTION (this << csgIndication);
309  m_csgIndication = csgIndication;
310  UpdateConfig (); // propagate the change to RRC level
311 }
312 
313 
314 void
316 {
317  NS_LOG_FUNCTION (this);
318  m_isConstructed = true;
319  UpdateConfig ();
320  m_phy->Initialize ();
321  m_mac->Initialize ();
322  m_rrc->Initialize ();
323  m_handoverAlgorithm->Initialize ();
324 
325  if (m_anr != 0)
326  {
327  m_anr->Initialize ();
328  }
329 }
330 
331 
332 bool
333 LteEnbNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
334 {
335  NS_LOG_FUNCTION (this << packet << dest << protocolNumber);
336  NS_ASSERT_MSG (protocolNumber == Ipv4L3Protocol::PROT_NUMBER, "unsupported protocol " << protocolNumber << ", only IPv4 is supported");
337  return m_rrc->SendData (packet);
338 }
339 
340 
341 void
343 {
344  NS_LOG_FUNCTION (this);
345 
346  if (m_isConstructed)
347  {
348  if (!m_isConfigured)
349  {
350  NS_LOG_LOGIC (this << " Configure cell " << m_cellId);
351  // we have to make sure that this function is called only once
353  m_isConfigured = true;
354  }
355 
356  NS_LOG_LOGIC (this << " Updating SIB1 of cell " << m_cellId
357  << " with CSG ID " << m_csgId
358  << " and CSG indication " << m_csgIndication);
359  m_rrc->SetCsgId (m_csgId, m_csgIndication);
360  }
361  else
362  {
363  /*
364  * Lower layers are not ready yet, so do nothing now and expect
365  * ``DoInitialize`` to re-invoke this function.
366  */
367  }
368 }
369 
370 
371 } // namespace ns3
uint16_t GetDlEarfcn() const
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Hold a bool native type.
Definition: boolean.h:38
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
uint16_t GetCellId() const
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
uint8_t GetUlBandwidth() const
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:170
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:95
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:86
void UpdateConfig()
Propagate attributes and configuration to sub-modules.
Hold an unsigned integer type.
Definition: uinteger.h:46
void SetUlBandwidth(uint8_t bw)
Ptr< LteEnbRrc > m_rrc
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:233
static TypeId GetTypeId(void)
Ptr< LteEnbPhy > m_phy
Ptr< LteEnbRrc > GetRrc() const
void SetDlBandwidth(uint8_t bw)
hold objects of type Ptr
Definition: pointer.h:33
void SetDlEarfcn(uint16_t earfcn)
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
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:84
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.
a unique identifier for an interface.
Definition: type-id.h:49
Ptr< LteEnbMac > GetMac(void) const
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
static const uint16_t PROT_NUMBER
Protocol number (0x0800)