author | Marco Miozzo <marco.miozzo@cttc.es> |
Thu, 07 Jul 2011 16:47:45 +0200 | |
changeset 8191 | 02ce2fb4883b |
parent 8189 | dde497458c54 |
child 8192 | 0d4ca39493cb |
permissions | -rw-r--r-- |
8189 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) |
|
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: Marco Miozzo <marco.miozzo@cttc.es> |
|
19 |
*/ |
|
20 |
||
21 |
#include "ns3/simulator.h" |
|
22 |
||
23 |
#include "ns3/log.h" |
|
24 |
||
25 |
#include "ns3/spectrum-test.h" |
|
26 |
||
27 |
#include "ns3/lte-phy-tag.h" |
|
28 |
#include "ns3/lte-test-ue-phy.h" |
|
29 |
#include "ns3/lte-sinr-chunk-processor.h" |
|
30 |
||
31 |
#include "ns3/lte-test-pathloss-model.h" |
|
32 |
||
33 |
NS_LOG_COMPONENT_DEFINE ("LtePathlossModelTest"); |
|
34 |
||
35 |
using namespace ns3; |
|
36 |
||
37 |
||
38 |
/** |
|
39 |
* Test 1.1 SINR calculation in downlink |
|
40 |
*/ |
|
41 |
||
42 |
/** |
|
43 |
* TestSuite |
|
44 |
*/ |
|
45 |
||
46 |
LtePathlossModelTestSuite::LtePathlossModelTestSuite () |
|
47 |
: TestSuite ("lte-pathloss-model", SYSTEM) |
|
48 |
{ |
|
49 |
// LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); |
|
50 |
||
51 |
// LogComponentEnable ("LteTestUePhy", logLevel); |
|
52 |
// LogComponentEnable ("LteDownlinkSinrTest", logLevel); |
|
53 |
||
54 |
// NS_LOG_INFO ("Creating LteDownlinkSinrTestSuite"); |
|
55 |
||
56 |
/** |
|
57 |
* Build Spectrum Model values for the TX signal |
|
58 |
*/ |
|
59 |
Ptr<SpectrumModel> sm; |
|
60 |
||
61 |
Bands bands; |
|
62 |
BandInfo bi; |
|
63 |
||
64 |
bi.fl = 2.400e9; |
|
65 |
bi.fc = 2.410e9; |
|
66 |
bi.fh = 2.420e9; |
|
67 |
bands.push_back (bi); |
|
68 |
||
69 |
bi.fl = 2.420e9; |
|
70 |
bi.fc = 2.431e9; |
|
71 |
bi.fh = 2.442e9; |
|
72 |
bands.push_back (bi); |
|
73 |
||
74 |
sm = Create<SpectrumModel> (bands); |
|
75 |
||
76 |
/** |
|
77 |
* TX signal #1: Power Spectral Density (W/Hz) of the signal of interest = [-46 -48] dBm and BW = [20 22] MHz |
|
78 |
*/ |
|
79 |
Ptr<SpectrumValue> rxPsd1 = Create<SpectrumValue> (sm); |
|
80 |
(*rxPsd1)[0] = 1.255943215755e-15; |
|
81 |
(*rxPsd1)[1] = 7.204059965732e-16; |
|
82 |
||
83 |
Ptr<SpectrumValue> theoreticalSinr1 = Create<SpectrumValue> (sm); |
|
84 |
(*theoreticalSinr1)[0] = 3.72589167251055; |
|
85 |
(*theoreticalSinr1)[1] = 3.72255684126076; |
|
86 |
||
87 |
AddTestCase (new LtePathlossModelTestCase (rxPsd1, theoreticalSinr1, "sdBm = [-46 -48]")); |
|
88 |
||
89 |
/** |
|
90 |
* TX signal #2: Power Spectral Density (W/Hz) of the signal of interest = [-63 -61] dBm and BW = [20 22] MHz |
|
91 |
*/ |
|
92 |
Ptr<SpectrumValue> rxPsd2 = Create<SpectrumValue> (sm); |
|
93 |
(*rxPsd2)[0] = 2.505936168136e-17; |
|
94 |
(*rxPsd2)[1] = 3.610582885110e-17; |
|
95 |
||
96 |
Ptr<SpectrumValue> theoreticalSinr2 = Create<SpectrumValue> (sm); |
|
97 |
(*theoreticalSinr2)[0] = 0.0743413124381667; |
|
98 |
(*theoreticalSinr2)[1] = 0.1865697965291756; |
|
99 |
||
100 |
AddTestCase (new LtePathlossModelTestCase (rxPsd2, theoreticalSinr2, "sdBm = [-63 -61]")); |
|
101 |
||
102 |
} |
|
103 |
||
104 |
static LtePathlossModelTestSuite ltePathlossModelTestSuite; |
|
105 |
||
106 |
||
107 |
/** |
|
108 |
* TestCase |
|
109 |
*/ |
|
110 |
||
111 |
LtePathlossModelTestCase::LtePathlossModelTestCase (Ptr<SpectrumValue> sv, Ptr<SpectrumValue> sinr, std::string name) |
|
112 |
: TestCase ("SINR calculation in downlink: " + name), |
|
113 |
m_sv (sv), |
|
114 |
m_sm (sv->GetSpectrumModel ()), |
|
115 |
m_sinr (sinr) |
|
116 |
{ |
|
117 |
NS_LOG_INFO ("Creating LtePathlossModelTestCase"); |
|
118 |
} |
|
119 |
||
120 |
LtePathlossModelTestCase::~LtePathlossModelTestCase () |
|
121 |
{ |
|
122 |
} |
|
123 |
||
124 |
void |
|
125 |
LtePathlossModelTestCase::DoRun (void) |
|
126 |
{ |
|
127 |
LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); |
|
128 |
||
129 |
LogComponentEnable ("LteEnbRrc", logLevel); |
|
130 |
LogComponentEnable ("LteUeRrc", logLevel); |
|
131 |
LogComponentEnable ("LteEnbMac", logLevel); |
|
132 |
LogComponentEnable ("LteUeMac", logLevel); |
|
133 |
LogComponentEnable ("LteRlc", logLevel); |
|
134 |
LogComponentEnable ("RrPacketScheduler", logLevel); |
|
135 |
||
136 |
LogComponentEnable ("LtePhy", logLevel); |
|
137 |
LogComponentEnable ("LteEnbPhy", logLevel); |
|
138 |
LogComponentEnable ("LteUePhy", logLevel); |
|
139 |
||
140 |
LogComponentEnable ("LteSpectrumPhy", logLevel); |
|
141 |
LogComponentEnable ("LteInterference", logLevel); |
|
142 |
LogComponentEnable ("LteSinrChunkProcessor", logLevel); |
|
143 |
||
144 |
LogComponentEnable ("LtePropagationLossModel", logLevel); |
|
145 |
LogComponentEnable ("LossModel", logLevel); |
|
146 |
LogComponentEnable ("ShadowingLossModel", logLevel); |
|
147 |
LogComponentEnable ("PenetrationLossModel", logLevel); |
|
148 |
LogComponentEnable ("MultipathLossModel", logLevel); |
|
149 |
LogComponentEnable ("PathLossModel", logLevel); |
|
150 |
||
151 |
LogComponentEnable ("LteNetDevice", logLevel); |
|
152 |
LogComponentEnable ("LteUeNetDevice", logLevel); |
|
153 |
LogComponentEnable ("LteEnbNetDevice", logLevel); |
|
154 |
||
155 |
/** |
|
156 |
* Instantiate a single receiving LteSpectrumPhy |
|
157 |
*/ |
|
158 |
Ptr<LteSpectrumPhy> dlPhy = CreateObject<LteSpectrumPhy> (); |
|
159 |
Ptr<LteSpectrumPhy> ulPhy = CreateObject<LteSpectrumPhy> (); |
|
160 |
Ptr<LteTestUePhy> uePhy = CreateObject<LteTestUePhy> (dlPhy, ulPhy); |
|
161 |
||
162 |
dlPhy->SetCellId (100); |
|
163 |
||
164 |
Ptr<LteCqiSinrChunkProcessor> chunkProcessor = Create<LteCqiSinrChunkProcessor> (uePhy->GetObject<LtePhy> ()); |
|
165 |
dlPhy->AddSinrChunkProcessor (chunkProcessor); |
|
8191
02ce2fb4883b
Remove dependences from SpectrumPropagationLossModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8189
diff
changeset
|
166 |
|
02ce2fb4883b
Remove dependences from SpectrumPropagationLossModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8189
diff
changeset
|
167 |
// Ptr<SpectrumChannel> m_downlinkChannel = CreateObject<SingleModelSpectrumChannel> (); |
02ce2fb4883b
Remove dependences from SpectrumPropagationLossModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8189
diff
changeset
|
168 |
// Ptr<SpectrumChannel> m_uplinkChannel = CreateObject<SingleModelSpectrumChannel> (); |
02ce2fb4883b
Remove dependences from SpectrumPropagationLossModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8189
diff
changeset
|
169 |
// Ptr<SpectrumPropagationLossModel> dlPropagationModel = Create<BuildingsSpectrumPropagationLossModel> (); |
02ce2fb4883b
Remove dependences from SpectrumPropagationLossModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8189
diff
changeset
|
170 |
// Ptr<SpectrumPropagationLossModel> ulPropagationModel = Create<BuildingsSpectrumPropagationLossModel> (); |
02ce2fb4883b
Remove dependences from SpectrumPropagationLossModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8189
diff
changeset
|
171 |
// m_downlinkChannel->AddSpectrumPropagationLossModel (dlPropagationModel); |
02ce2fb4883b
Remove dependences from SpectrumPropagationLossModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8189
diff
changeset
|
172 |
// m_uplinkChannel->AddSpectrumPropagationLossModel (ulPropagationModel); |
02ce2fb4883b
Remove dependences from SpectrumPropagationLossModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8189
diff
changeset
|
173 |
// m_downlinkPropagationLossModel = CreateObject<BuildingsPropagationLossModel> (); |
02ce2fb4883b
Remove dependences from SpectrumPropagationLossModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8189
diff
changeset
|
174 |
// m_uplinkPropagationLossModel = CreateObject<BuildingsPropagationLossModel> (); |
02ce2fb4883b
Remove dependences from SpectrumPropagationLossModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8189
diff
changeset
|
175 |
// m_downlinkChannel->AddPropagationLossModel (m_downlinkPropagationLossModel); |
02ce2fb4883b
Remove dependences from SpectrumPropagationLossModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8189
diff
changeset
|
176 |
// m_uplinkChannel->AddPropagationLossModel (m_uplinkPropagationLossModel); |
02ce2fb4883b
Remove dependences from SpectrumPropagationLossModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8189
diff
changeset
|
177 |
|
02ce2fb4883b
Remove dependences from SpectrumPropagationLossModel
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8189
diff
changeset
|
178 |
|
8189 | 179 |
|
180 |
/** |
|
181 |
* Generate several calls to LteSpectrumPhy::StartRx corresponding to several signals. |
|
182 |
* One will be the signal of interest, i.e., the PhyTag of the first Packet in the Packet burst |
|
183 |
* will have the same CellId of the receiving PHY; |
|
184 |
* the others will have a different CellId and hence will be the interfering signals |
|
185 |
*/ |
|
186 |
||
187 |
// Number of packet bursts (1 data + 4 interferences) |
|
188 |
int numOfPbs = 5; |
|
189 |
||
190 |
// Number of packets in the packet bursts |
|
191 |
int numOfPkts = 10; |
|
192 |
||
193 |
// Packet bursts |
|
194 |
Ptr<PacketBurst> packetBursts[numOfPbs]; |
|
195 |
||
196 |
// Packets |
|
197 |
Ptr<Packet> pkt[numOfPbs][numOfPkts]; |
|
198 |
||
199 |
// Phy tags |
|
200 |
LtePhyTag pktTag[numOfPbs]; |
|
201 |
||
202 |
/** |
|
203 |
* Build packet burst |
|
204 |
*/ |
|
205 |
for ( int pb = 0 ; pb < numOfPbs ; pb++ ) |
|
206 |
{ |
|
207 |
// Create packet burst |
|
208 |
packetBursts[pb] = CreateObject<PacketBurst> (); |
|
209 |
||
210 |
// Create packets and add them to the burst |
|
211 |
for ( int i = 0 ; i < numOfPkts ; i++ ) |
|
212 |
{ |
|
213 |
pkt[pb][i] = Create<Packet> (1000); |
|
214 |
||
215 |
if ( i == 0 ) |
|
216 |
{ |
|
217 |
// Create phy tag (different for each packet burst) |
|
218 |
// and add to the first packet |
|
219 |
pktTag[pb] = LtePhyTag (100 * (pb + 1)); |
|
220 |
pkt[pb][i]->AddPacketTag ( pktTag[pb] ); |
|
221 |
} |
|
222 |
||
223 |
packetBursts[pb]->AddPacket ( pkt[pb][i] ); |
|
224 |
} |
|
225 |
} |
|
226 |
||
227 |
||
228 |
Ptr<SpectrumValue> noisePsd = Create<SpectrumValue> (m_sm); |
|
229 |
Ptr<SpectrumValue> i1 = Create<SpectrumValue> (m_sm); |
|
230 |
Ptr<SpectrumValue> i2 = Create<SpectrumValue> (m_sm); |
|
231 |
Ptr<SpectrumValue> i3 = Create<SpectrumValue> (m_sm); |
|
232 |
Ptr<SpectrumValue> i4 = Create<SpectrumValue> (m_sm); |
|
233 |
||
234 |
(*noisePsd)[0] = 5.000000000000e-19; |
|
235 |
(*noisePsd)[1] = 4.545454545455e-19; |
|
236 |
||
237 |
(*i1)[0] = 5.000000000000e-18; |
|
238 |
(*i2)[0] = 5.000000000000e-16; |
|
239 |
(*i3)[0] = 1.581138830084e-16; |
|
240 |
(*i4)[0] = 7.924465962306e-17; |
|
241 |
(*i1)[1] = 1.437398936440e-18; |
|
242 |
(*i2)[1] = 5.722388235428e-16; |
|
243 |
(*i3)[1] = 7.204059965732e-17; |
|
244 |
(*i4)[1] = 5.722388235428e-17; |
|
245 |
||
246 |
Time ts = Seconds (1); |
|
247 |
Time ds = Seconds (1); |
|
248 |
Time ti1 = Seconds (0); |
|
249 |
Time di1 = Seconds (3); |
|
250 |
Time ti2 = Seconds (0.7); |
|
251 |
Time di2 = Seconds (1); |
|
252 |
Time ti3 = Seconds (1.2); |
|
253 |
Time di3 = Seconds (1); |
|
254 |
Time ti4 = Seconds (1.5); |
|
255 |
Time di4 = Seconds (0.1); |
|
256 |
||
257 |
dlPhy->SetNoisePowerSpectralDensity (noisePsd); |
|
258 |
||
259 |
/** |
|
260 |
* Schedule the reception of the data signal plus the interference signals |
|
261 |
*/ |
|
262 |
||
263 |
// eNB sends data to 2 UEs through 2 subcarriers |
|
264 |
Simulator::Schedule (ts, &LteSpectrumPhy::StartRx, dlPhy, packetBursts[0], m_sv, dlPhy->GetSpectrumType (), ds); |
|
265 |
||
266 |
Simulator::Schedule (ti1, &LteSpectrumPhy::StartRx, dlPhy, packetBursts[1], i1, dlPhy->GetSpectrumType (), di1); |
|
267 |
Simulator::Schedule (ti2, &LteSpectrumPhy::StartRx, dlPhy, packetBursts[2], i2, dlPhy->GetSpectrumType (), di2); |
|
268 |
Simulator::Schedule (ti3, &LteSpectrumPhy::StartRx, dlPhy, packetBursts[3], i3, dlPhy->GetSpectrumType (), di3); |
|
269 |
Simulator::Schedule (ti4, &LteSpectrumPhy::StartRx, dlPhy, packetBursts[4], i4, dlPhy->GetSpectrumType (), di4); |
|
270 |
||
271 |
Simulator::Stop (Seconds (5.0)); |
|
272 |
Simulator::Run (); |
|
273 |
Simulator::Destroy (); |
|
274 |
||
275 |
/** |
|
276 |
* Check that the values passed to LteSinrChunkProcessor::EvaluateSinrChunk () correspond |
|
277 |
* to known values which have been calculated offline (with octave) for the generated signals |
|
278 |
*/ |
|
279 |
SpectrumValue calculatedSinr = uePhy->GetSinr (); |
|
280 |
||
281 |
NS_LOG_INFO ("Theoretical SINR: " << *m_sinr); |
|
282 |
NS_LOG_INFO ("Calculated SINR: " << calculatedSinr); |
|
283 |
||
284 |
NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(calculatedSinr, *m_sinr, 0.0000001, "Wrong SINR !"); |
|
285 |
} |