author | Nicola Baldo <nbaldo@cttc.es> |
Mon, 05 Mar 2012 15:52:14 +0100 | |
changeset 8664 | ab4c821fc251 |
parent 8647 | f6fad6b36154 |
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 <marco.miozzo@cttc.es> |
20 |
* Nicola Baldo <nbaldo@cttc.es> |
|
6705 | 21 |
*/ |
22 |
||
23 |
#include <ns3/object-factory.h> |
|
24 |
#include <ns3/log.h> |
|
25 |
#include <math.h> |
|
26 |
#include <ns3/simulator.h> |
|
7949 | 27 |
#include <ns3/double.h> |
7887 | 28 |
#include "lte-ue-phy.h" |
29 |
#include "lte-enb-phy.h" |
|
6705 | 30 |
#include "lte-net-device.h" |
7887 | 31 |
#include "lte-ue-net-device.h" |
32 |
#include "lte-enb-net-device.h" |
|
6705 | 33 |
#include "lte-spectrum-value-helper.h" |
7887 | 34 |
#include "lte-amc.h" |
7886 | 35 |
#include "lte-ue-mac.h" |
36 |
#include "ff-mac-common.h" |
|
37 |
#include "lte-sinr-chunk-processor.h" |
|
38 |
||
6705 | 39 |
|
7887 | 40 |
NS_LOG_COMPONENT_DEFINE ("LteUePhy"); |
6705 | 41 |
|
42 |
namespace ns3 { |
|
43 |
||
7886 | 44 |
//////////////////////////////////////// |
45 |
// member SAP forwarders |
|
46 |
//////////////////////////////////////// |
|
47 |
||
48 |
||
7887 | 49 |
class UeMemberLteUePhySapProvider : public LteUePhySapProvider |
7886 | 50 |
{ |
51 |
public: |
|
7887 | 52 |
UeMemberLteUePhySapProvider (LteUePhy* phy); |
7886 | 53 |
|
54 |
// inherited from LtePhySapProvider |
|
55 |
virtual void SendMacPdu (Ptr<Packet> p); |
|
56 |
virtual void SetBandwidth (uint8_t ulBandwidth, uint8_t dlBandwidth); |
|
57 |
virtual void SendIdealControlMessage (Ptr<IdealControlMessage> msg); |
|
58 |
||
59 |
private: |
|
7887 | 60 |
LteUePhy* m_phy; |
7886 | 61 |
}; |
62 |
||
7887 | 63 |
UeMemberLteUePhySapProvider::UeMemberLteUePhySapProvider (LteUePhy* phy) : m_phy (phy) |
7886 | 64 |
{ |
65 |
||
66 |
} |
|
67 |
||
68 |
||
69 |
void |
|
7887 | 70 |
UeMemberLteUePhySapProvider::SendMacPdu (Ptr<Packet> p) |
7886 | 71 |
{ |
72 |
m_phy->DoSendMacPdu (p); |
|
73 |
} |
|
74 |
||
75 |
void |
|
7887 | 76 |
UeMemberLteUePhySapProvider::SetBandwidth (uint8_t ulBandwidth, uint8_t dlBandwidth) |
7886 | 77 |
{ |
78 |
m_phy->DoSetBandwidth (ulBandwidth, dlBandwidth); |
|
79 |
} |
|
80 |
||
81 |
void |
|
7887 | 82 |
UeMemberLteUePhySapProvider::SendIdealControlMessage (Ptr<IdealControlMessage> msg) |
7886 | 83 |
{ |
84 |
m_phy->DoSendIdealControlMessage (msg); |
|
85 |
} |
|
86 |
||
87 |
||
88 |
||
89 |
//////////////////////////////////////// |
|
7887 | 90 |
// generic LteUePhy methods |
7886 | 91 |
//////////////////////////////////////// |
92 |
||
6705 | 93 |
|
7887 | 94 |
NS_OBJECT_ENSURE_REGISTERED (LteUePhy); |
6705 | 95 |
|
96 |
||
7887 | 97 |
LteUePhy::LteUePhy () |
7980
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
98 |
{ |
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
99 |
NS_LOG_FUNCTION (this); |
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
100 |
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
|
101 |
} |
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
102 |
|
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
103 |
LteUePhy::LteUePhy (Ptr<LteSpectrumPhy> dlPhy, Ptr<LteSpectrumPhy> ulPhy) |
f07d99163a56
LteSpectrumPhy instances now plugged onto LtePhy via its constructor
Nicola Baldo <nbaldo@cttc.es>
parents:
7949
diff
changeset
|
104 |
: LtePhy (dlPhy, ulPhy), |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
105 |
m_p10CqiPeriocity (MilliSeconds (1)), |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
106 |
// ideal behavior |
7895
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
107 |
m_p10CqiLast (MilliSeconds (0)), |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
108 |
m_a30CqiPeriocity (MilliSeconds (1)), |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
109 |
// ideal behavior |
7895
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
110 |
m_a30CqiLast (MilliSeconds (0)) |
6705 | 111 |
{ |
8522
795ea37db2ff
Change LteAmc* to Ptr<LteAmc> in LteUePhy
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8517
diff
changeset
|
112 |
m_amc = CreateObject <LteAmc> (); |
7887 | 113 |
m_uePhySapProvider = new UeMemberLteUePhySapProvider (this); |
6705 | 114 |
} |
115 |
||
116 |
||
7887 | 117 |
LteUePhy::~LteUePhy () |
6705 | 118 |
{ |
119 |
} |
|
120 |
||
7886 | 121 |
void |
7887 | 122 |
LteUePhy::DoDispose () |
7886 | 123 |
{ |
7913
ed3a9f8a76d7
added DoDispose to lte-phy and lte-spectrum-phy
Nicola Baldo <nbaldo@cttc.es>
parents:
7895
diff
changeset
|
124 |
NS_LOG_FUNCTION (this); |
7930
ccb40542ae88
fixed memory leak in PHY SAP usage
Nicola Baldo <nbaldo@cttc.es>
parents:
7928
diff
changeset
|
125 |
delete m_uePhySapProvider; |
7913
ed3a9f8a76d7
added DoDispose to lte-phy and lte-spectrum-phy
Nicola Baldo <nbaldo@cttc.es>
parents:
7895
diff
changeset
|
126 |
LtePhy::DoDispose (); |
7886 | 127 |
} |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
128 |
|
7886 | 129 |
|
6705 | 130 |
|
131 |
TypeId |
|
7887 | 132 |
LteUePhy::GetTypeId (void) |
6705 | 133 |
{ |
7887 | 134 |
static TypeId tid = TypeId ("ns3::LteUePhy") |
6707
2ac68a0381ca
improved module after Tom's review
Giuseppe Piro <g.piro@poliba.it>
parents:
6705
diff
changeset
|
135 |
.SetParent<LtePhy> () |
7887 | 136 |
.AddConstructor<LteUePhy> () |
7949 | 137 |
.AddAttribute ("TxPower", |
138 |
"Transmission power in dBm", |
|
139 |
DoubleValue (10.0), |
|
140 |
MakeDoubleAccessor (&LteUePhy::SetTxPower, |
|
141 |
&LteUePhy::GetTxPower), |
|
142 |
MakeDoubleChecker<double> ()) |
|
7981 | 143 |
.AddAttribute ("NoiseFigure", |
144 |
"Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver." |
|
145 |
" According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is " |
|
146 |
"\"the difference in decibels (dB) between" |
|
147 |
" the noise output of the actual receiver to the noise output of an " |
|
148 |
" ideal receiver with the same overall gain and bandwidth when the receivers " |
|
149 |
" are connected to sources at the standard noise temperature T0.\" " |
|
150 |
"In this model, we consider T0 = 290K.", |
|
151 |
DoubleValue (9.0), |
|
152 |
MakeDoubleAccessor (&LteUePhy::SetNoiseFigure, |
|
153 |
&LteUePhy::GetNoiseFigure), |
|
154 |
MakeDoubleChecker<double> ()) |
|
8664
ab4c821fc251
revision after Giuseppe's comments http://codereview.appspot.com/4626069/#msg1
Nicola Baldo <nbaldo@cttc.es>
parents:
8647
diff
changeset
|
155 |
.AddAttribute ("MacToChannelDelay", |
ab4c821fc251
revision after Giuseppe's comments http://codereview.appspot.com/4626069/#msg1
Nicola Baldo <nbaldo@cttc.es>
parents:
8647
diff
changeset
|
156 |
"The delay in TTI units that occurs between a scheduling decision in the MAC and the actual start of the transmission by the PHY. This is intended to be used to model the latency of real PHY and MAC implementations.", |
ab4c821fc251
revision after Giuseppe's comments http://codereview.appspot.com/4626069/#msg1
Nicola Baldo <nbaldo@cttc.es>
parents:
8647
diff
changeset
|
157 |
UintegerValue (1), |
ab4c821fc251
revision after Giuseppe's comments http://codereview.appspot.com/4626069/#msg1
Nicola Baldo <nbaldo@cttc.es>
parents:
8647
diff
changeset
|
158 |
MakeUintegerAccessor (&LteUePhy::m_macChTtiDelay), |
ab4c821fc251
revision after Giuseppe's comments http://codereview.appspot.com/4626069/#msg1
Nicola Baldo <nbaldo@cttc.es>
parents:
8647
diff
changeset
|
159 |
MakeUintegerChecker<uint8_t> (1,255)) |
6705 | 160 |
; |
161 |
return tid; |
|
162 |
} |
|
163 |
||
8015 | 164 |
void |
165 |
LteUePhy::DoStart () |
|
166 |
{ |
|
167 |
NS_LOG_FUNCTION (this); |
|
168 |
Ptr<SpectrumValue> noisePsd = LteSpectrumValueHelper::CreateNoisePowerSpectralDensity (m_dlEarfcn, m_dlBandwidth, m_noiseFigure); |
|
169 |
m_downlinkSpectrumPhy->SetNoisePowerSpectralDensity (noisePsd); |
|
170 |
LtePhy::DoStart (); |
|
171 |
} |
|
6705 | 172 |
|
7886 | 173 |
void |
7887 | 174 |
LteUePhy::SetLteUePhySapUser (LteUePhySapUser* s) |
6705 | 175 |
{ |
7913
ed3a9f8a76d7
added DoDispose to lte-phy and lte-spectrum-phy
Nicola Baldo <nbaldo@cttc.es>
parents:
7895
diff
changeset
|
176 |
NS_LOG_FUNCTION (this); |
7886 | 177 |
m_uePhySapUser = s; |
178 |
} |
|
179 |
||
180 |
LteUePhySapProvider* |
|
7887 | 181 |
LteUePhy::GetLteUePhySapProvider () |
7886 | 182 |
{ |
7913
ed3a9f8a76d7
added DoDispose to lte-phy and lte-spectrum-phy
Nicola Baldo <nbaldo@cttc.es>
parents:
7895
diff
changeset
|
183 |
NS_LOG_FUNCTION (this); |
7886 | 184 |
return (m_uePhySapProvider); |
6705 | 185 |
} |
186 |
||
7949 | 187 |
void |
7981 | 188 |
LteUePhy::SetNoiseFigure (double nf) |
189 |
{ |
|
190 |
NS_LOG_FUNCTION (this << nf); |
|
191 |
m_noiseFigure = nf; |
|
192 |
} |
|
193 |
||
194 |
double |
|
195 |
LteUePhy::GetNoiseFigure () const |
|
196 |
{ |
|
197 |
NS_LOG_FUNCTION (this); |
|
198 |
return m_noiseFigure; |
|
199 |
} |
|
200 |
||
201 |
void |
|
7949 | 202 |
LteUePhy::SetTxPower (double pow) |
203 |
{ |
|
204 |
NS_LOG_FUNCTION (this << pow); |
|
205 |
m_txPower = pow; |
|
206 |
} |
|
207 |
||
208 |
double |
|
209 |
LteUePhy::GetTxPower () const |
|
210 |
{ |
|
211 |
NS_LOG_FUNCTION (this); |
|
212 |
return m_txPower; |
|
213 |
} |
|
6705 | 214 |
|
7886 | 215 |
void |
7887 | 216 |
LteUePhy::DoSendMacPdu (Ptr<Packet> p) |
6705 | 217 |
{ |
218 |
NS_LOG_FUNCTION (this); |
|
7886 | 219 |
|
220 |
SetMacPdu (p); |
|
6705 | 221 |
} |
222 |
||
223 |
||
224 |
void |
|
7887 | 225 |
LteUePhy::PhyPduReceived (Ptr<Packet> p) |
7886 | 226 |
{ |
227 |
m_uePhySapUser->ReceivePhyPdu (p); |
|
228 |
} |
|
229 |
||
230 |
void |
|
7887 | 231 |
LteUePhy::DoSetUplinkSubChannels () |
6705 | 232 |
{ |
233 |
NS_LOG_FUNCTION (this); |
|
234 |
||
235 |
/* |
|
236 |
* XXX: the uplink scheduler is not implemented yet! |
|
237 |
* Now, all uplink sub channels can be used for uplink transmission |
|
238 |
*/ |
|
239 |
SetSubChannelsForTransmission (GetUplinkSubChannels ()); |
|
240 |
} |
|
241 |
||
242 |
||
243 |
void |
|
7887 | 244 |
LteUePhy::SetSubChannelsForTransmission (std::vector <int> mask) |
6705 | 245 |
{ |
246 |
NS_LOG_FUNCTION (this); |
|
247 |
||
248 |
m_subChannelsForTransmission = mask; |
|
249 |
||
250 |
Ptr<SpectrumValue> txPsd = CreateTxPowerSpectralDensity (); |
|
7928
b736f63e9bdf
removed LtePhy::Get{Up,Down}linkSpectrumPhy methods which are evil
Nicola Baldo <nbaldo@cttc.es>
parents:
7913
diff
changeset
|
251 |
m_uplinkSpectrumPhy->SetTxPowerSpectralDensity (txPsd); |
6705 | 252 |
} |
253 |
||
254 |
||
255 |
void |
|
7887 | 256 |
LteUePhy::SetSubChannelsForReception (std::vector <int> mask) |
6705 | 257 |
{ |
258 |
NS_LOG_FUNCTION (this); |
|
259 |
m_subChannelsForReception = mask; |
|
260 |
} |
|
261 |
||
262 |
||
263 |
std::vector <int> |
|
7887 | 264 |
LteUePhy::GetSubChannelsForTransmission () |
6705 | 265 |
{ |
266 |
NS_LOG_FUNCTION (this); |
|
267 |
return m_subChannelsForTransmission; |
|
268 |
} |
|
269 |
||
270 |
||
271 |
std::vector <int> |
|
7887 | 272 |
LteUePhy::GetSubChannelsForReception () |
6705 | 273 |
{ |
274 |
NS_LOG_FUNCTION (this); |
|
275 |
return m_subChannelsForReception; |
|
276 |
} |
|
277 |
||
278 |
||
279 |
Ptr<SpectrumValue> |
|
7887 | 280 |
LteUePhy::CreateTxPowerSpectralDensity () |
6705 | 281 |
{ |
282 |
NS_LOG_FUNCTION (this); |
|
283 |
LteSpectrumValueHelper psdHelper; |
|
8015 | 284 |
Ptr<SpectrumValue> psd = psdHelper.CreateTxPowerSpectralDensity (m_ulEarfcn, m_ulBandwidth, m_txPower, GetSubChannelsForTransmission ()); |
6705 | 285 |
|
286 |
return psd; |
|
287 |
} |
|
288 |
||
289 |
void |
|
8664
ab4c821fc251
revision after Giuseppe's comments http://codereview.appspot.com/4626069/#msg1
Nicola Baldo <nbaldo@cttc.es>
parents:
8647
diff
changeset
|
290 |
LteUePhy::GenerateCqiReport (const SpectrumValue& sinr) |
7886 | 291 |
{ |
292 |
NS_LOG_FUNCTION (this); |
|
7895
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
293 |
// check periodic wideband CQI |
7886 | 294 |
if (Simulator::Now () > m_p10CqiLast + m_p10CqiPeriocity) |
295 |
{ |
|
7887 | 296 |
Ptr<LteUeNetDevice> thisDevice = GetDevice ()->GetObject<LteUeNetDevice> (); |
7886 | 297 |
Ptr<DlCqiIdealControlMessage> msg = CreateDlCqiFeedbackMessage (sinr); |
298 |
DoSendIdealControlMessage (msg); |
|
299 |
m_p10CqiLast = Simulator::Now (); |
|
300 |
} |
|
7895
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
301 |
// check aperiodic high-layer configured subband CQI |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
302 |
if (Simulator::Now () > m_a30CqiLast + m_a30CqiPeriocity) |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
303 |
{ |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
304 |
Ptr<LteUeNetDevice> thisDevice = GetDevice ()->GetObject<LteUeNetDevice> (); |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
305 |
Ptr<DlCqiIdealControlMessage> msg = CreateDlCqiFeedbackMessage (sinr); |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
306 |
DoSendIdealControlMessage (msg); |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
307 |
m_a30CqiLast = Simulator::Now (); |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
308 |
} |
7886 | 309 |
} |
310 |
||
311 |
||
312 |
||
313 |
Ptr<DlCqiIdealControlMessage> |
|
7887 | 314 |
LteUePhy::CreateDlCqiFeedbackMessage (const SpectrumValue& sinr) |
6705 | 315 |
{ |
316 |
NS_LOG_FUNCTION (this); |
|
7886 | 317 |
|
8170
5be3dcd75840
removed unused CqiIdealControlMessage and UlCqiIdealControlMessage
Nicola Baldo <nbaldo@cttc.es>
parents:
8148
diff
changeset
|
318 |
// CREATE DlCqiIdealControlMessage |
7886 | 319 |
Ptr<DlCqiIdealControlMessage> msg = Create<DlCqiIdealControlMessage> (); |
7895
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
320 |
CqiListElement_s dlcqi; |
8647
f6fad6b36154
Update LteUePhy for generating wideband and subband CQIs with LteAmc::MiErrorModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8646
diff
changeset
|
321 |
std::vector<int> cqi; |
7895
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
322 |
if (Simulator::Now () > m_p10CqiLast + m_p10CqiPeriocity) |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
323 |
{ |
8647
f6fad6b36154
Update LteUePhy for generating wideband and subband CQIs with LteAmc::MiErrorModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8646
diff
changeset
|
324 |
cqi = m_amc->CreateCqiFeedbacks (sinr, m_dlBandwidth); |
7886 | 325 |
|
7895
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
326 |
int nbSubChannels = cqi.size (); |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
327 |
double cqiSum = 0.0; |
8019
3f88f08f0e55
LENA-93 DL CQI averaged over active RBs only in UE PHY
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7981
diff
changeset
|
328 |
int activeSubChannels = 0; |
7895
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
329 |
// average the CQIs of the different RBs |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
330 |
for (int i = 0; i < nbSubChannels; i++) |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
331 |
{ |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
332 |
if (cqi.at (i) != -1) |
8019
3f88f08f0e55
LENA-93 DL CQI averaged over active RBs only in UE PHY
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7981
diff
changeset
|
333 |
{ |
3f88f08f0e55
LENA-93 DL CQI averaged over active RBs only in UE PHY
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7981
diff
changeset
|
334 |
cqiSum += cqi.at (i); |
3f88f08f0e55
LENA-93 DL CQI averaged over active RBs only in UE PHY
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7981
diff
changeset
|
335 |
activeSubChannels++; |
3f88f08f0e55
LENA-93 DL CQI averaged over active RBs only in UE PHY
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7981
diff
changeset
|
336 |
} |
8042
874d9e7e652b
LteUePhy::CreateDlCqiFeedbackMessage fix bug on computation of CQI (no control on activeSubChannels!=0)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8022
diff
changeset
|
337 |
NS_LOG_DEBUG (this << " subch " << i << " cqi " << cqi.at (i)); |
7895
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
338 |
} |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
339 |
dlcqi.m_rnti = m_rnti; |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
340 |
dlcqi.m_ri = 1; // not yet used |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
341 |
dlcqi.m_cqiType = CqiListElement_s::P10; // Peridic CQI using PUCCH wideband |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
342 |
if (activeSubChannels > 0) |
8042
874d9e7e652b
LteUePhy::CreateDlCqiFeedbackMessage fix bug on computation of CQI (no control on activeSubChannels!=0)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8022
diff
changeset
|
343 |
{ |
874d9e7e652b
LteUePhy::CreateDlCqiFeedbackMessage fix bug on computation of CQI (no control on activeSubChannels!=0)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8022
diff
changeset
|
344 |
dlcqi.m_wbCqi.push_back ((uint16_t) cqiSum / activeSubChannels); |
874d9e7e652b
LteUePhy::CreateDlCqiFeedbackMessage fix bug on computation of CQI (no control on activeSubChannels!=0)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8022
diff
changeset
|
345 |
} |
874d9e7e652b
LteUePhy::CreateDlCqiFeedbackMessage fix bug on computation of CQI (no control on activeSubChannels!=0)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8022
diff
changeset
|
346 |
else |
874d9e7e652b
LteUePhy::CreateDlCqiFeedbackMessage fix bug on computation of CQI (no control on activeSubChannels!=0)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8022
diff
changeset
|
347 |
{ |
874d9e7e652b
LteUePhy::CreateDlCqiFeedbackMessage fix bug on computation of CQI (no control on activeSubChannels!=0)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8022
diff
changeset
|
348 |
// approximate with the worst case -> CQI = 1 |
874d9e7e652b
LteUePhy::CreateDlCqiFeedbackMessage fix bug on computation of CQI (no control on activeSubChannels!=0)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8022
diff
changeset
|
349 |
dlcqi.m_wbCqi.push_back (1); |
874d9e7e652b
LteUePhy::CreateDlCqiFeedbackMessage fix bug on computation of CQI (no control on activeSubChannels!=0)
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8022
diff
changeset
|
350 |
} |
8019
3f88f08f0e55
LENA-93 DL CQI averaged over active RBs only in UE PHY
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7981
diff
changeset
|
351 |
//NS_LOG_DEBUG (this << " Generate P10 CQI feedback " << (uint16_t) cqiSum / activeSubChannels); |
7895
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
352 |
dlcqi.m_wbPmi = 0; // not yet used |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
353 |
// dl.cqi.m_sbMeasResult others CQI report modes: not yet implemented |
7886 | 354 |
} |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
355 |
else if (Simulator::Now () > m_a30CqiLast + m_a30CqiPeriocity) |
7895
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
356 |
{ |
8647
f6fad6b36154
Update LteUePhy for generating wideband and subband CQIs with LteAmc::MiErrorModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8646
diff
changeset
|
357 |
cqi = m_amc->CreateCqiFeedbacks (sinr, GetRbgSize ()); |
f6fad6b36154
Update LteUePhy for generating wideband and subband CQIs with LteAmc::MiErrorModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8646
diff
changeset
|
358 |
int nbSubChannels = m_dlBandwidth; |
7895
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
359 |
int rbgSize = GetRbgSize (); |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
360 |
double cqiSum = 0.0; |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
361 |
int cqiNum = 0; |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
362 |
SbMeasResult_s rbgMeas; |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
363 |
//NS_LOG_DEBUG (this << " Create A30 CQI feedback, RBG " << rbgSize << " cqiNum " << nbSubChannels << " band " << (uint16_t)m_dlBandwidth); |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
364 |
for (int i = 0; i < nbSubChannels; i++) |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
365 |
{ |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
366 |
if (cqi.at (i) != -1) |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
367 |
{ |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
368 |
cqiSum += cqi.at (i); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
369 |
} |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
370 |
// else "nothing" no CQI is treated as CQI = 0 (worst case scenario) |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
371 |
cqiNum++; |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
372 |
if (cqiNum == rbgSize) |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
373 |
{ |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
374 |
// average the CQIs of the different RBGs |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
375 |
//NS_LOG_DEBUG (this << " RBG CQI " << (uint16_t) cqiSum / rbgSize); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
376 |
HigherLayerSelected_s hlCqi; |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
377 |
hlCqi.m_sbPmi = 0; // not yet used |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
378 |
hlCqi.m_sbCqi.push_back ((uint16_t) cqiSum / rbgSize); // only CW0 (SISO mode) |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
379 |
rbgMeas.m_higherLayerSelected.push_back (hlCqi); |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
380 |
cqiSum = 0.0; |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
381 |
cqiNum = 0; |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
382 |
} |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
383 |
} |
7895
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
384 |
dlcqi.m_rnti = m_rnti; |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
385 |
dlcqi.m_ri = 1; // not yet used |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
386 |
dlcqi.m_cqiType = CqiListElement_s::A30; // Aperidic CQI using PUSCH |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
387 |
//dlcqi.m_wbCqi.push_back ((uint16_t) cqiSum / nbSubChannels); |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
388 |
dlcqi.m_wbPmi = 0; // not yet used |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
389 |
dlcqi.m_sbMeasResult = rbgMeas; |
f20bb71f9b71
Aperiodic high layer configured subband CQI (A30 type) implemented
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7893
diff
changeset
|
390 |
} |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
391 |
|
7886 | 392 |
msg->SetDlCqi (dlcqi); |
393 |
return msg; |
|
6705 | 394 |
} |
395 |
||
7886 | 396 |
|
397 |
||
6705 | 398 |
void |
7887 | 399 |
LteUePhy::DoSendIdealControlMessage (Ptr<IdealControlMessage> msg) |
6705 | 400 |
{ |
401 |
NS_LOG_FUNCTION (this << msg); |
|
7887 | 402 |
Ptr<LteUeNetDevice> thisDevice = GetDevice ()->GetObject<LteUeNetDevice> (); |
403 |
Ptr<LteEnbNetDevice> remoteDevice = thisDevice->GetTargetEnb (); |
|
7886 | 404 |
msg->SetSourceDevice (thisDevice); |
405 |
msg->SetDestinationDevice (remoteDevice); |
|
406 |
SetControlMessages (msg); |
|
6705 | 407 |
} |
408 |
||
409 |
||
410 |
void |
|
7887 | 411 |
LteUePhy::ReceiveIdealControlMessage (Ptr<IdealControlMessage> msg) |
6705 | 412 |
{ |
413 |
NS_LOG_FUNCTION (this << msg); |
|
414 |
||
7886 | 415 |
if (msg->GetMessageType () == IdealControlMessage::DL_DCI) |
6705 | 416 |
{ |
7886 | 417 |
Ptr<DlDciIdealControlMessage> msg2 = DynamicCast<DlDciIdealControlMessage> (msg); |
6705 | 418 |
|
7886 | 419 |
DlDciListElement_s dci = msg2->GetDci (); |
6705 | 420 |
|
7886 | 421 |
if (dci.m_resAlloc != 0) |
6705 | 422 |
{ |
7886 | 423 |
NS_FATAL_ERROR ("Resource Allocation type not implemented"); |
424 |
} |
|
425 |
||
426 |
std::vector <int> dlRb; |
|
6705 | 427 |
|
7886 | 428 |
// translate the DCI to Spectrum framework |
429 |
uint32_t mask = 0x1; |
|
430 |
for (int i = 0; i < 32; i++) |
|
431 |
{ |
|
432 |
if (((dci.m_rbBitmap & mask) >> i) == 1) |
|
6705 | 433 |
{ |
7886 | 434 |
for (int k = 0; k < GetRbgSize (); k++) |
6705 | 435 |
{ |
7886 | 436 |
dlRb.push_back ((i * GetRbgSize ()) + k); |
437 |
//NS_LOG_DEBUG(this << "DL-DCI allocated PRB " << (i*GetRbgSize()) + k); |
|
6705 | 438 |
} |
439 |
} |
|
7886 | 440 |
mask = (mask << 1); |
6705 | 441 |
} |
8511
46046bbb2a5c
Add info in LteSpectrumPhy on TB from DCI elaborated by LteEnbPhy and LteUePhy
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8253
diff
changeset
|
442 |
|
46046bbb2a5c
Add info in LteSpectrumPhy on TB from DCI elaborated by LteEnbPhy and LteUePhy
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8253
diff
changeset
|
443 |
// send TB info to LteSpectrumPhy |
8512
3b33e0855d77
commit debug stuff for merge with ns-3-lena-dev
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8511
diff
changeset
|
444 |
NS_LOG_DEBUG (this << " UE " << m_rnti << " DCI " << dci.m_rnti << " bimap " << dci.m_rbBitmap); |
8511
46046bbb2a5c
Add info in LteSpectrumPhy on TB from DCI elaborated by LteEnbPhy and LteUePhy
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8253
diff
changeset
|
445 |
m_downlinkSpectrumPhy->AddExpectedTb (dci.m_rnti, dci.m_tbsSize.at (0), dci.m_mcs.at (0), dlRb); // SISO mode |
6705 | 446 |
|
7886 | 447 |
SetSubChannelsForReception (dlRb); |
448 |
||
6705 | 449 |
|
450 |
} |
|
7886 | 451 |
else if (msg->GetMessageType () == IdealControlMessage::UL_DCI) |
452 |
{ |
|
453 |
// set the uplink bandwidht according to the UL-CQI |
|
454 |
Ptr<UlDciIdealControlMessage> msg2 = DynamicCast<UlDciIdealControlMessage> (msg); |
|
455 |
UlDciListElement_s dci = msg2->GetDci (); |
|
456 |
std::vector <int> ulRb; |
|
457 |
for (int i = 0; i < dci.m_rbLen; i++) |
|
458 |
{ |
|
459 |
ulRb.push_back (i + dci.m_rbStart); |
|
460 |
//NS_LOG_DEBUG (this << " UE RB " << i + dci.m_rbStart); |
|
461 |
} |
|
462 |
SetSubChannelsForTransmission (ulRb); |
|
463 |
// pass the info to the MAC |
|
464 |
m_uePhySapUser->ReceiveIdealControlMessage (msg); |
|
465 |
} |
|
6705 | 466 |
else |
467 |
{ |
|
7886 | 468 |
// pass the message to UE-MAC |
469 |
m_uePhySapUser->ReceiveIdealControlMessage (msg); |
|
6705 | 470 |
} |
471 |
||
472 |
||
473 |
} |
|
474 |
||
475 |
||
7886 | 476 |
void |
7887 | 477 |
LteUePhy::SubframeIndication (uint32_t frameNo, uint32_t subframeNo) |
7886 | 478 |
{ |
479 |
// trigger from eNB |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
480 |
|
7886 | 481 |
// send control messages |
482 |
std::list<Ptr<IdealControlMessage> > ctrlMsg = GetControlMessages (); |
|
483 |
if (ctrlMsg.size () > 0) |
|
484 |
{ |
|
7887 | 485 |
Ptr<LtePhy> phy = GetDevice ()->GetObject<LteUeNetDevice> ()->GetTargetEnb ()->GetPhy (); |
7886 | 486 |
std::list<Ptr<IdealControlMessage> >::iterator it; |
487 |
it = ctrlMsg.begin (); |
|
488 |
while (it != ctrlMsg.end ()) |
|
489 |
{ |
|
490 |
Ptr<IdealControlMessage> msg = (*it); |
|
491 |
phy->ReceiveIdealControlMessage (msg); |
|
492 |
ctrlMsg.pop_front (); |
|
493 |
it = ctrlMsg.begin (); |
|
494 |
} |
|
495 |
} |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
496 |
|
7886 | 497 |
// send packets in queue |
498 |
// send the current burts of packets |
|
499 |
Ptr<PacketBurst> pb = GetPacketBurst (); |
|
500 |
if (pb) |
|
501 |
{ |
|
8506
f9616c9094a5
integrated AntennaModel with LTE, including system test
Nicola Baldo <nbaldo@cttc.es>
parents:
8415
diff
changeset
|
502 |
NS_LOG_LOGIC (this << " start TX"); |
7928
b736f63e9bdf
removed LtePhy::Get{Up,Down}linkSpectrumPhy methods which are evil
Nicola Baldo <nbaldo@cttc.es>
parents:
7913
diff
changeset
|
503 |
m_uplinkSpectrumPhy->StartTx (pb); |
7886 | 504 |
} |
8415
e9a27a8c6331
Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents:
8253
diff
changeset
|
505 |
|
e9a27a8c6331
Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents:
8253
diff
changeset
|
506 |
// trigger the MAC |
e9a27a8c6331
Uplink scheduler with multiple bearers (LCs) allocates in a Round Robin fashion the active ones
mmiozzo
parents:
8253
diff
changeset
|
507 |
m_uePhySapUser->SubframeIndication (frameNo, subframeNo); |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8042
diff
changeset
|
508 |
|
7886 | 509 |
} |
510 |
||
511 |
||
512 |
void |
|
7893 | 513 |
LteUePhy::SetEnbCellId (uint16_t cellId) |
7886 | 514 |
{ |
7893 | 515 |
m_enbCellId = cellId; |
516 |
m_downlinkSpectrumPhy->SetCellId (cellId); |
|
517 |
m_uplinkSpectrumPhy->SetCellId (cellId); |
|
7886 | 518 |
} |
519 |
||
520 |
||
521 |
||
522 |
void |
|
7887 | 523 |
LteUePhy::SetRnti (uint16_t rnti) |
7886 | 524 |
{ |
525 |
NS_LOG_FUNCTION (this << rnti); |
|
526 |
m_rnti = rnti; |
|
527 |
} |
|
528 |
||
529 |
||
530 |
||
6705 | 531 |
} // namespace ns3 |