author | Marco Miozzo <marco.miozzo@cttc.es> |
Mon, 25 Jun 2012 13:41:13 +0200 | |
changeset 9036 | 5e09b29d4af5 |
parent 9035 | e40974228d94 |
child 9038 | e1d67c8aa95b |
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 |
||
9036 | 38 |
|
7980
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
39 |
LtePhy::LtePhy () |
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
40 |
{ |
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
41 |
NS_LOG_FUNCTION (this); |
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
42 |
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
|
43 |
} |
6705 | 44 |
|
7980
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
45 |
LtePhy::LtePhy (Ptr<LteSpectrumPhy> dlPhy, Ptr<LteSpectrumPhy> ulPhy) |
7981 | 46 |
: m_downlinkSpectrumPhy (dlPhy), |
7980
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
47 |
m_uplinkSpectrumPhy (ulPhy), |
7886 | 48 |
m_tti (0.001), |
49 |
m_ulBandwidth (0), |
|
50 |
m_dlBandwidth (0), |
|
51 |
m_rbgSize (0), |
|
9036 | 52 |
m_macChTtiDelay (0), |
53 |
m_cellId (0) |
|
6705 | 54 |
{ |
7929 | 55 |
NS_LOG_FUNCTION (this); |
6705 | 56 |
} |
57 |
||
58 |
||
59 |
TypeId |
|
60 |
LtePhy::GetTypeId (void) |
|
61 |
{ |
|
62 |
static TypeId tid = TypeId ("ns3::LtePhy") |
|
63 |
.SetParent<Object> () |
|
64 |
; |
|
65 |
return tid; |
|
66 |
} |
|
67 |
||
68 |
||
69 |
LtePhy::~LtePhy () |
|
70 |
{ |
|
7929 | 71 |
NS_LOG_FUNCTION (this); |
6705 | 72 |
} |
73 |
||
74 |
void |
|
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
75 |
LtePhy::DoDispose () |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
76 |
{ |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
77 |
NS_LOG_FUNCTION (this); |
7921 | 78 |
m_packetBurstQueue.clear (); |
79 |
m_controlMessagesQueue.clear (); |
|
80 |
m_downlinkSpectrumPhy->Dispose (); |
|
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
81 |
m_downlinkSpectrumPhy = 0; |
7921 | 82 |
m_uplinkSpectrumPhy->Dispose (); |
6710
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; |
7913
ed3a9f8a76d7
added DoDispose to lte-phy and lte-spectrum-phy
Nicola Baldo <nbaldo@cttc.es>
parents:
7911
diff
changeset
|
85 |
Object::DoDispose (); |
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
86 |
} |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
87 |
|
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6705
diff
changeset
|
88 |
void |
6705 | 89 |
LtePhy::SetDevice (Ptr<LteNetDevice> d) |
90 |
{ |
|
91 |
NS_LOG_FUNCTION (this << d); |
|
92 |
m_netDevice = d; |
|
93 |
} |
|
94 |
||
95 |
||
96 |
Ptr<LteNetDevice> |
|
97 |
LtePhy::GetDevice () |
|
98 |
{ |
|
99 |
NS_LOG_FUNCTION (this); |
|
100 |
return m_netDevice; |
|
101 |
} |
|
102 |
||
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
|
103 |
Ptr<LteSpectrumPhy> |
6705 | 104 |
LtePhy::GetDownlinkSpectrumPhy () |
105 |
{ |
|
106 |
return m_downlinkSpectrumPhy; |
|
107 |
} |
|
108 |
||
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
|
109 |
Ptr<LteSpectrumPhy> |
6705 | 110 |
LtePhy::GetUplinkSpectrumPhy () |
111 |
{ |
|
112 |
return m_uplinkSpectrumPhy; |
|
113 |
} |
|
114 |
||
115 |
||
116 |
void |
|
117 |
LtePhy::SetDownlinkChannel (Ptr<SpectrumChannel> c) |
|
118 |
{ |
|
119 |
NS_LOG_FUNCTION (this << c); |
|
120 |
m_downlinkSpectrumPhy->SetChannel (c); |
|
121 |
} |
|
122 |
||
123 |
void |
|
124 |
LtePhy::SetUplinkChannel (Ptr<SpectrumChannel> c) |
|
125 |
{ |
|
126 |
NS_LOG_FUNCTION (this << c); |
|
127 |
m_uplinkSpectrumPhy->SetChannel (c); |
|
128 |
} |
|
129 |
||
130 |
void |
|
131 |
LtePhy::SetDownlinkSubChannels (std::vector<int> mask ) |
|
132 |
{ |
|
133 |
NS_LOG_FUNCTION (this); |
|
134 |
m_listOfDownlinkSubchannel = mask; |
|
135 |
DoSetDownlinkSubChannels (); |
|
136 |
} |
|
137 |
||
138 |
||
139 |
void |
|
140 |
LtePhy::DoSetDownlinkSubChannels () |
|
141 |
{ |
|
142 |
NS_LOG_FUNCTION (this); |
|
143 |
} |
|
144 |
||
145 |
||
146 |
void |
|
147 |
LtePhy::SetUplinkSubChannels (std::vector<int> mask ) |
|
148 |
{ |
|
149 |
NS_LOG_FUNCTION (this); |
|
150 |
m_listOfUplinkSubchannel = mask; |
|
151 |
DoSetUplinkSubChannels (); |
|
152 |
} |
|
153 |
||
154 |
||
155 |
void |
|
156 |
LtePhy::DoSetUplinkSubChannels () |
|
157 |
{ |
|
158 |
NS_LOG_FUNCTION (this); |
|
159 |
} |
|
160 |
||
161 |
||
162 |
std::vector<int> |
|
163 |
LtePhy::GetDownlinkSubChannels (void) |
|
164 |
{ |
|
165 |
NS_LOG_FUNCTION (this); |
|
166 |
return m_listOfDownlinkSubchannel; |
|
167 |
} |
|
168 |
||
169 |
||
170 |
std::vector<int> |
|
171 |
LtePhy::GetUplinkSubChannels (void) |
|
172 |
{ |
|
173 |
NS_LOG_FUNCTION (this); |
|
174 |
return m_listOfUplinkSubchannel; |
|
175 |
} |
|
176 |
||
177 |
void |
|
178 |
LtePhy::SetTti (double tti) |
|
179 |
{ |
|
180 |
NS_LOG_FUNCTION (this << tti); |
|
181 |
m_tti = tti; |
|
182 |
} |
|
183 |
||
184 |
||
185 |
double |
|
186 |
LtePhy::GetTti (void) const |
|
187 |
{ |
|
188 |
NS_LOG_FUNCTION (this << m_tti); |
|
189 |
return m_tti; |
|
190 |
} |
|
191 |
||
192 |
void |
|
7886 | 193 |
LtePhy::DoSetBandwidth (uint8_t ulBandwidth, uint8_t dlBandwidth) |
6705 | 194 |
{ |
7886 | 195 |
m_ulBandwidth = ulBandwidth; |
196 |
m_dlBandwidth = dlBandwidth; |
|
197 |
||
198 |
int Type0AllocationRbg[4] = { |
|
199 |
10, // RGB size 1 |
|
200 |
26, // RGB size 2 |
|
201 |
63, // RGB size 3 |
|
202 |
110 // RGB size 4 |
|
203 |
}; // see table 7.1.6.1-1 of 36.213 |
|
204 |
for (int i = 0; i < 4; i++) |
|
205 |
{ |
|
206 |
if (dlBandwidth < Type0AllocationRbg[i]) |
|
207 |
{ |
|
208 |
m_rbgSize = i + 1; |
|
209 |
break; |
|
210 |
} |
|
211 |
} |
|
6705 | 212 |
} |
213 |
||
9036 | 214 |
|
215 |
uint16_t |
|
216 |
LtePhy::GetSrsPeriodicity (uint16_t srsCI) const |
|
217 |
{ |
|
218 |
// from 3GPP TS 36.213 table 8.2-1 UE Specific SRS Periodicity |
|
219 |
uint16_t SrsPeriodicity[9] = {0, 2, 5, 10, 20, 40, 80, 160, 320}; |
|
220 |
uint16_t SrsCiLow[9] = {0, 0, 2, 7, 17, 37, 77, 157, 317}; |
|
221 |
uint16_t SrsCiHigh[9] = {0, 1, 6, 16, 36, 76, 156, 316, 636}; |
|
222 |
uint8_t i; |
|
223 |
for (i = 8; i > 0; i --) |
|
224 |
{ |
|
225 |
if ((srsCI>=SrsCiLow[i])&&(srsCI<=SrsCiHigh[i])) |
|
226 |
{ |
|
227 |
break; |
|
228 |
} |
|
229 |
} |
|
230 |
return SrsPeriodicity[i]; |
|
231 |
} |
|
232 |
||
233 |
uint16_t |
|
234 |
LtePhy::GetSrsSubframeOffset (uint16_t srsCI) const |
|
235 |
{ |
|
236 |
// from 3GPP TS 36.213 table 8.2-1 UE Specific SRS Periodicity |
|
237 |
uint16_t SrsSubframeOffset[9] = {0, 0, 2, 7, 17, 37, 77, 157, 317}; |
|
238 |
uint16_t SrsCiLow[9] = {0, 0, 2, 7, 17, 37, 77, 157, 317}; |
|
239 |
uint16_t SrsCiHigh[9] = {0, 1, 6, 16, 36, 76, 156, 316, 636}; |
|
240 |
uint8_t i; |
|
241 |
for (i = 8; i > 0; i --) |
|
242 |
{ |
|
243 |
if ((srsCI>=SrsCiLow[i])&&(srsCI<=SrsCiHigh[i])) |
|
244 |
{ |
|
245 |
break; |
|
246 |
} |
|
247 |
} |
|
248 |
return (srsCI - SrsSubframeOffset[i]); |
|
249 |
} |
|
250 |
||
8015 | 251 |
void |
252 |
LtePhy::DoSetEarfcn (uint16_t dlEarfcn, uint16_t ulEarfcn) |
|
253 |
{ |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
254 |
m_dlEarfcn = dlEarfcn; |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
255 |
m_ulEarfcn = ulEarfcn; |
8015 | 256 |
} |
6705 | 257 |
|
7886 | 258 |
uint8_t |
259 |
LtePhy::GetRbgSize (void) const |
|
6705 | 260 |
{ |
7886 | 261 |
return m_rbgSize; |
6705 | 262 |
} |
263 |
||
7886 | 264 |
void |
265 |
LtePhy::SetMacPdu (Ptr<Packet> p) |
|
6705 | 266 |
{ |
8728
5a99218bfd1b
Bug-fix on m_macChTtiDelay management on UE-eNB PHY and consequently update RR-PF schedulers and tests
mmiozzo
parents:
8670
diff
changeset
|
267 |
m_packetBurstQueue.at (m_packetBurstQueue.size () - 1)->AddPacket (p); |
7886 | 268 |
} |
269 |
||
270 |
Ptr<PacketBurst> |
|
271 |
LtePhy::GetPacketBurst (void) |
|
272 |
{ |
|
273 |
if (m_packetBurstQueue.at (0)->GetSize () > 0) |
|
274 |
{ |
|
275 |
Ptr<PacketBurst> ret = m_packetBurstQueue.at (0)->Copy (); |
|
276 |
m_packetBurstQueue.erase (m_packetBurstQueue.begin ()); |
|
277 |
m_packetBurstQueue.push_back (CreateObject <PacketBurst> ()); |
|
278 |
return (ret); |
|
279 |
} |
|
280 |
else |
|
281 |
{ |
|
282 |
m_packetBurstQueue.erase (m_packetBurstQueue.begin ()); |
|
283 |
m_packetBurstQueue.push_back (CreateObject <PacketBurst> ()); |
|
284 |
return (0); |
|
285 |
} |
|
6705 | 286 |
} |
287 |
||
7886 | 288 |
|
289 |
void |
|
9035
e40974228d94
Update Phy Layer for managing different frames for different set of channels (data vs. ctrl and srs)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8729
diff
changeset
|
290 |
LtePhy::SetControlMessages (Ptr<LteControlMessage> m) |
7886 | 291 |
{ |
8728
5a99218bfd1b
Bug-fix on m_macChTtiDelay management on UE-eNB PHY and consequently update RR-PF schedulers and tests
mmiozzo
parents:
8670
diff
changeset
|
292 |
// In uplink the queue of control messages and packet are of different sizes |
5a99218bfd1b
Bug-fix on m_macChTtiDelay management on UE-eNB PHY and consequently update RR-PF schedulers and tests
mmiozzo
parents:
8670
diff
changeset
|
293 |
// for avoiding TTI cancellation due to synchronization of subframe triggers |
5a99218bfd1b
Bug-fix on m_macChTtiDelay management on UE-eNB PHY and consequently update RR-PF schedulers and tests
mmiozzo
parents:
8670
diff
changeset
|
294 |
m_controlMessagesQueue.at (m_controlMessagesQueue.size () - 1).push_back (m); |
7886 | 295 |
} |
296 |
||
9035
e40974228d94
Update Phy Layer for managing different frames for different set of channels (data vs. ctrl and srs)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8729
diff
changeset
|
297 |
std::list<Ptr<LteControlMessage> > |
7886 | 298 |
LtePhy::GetControlMessages (void) |
299 |
{ |
|
300 |
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
|
301 |
{ |
9035
e40974228d94
Update Phy Layer for managing different frames for different set of channels (data vs. ctrl and srs)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8729
diff
changeset
|
302 |
std::list<Ptr<LteControlMessage> > ret = m_controlMessagesQueue.at (0); |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
303 |
m_controlMessagesQueue.erase (m_controlMessagesQueue.begin ()); |
9035
e40974228d94
Update Phy Layer for managing different frames for different set of channels (data vs. ctrl and srs)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8729
diff
changeset
|
304 |
std::list<Ptr<LteControlMessage> > newlist; |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
305 |
m_controlMessagesQueue.push_back (newlist); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
306 |
return (ret); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
307 |
} |
7886 | 308 |
else |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
309 |
{ |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
310 |
m_controlMessagesQueue.erase (m_controlMessagesQueue.begin ()); |
9035
e40974228d94
Update Phy Layer for managing different frames for different set of channels (data vs. ctrl and srs)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8729
diff
changeset
|
311 |
std::list<Ptr<LteControlMessage> > newlist; |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
312 |
m_controlMessagesQueue.push_back (newlist); |
9035
e40974228d94
Update Phy Layer for managing different frames for different set of channels (data vs. ctrl and srs)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8729
diff
changeset
|
313 |
std::list<Ptr<LteControlMessage> > emptylist; |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
314 |
return (emptylist); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
315 |
} |
7886 | 316 |
} |
317 |
||
318 |
||
319 |
void |
|
320 |
LtePhy::DoSetCellId (uint16_t cellId) |
|
321 |
{ |
|
322 |
m_cellId = cellId; |
|
323 |
m_downlinkSpectrumPhy->SetCellId (cellId); |
|
324 |
m_uplinkSpectrumPhy->SetCellId (cellId); |
|
325 |
} |
|
326 |
||
327 |
||
6705 | 328 |
} // namespace ns3 |