A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
51
uint16_t
LteEnbNetDevice::m_cellIdCounter
= 0;
52
53
TypeId
LteEnbNetDevice::GetTypeId
(
void
)
54
{
55
static
TypeId
56
tid =
57
TypeId
(
"ns3::LteEnbNetDevice"
)
58
.
SetParent
<
LteNetDevice
> ()
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
,
84
&
LteEnbNetDevice::GetUlBandwidth
),
85
MakeUintegerChecker<uint8_t> ())
86
.AddAttribute (
"DlBandwidth"
,
87
"Downlink Transmission Bandwidth Configuration in number of Resource Blocks"
,
88
UintegerValue
(25),
89
MakeUintegerAccessor (&
LteEnbNetDevice::SetDlBandwidth
,
90
&
LteEnbNetDevice::GetDlBandwidth
),
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
113
LteEnbNetDevice::LteEnbNetDevice
()
114
{
115
NS_LOG_FUNCTION
(
this
);
116
}
117
118
LteEnbNetDevice::~LteEnbNetDevice
(
void
)
119
{
120
NS_LOG_FUNCTION
(
this
);
121
}
122
123
void
124
LteEnbNetDevice::DoDispose
()
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
140
LteNetDevice::DoDispose
();
141
}
142
143
144
145
Ptr<LteEnbMac>
146
LteEnbNetDevice::GetMac
(
void
)
const
147
{
148
NS_LOG_FUNCTION
(
this
);
149
return
m_mac
;
150
}
151
152
153
Ptr<LteEnbPhy>
154
LteEnbNetDevice::GetPhy
(
void
)
const
155
{
156
NS_LOG_FUNCTION
(
this
);
157
return
m_phy
;
158
}
159
160
161
Ptr<LteEnbRrc>
162
LteEnbNetDevice::GetRrc
()
const
163
{
164
return
m_rrc
;
165
}
166
167
uint16_t
168
LteEnbNetDevice::GetCellId
()
const
169
{
170
return
m_cellId
;
171
}
172
173
uint8_t
174
LteEnbNetDevice::GetUlBandwidth
()
const
175
{
176
return
m_ulBandwidth
;
177
}
178
179
void
180
LteEnbNetDevice::SetUlBandwidth
(uint8_t bw)
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
200
LteEnbNetDevice::GetDlBandwidth
()
const
201
{
202
return
m_dlBandwidth
;
203
}
204
205
void
206
LteEnbNetDevice::SetDlBandwidth
(uint8_t bw)
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
226
LteEnbNetDevice::GetDlEarfcn
()
const
227
{
228
return
m_dlEarfcn
;
229
}
230
231
void
232
LteEnbNetDevice::SetDlEarfcn
(uint16_t earfcn)
233
{
234
m_dlEarfcn
= earfcn;
235
}
236
237
uint16_t
238
LteEnbNetDevice::GetUlEarfcn
()
const
239
{
240
return
m_ulEarfcn
;
241
}
242
243
void
244
LteEnbNetDevice::SetUlEarfcn
(uint16_t earfcn)
245
{
246
m_ulEarfcn
= earfcn;
247
}
248
249
250
void
251
LteEnbNetDevice::DoStart
(
void
)
252
{
253
NS_ABORT_MSG_IF
(
m_cellIdCounter
== 65535,
"max num eNBs exceeded"
);
254
m_cellId
= ++
m_cellIdCounter
;
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
275
LteEnbNetDevice::UpdateConfig
(
void
)
276
{
277
NS_LOG_FUNCTION
(
this
);
278
279
m_rrc
->
ConfigureCell
(
m_ulBandwidth
,
m_dlBandwidth
);
280
281
// Configuring directly for now, but ideally we should use the PHY
282
// SAP instead. Probably should handle this through the RRC.
283
m_phy
->
DoSetBandwidth
(
m_ulBandwidth
,
m_dlBandwidth
);
284
m_phy
->
DoSetEarfcn
(
m_dlEarfcn
,
m_ulEarfcn
);
285
m_phy
->
DoSetCellId
(
m_cellId
);
286
287
}
288
289
290
}
// namespace ns3
src
lte
model
lte-enb-net-device.cc
Generated on Tue Nov 13 2012 10:32:16 for ns-3 by
1.8.1.2