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/ipv4-l3-protocol.h>
42 #include <ns3/abort.h>
43 #include <ns3/log.h>
44 
45 NS_LOG_COMPONENT_DEFINE ("LteEnbNetDevice");
46 
47 namespace ns3 {
48 
49 NS_OBJECT_ENSURE_REGISTERED ( LteEnbNetDevice);
50 
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 ("LteEnbMac",
66  "The MAC associated to this EnbNetDevice",
67  PointerValue (),
68  MakePointerAccessor (&LteEnbNetDevice::m_mac),
69  MakePointerChecker <LteEnbMac> ())
70  .AddAttribute ("FfMacScheduler",
71  "The scheduler associated to this EnbNetDevice",
72  PointerValue (),
73  MakePointerAccessor (&LteEnbNetDevice::m_scheduler),
74  MakePointerChecker <FfMacScheduler> ())
75  .AddAttribute ("LteEnbPhy",
76  "The PHY associated to this EnbNetDevice",
77  PointerValue (),
78  MakePointerAccessor (&LteEnbNetDevice::m_phy),
79  MakePointerChecker <LteEnbPhy> ())
80  .AddAttribute ("UlBandwidth",
81  "Uplink Transmission Bandwidth Configuration in number of Resource Blocks",
82  UintegerValue (25),
83  MakeUintegerAccessor (&LteEnbNetDevice::SetUlBandwidth,
85  MakeUintegerChecker<uint8_t> ())
86  .AddAttribute ("DlBandwidth",
87  "Downlink Transmission Bandwidth Configuration in number of Resource Blocks",
88  UintegerValue (25),
89  MakeUintegerAccessor (&LteEnbNetDevice::SetDlBandwidth,
91  MakeUintegerChecker<uint8_t> ())
92  .AddAttribute ("CellId",
93  "Cell Identifier",
94  UintegerValue (0),
95  MakeUintegerAccessor (&LteEnbNetDevice::m_cellId),
96  MakeUintegerChecker<uint16_t> ())
97  .AddAttribute ("DlEarfcn",
98  "Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
99  "as per 3GPP 36.101 Section 5.7.3. ",
100  UintegerValue (100),
101  MakeUintegerAccessor (&LteEnbNetDevice::m_dlEarfcn),
102  MakeUintegerChecker<uint16_t> (0, 6149))
103  .AddAttribute ("UlEarfcn",
104  "Uplink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
105  "as per 3GPP 36.101 Section 5.7.3. ",
106  UintegerValue (18100),
107  MakeUintegerAccessor (&LteEnbNetDevice::m_ulEarfcn),
108  MakeUintegerChecker<uint16_t> (18000, 24149))
109  ;
110  return tid;
111 }
112 
114 {
115  NS_LOG_FUNCTION (this);
116 }
117 
119 {
120  NS_LOG_FUNCTION (this);
121 }
122 
123 void
125 {
126  NS_LOG_FUNCTION (this);
127 
128  m_mac->Dispose ();
129  m_mac = 0;
130 
131  m_scheduler->Dispose ();
132  m_scheduler = 0;
133 
134  m_rrc->Dispose ();
135  m_rrc = 0;
136 
137  m_phy->Dispose ();
138  m_phy = 0;
139 
141 }
142 
143 
144 
147 {
148  NS_LOG_FUNCTION (this);
149  return m_mac;
150 }
151 
152 
155 {
156  NS_LOG_FUNCTION (this);
157  return m_phy;
158 }
159 
160 
163 {
164  return m_rrc;
165 }
166 
167 uint16_t
169 {
170  return m_cellId;
171 }
172 
173 uint8_t
175 {
176  return m_ulBandwidth;
177 }
178 
179 void
181 {
182  switch (bw)
183  {
184  case 6:
185  case 15:
186  case 25:
187  case 50:
188  case 75:
189  case 100:
190  m_ulBandwidth = bw;
191  break;
192 
193  default:
194  NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) bw);
195  break;
196  }
197 }
198 
199 uint8_t
201 {
202  return m_dlBandwidth;
203 }
204 
205 void
207 {
208  switch (bw)
209  {
210  case 6:
211  case 15:
212  case 25:
213  case 50:
214  case 75:
215  case 100:
216  m_dlBandwidth = bw;
217  break;
218 
219  default:
220  NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) bw);
221  break;
222  }
223 }
224 
225 uint16_t
227 {
228  return m_dlEarfcn;
229 }
230 
231 void
233 {
234  m_dlEarfcn = earfcn;
235 }
236 
237 uint16_t
239 {
240  return m_ulEarfcn;
241 }
242 
243 void
245 {
246  m_ulEarfcn = earfcn;
247 }
248 
249 
250 void
252 {
253  NS_ABORT_MSG_IF (m_cellIdCounter == 65535, "max num eNBs exceeded");
255  UpdateConfig ();
256  m_phy->Start ();
257  m_mac->Start ();
258  m_rrc->Start ();
259 }
260 
261 
262 
263 bool
264 LteEnbNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
265 {
266  NS_LOG_FUNCTION (this << packet << dest << protocolNumber);
267  NS_ASSERT_MSG (protocolNumber == Ipv4L3Protocol::PROT_NUMBER, "unsupported protocol " << protocolNumber << ", only IPv4 is supported");
268  return m_rrc->Send (packet);
269 }
270 
271 
272 
273 
274 void
276 {
277  NS_LOG_FUNCTION (this);
278 
281 
282  // Configuring directly for now, but ideally we should use the PHY
283  // SAP instead. Probably should handle this through the RRC.
287 
288 }
289 
290 
291 } // namespace ns3