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  ;
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 (),
64  MakePointerAccessor (&LteEnbNetDevice::m_rrc),
65  MakePointerChecker <LteEnbRrc> ())
66  .AddAttribute ("LteHandoverAlgorithm",
67  "The handover algorithm associated to this EnbNetDevice",
68  PointerValue (),
69  MakePointerAccessor (&LteEnbNetDevice::m_handoverAlgorithm),
70  MakePointerChecker <LteHandoverAlgorithm> ())
71  .AddAttribute ("LteAnr",
72  "The automatic neighbour relation function associated to this EnbNetDevice",
73  PointerValue (),
74  MakePointerAccessor (&LteEnbNetDevice::m_anr),
75  MakePointerChecker <LteAnr> ())
76  .AddAttribute ("LteEnbMac",
77  "The MAC associated to this EnbNetDevice",
78  PointerValue (),
79  MakePointerAccessor (&LteEnbNetDevice::m_mac),
80  MakePointerChecker <LteEnbMac> ())
81  .AddAttribute ("FfMacScheduler",
82  "The scheduler associated to this EnbNetDevice",
83  PointerValue (),
84  MakePointerAccessor (&LteEnbNetDevice::m_scheduler),
85  MakePointerChecker <FfMacScheduler> ())
86  .AddAttribute ("LteEnbPhy",
87  "The PHY associated to this EnbNetDevice",
88  PointerValue (),
89  MakePointerAccessor (&LteEnbNetDevice::m_phy),
90  MakePointerChecker <LteEnbPhy> ())
91  .AddAttribute ("UlBandwidth",
92  "Uplink Transmission Bandwidth Configuration in number of Resource Blocks",
93  UintegerValue (25),
94  MakeUintegerAccessor (&LteEnbNetDevice::SetUlBandwidth,
96  MakeUintegerChecker<uint8_t> ())
97  .AddAttribute ("DlBandwidth",
98  "Downlink Transmission Bandwidth Configuration in number of Resource Blocks",
99  UintegerValue (25),
100  MakeUintegerAccessor (&LteEnbNetDevice::SetDlBandwidth,
102  MakeUintegerChecker<uint8_t> ())
103  .AddAttribute ("CellId",
104  "Cell Identifier",
105  UintegerValue (0),
106  MakeUintegerAccessor (&LteEnbNetDevice::m_cellId),
107  MakeUintegerChecker<uint16_t> ())
108  .AddAttribute ("DlEarfcn",
109  "Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
110  "as per 3GPP 36.101 Section 5.7.3. ",
111  UintegerValue (100),
112  MakeUintegerAccessor (&LteEnbNetDevice::m_dlEarfcn),
113  MakeUintegerChecker<uint16_t> (0, 6599))
114  .AddAttribute ("UlEarfcn",
115  "Uplink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
116  "as per 3GPP 36.101 Section 5.7.3. ",
117  UintegerValue (18100),
118  MakeUintegerAccessor (&LteEnbNetDevice::m_ulEarfcn),
119  MakeUintegerChecker<uint16_t> (18000, 24599))
120  .AddAttribute ("CsgId",
121  "The Closed Subscriber Group (CSG) identity that this eNodeB belongs to",
122  UintegerValue (0),
123  MakeUintegerAccessor (&LteEnbNetDevice::SetCsgId,
125  MakeUintegerChecker<uint32_t> ())
126  .AddAttribute ("CsgIndication",
127  "If true, only UEs which are members of the CSG (i.e. same CSG ID) "
128  "can gain access to the eNodeB, therefore enforcing closed access mode. "
129  "Otherwise, the eNodeB operates as a non-CSG cell and implements open access mode.",
130  BooleanValue (false),
131  MakeBooleanAccessor (&LteEnbNetDevice::SetCsgIndication,
133  MakeBooleanChecker ())
134  ;
135  return tid;
136 }
137 
139  : m_isConstructed (false),
140  m_isConfigured (false),
141  m_anr (0)
142 {
143  NS_LOG_FUNCTION (this);
144 }
145 
147 {
148  NS_LOG_FUNCTION (this);
149 }
150 
151 void
153 {
154  NS_LOG_FUNCTION (this);
155 
156  m_mac->Dispose ();
157  m_mac = 0;
158 
159  m_scheduler->Dispose ();
160  m_scheduler = 0;
161 
162  m_rrc->Dispose ();
163  m_rrc = 0;
164 
165  m_handoverAlgorithm->Dispose ();
167 
168  if (m_anr != 0)
169  {
170  m_anr->Dispose ();
171  m_anr = 0;
172  }
173 
174  m_phy->Dispose ();
175  m_phy = 0;
176 
178 }
179 
180 
181 
184 {
185  return m_mac;
186 }
187 
190 {
191  return m_phy;
192 }
193 
196 {
197  return m_rrc;
198 }
199 
200 uint16_t
202 {
203  return m_cellId;
204 }
205 
206 uint8_t
208 {
209  return m_ulBandwidth;
210 }
211 
212 void
214 {
215  NS_LOG_FUNCTION (this << uint16_t (bw));
216  switch (bw)
217  {
218  case 6:
219  case 15:
220  case 25:
221  case 50:
222  case 75:
223  case 100:
224  m_ulBandwidth = bw;
225  break;
226 
227  default:
228  NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) bw);
229  break;
230  }
231 }
232 
233 uint8_t
235 {
236  return m_dlBandwidth;
237 }
238 
239 void
241 {
242  NS_LOG_FUNCTION (this << uint16_t (bw));
243  switch (bw)
244  {
245  case 6:
246  case 15:
247  case 25:
248  case 50:
249  case 75:
250  case 100:
251  m_dlBandwidth = bw;
252  break;
253 
254  default:
255  NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) bw);
256  break;
257  }
258 }
259 
260 uint16_t
262 {
263  return m_dlEarfcn;
264 }
265 
266 void
268 {
269  NS_LOG_FUNCTION (this << earfcn);
270  m_dlEarfcn = earfcn;
271 }
272 
273 uint16_t
275 {
276  return m_ulEarfcn;
277 }
278 
279 void
281 {
282  NS_LOG_FUNCTION (this << earfcn);
283  m_ulEarfcn = earfcn;
284 }
285 
286 uint32_t
288 {
289  return m_csgId;
290 }
291 
292 void
294 {
295  NS_LOG_FUNCTION (this << csgId);
296  m_csgId = csgId;
297  UpdateConfig (); // propagate the change to RRC level
298 }
299 
300 bool
302 {
303  return m_csgIndication;
304 }
305 
306 void
308 {
309  NS_LOG_FUNCTION (this << csgIndication);
310  m_csgIndication = csgIndication;
311  UpdateConfig (); // propagate the change to RRC level
312 }
313 
314 
315 void
317 {
318  NS_LOG_FUNCTION (this);
319  m_isConstructed = true;
320  UpdateConfig ();
321  m_phy->Initialize ();
322  m_mac->Initialize ();
323  m_rrc->Initialize ();
324  m_handoverAlgorithm->Initialize ();
325 
326  if (m_anr != 0)
327  {
328  m_anr->Initialize ();
329  }
330 }
331 
332 
333 bool
334 LteEnbNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
335 {
336  NS_LOG_FUNCTION (this << packet << dest << protocolNumber);
337  NS_ASSERT_MSG (protocolNumber == Ipv4L3Protocol::PROT_NUMBER, "unsupported protocol " << protocolNumber << ", only IPv4 is supported");
338  return m_rrc->SendData (packet);
339 }
340 
341 
342 void
344 {
345  NS_LOG_FUNCTION (this);
346 
347  if (m_isConstructed)
348  {
349  if (!m_isConfigured)
350  {
351  NS_LOG_LOGIC (this << " Configure cell " << m_cellId);
352  // we have to make sure that this function is called only once
354  m_isConfigured = true;
355  }
356 
357  NS_LOG_LOGIC (this << " Updating SIB1 of cell " << m_cellId
358  << " with CSG ID " << m_csgId
359  << " and CSG indication " << m_csgIndication);
360  m_rrc->SetCsgId (m_csgId, m_csgIndication);
361  }
362  else
363  {
364  /*
365  * Lower layers are not ready yet, so do nothing now and expect
366  * ``DoInitialize`` to re-invoke this function.
367  */
368  }
369 }
370 
371 
372 } // namespace ns3
uint16_t GetDlEarfcn() const
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
Hold a bool native type.
Definition: boolean.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
NS_LOG_COMPONENT_DEFINE("LteEnbNetDevice")
uint8_t m_dlBandwidth
downlink bandwidth in RBs
Ptr< LteEnbPhy > GetPhy(void) const
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
uint16_t m_dlEarfcn
downlink carrier frequency
uint32_t GetCsgId() const
Returns the CSG ID of the eNodeB.
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
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)
Definition: log.h:368
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)
Definition: assert.h:86
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:611
static const uint16_t PROT_NUMBER
Protocol number (0x0800)