author | Nicola Baldo <nbaldo@cttc.es> |
Tue, 29 Mar 2011 17:33:07 +0200 | |
changeset 7911 | 0d2783c3500e |
parent 7906 | d58de34e41d3 |
child 7913 | ed3a9f8a76d7 |
permissions | -rw-r--r-- |
6705 | 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> |
|
7886 | 19 |
* Marco Miozzo <mmiozzo@cttc.es> |
6705 | 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 |
||
7886 | 38 |
|
6705 | 39 |
|
40 |
LtePhy::LtePhy () |
|
41 |
: m_netDevice (0), |
|
42 |
m_downlinkSpectrumPhy (0), |
|
7886 | 43 |
m_uplinkSpectrumPhy (0), |
44 |
m_txPower (43), // dBm |
|
45 |
m_tti (0.001), |
|
46 |
m_ulBandwidth (0), |
|
47 |
m_dlBandwidth (0), |
|
48 |
m_rbgSize (0), |
|
49 |
m_macChTtiDelay (1) // 1 TTI delay between MAC and CH |
|
6705 | 50 |
{ |
7886 | 51 |
for (int i = 0; i < m_macChTtiDelay; i++) |
52 |
{ |
|
53 |
Ptr<PacketBurst> pb = CreateObject <PacketBurst> (); |
|
54 |
m_packetBurstQueue.push_back (pb); |
|
55 |
} |
|
56 |
for (int i = 0; i < m_macChTtiDelay; i++) |
|
57 |
{ |
|
58 |
std::list<Ptr<IdealControlMessage> > l; |
|
59 |
m_controlMessagesQueue.push_back (l); |
|
60 |
} |
|
6705 | 61 |
} |
62 |
||
63 |
||
64 |
TypeId |
|
65 |
LtePhy::GetTypeId (void) |
|
66 |
{ |
|
67 |
static TypeId tid = TypeId ("ns3::LtePhy") |
|
68 |
.SetParent<Object> () |
|
69 |
; |
|
70 |
return tid; |
|
71 |
} |
|
72 |
||
73 |
||
74 |
LtePhy::~LtePhy () |
|
75 |
{ |
|
76 |
} |
|
77 |
||
78 |
void |
|
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
79 |
LtePhy::DoDispose () |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
80 |
{ |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
81 |
NS_LOG_FUNCTION (this); |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
82 |
m_downlinkSpectrumPhy = 0; |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
83 |
m_uplinkSpectrumPhy = 0; |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
84 |
m_netDevice = 0; |
7886 | 85 |
for (int i = 0; i < m_macChTtiDelay; i++) |
86 |
{ |
|
7906
d58de34e41d3
MAC, RRC and Scheduler created by LenaHelper
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7886
diff
changeset
|
87 |
m_packetBurstQueue.erase (m_packetBurstQueue.begin (), m_packetBurstQueue.end ()); |
d58de34e41d3
MAC, RRC and Scheduler created by LenaHelper
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7886
diff
changeset
|
88 |
m_controlMessagesQueue.erase (m_controlMessagesQueue.begin (), m_controlMessagesQueue.end ()); |
7886 | 89 |
} |
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
90 |
} |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
91 |
|
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
92 |
void |
6705 | 93 |
LtePhy::SetDevice (Ptr<LteNetDevice> d) |
94 |
{ |
|
95 |
NS_LOG_FUNCTION (this << d); |
|
96 |
m_netDevice = d; |
|
97 |
} |
|
98 |
||
99 |
||
100 |
Ptr<LteNetDevice> |
|
101 |
LtePhy::GetDevice () |
|
102 |
{ |
|
103 |
NS_LOG_FUNCTION (this); |
|
104 |
return m_netDevice; |
|
105 |
} |
|
106 |
||
107 |
||
108 |
void |
|
109 |
LtePhy::SetDownlinkSpectrumPhy (Ptr<LteSpectrumPhy> s) |
|
110 |
{ |
|
111 |
NS_LOG_FUNCTION (this << s); |
|
112 |
m_downlinkSpectrumPhy = s; |
|
113 |
} |
|
114 |
||
115 |
||
116 |
void |
|
117 |
LtePhy::SetUplinkSpectrumPhy (Ptr<LteSpectrumPhy> s) |
|
118 |
{ |
|
119 |
NS_LOG_FUNCTION (this << s); |
|
120 |
m_uplinkSpectrumPhy = s; |
|
121 |
} |
|
122 |
||
123 |
||
124 |
Ptr<LteSpectrumPhy> |
|
125 |
LtePhy::GetDownlinkSpectrumPhy () |
|
126 |
{ |
|
127 |
NS_LOG_FUNCTION (this); |
|
128 |
return m_downlinkSpectrumPhy; |
|
129 |
} |
|
130 |
||
131 |
||
132 |
Ptr<LteSpectrumPhy> |
|
133 |
LtePhy::GetUplinkSpectrumPhy () |
|
134 |
{ |
|
135 |
NS_LOG_FUNCTION (this); |
|
136 |
return m_uplinkSpectrumPhy; |
|
137 |
} |
|
138 |
||
139 |
||
140 |
void |
|
141 |
LtePhy::SetDownlinkChannel (Ptr<SpectrumChannel> c) |
|
142 |
{ |
|
143 |
NS_LOG_FUNCTION (this << c); |
|
144 |
m_downlinkSpectrumPhy->SetChannel (c); |
|
145 |
} |
|
146 |
||
147 |
void |
|
148 |
LtePhy::SetUplinkChannel (Ptr<SpectrumChannel> c) |
|
149 |
{ |
|
150 |
NS_LOG_FUNCTION (this << c); |
|
151 |
m_uplinkSpectrumPhy->SetChannel (c); |
|
152 |
} |
|
153 |
||
154 |
void |
|
155 |
LtePhy::SetDownlinkSubChannels (std::vector<int> mask ) |
|
156 |
{ |
|
157 |
NS_LOG_FUNCTION (this); |
|
158 |
m_listOfDownlinkSubchannel = mask; |
|
159 |
DoSetDownlinkSubChannels (); |
|
160 |
} |
|
161 |
||
162 |
||
163 |
void |
|
164 |
LtePhy::DoSetDownlinkSubChannels () |
|
165 |
{ |
|
166 |
NS_LOG_FUNCTION (this); |
|
167 |
} |
|
168 |
||
169 |
||
170 |
void |
|
171 |
LtePhy::SetUplinkSubChannels (std::vector<int> mask ) |
|
172 |
{ |
|
173 |
NS_LOG_FUNCTION (this); |
|
174 |
m_listOfUplinkSubchannel = mask; |
|
175 |
DoSetUplinkSubChannels (); |
|
176 |
} |
|
177 |
||
178 |
||
179 |
void |
|
180 |
LtePhy::DoSetUplinkSubChannels () |
|
181 |
{ |
|
182 |
NS_LOG_FUNCTION (this); |
|
183 |
} |
|
184 |
||
185 |
||
186 |
std::vector<int> |
|
187 |
LtePhy::GetDownlinkSubChannels (void) |
|
188 |
{ |
|
189 |
NS_LOG_FUNCTION (this); |
|
190 |
return m_listOfDownlinkSubchannel; |
|
191 |
} |
|
192 |
||
193 |
||
194 |
std::vector<int> |
|
195 |
LtePhy::GetUplinkSubChannels (void) |
|
196 |
{ |
|
197 |
NS_LOG_FUNCTION (this); |
|
198 |
return m_listOfUplinkSubchannel; |
|
199 |
} |
|
200 |
||
201 |
||
202 |
void |
|
203 |
LtePhy::SetTxPower (double pw) |
|
204 |
{ |
|
205 |
NS_LOG_FUNCTION (this << pw); |
|
206 |
m_txPower = pw; |
|
207 |
} |
|
208 |
||
209 |
||
210 |
double |
|
211 |
LtePhy::GetTxPower (void) |
|
212 |
{ |
|
213 |
NS_LOG_FUNCTION (this); |
|
214 |
return m_txPower; |
|
215 |
} |
|
216 |
||
217 |
void |
|
218 |
LtePhy::SetTti (double tti) |
|
219 |
{ |
|
220 |
NS_LOG_FUNCTION (this << tti); |
|
221 |
m_tti = tti; |
|
222 |
} |
|
223 |
||
224 |
||
225 |
double |
|
226 |
LtePhy::GetTti (void) const |
|
227 |
{ |
|
228 |
NS_LOG_FUNCTION (this << m_tti); |
|
229 |
return m_tti; |
|
230 |
} |
|
231 |
||
232 |
void |
|
7886 | 233 |
LtePhy::DoSetBandwidth (uint8_t ulBandwidth, uint8_t dlBandwidth) |
6705 | 234 |
{ |
7886 | 235 |
m_ulBandwidth = ulBandwidth; |
236 |
m_dlBandwidth = dlBandwidth; |
|
237 |
||
238 |
int Type0AllocationRbg[4] = { |
|
239 |
10, // RGB size 1 |
|
240 |
26, // RGB size 2 |
|
241 |
63, // RGB size 3 |
|
242 |
110 // RGB size 4 |
|
243 |
}; // see table 7.1.6.1-1 of 36.213 |
|
244 |
for (int i = 0; i < 4; i++) |
|
245 |
{ |
|
246 |
if (dlBandwidth < Type0AllocationRbg[i]) |
|
247 |
{ |
|
248 |
m_rbgSize = i + 1; |
|
249 |
break; |
|
250 |
} |
|
251 |
} |
|
6705 | 252 |
} |
253 |
||
254 |
||
7886 | 255 |
uint8_t |
256 |
LtePhy::GetRbgSize (void) const |
|
6705 | 257 |
{ |
7886 | 258 |
return m_rbgSize; |
6705 | 259 |
} |
260 |
||
261 |
||
262 |
void |
|
7886 | 263 |
LtePhy::SetMacChDelay (uint8_t delay) |
6705 | 264 |
{ |
7886 | 265 |
int old_delay = m_macChTtiDelay; |
266 |
m_macChTtiDelay = delay; |
|
267 |
m_packetBurstQueue.resize (delay); |
|
268 |
for (int i = old_delay - 1; i < delay; i++) |
|
269 |
{ |
|
270 |
Ptr<PacketBurst> pb = CreateObject <PacketBurst> (); |
|
271 |
m_packetBurstQueue.push_back (pb); |
|
272 |
} |
|
6705 | 273 |
} |
274 |
||
275 |
||
7886 | 276 |
uint8_t |
277 |
LtePhy::GetMacChDelay (void) |
|
278 |
{ |
|
279 |
return (m_macChTtiDelay); |
|
280 |
} |
|
281 |
||
282 |
void |
|
283 |
LtePhy::SetMacPdu (Ptr<Packet> p) |
|
6705 | 284 |
{ |
7886 | 285 |
m_packetBurstQueue.at (m_macChTtiDelay - 1)->AddPacket (p); |
286 |
} |
|
287 |
||
288 |
Ptr<PacketBurst> |
|
289 |
LtePhy::GetPacketBurst (void) |
|
290 |
{ |
|
291 |
if (m_packetBurstQueue.at (0)->GetSize () > 0) |
|
292 |
{ |
|
293 |
Ptr<PacketBurst> ret = m_packetBurstQueue.at (0)->Copy (); |
|
294 |
m_packetBurstQueue.erase (m_packetBurstQueue.begin ()); |
|
295 |
m_packetBurstQueue.push_back (CreateObject <PacketBurst> ()); |
|
296 |
return (ret); |
|
297 |
} |
|
298 |
else |
|
299 |
{ |
|
300 |
m_packetBurstQueue.erase (m_packetBurstQueue.begin ()); |
|
301 |
m_packetBurstQueue.push_back (CreateObject <PacketBurst> ()); |
|
302 |
return (0); |
|
303 |
} |
|
6705 | 304 |
} |
305 |
||
7886 | 306 |
|
307 |
void |
|
308 |
LtePhy::SetControlMessages (Ptr<IdealControlMessage> m) |
|
309 |
{ |
|
310 |
m_controlMessagesQueue.at (m_macChTtiDelay - 1).push_back (m); |
|
311 |
} |
|
312 |
||
313 |
std::list<Ptr<IdealControlMessage> > |
|
314 |
LtePhy::GetControlMessages (void) |
|
315 |
{ |
|
316 |
if (m_controlMessagesQueue.at (0).size () > 0) |
|
317 |
{ |
|
318 |
std::list<Ptr<IdealControlMessage> > ret = m_controlMessagesQueue.at (0); |
|
319 |
m_controlMessagesQueue.erase (m_controlMessagesQueue.begin ()); |
|
320 |
std::list<Ptr<IdealControlMessage> > newlist; |
|
321 |
m_controlMessagesQueue.push_back (newlist); |
|
322 |
return (ret); |
|
323 |
} |
|
324 |
else |
|
325 |
{ |
|
326 |
m_controlMessagesQueue.erase (m_controlMessagesQueue.begin ()); |
|
327 |
std::list<Ptr<IdealControlMessage> > newlist; |
|
328 |
m_controlMessagesQueue.push_back (newlist); |
|
329 |
std::list<Ptr<IdealControlMessage> > emptylist; |
|
330 |
return (emptylist); |
|
331 |
} |
|
332 |
} |
|
333 |
||
334 |
||
335 |
void |
|
336 |
LtePhy::DoSetCellId (uint16_t cellId) |
|
337 |
{ |
|
338 |
m_cellId = cellId; |
|
339 |
m_downlinkSpectrumPhy->SetCellId (cellId); |
|
340 |
m_uplinkSpectrumPhy->SetCellId (cellId); |
|
341 |
} |
|
342 |
||
343 |
||
6705 | 344 |
} // namespace ns3 |