Left: | ||
Right: |
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 | |
22 #include "lte-spectrum-value-helper.h" | |
23 #include <cmath> | |
24 | |
25 namespace ns3 { | |
26 | |
27 Ptr<SpectrumModel> LteSpectrumModel; | |
Nicola Baldo
2010/08/04 12:40:38
There is still a single LteSpectrumModel used both
GiuseppePiro
2010/08/06 14:09:47
Done.
| |
28 | |
29 | |
30 | |
31 class static_LteSpectrumModel_initializer | |
32 { | |
33 public: | |
34 static_LteSpectrumModel_initializer () | |
35 { | |
36 | |
37 std::vector<double> freqs; | |
38 for (int i = 0; i < 100; ++i) | |
39 { | |
40 | |
41 double centralFrequencyOfPRB = 1.99109 + (i * 0.00018); | |
42 freqs.push_back (centralFrequencyOfPRB * 1e9); | |
Nicola Baldo
2010/08/04 12:40:38
You have exactly the same code in lte-spectrum-mod
GiuseppePiro
2010/08/06 14:09:47
Done.
| |
43 } | |
44 | |
45 LteSpectrumModel = Create<SpectrumModel> (freqs); | |
46 } | |
47 | |
48 } static_LteSpectrumModel_initializer_instance; | |
49 | |
50 | |
51 | |
52 | |
53 | |
54 Ptr<SpectrumValue>· | |
55 LteSpectrumValueHelper::CreateTxPowerSpectralDensity (double powerTx, std::vecto r<int> channels) | |
56 {·· | |
57 Ptr<SpectrumValue> txPsd = Create <SpectrumValue> (LteSpectrumModel); | |
58 | |
59 // powerTx is expressed in dBm. We must convert it into natural unit. | |
60 powerTx = pow(10., (powerTx - 30)/10); | |
61 | |
62 double txPowerDensity = (powerTx / channels.size ()) / 180000; | |
63 | |
64 for (std::vector <int>::iterator it = channels.begin (); it != channels.end () ; it++) | |
65 { | |
66 int idSubChannel = (*it); | |
67 (*txPsd)[idSubChannel] = txPowerDensity; | |
68 } | |
69 | |
70 return txPsd; | |
71 } | |
72 | |
73 | |
74 Ptr<SpectrumValue>· | |
75 LteSpectrumValueHelper::CreateNoisePowerSpectralDensity (void) | |
76 { | |
77 Ptr<SpectrumValue> txPsd = Create <SpectrumValue> (LteSpectrumModel); | |
78 | |
79 double noise_db = 2.5 + (-174) + (10.*log10(180000)) - 30; | |
80 double noisePowerDensity = (pow(10.,noise_db/10)) / 180000; | |
81 | |
82 (*txPsd) = noisePowerDensity; | |
83 | |
84 return txPsd; | |
85 } | |
86 | |
87 } //namespace ns3 | |
OLD | NEW |