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-phy.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
* Marco Miozzo <mmiozzo@cttc.es>
20
*/
21
22
#include <ns3/waveform-generator.h>
23
#include <ns3/object-factory.h>
24
#include <ns3/log.h>
25
#include <math.h>
26
#include <ns3/simulator.h>
27
#include "ns3/spectrum-error-model.h"
28
#include "
lte-phy.h
"
29
#include "
lte-net-device.h
"
30
31
NS_LOG_COMPONENT_DEFINE
(
"LtePhy"
);
32
33
namespace
ns3 {
34
35
36
NS_OBJECT_ENSURE_REGISTERED
(LtePhy);
37
38
LtePhy::LtePhy
()
39
{
40
NS_LOG_FUNCTION
(
this
);
41
NS_FATAL_ERROR
(
"This constructor should not be called"
);
42
}
43
44
LtePhy::LtePhy
(
Ptr<LteSpectrumPhy>
dlPhy,
Ptr<LteSpectrumPhy>
ulPhy)
45
: m_downlinkSpectrumPhy (dlPhy),
46
m_uplinkSpectrumPhy (ulPhy),
47
m_tti (0.001),
48
m_ulBandwidth (0),
49
m_dlBandwidth (0),
50
m_rbgSize (0),
51
m_macChTtiDelay (0)
52
{
53
NS_LOG_FUNCTION
(
this
);
54
}
55
56
57
TypeId
58
LtePhy::GetTypeId
(
void
)
59
{
60
static
TypeId
tid =
TypeId
(
"ns3::LtePhy"
)
61
.
SetParent
<
Object
> ()
62
;
63
return
tid;
64
}
65
66
67
LtePhy::~LtePhy
()
68
{
69
NS_LOG_FUNCTION
(
this
);
70
}
71
72
void
73
LtePhy::DoDispose
()
74
{
75
NS_LOG_FUNCTION
(
this
);
76
m_packetBurstQueue
.clear ();
77
m_controlMessagesQueue
.clear ();
78
m_downlinkSpectrumPhy
->
Dispose
();
79
m_downlinkSpectrumPhy
= 0;
80
m_uplinkSpectrumPhy
->
Dispose
();
81
m_uplinkSpectrumPhy
= 0;
82
m_netDevice
= 0;
83
Object::DoDispose
();
84
}
85
86
void
87
LtePhy::SetDevice
(
Ptr<LteNetDevice>
d)
88
{
89
NS_LOG_FUNCTION
(
this
<< d);
90
m_netDevice
= d;
91
}
92
93
94
Ptr<LteNetDevice>
95
LtePhy::GetDevice
()
96
{
97
NS_LOG_FUNCTION
(
this
);
98
return
m_netDevice
;
99
}
100
101
Ptr<LteSpectrumPhy>
102
LtePhy::GetDownlinkSpectrumPhy
()
103
{
104
return
m_downlinkSpectrumPhy
;
105
}
106
107
Ptr<LteSpectrumPhy>
108
LtePhy::GetUplinkSpectrumPhy
()
109
{
110
return
m_uplinkSpectrumPhy
;
111
}
112
113
114
void
115
LtePhy::SetDownlinkChannel
(
Ptr<SpectrumChannel>
c)
116
{
117
NS_LOG_FUNCTION
(
this
<< c);
118
m_downlinkSpectrumPhy
->
SetChannel
(c);
119
}
120
121
void
122
LtePhy::SetUplinkChannel
(
Ptr<SpectrumChannel>
c)
123
{
124
NS_LOG_FUNCTION
(
this
<< c);
125
m_uplinkSpectrumPhy
->
SetChannel
(c);
126
}
127
128
void
129
LtePhy::SetDownlinkSubChannels
(std::vector<int> mask )
130
{
131
NS_LOG_FUNCTION
(
this
);
132
m_listOfDownlinkSubchannel
= mask;
133
DoSetDownlinkSubChannels
();
134
}
135
136
137
void
138
LtePhy::DoSetDownlinkSubChannels
()
139
{
140
NS_LOG_FUNCTION
(
this
);
141
}
142
143
144
void
145
LtePhy::SetUplinkSubChannels
(std::vector<int> mask )
146
{
147
NS_LOG_FUNCTION
(
this
);
148
m_listOfUplinkSubchannel
= mask;
149
DoSetUplinkSubChannels
();
150
}
151
152
153
void
154
LtePhy::DoSetUplinkSubChannels
()
155
{
156
NS_LOG_FUNCTION
(
this
);
157
}
158
159
160
std::vector<int>
161
LtePhy::GetDownlinkSubChannels
(
void
)
162
{
163
NS_LOG_FUNCTION
(
this
);
164
return
m_listOfDownlinkSubchannel
;
165
}
166
167
168
std::vector<int>
169
LtePhy::GetUplinkSubChannels
(
void
)
170
{
171
NS_LOG_FUNCTION
(
this
);
172
return
m_listOfUplinkSubchannel
;
173
}
174
175
void
176
LtePhy::SetTti
(
double
tti)
177
{
178
NS_LOG_FUNCTION
(
this
<< tti);
179
m_tti
= tti;
180
}
181
182
183
double
184
LtePhy::GetTti
(
void
)
const
185
{
186
NS_LOG_FUNCTION
(
this
<<
m_tti
);
187
return
m_tti
;
188
}
189
190
void
191
LtePhy::DoSetBandwidth
(uint8_t ulBandwidth, uint8_t dlBandwidth)
192
{
193
m_ulBandwidth
= ulBandwidth;
194
m_dlBandwidth
= dlBandwidth;
195
196
int
Type0AllocationRbg
[4] = {
197
10,
// RGB size 1
198
26,
// RGB size 2
199
63,
// RGB size 3
200
110
// RGB size 4
201
};
// see table 7.1.6.1-1 of 36.213
202
for
(
int
i = 0; i < 4; i++)
203
{
204
if
(dlBandwidth < Type0AllocationRbg[i])
205
{
206
m_rbgSize
= i + 1;
207
break
;
208
}
209
}
210
}
211
212
void
213
LtePhy::DoSetEarfcn
(uint16_t dlEarfcn, uint16_t ulEarfcn)
214
{
215
m_dlEarfcn
= dlEarfcn;
216
m_ulEarfcn
= ulEarfcn;
217
}
218
219
uint8_t
220
LtePhy::GetRbgSize
(
void
)
const
221
{
222
return
m_rbgSize
;
223
}
224
225
void
226
LtePhy::SetMacPdu
(
Ptr<Packet>
p)
227
{
228
m_packetBurstQueue
.at (
m_packetBurstQueue
.size () - 1)->AddPacket (p);
229
}
230
231
Ptr<PacketBurst>
232
LtePhy::GetPacketBurst
(
void
)
233
{
234
if
(
m_packetBurstQueue
.at (0)->GetSize () > 0)
235
{
236
Ptr<PacketBurst>
ret =
m_packetBurstQueue
.at (0)->Copy ();
237
m_packetBurstQueue
.erase (
m_packetBurstQueue
.begin ());
238
m_packetBurstQueue
.push_back (CreateObject <PacketBurst> ());
239
return
(ret);
240
}
241
else
242
{
243
m_packetBurstQueue
.erase (
m_packetBurstQueue
.begin ());
244
m_packetBurstQueue
.push_back (CreateObject <PacketBurst> ());
245
return
(0);
246
}
247
}
248
249
250
void
251
LtePhy::SetControlMessages
(
Ptr<IdealControlMessage>
m)
252
{
253
// In uplink the queue of control messages and packet are of different sizes
254
// for avoiding TTI cancellation due to synchronization of subframe triggers
255
m_controlMessagesQueue
.at (
m_controlMessagesQueue
.size () - 1).push_back (m);
256
}
257
258
std::list<Ptr<IdealControlMessage> >
259
LtePhy::GetControlMessages
(
void
)
260
{
261
if
(
m_controlMessagesQueue
.at (0).size () > 0)
262
{
263
std::list<Ptr<IdealControlMessage> > ret =
m_controlMessagesQueue
.at (0);
264
m_controlMessagesQueue
.erase (
m_controlMessagesQueue
.begin ());
265
std::list<Ptr<IdealControlMessage> > newlist;
266
m_controlMessagesQueue
.push_back (newlist);
267
return
(ret);
268
}
269
else
270
{
271
m_controlMessagesQueue
.erase (
m_controlMessagesQueue
.begin ());
272
std::list<Ptr<IdealControlMessage> > newlist;
273
m_controlMessagesQueue
.push_back (newlist);
274
std::list<Ptr<IdealControlMessage> > emptylist;
275
return
(emptylist);
276
}
277
}
278
279
280
void
281
LtePhy::DoSetCellId
(uint16_t cellId)
282
{
283
m_cellId
= cellId;
284
m_downlinkSpectrumPhy
->
SetCellId
(cellId);
285
m_uplinkSpectrumPhy
->
SetCellId
(cellId);
286
}
287
288
289
}
// namespace ns3
src
lte
model
lte-phy.cc
Generated on Tue Nov 13 2012 10:32:17 for ns-3 by
1.8.1.2