OLD | NEW |
(Empty) | |
| 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> |
| 19 */ |
| 20 |
| 21 #include <ns3/waveform-generator.h> |
| 22 #include <ns3/object-factory.h> |
| 23 #include <ns3/log.h> |
| 24 #include <math.h> |
| 25 #include <ns3/simulator.h> |
| 26 #include <ns3/trace-source-accessor.h> |
| 27 #include "../spectrum/spectrum-error-model.h" |
| 28 #include "lte-spectrum-error-model.h" |
| 29 #include "lte-spectrum-phy.h" |
| 30 #include "lte-net-device.h" |
| 31 #include "ue-lte-spectrum-phy.h" |
| 32 #include "lte-spectrum-value-helper.h" |
| 33 #include "ue-net-device.h" |
| 34 #include "ue-phy.h" |
| 35 |
| 36 NS_LOG_COMPONENT_DEFINE ("UeLteSpectrumPhy"); |
| 37 |
| 38 namespace ns3 { |
| 39 |
| 40 |
| 41 NS_OBJECT_ENSURE_REGISTERED (UeLteSpectrumPhy); |
| 42 |
| 43 UeLteSpectrumPhy::UeLteSpectrumPhy () |
| 44 { |
| 45 SetMobility (0); |
| 46 SetDevice (0); |
| 47 SetChannel (0); |
| 48 SetState (LteSpectrumPhy::IDLE); |
| 49 GetSpectrumInterference ()->SetErrorModel (CreateObject<LteSpectrumErrorModel>
()); |
| 50 |
| 51 LteSpectrumValueHelper psdHelper; |
| 52 Ptr<SpectrumValue> noisePsd = psdHelper.CreateNoisePowerSpectralDensity(); |
| 53 SetNoisePowerSpectralDensity(noisePsd); |
| 54 } |
| 55 |
| 56 |
| 57 UeLteSpectrumPhy::~UeLteSpectrumPhy () |
| 58 { |
| 59 } |
| 60 |
| 61 |
| 62 TypeId |
| 63 UeLteSpectrumPhy::GetTypeId (void) |
| 64 { |
| 65 static TypeId tid = TypeId ("ns3::UeLteSpectrumPhy") |
| 66 .SetParent<LteSpectrumPhy> () |
| 67 .AddConstructor<UeLteSpectrumPhy> () |
| 68 ; |
| 69 return tid; |
| 70 } |
| 71 |
| 72 |
| 73 |
| 74 void |
| 75 UeLteSpectrumPhy::CalcSinrValues (Ptr <const SpectrumValue> rxPsd, Ptr <const Sp
ectrumValue> noise) |
| 76 { |
| 77 /* |
| 78 * TO DO: |
| 79 * Compute the SINR of the incoming signal, using the rxPsd and the Noise Psd. |
| 80 * Transfer this value to the device that will compute the CQI value. |
| 81 * |
| 82 * the UE receives the signal from the eNB. It computes the SINR and tranfers· |
| 83 * it to the UeNetDevice. The UeNetDevice, receiving SINR values, uses the AMC
module to convert· |
| 84 * SINR to CQI. Then, it will send CQI feedback to the eNB. |
| 85 * |
| 86 */ |
| 87 NS_LOG_FUNCTION (this << *rxPsd << *noise); |
| 88 |
| 89 std::vector<double> sinr, rx, n; |
| 90 ·· |
| 91 for (Values::const_iterator it = rxPsd->ConstValuesBegin ();· |
| 92 it != rxPsd->ConstValuesEnd (); it ++ ) |
| 93 { |
| 94 double power; //power transmission for the current sub channel [dB] |
| 95 if ((*it) != 0.) |
| 96 { |
| 97 power = (*it); |
| 98 power = 10 * log10(180000. * power); |
| 99 } |
| 100 else |
| 101 { |
| 102 power = 0.; |
| 103 } |
| 104 rx.push_back(power); |
| 105 } |
| 106 |
| 107 for (Values::const_iterator it = noise->ConstValuesBegin (); |
| 108 it != noise->ConstValuesEnd (); it ++ ) |
| 109 { |
| 110 double noise = (*it); |
| 111 noise = 10 * log10(180000. * noise); |
| 112 n.push_back(noise); |
| 113 } |
| 114 |
| 115 ·· |
| 116 //compute sinr |
| 117 · |
| 118 int subChannels = rx.size (); |
| 119 NS_LOG_INFO (this << "sinr: "); |
| 120 ·· |
| 121 for (int i = 0; i < subChannels; i++) |
| 122 { |
| 123 if (rx.at(i) != 0) |
| 124 { |
| 125 double sinr_ = rx.at(i) - n.at(i);· |
| 126 ···· |
| 127 sinr.push_back(sinr_); |
| 128 |
| 129 NS_LOG_INFO (this << rx.at(i) << n.at(i) << sinr_); |
| 130 } |
| 131 } |
| 132 |
| 133 //forward computed SINRs to the device that will use the AMC Module to compute
CQI feedbacks |
| 134 Ptr<UeLtePhy> phy = GetDevice ()->GetObject<UeNetDevice> ()->GetPhy ()->GetObj
ect<UeLtePhy> ();· |
| 135 phy->CreateCqiFeedbacks (sinr); |
| 136 }· |
| 137 |
| 138 |
| 139 } // namespace ns3 |
OLD | NEW |