author | Manuel Requena <manuel.requena@cttc.es> |
Tue, 26 Mar 2013 10:41:49 +0100 | |
changeset 10019 | 6efd95740e39 |
parent 9346 | 00e674a0d567 |
child 9653 | 382d27da8905 |
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::SetTti (double tti) |
|
132 |
{ |
|
133 |
NS_LOG_FUNCTION (this << tti); |
|
134 |
m_tti = tti; |
|
135 |
} |
|
136 |
||
137 |
||
138 |
double |
|
139 |
LtePhy::GetTti (void) const |
|
140 |
{ |
|
141 |
NS_LOG_FUNCTION (this << m_tti); |
|
142 |
return m_tti; |
|
143 |
} |
|
144 |
||
9036 | 145 |
|
146 |
uint16_t |
|
9038
e1d67c8aa95b
Polish code according to codereview
Marco Miozzo <marco.miozzo@cttc.es>
parents:
9036
diff
changeset
|
147 |
LtePhy::GetSrsPeriodicity (uint16_t srcCi) const |
9036 | 148 |
{ |
149 |
// from 3GPP TS 36.213 table 8.2-1 UE Specific SRS Periodicity |
|
150 |
uint16_t SrsPeriodicity[9] = {0, 2, 5, 10, 20, 40, 80, 160, 320}; |
|
151 |
uint16_t SrsCiLow[9] = {0, 0, 2, 7, 17, 37, 77, 157, 317}; |
|
152 |
uint16_t SrsCiHigh[9] = {0, 1, 6, 16, 36, 76, 156, 316, 636}; |
|
153 |
uint8_t i; |
|
154 |
for (i = 8; i > 0; i --) |
|
155 |
{ |
|
9038
e1d67c8aa95b
Polish code according to codereview
Marco Miozzo <marco.miozzo@cttc.es>
parents:
9036
diff
changeset
|
156 |
if ((srcCi>=SrsCiLow[i])&&(srcCi<=SrsCiHigh[i])) |
9036 | 157 |
{ |
158 |
break; |
|
159 |
} |
|
160 |
} |
|
161 |
return SrsPeriodicity[i]; |
|
162 |
} |
|
163 |
||
164 |
uint16_t |
|
9038
e1d67c8aa95b
Polish code according to codereview
Marco Miozzo <marco.miozzo@cttc.es>
parents:
9036
diff
changeset
|
165 |
LtePhy::GetSrsSubframeOffset (uint16_t srcCi) const |
9036 | 166 |
{ |
167 |
// from 3GPP TS 36.213 table 8.2-1 UE Specific SRS Periodicity |
|
168 |
uint16_t SrsSubframeOffset[9] = {0, 0, 2, 7, 17, 37, 77, 157, 317}; |
|
169 |
uint16_t SrsCiLow[9] = {0, 0, 2, 7, 17, 37, 77, 157, 317}; |
|
170 |
uint16_t SrsCiHigh[9] = {0, 1, 6, 16, 36, 76, 156, 316, 636}; |
|
171 |
uint8_t i; |
|
172 |
for (i = 8; i > 0; i --) |
|
173 |
{ |
|
9038
e1d67c8aa95b
Polish code according to codereview
Marco Miozzo <marco.miozzo@cttc.es>
parents:
9036
diff
changeset
|
174 |
if ((srcCi>=SrsCiLow[i])&&(srcCi<=SrsCiHigh[i])) |
9036 | 175 |
{ |
176 |
break; |
|
177 |
} |
|
178 |
} |
|
9038
e1d67c8aa95b
Polish code according to codereview
Marco Miozzo <marco.miozzo@cttc.es>
parents:
9036
diff
changeset
|
179 |
return (srcCi - SrsSubframeOffset[i]); |
9036 | 180 |
} |
181 |
||
7886 | 182 |
uint8_t |
183 |
LtePhy::GetRbgSize (void) const |
|
6705 | 184 |
{ |
7886 | 185 |
return m_rbgSize; |
6705 | 186 |
} |
187 |
||
7886 | 188 |
void |
189 |
LtePhy::SetMacPdu (Ptr<Packet> p) |
|
6705 | 190 |
{ |
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
|
191 |
m_packetBurstQueue.at (m_packetBurstQueue.size () - 1)->AddPacket (p); |
7886 | 192 |
} |
193 |
||
194 |
Ptr<PacketBurst> |
|
195 |
LtePhy::GetPacketBurst (void) |
|
196 |
{ |
|
197 |
if (m_packetBurstQueue.at (0)->GetSize () > 0) |
|
198 |
{ |
|
199 |
Ptr<PacketBurst> ret = m_packetBurstQueue.at (0)->Copy (); |
|
200 |
m_packetBurstQueue.erase (m_packetBurstQueue.begin ()); |
|
201 |
m_packetBurstQueue.push_back (CreateObject <PacketBurst> ()); |
|
202 |
return (ret); |
|
203 |
} |
|
204 |
else |
|
205 |
{ |
|
206 |
m_packetBurstQueue.erase (m_packetBurstQueue.begin ()); |
|
207 |
m_packetBurstQueue.push_back (CreateObject <PacketBurst> ()); |
|
208 |
return (0); |
|
209 |
} |
|
6705 | 210 |
} |
211 |
||
7886 | 212 |
|
213 |
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
|
214 |
LtePhy::SetControlMessages (Ptr<LteControlMessage> m) |
7886 | 215 |
{ |
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
|
216 |
// 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
|
217 |
// 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
|
218 |
m_controlMessagesQueue.at (m_controlMessagesQueue.size () - 1).push_back (m); |
7886 | 219 |
} |
220 |
||
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
|
221 |
std::list<Ptr<LteControlMessage> > |
7886 | 222 |
LtePhy::GetControlMessages (void) |
223 |
{ |
|
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8729
diff
changeset
|
224 |
NS_LOG_FUNCTION (this); |
7886 | 225 |
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
|
226 |
{ |
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
|
227 |
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
|
228 |
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
|
229 |
std::list<Ptr<LteControlMessage> > newlist; |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
230 |
m_controlMessagesQueue.push_back (newlist); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
231 |
return (ret); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
232 |
} |
7886 | 233 |
else |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
234 |
{ |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
235 |
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
|
236 |
std::list<Ptr<LteControlMessage> > newlist; |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
237 |
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
|
238 |
std::list<Ptr<LteControlMessage> > emptylist; |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
239 |
return (emptylist); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8064
diff
changeset
|
240 |
} |
7886 | 241 |
} |
242 |
||
243 |
||
244 |
void |
|
245 |
LtePhy::DoSetCellId (uint16_t cellId) |
|
246 |
{ |
|
247 |
m_cellId = cellId; |
|
248 |
m_downlinkSpectrumPhy->SetCellId (cellId); |
|
249 |
m_uplinkSpectrumPhy->SetCellId (cellId); |
|
250 |
} |
|
251 |
||
252 |
||
6705 | 253 |
} // namespace ns3 |