author | Nicola Baldo <nbaldo@cttc.es> |
Mon, 04 Feb 2013 18:47:25 +0100 | |
changeset 9653 | 382d27da8905 |
parent 9077 | 16e6f501eeef |
child 10680 | ace43d9baa17 |
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> |
|
7993 | 19 |
* Nicola Baldo <nbaldo@cttc.es> |
6705 | 20 |
*/ |
21 |
||
8106
65bf071cf610
Added execution-time-reference simulation program to perform profiling on the execution time and memory usage.
jnin
parents:
8060
diff
changeset
|
22 |
#include <map> |
8015 | 23 |
#include <cmath> |
6705 | 24 |
|
7993 | 25 |
#include <ns3/log.h> |
8106
65bf071cf610
Added execution-time-reference simulation program to perform profiling on the execution time and memory usage.
jnin
parents:
8060
diff
changeset
|
26 |
#include <ns3/fatal-error.h> |
6705 | 27 |
|
28 |
#include "lte-spectrum-value-helper.h" |
|
7993 | 29 |
|
9077
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
30 |
// just needed to log a std::vector<int> properly... |
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
31 |
namespace std { |
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
32 |
|
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
33 |
ostream& |
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
34 |
operator << (ostream& os, const vector<int>& v) |
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
35 |
{ |
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
36 |
vector<int>::const_iterator it = v.begin (); |
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
37 |
while (it != v.end ()) |
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
38 |
{ |
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
39 |
os << *it << " " ; |
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
40 |
++it; |
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
41 |
} |
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
42 |
os << endl; |
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
43 |
return os; |
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
44 |
} |
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
45 |
|
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
46 |
} |
16e6f501eeef
Really fix bug 1345 - ns-3 should build with clang >= 3.0 (requires -Wno-deprecated due to sgi-hashmap.h)
Vedran Mileti? <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
47 |
|
7993 | 48 |
NS_LOG_COMPONENT_DEFINE ("LteSpectrumValueHelper"); |
6705 | 49 |
|
50 |
namespace ns3 { |
|
51 |
||
7993 | 52 |
/** |
53 |
* Table 5.7.3-1 "E-UTRA channel numbers" from 3GPP TS 36.101 |
|
54 |
* The table was converted to C syntax doing a cut & paste from TS 36.101 and running the following filter: |
|
55 |
* awk '{if ((NR % 7) == 1) printf("{"); printf ("%s",$0); if ((NR % 7) == 0) printf("},\n"); else printf(", ");}' | sed 's/ – /, /g' |
|
56 |
*/ |
|
57 |
struct EutraChannelNumbers |
|
6705 | 58 |
{ |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
59 |
uint8_t band; |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
60 |
double fDlLow; |
7993 | 61 |
uint16_t nOffsDl; |
62 |
uint16_t rangeNdl1; |
|
63 |
uint16_t rangeNdl2; |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
64 |
double fUlLow; |
7993 | 65 |
uint16_t nOffsUl; |
66 |
uint16_t rangeNul1; |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
67 |
uint16_t rangeNul2; |
7993 | 68 |
} g_eutraChannelNumbers[] = { |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
69 |
{ 1, 2110, 0, 0, 599, 1920, 18000, 18000, 18599}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
70 |
{ 2, 1930, 600, 600, 1199, 1850, 18600, 18600, 19199}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
71 |
{ 3, 1805, 1200, 1200, 1949, 1710, 19200, 19200, 19949}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
72 |
{ 4, 2110, 1950, 1950, 2399, 1710, 19950, 19950, 20399}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
73 |
{ 5, 869, 2400, 2400, 2649, 824, 20400, 20400, 20649}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
74 |
{ 6, 875, 2650, 2650, 2749, 830, 20650, 20650, 20749}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
75 |
{ 7, 2620, 2750, 2750, 3449, 2500, 20750, 20750, 21449}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
76 |
{ 8, 925, 3450, 3450, 3799, 880, 21450, 21450, 21799}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
77 |
{ 9, 1844.9, 3800, 3800, 4149, 1749.9, 21800, 21800, 22149}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
78 |
{ 10, 2110, 4150, 4150, 4749, 1710, 22150, 22150, 22749}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
79 |
{ 11, 1475.9, 4750, 4750, 4949, 1427.9, 22750, 22750, 22949}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
80 |
{ 12, 728, 5000, 5000, 5179, 698, 23000, 23000, 23179}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
81 |
{ 13, 746, 5180, 5180, 5279, 777, 23180, 23180, 23279}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
82 |
{ 14, 758, 5280, 5280, 5379, 788, 23280, 23280, 23379}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
83 |
{ 17, 734, 5730, 5730, 5849, 704, 23730, 23730, 23849}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
84 |
{ 18, 860, 5850, 5850, 5999, 815, 23850, 23850, 23999}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
85 |
{ 19, 875, 6000, 6000, 6149, 830, 24000, 24000, 24149}, |
8663
5e7f07723483
fixed typo in g_eutraChannelNumbers
Luca Costantino <luca.costantino@gmail.com>
parents:
8253
diff
changeset
|
86 |
{ 20, 791, 6150, 6150, 6449, 832, 24150, 24150, 24449}, |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
87 |
{ 21, 1495.9, 6450, 6450, 6599, 1447.9, 24450, 24450, 24599}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
88 |
{ 33, 1900, 36000, 36000, 36199, 1900, 36000, 36000, 36199}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
89 |
{ 34, 2010, 36200, 36200, 36349, 2010, 36200, 36200, 36349}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
90 |
{ 35, 1850, 36350, 36350, 36949, 1850, 36350, 36350, 36949}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
91 |
{ 36, 1930, 36950, 36950, 37549, 1930, 36950, 36950, 37549}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
92 |
{ 37, 1910, 37550, 37550, 37749, 1910, 37550, 37550, 37749}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
93 |
{ 38, 2570, 37750, 37750, 38249, 2570, 37750, 37750, 38249}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
94 |
{ 39, 1880, 38250, 38250, 38649, 1880, 38250, 38250, 38649}, |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
95 |
{ 40, 2300, 38650, 38650, 39649, 2300, 38650, 38650, 39649} |
7993 | 96 |
}; |
6705 | 97 |
|
7993 | 98 |
#define NUM_EUTRA_BANDS (sizeof (g_eutraChannelNumbers) / sizeof (EutraChannelNumbers)) |
6705 | 99 |
|
7993 | 100 |
double |
101 |
LteSpectrumValueHelper::GetCarrierFrequency (uint16_t earfcn) |
|
102 |
{ |
|
103 |
NS_LOG_FUNCTION (earfcn); |
|
104 |
if (earfcn < 7000) |
|
105 |
{ |
|
106 |
// FDD downlink |
|
107 |
return GetDownlinkCarrierFrequency (earfcn); |
|
108 |
} |
|
109 |
else |
|
110 |
{ |
|
111 |
// either FDD uplink or TDD (for which uplink & downlink have same frequency) |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
112 |
return GetUplinkCarrierFrequency (earfcn); |
7993 | 113 |
} |
114 |
} |
|
6705 | 115 |
|
7993 | 116 |
double |
117 |
LteSpectrumValueHelper::GetDownlinkCarrierFrequency (uint16_t nDl) |
|
6705 | 118 |
{ |
7993 | 119 |
NS_LOG_FUNCTION (nDl); |
120 |
for (uint16_t i = 0; i < NUM_EUTRA_BANDS; ++i) |
|
121 |
{ |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
122 |
if ((g_eutraChannelNumbers[i].rangeNdl1 <= nDl) |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
123 |
&& (g_eutraChannelNumbers[i].rangeNdl2 >= nDl)) |
7993 | 124 |
{ |
125 |
NS_LOG_LOGIC ("entry " << i << " fDlLow=" << g_eutraChannelNumbers[i].fDlLow); |
|
8015 | 126 |
return 1.0e6 * (g_eutraChannelNumbers[i].fDlLow + 0.1 * (nDl - g_eutraChannelNumbers[i].nOffsDl)); |
7993 | 127 |
} |
128 |
} |
|
129 |
NS_LOG_ERROR ("invalid EARFCN " << nDl); |
|
130 |
return 0.0; |
|
131 |
} |
|
6705 | 132 |
|
7993 | 133 |
double |
134 |
LteSpectrumValueHelper::GetUplinkCarrierFrequency (uint16_t nUl) |
|
135 |
{ |
|
136 |
NS_LOG_FUNCTION (nUl); |
|
137 |
for (uint16_t i = 0; i < NUM_EUTRA_BANDS; ++i) |
|
138 |
{ |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
139 |
if ((g_eutraChannelNumbers[i].rangeNul1 <= nUl) |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
140 |
&& (g_eutraChannelNumbers[i].rangeNul2 >= nUl)) |
7993 | 141 |
{ |
142 |
NS_LOG_LOGIC ("entry " << i << " fUlLow=" << g_eutraChannelNumbers[i].fUlLow); |
|
8015 | 143 |
return 1.0e6 * (g_eutraChannelNumbers[i].fUlLow + 0.1 * (nUl - g_eutraChannelNumbers[i].nOffsUl)); |
7993 | 144 |
} |
145 |
} |
|
146 |
NS_LOG_ERROR ("invalid EARFCN " << nUl); |
|
147 |
return 0.0; |
|
148 |
} |
|
6705 | 149 |
|
8015 | 150 |
double |
151 |
LteSpectrumValueHelper::GetChannelBandwidth (uint8_t transmissionBandwidth) |
|
6705 | 152 |
{ |
8015 | 153 |
NS_LOG_FUNCTION ((uint16_t) transmissionBandwidth); |
154 |
switch (transmissionBandwidth) |
|
155 |
{ |
|
156 |
case 6: |
|
157 |
return 1.4e6; |
|
158 |
case 15: |
|
159 |
return 3.0e6; |
|
160 |
case 25: |
|
161 |
return 5.0e6; |
|
162 |
case 50: |
|
163 |
return 10.0e6; |
|
164 |
case 75: |
|
165 |
return 15.0e6; |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
166 |
case 100: |
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
167 |
return 20.0e6; |
8015 | 168 |
default: |
169 |
NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) transmissionBandwidth); |
|
170 |
} |
|
171 |
} |
|
6705 | 172 |
|
173 |
||
174 |
||
175 |
||
8015 | 176 |
struct LteSpectrumModelId |
177 |
{ |
|
178 |
LteSpectrumModelId (uint16_t f, uint8_t b); |
|
179 |
uint16_t earfcn; |
|
180 |
uint8_t bandwidth; |
|
181 |
}; |
|
182 |
||
183 |
LteSpectrumModelId::LteSpectrumModelId (uint16_t f, uint8_t b) |
|
184 |
: earfcn (f), |
|
185 |
bandwidth (b) |
|
186 |
{ |
|
187 |
} |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
188 |
|
8015 | 189 |
bool |
190 |
operator < (const LteSpectrumModelId& a, const LteSpectrumModelId& b) |
|
191 |
{ |
|
192 |
return ( (a.earfcn < b.earfcn) || ( (a.earfcn == b.earfcn) && (a.bandwidth < b.bandwidth) ) ); |
|
193 |
} |
|
194 |
||
195 |
||
196 |
static std::map<LteSpectrumModelId, Ptr<SpectrumModel> > g_lteSpectrumModelMap; |
|
197 |
||
198 |
||
199 |
Ptr<SpectrumModel> |
|
200 |
LteSpectrumValueHelper::GetSpectrumModel (uint16_t earfcn, uint8_t txBandwidthConfiguration) |
|
6705 | 201 |
{ |
8015 | 202 |
NS_LOG_FUNCTION (earfcn << (uint16_t) txBandwidthConfiguration); |
203 |
Ptr<SpectrumModel> ret; |
|
204 |
LteSpectrumModelId key (earfcn, txBandwidthConfiguration); |
|
205 |
std::map<LteSpectrumModelId, Ptr<SpectrumModel> >::iterator it = g_lteSpectrumModelMap.find (key); |
|
206 |
if (it != g_lteSpectrumModelMap.end ()) |
|
207 |
{ |
|
208 |
ret = it->second; |
|
209 |
} |
|
210 |
else |
|
211 |
{ |
|
212 |
double fc = GetCarrierFrequency (earfcn); |
|
213 |
NS_ASSERT_MSG (fc != 0, "invalid EARFCN=" << earfcn); |
|
214 |
||
215 |
double f = fc - (txBandwidthConfiguration * 180e3 / 2.0); |
|
216 |
Bands rbs; |
|
217 |
for (uint8_t numrb = 0; numrb < txBandwidthConfiguration; ++numrb) |
|
218 |
{ |
|
219 |
BandInfo rb; |
|
220 |
rb.fl = f; |
|
221 |
f += 90e3; |
|
222 |
rb.fc = f; |
|
223 |
f += 90e3; |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
224 |
rb.fh = f; |
8015 | 225 |
rbs.push_back (rb); |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
226 |
} |
8015 | 227 |
ret = Create<SpectrumModel> (rbs); |
228 |
g_lteSpectrumModelMap.insert (std::pair<LteSpectrumModelId, Ptr<SpectrumModel> > (key, ret)); |
|
229 |
} |
|
230 |
NS_LOG_LOGIC ("returning SpectrumModel::GetUid () == " << ret->GetUid ()); |
|
231 |
return ret; |
|
232 |
} |
|
233 |
||
234 |
Ptr<SpectrumValue> |
|
235 |
LteSpectrumValueHelper::CreateTxPowerSpectralDensity (uint16_t earfcn, uint8_t txBandwidthConfiguration, double powerTx, std::vector <int> activeRbs) |
|
236 |
{ |
|
237 |
NS_LOG_FUNCTION (earfcn << (uint16_t) txBandwidthConfiguration << powerTx << activeRbs); |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
238 |
|
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
239 |
Ptr<SpectrumModel> model = GetSpectrumModel (earfcn, txBandwidthConfiguration); |
8015 | 240 |
Ptr<SpectrumValue> txPsd = Create <SpectrumValue> (model); |
6705 | 241 |
|
242 |
// powerTx is expressed in dBm. We must convert it into natural unit. |
|
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Mileti? <rivanvx@gmail.com>
parents:
8663
diff
changeset
|
243 |
double powerTxW = std::pow (10., (powerTx - 30) / 10); |
6705 | 244 |
|
8060
f8cef15d3cd0
fixed TX and noise PSD calculations
Nicola Baldo <nbaldo@cttc.es>
parents:
8015
diff
changeset
|
245 |
double txPowerDensity = (powerTxW / (txBandwidthConfiguration * 180000)); |
6705 | 246 |
|
8015 | 247 |
for (std::vector <int>::iterator it = activeRbs.begin (); it != activeRbs.end (); it++) |
6705 | 248 |
{ |
8015 | 249 |
int rbId = (*it); |
250 |
(*txPsd)[rbId] = txPowerDensity; |
|
6705 | 251 |
} |
252 |
||
8015 | 253 |
NS_LOG_LOGIC (*txPsd); |
254 |
||
6705 | 255 |
return txPsd; |
256 |
} |
|
257 |
||
258 |
||
259 |
Ptr<SpectrumValue> |
|
8015 | 260 |
LteSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint16_t earfcn, uint8_t txBandwidthConfiguration, double noiseFigure) |
6705 | 261 |
{ |
8015 | 262 |
NS_LOG_FUNCTION (earfcn << (uint16_t) txBandwidthConfiguration << noiseFigure); |
263 |
Ptr<SpectrumModel> model = GetSpectrumModel (earfcn, txBandwidthConfiguration); |
|
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8106
diff
changeset
|
264 |
return CreateNoisePowerSpectralDensity (noiseFigure, model); |
6705 | 265 |
} |
266 |
||
267 |
Ptr<SpectrumValue> |
|
7981 | 268 |
LteSpectrumValueHelper::CreateNoisePowerSpectralDensity (double noiseFigureDb, Ptr<SpectrumModel> spectrumModel) |
6705 | 269 |
{ |
8015 | 270 |
NS_LOG_FUNCTION (noiseFigureDb << spectrumModel); |
6705 | 271 |
|
272 |
||
8060
f8cef15d3cd0
fixed TX and noise PSD calculations
Nicola Baldo <nbaldo@cttc.es>
parents:
8015
diff
changeset
|
273 |
// see "LTE - From theory to practice" |
f8cef15d3cd0
fixed TX and noise PSD calculations
Nicola Baldo <nbaldo@cttc.es>
parents:
8015
diff
changeset
|
274 |
// Section 22.4.4.2 Thermal Noise and Receiver Noise Figure |
f8cef15d3cd0
fixed TX and noise PSD calculations
Nicola Baldo <nbaldo@cttc.es>
parents:
8015
diff
changeset
|
275 |
const double kT_dBm_Hz = -174.0; // dBm/Hz |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Mileti? <rivanvx@gmail.com>
parents:
8663
diff
changeset
|
276 |
double kT_W_Hz = std::pow (10.0, (kT_dBm_Hz - 30) / 10.0); |
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Mileti? <rivanvx@gmail.com>
parents:
8663
diff
changeset
|
277 |
double noiseFigureLinear = std::pow (10.0, noiseFigureDb / 10.0); |
8060
f8cef15d3cd0
fixed TX and noise PSD calculations
Nicola Baldo <nbaldo@cttc.es>
parents:
8015
diff
changeset
|
278 |
double noisePowerSpectralDensity = kT_W_Hz * noiseFigureLinear; |
6705 | 279 |
|
7981 | 280 |
Ptr<SpectrumValue> noisePsd = Create <SpectrumValue> (spectrumModel); |
281 |
(*noisePsd) = noisePowerSpectralDensity; |
|
282 |
return noisePsd; |
|
6705 | 283 |
} |
284 |
||
285 |
} // namespace ns3 |