author | Nicola Baldo <nbaldo@cttc.es> |
Thu, 26 Jan 2012 14:51:33 +0100 | |
changeset 8589 | 426a5a05ec49 |
parent 8253 | 6faee3d1d1d0 |
child 8670 | 8f63d16fb2e8 |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Mileti? <rivanvx@gmail.com>
parents:
6852
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
6705 | 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 |
||
7980
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
38 |
LtePhy::LtePhy () |
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
39 |
{ |
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
40 |
NS_LOG_FUNCTION (this); |
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
41 |
NS_FATAL_ERROR ("This constructor should not be called"); |
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
42 |
} |
6705 | 43 |
|
7980
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
44 |
LtePhy::LtePhy (Ptr<LteSpectrumPhy> dlPhy, Ptr<LteSpectrumPhy> ulPhy) |
7981 | 45 |
: m_downlinkSpectrumPhy (dlPhy), |
7980
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
46 |
m_uplinkSpectrumPhy (ulPhy), |
7886 | 47 |
m_tti (0.001), |
48 |
m_ulBandwidth (0), |
|
49 |
m_dlBandwidth (0), |
|
50 |
m_rbgSize (0), |
|
51 |
m_macChTtiDelay (1) // 1 TTI delay between MAC and CH |
|
6705 | 52 |
{ |
7929 | 53 |
NS_LOG_FUNCTION (this); |
7886 | 54 |
for (int i = 0; i < m_macChTtiDelay; i++) |
55 |
{ |
|
56 |
Ptr<PacketBurst> pb = CreateObject <PacketBurst> (); |
|
57 |
m_packetBurstQueue.push_back (pb); |
|
58 |
} |
|
59 |
for (int i = 0; i < m_macChTtiDelay; i++) |
|
60 |
{ |
|
61 |
std::list<Ptr<IdealControlMessage> > l; |
|
62 |
m_controlMessagesQueue.push_back (l); |
|
63 |
} |
|
6705 | 64 |
} |
65 |
||
66 |
||
67 |
TypeId |
|
68 |
LtePhy::GetTypeId (void) |
|
69 |
{ |
|
70 |
static TypeId tid = TypeId ("ns3::LtePhy") |
|
71 |
.SetParent<Object> () |
|
72 |
; |
|
73 |
return tid; |
|
74 |
} |
|
75 |
||
76 |
||
77 |
LtePhy::~LtePhy () |
|
78 |
{ |
|
7929 | 79 |
NS_LOG_FUNCTION (this); |
6705 | 80 |
} |
81 |
||
82 |
void |
|
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
83 |
LtePhy::DoDispose () |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
84 |
{ |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
85 |
NS_LOG_FUNCTION (this); |
7921 | 86 |
m_packetBurstQueue.clear (); |
87 |
m_controlMessagesQueue.clear (); |
|
88 |
m_downlinkSpectrumPhy->Dispose (); |
|
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
89 |
m_downlinkSpectrumPhy = 0; |
7921 | 90 |
m_uplinkSpectrumPhy->Dispose (); |
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
91 |
m_uplinkSpectrumPhy = 0; |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
92 |
m_netDevice = 0; |
7913
ed3a9f8a76d7
added DoDispose to lte-phy and lte-spectrum-phy
Nicola Baldo <nbaldo@cttc.es>
parents:
7911
diff
changeset
|
93 |
Object::DoDispose (); |
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
94 |
} |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
95 |
|
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
96 |
void |
6705 | 97 |
LtePhy::SetDevice (Ptr<LteNetDevice> d) |
98 |
{ |
|
99 |
NS_LOG_FUNCTION (this << d); |
|
100 |
m_netDevice = d; |
|
101 |
} |
|
102 |
||
103 |
||
104 |
Ptr<LteNetDevice> |
|
105 |
LtePhy::GetDevice () |
|
106 |
{ |
|
107 |
NS_LOG_FUNCTION (this); |
|
108 |
return m_netDevice; |
|
109 |
} |
|
110 |
||
8064
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8015
diff
changeset
|
111 |
Ptr<LteSpectrumPhy> |
6705 | 112 |
LtePhy::GetDownlinkSpectrumPhy () |
113 |
{ |
|
114 |
return m_downlinkSpectrumPhy; |
|
115 |
} |
|
116 |
||
8064
026861f85f53
added SNR test to lte-test-link-adaptation & updated it with new tx psd & noise values
Nicola Baldo <nbaldo@cttc.es>
parents:
8015
diff
changeset
|
117 |
Ptr<LteSpectrumPhy> |
6705 | 118 |
LtePhy::GetUplinkSpectrumPhy () |
119 |
{ |
|
120 |
return m_uplinkSpectrumPhy; |
|
121 |
} |
|
122 |
||
123 |
||
124 |
void |
|
125 |
LtePhy::SetDownlinkChannel (Ptr<SpectrumChannel> c) |
|
126 |
{ |
|
127 |
NS_LOG_FUNCTION (this << c); |
|
128 |
m_downlinkSpectrumPhy->SetChannel (c); |
|
129 |
} |
|
130 |
||
131 |
void |
|
132 |
LtePhy::SetUplinkChannel (Ptr<SpectrumChannel> c) |
|
133 |
{ |
|
134 |
NS_LOG_FUNCTION (this << c); |
|
135 |
m_uplinkSpectrumPhy->SetChannel (c); |
|
136 |
} |
|
137 |
||
138 |
void |
|
139 |
LtePhy::SetDownlinkSubChannels (std::vector<int> mask ) |
|
140 |
{ |
|
141 |
NS_LOG_FUNCTION (this); |
|
142 |
m_listOfDownlinkSubchannel = mask; |
|
143 |
DoSetDownlinkSubChannels (); |
|
144 |
} |
|
145 |
||
146 |
||
147 |
void |
|
148 |
LtePhy::DoSetDownlinkSubChannels () |
|
149 |
{ |
|
150 |
NS_LOG_FUNCTION (this); |
|
151 |
} |
|
152 |
||
153 |
||
154 |
void |
|
155 |
LtePhy::SetUplinkSubChannels (std::vector<int> mask ) |
|
156 |
{ |
|
157 |
NS_LOG_FUNCTION (this); |
|
158 |
m_listOfUplinkSubchannel = mask; |
|
159 |
DoSetUplinkSubChannels (); |
|
160 |
} |
|
161 |
||
162 |
||
163 |
void |
|
164 |
LtePhy::DoSetUplinkSubChannels () |
|
165 |
{ |
|
166 |
NS_LOG_FUNCTION (this); |
|
167 |
} |
|
168 |
||
169 |
||
170 |
std::vector<int> |
|
171 |
LtePhy::GetDownlinkSubChannels (void) |
|
172 |
{ |
|
173 |
NS_LOG_FUNCTION (this); |
|
174 |
return m_listOfDownlinkSubchannel; |
|
175 |
} |
|
176 |
||
177 |
||
178 |
std::vector<int> |
|
179 |
LtePhy::GetUplinkSubChannels (void) |
|
180 |
{ |
|
181 |
NS_LOG_FUNCTION (this); |
|
182 |
return m_listOfUplinkSubchannel; |
|
183 |
} |
|
184 |
||
185 |
void |
|
186 |
LtePhy::SetTti (double tti) |
|
187 |
{ |
|
188 |
NS_LOG_FUNCTION (this << tti); |
|
189 |
m_tti = tti; |
|
190 |
} |
|
191 |
||
192 |
||
193 |
double |
|
194 |
LtePhy::GetTti (void) const |
|
195 |
{ |
|
196 |
NS_LOG_FUNCTION (this << m_tti); |
|
197 |
return m_tti; |
|
198 |
} |
|
199 |
||
200 |
void |
|
7886 | 201 |
LtePhy::DoSetBandwidth (uint8_t ulBandwidth, uint8_t dlBandwidth) |
6705 | 202 |
{ |
7886 | 203 |
m_ulBandwidth = ulBandwidth; |
204 |
m_dlBandwidth = dlBandwidth; |
|
205 |
||
206 |
int Type0AllocationRbg[4] = { |
|
207 |
10, // RGB size 1 |
|
208 |
26, // RGB size 2 |
|
209 |
63, // RGB size 3 |
|
210 |
110 // RGB size 4 |
|
211 |
}; // see table 7.1.6.1-1 of 36.213 |
|
212 |
for (int i = 0; i < 4; i++) |
|
213 |
{ |
|
214 |
if (dlBandwidth < Type0AllocationRbg[i]) |
|
215 |
{ |
|
216 |
m_rbgSize = i + 1; |
|
217 |
break; |
|
218 |
} |
|
219 |
} |
|
6705 | 220 |
} |
221 |
||
8015 | 222 |
void |
223 |
LtePhy::DoSetEarfcn (uint16_t dlEarfcn, uint16_t ulEarfcn) |
|
224 |
{ |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
225 |
m_dlEarfcn = dlEarfcn; |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
226 |
m_ulEarfcn = ulEarfcn; |
8015 | 227 |
} |
6705 | 228 |
|
7886 | 229 |
uint8_t |
230 |
LtePhy::GetRbgSize (void) const |
|
6705 | 231 |
{ |
7886 | 232 |
return m_rbgSize; |
6705 | 233 |
} |
234 |
||
235 |
||
236 |
void |
|
7886 | 237 |
LtePhy::SetMacChDelay (uint8_t delay) |
6705 | 238 |
{ |
7886 | 239 |
m_macChTtiDelay = delay; |
240 |
m_packetBurstQueue.resize (delay); |
|
6705 | 241 |
} |
242 |
||
243 |
||
7886 | 244 |
uint8_t |
245 |
LtePhy::GetMacChDelay (void) |
|
246 |
{ |
|
247 |
return (m_macChTtiDelay); |
|
248 |
} |
|
249 |
||
250 |
void |
|
251 |
LtePhy::SetMacPdu (Ptr<Packet> p) |
|
6705 | 252 |
{ |
7886 | 253 |
m_packetBurstQueue.at (m_macChTtiDelay - 1)->AddPacket (p); |
254 |
} |
|
255 |
||
256 |
Ptr<PacketBurst> |
|
257 |
LtePhy::GetPacketBurst (void) |
|
258 |
{ |
|
259 |
if (m_packetBurstQueue.at (0)->GetSize () > 0) |
|
260 |
{ |
|
261 |
Ptr<PacketBurst> ret = m_packetBurstQueue.at (0)->Copy (); |
|
262 |
m_packetBurstQueue.erase (m_packetBurstQueue.begin ()); |
|
263 |
m_packetBurstQueue.push_back (CreateObject <PacketBurst> ()); |
|
264 |
return (ret); |
|
265 |
} |
|
266 |
else |
|
267 |
{ |
|
268 |
m_packetBurstQueue.erase (m_packetBurstQueue.begin ()); |
|
269 |
m_packetBurstQueue.push_back (CreateObject <PacketBurst> ()); |
|
270 |
return (0); |
|
271 |
} |
|
6705 | 272 |
} |
273 |
||
7886 | 274 |
|
275 |
void |
|
276 |
LtePhy::SetControlMessages (Ptr<IdealControlMessage> m) |
|
277 |
{ |
|
278 |
m_controlMessagesQueue.at (m_macChTtiDelay - 1).push_back (m); |
|
279 |
} |
|
280 |
||
281 |
std::list<Ptr<IdealControlMessage> > |
|
282 |
LtePhy::GetControlMessages (void) |
|
283 |
{ |
|
284 |
if (m_controlMessagesQueue.at (0).size () > 0) |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
285 |
{ |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
286 |
std::list<Ptr<IdealControlMessage> > ret = m_controlMessagesQueue.at (0); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
287 |
m_controlMessagesQueue.erase (m_controlMessagesQueue.begin ()); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
288 |
std::list<Ptr<IdealControlMessage> > newlist; |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
289 |
m_controlMessagesQueue.push_back (newlist); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
290 |
return (ret); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
291 |
} |
7886 | 292 |
else |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
293 |
{ |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
294 |
m_controlMessagesQueue.erase (m_controlMessagesQueue.begin ()); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
295 |
std::list<Ptr<IdealControlMessage> > newlist; |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
296 |
m_controlMessagesQueue.push_back (newlist); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
297 |
std::list<Ptr<IdealControlMessage> > emptylist; |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
298 |
return (emptylist); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
299 |
} |
7886 | 300 |
} |
301 |
||
302 |
||
303 |
void |
|
304 |
LtePhy::DoSetCellId (uint16_t cellId) |
|
305 |
{ |
|
306 |
m_cellId = cellId; |
|
307 |
m_downlinkSpectrumPhy->SetCellId (cellId); |
|
308 |
m_uplinkSpectrumPhy->SetCellId (cellId); |
|
309 |
} |
|
310 |
||
311 |
||
6705 | 312 |
} // namespace ns3 |