A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-test-downlink-sinr.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Manuel Requena <manuel.requena@cttc.es>
7 * Modified by Marco Miozzo <mmiozzo@ctt.es>
8 * Extend to Data and Ctrl frames
9 */
10
12
13#include "lte-test-ue-phy.h"
14
15#include "ns3/boolean.h"
16#include "ns3/log.h"
17#include "ns3/lte-helper.h"
18#include "ns3/lte-phy-tag.h"
19#include "ns3/lte-spectrum-signal-parameters.h"
20#include "ns3/simulator.h"
21#include "ns3/spectrum-test.h"
22#include <ns3/lte-chunk-processor.h>
23#include <ns3/lte-control-messages.h>
24
25using namespace ns3;
26
27NS_LOG_COMPONENT_DEFINE("LteDownlinkSinrTest");
28
29/**
30 * Test 1.1 SINR calculation in downlink
31 */
32
33/**
34 * TestSuite
35 */
36
38 : TestSuite("lte-downlink-sinr", Type::SYSTEM)
39{
40 /**
41 * Build Spectrum Model values for the TX signal
42 */
44
45 Bands bands;
46 BandInfo bi;
47
48 bi.fl = 2.400e9;
49 bi.fc = 2.410e9;
50 bi.fh = 2.420e9;
51 bands.push_back(bi);
52
53 bi.fl = 2.420e9;
54 bi.fc = 2.431e9;
55 bi.fh = 2.442e9;
56 bands.push_back(bi);
57
58 sm = Create<SpectrumModel>(bands);
59
60 /**
61 * TX signal #1: Power Spectral Density (W/Hz) of the signal of interest = [-46 -48] dBm and BW
62 * = [20 22] MHz
63 */
65 (*rxPsd1)[0] = 1.255943215755e-15;
66 (*rxPsd1)[1] = 7.204059965732e-16;
67
68 Ptr<SpectrumValue> theoreticalSinr1 = Create<SpectrumValue>(sm);
69 (*theoreticalSinr1)[0] = 3.72589167251055;
70 (*theoreticalSinr1)[1] = 3.72255684126076;
71
72 AddTestCase(new LteDownlinkDataSinrTestCase(rxPsd1, theoreticalSinr1, "sdBm = [-46 -48]"),
73 TestCase::Duration::QUICK);
74 AddTestCase(new LteDownlinkCtrlSinrTestCase(rxPsd1, theoreticalSinr1, "sdBm = [-46 -48]"),
75 TestCase::Duration::QUICK);
76
77 /**
78 * TX signal #2: Power Spectral Density (W/Hz) of the signal of interest = [-63 -61] dBm and BW
79 * = [20 22] MHz
80 */
82 (*rxPsd2)[0] = 2.505936168136e-17;
83 (*rxPsd2)[1] = 3.610582885110e-17;
84
85 Ptr<SpectrumValue> theoreticalSinr2 = Create<SpectrumValue>(sm);
86 (*theoreticalSinr2)[0] = 0.0743413124381667;
87 (*theoreticalSinr2)[1] = 0.1865697965291756;
88
89 AddTestCase(new LteDownlinkDataSinrTestCase(rxPsd2, theoreticalSinr2, "sdBm = [-63 -61]"),
90 TestCase::Duration::QUICK);
91 AddTestCase(new LteDownlinkCtrlSinrTestCase(rxPsd2, theoreticalSinr2, "sdBm = [-63 -61]"),
92 TestCase::Duration::QUICK);
93}
94
95/**
96 * \ingroup lte-test
97 * Static variable for test initialization
98 */
100
101/**
102 * TestCase Data
103 */
104
107 std::string name)
108 : TestCase("SINR calculation in downlink Data frame: " + name),
109 m_sv(sv),
110 m_sm(sv->GetSpectrumModel()),
111 m_expectedSinr(sinr)
112{
113 NS_LOG_INFO("Creating LenaDownlinkSinrTestCase");
114}
115
119
120void
122{
123 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
124 /**
125 * Instantiate a single receiving LteSpectrumPhy
126 */
129 Ptr<LteTestUePhy> uePhy = CreateObject<LteTestUePhy>(dlPhy, ulPhy);
130 uint16_t cellId = 100;
131 dlPhy->SetCellId(cellId);
132 ulPhy->SetCellId(cellId);
133
135 LteSpectrumValueCatcher actualSinrCatcher;
136 chunkProcessor->AddCallback(
138 dlPhy->AddDataSinrChunkProcessor(chunkProcessor);
139
140 /**
141 * Generate several calls to LteSpectrumPhy::StartRx corresponding to
142 * several signals. One will be the signal of interest, i.e., the
143 * LteSpectrumSignalParametersDataFrame of the Packet burst
144 * will have the same CellId of the receiving PHY; the others will have
145 * a different CellId and hence will be the interfering signals
146 */
147
148 // Number of packet bursts (1 data + 4 interferences)
149 constexpr int numOfPbs = 5;
150
151 // Number of packets in the packet bursts
152 constexpr int numOfPkts = 10;
153
154 // Packet bursts
155 Ptr<PacketBurst> packetBursts[numOfPbs];
156
157 // Packets
158 Ptr<Packet> pkt[numOfPbs][numOfPkts];
159
160 // Packet bursts cellId
161 uint16_t pbCellId[numOfPbs];
162
163 /**
164 * Build packet burst
165 */
166 for (int pb = 0; pb < numOfPbs; pb++)
167 {
168 // Create packet burst
169 packetBursts[pb] = CreateObject<PacketBurst>();
170 pbCellId[pb] = cellId * (pb + 1);
171
172 // Create packets and add them to the burst
173 for (int i = 0; i < numOfPkts; i++)
174 {
175 pkt[pb][i] = Create<Packet>(1000);
176
177 packetBursts[pb]->AddPacket(pkt[pb][i]);
178 }
179 }
180
186
187 (*noisePsd)[0] = 5.000000000000e-19;
188 (*noisePsd)[1] = 4.545454545455e-19;
189
190 (*i1)[0] = 5.000000000000e-18;
191 (*i2)[0] = 5.000000000000e-16;
192 (*i3)[0] = 1.581138830084e-16;
193 (*i4)[0] = 7.924465962306e-17;
194 (*i1)[1] = 1.437398936440e-18;
195 (*i2)[1] = 5.722388235428e-16;
196 (*i3)[1] = 7.204059965732e-17;
197 (*i4)[1] = 5.722388235428e-17;
198
199 Time ts = Seconds(1);
200 Time ds = Seconds(1);
201 Time ti1 = Seconds(0);
202 Time di1 = Seconds(3);
203 Time ti2 = Seconds(0.7);
204 Time di2 = Seconds(1);
205 Time ti3 = Seconds(1.2);
206 Time di3 = Seconds(1);
207 Time ti4 = Seconds(1.5);
208 Time di4 = Seconds(0.1);
209
210 dlPhy->SetNoisePowerSpectralDensity(noisePsd);
211
212 /**
213 * Schedule the reception of the data signal plus the interference signals
214 */
215
216 // eNB sends data to 2 UEs through 2 subcarriers
218 sp1->psd = m_sv;
219 sp1->txPhy = nullptr;
220 sp1->duration = ds;
221 sp1->packetBurst = packetBursts[0];
222 sp1->cellId = pbCellId[0];
224
226 ip1->psd = i1;
227 ip1->txPhy = nullptr;
228 ip1->duration = di1;
229 ip1->packetBurst = packetBursts[1];
230 ip1->cellId = pbCellId[1];
232
234 ip2->psd = i2;
235 ip2->txPhy = nullptr;
236 ip2->duration = di2;
237 ip2->packetBurst = packetBursts[2];
238 ip2->cellId = pbCellId[2];
240
242 ip3->psd = i3;
243 ip3->txPhy = nullptr;
244 ip3->duration = di3;
245 ip3->packetBurst = packetBursts[3];
246 ip3->cellId = pbCellId[3];
248
250 ip4->psd = i4;
251 ip4->txPhy = nullptr;
252 ip4->duration = di4;
253 ip4->packetBurst = packetBursts[4];
254 ip4->cellId = pbCellId[4];
256
259
260 NS_LOG_INFO("Data Frame - Theoretical SINR: " << *m_expectedSinr);
261 NS_LOG_INFO("Data Frame - Calculated SINR: " << *(actualSinrCatcher.GetValue()));
262
265 0.0000001,
266 "Data Frame - Wrong SINR !");
267 dlPhy->Dispose();
269}
270
271/**
272 * TestCase CTRL
273 */
274
277 std::string name)
278 : TestCase("SINR calculation in downlink Ctrl Frame: " + name),
279 m_sv(sv),
280 m_sm(sv->GetSpectrumModel()),
281 m_expectedSinr(sinr)
282{
283 NS_LOG_INFO("Creating LenaDownlinkCtrlSinrTestCase");
284}
285
289
290void
292{
293 /**
294 * Instantiate a single receiving LteSpectrumPhy
295 */
296 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
299 Ptr<LteTestUePhy> uePhy = CreateObject<LteTestUePhy>(dlPhy, ulPhy);
300 uint16_t cellId = 100;
301 dlPhy->SetCellId(cellId);
302 ulPhy->SetCellId(cellId);
303
305 LteSpectrumValueCatcher actualSinrCatcher;
306 chunkProcessor->AddCallback(
308 dlPhy->AddCtrlSinrChunkProcessor(chunkProcessor);
309
310 /**
311 * Generate several calls to LteSpectrumPhy::StartRx corresponding to several signals. One will
312 * be the signal of interest, i.e., the LteSpectrumSignalParametersDlCtrlFrame of the first
313 * signal will have the same CellId of the receiving PHY; the others will have a different
314 * CellId and hence will be the interfering signals
315 */
316
317 // Number of ctrl bursts (1 data + 4 interferences)
318 const int numOfUes = 5;
319
320 // Number of control messages in the list
321 const int numOfCtrlMsgs = 10;
322
323 // control messages in the list
324 std::list<Ptr<LteControlMessage>> ctrlMsgList[numOfUes];
325
326 // signals cellId
327 uint16_t pbCellId[numOfUes];
328
329 /**
330 * Build ctrl msg lists
331 */
332 for (int pb = 0; pb < numOfUes; pb++)
333 {
334 pbCellId[pb] = cellId * (pb + 1);
335
336 // Create ctrl msg and add them to the list
337 for (int i = 0; i < numOfCtrlMsgs; i++)
338 {
341 msg->SetDci(dci);
342 ctrlMsgList[pb].emplace_back(msg);
343 }
344 }
345
351
352 (*noisePsd)[0] = 5.000000000000e-19;
353 (*noisePsd)[1] = 4.545454545455e-19;
354
355 (*i1)[0] = 5.000000000000e-18;
356 (*i2)[0] = 5.000000000000e-16;
357 (*i3)[0] = 1.581138830084e-16;
358 (*i4)[0] = 7.924465962306e-17;
359 (*i1)[1] = 1.437398936440e-18;
360 (*i2)[1] = 5.722388235428e-16;
361 (*i3)[1] = 7.204059965732e-17;
362 (*i4)[1] = 5.722388235428e-17;
363
364 Time ts = Seconds(1);
365 Time ds = Seconds(1);
366 Time ti1 = Seconds(0);
367 Time di1 = Seconds(3);
368 Time ti2 = Seconds(0.7);
369 Time di2 = Seconds(1);
370 Time ti3 = Seconds(1.2);
371 Time di3 = Seconds(1);
372 Time ti4 = Seconds(1.5);
373 Time di4 = Seconds(0.1);
374
375 dlPhy->SetNoisePowerSpectralDensity(noisePsd);
376
377 /**
378 * Schedule the reception of the data signal plus the interference signals
379 */
380
381 // eNB sends data to 2 UEs through 2 subcarriers
384 sp1->psd = m_sv;
385 sp1->txPhy = nullptr;
386 sp1->duration = ds;
387 sp1->ctrlMsgList = ctrlMsgList[0];
388 sp1->cellId = pbCellId[0];
389 sp1->pss = false;
391
394 ip1->psd = i1;
395 ip1->txPhy = nullptr;
396 ip1->duration = di1;
397 ip1->ctrlMsgList = ctrlMsgList[1];
398 ip1->cellId = pbCellId[1];
399 ip1->pss = false;
401
404 ip2->psd = i2;
405 ip2->txPhy = nullptr;
406 ip2->duration = di2;
407 ip2->ctrlMsgList = ctrlMsgList[2];
408 ip2->cellId = pbCellId[2];
409 ip2->pss = false;
411
414 ip3->psd = i3;
415 ip3->txPhy = nullptr;
416 ip3->duration = di3;
417 ip3->ctrlMsgList = ctrlMsgList[3];
418 ip3->cellId = pbCellId[3];
419 ip3->pss = false;
421
424 ip4->psd = i4;
425 ip4->txPhy = nullptr;
426 ip4->duration = di4;
427 ip4->ctrlMsgList = ctrlMsgList[4];
428 ip4->cellId = pbCellId[4];
429 ip4->pss = false;
431
434
435 NS_LOG_INFO("Ctrl Frame - Theoretical SINR: " << *m_expectedSinr);
436 NS_LOG_INFO("Ctrl Frame - Calculated SINR: " << *(actualSinrCatcher.GetValue()));
437
440 0.0000001,
441 "Data Frame - Wrong SINR !");
442 dlPhy->Dispose();
444}
void StartRx(Ptr< SpectrumSignalParameters > params) override
Notify the SpectrumPhy instance of an incoming signal.
A sink to be plugged to the callback of LteChunkProcessor allowing to save and later retrieve the lat...
Ptr< SpectrumValue > GetValue()
void ReportValue(const SpectrumValue &value)
function to be plugged to LteChunkProcessor::AddCallback ()
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:883
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
static LteDownlinkSinrTestSuite lteDownlinkSinrTestSuite
Static variable for test initialization.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
#define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(actual, expected, tol, msg)
Test if two SpectrumValue instances are equal within a given tolerance.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition callback.h:684
std::vector< BandInfo > Bands
Container of BandInfo.
The building block of a SpectrumModel.
double fc
center frequency
double fl
lower limit of subband
double fh
upper limit of subband
See section 4.3.1 dlDciListElement.