27#include "ns3/lte-phy-tag.h"
28#include "ns3/lte-spectrum-signal-parameters.h"
29#include "ns3/simulator.h"
30#include "ns3/spectrum-test.h"
31#include <ns3/lte-chunk-processor.h>
32#include <ns3/lte-helper.h>
66 sm = Create<SpectrumModel>(bands);
73 (*rxPsd1)[0] = 1.255943215755e-15;
78 (*rxPsd2)[1] = 7.204059965732e-16;
81 (*theoreticalSinr1)[0] = 3.72589167251055;
82 (*theoreticalSinr1)[1] = 3.72255684126076;
87 "sdBm = [-46 -inf] and [-inf -48]"),
93 "sdBm = [-46 -inf] and [-inf -48]"),
101 (*rxPsd3)[0] = 2.505936168136e-17;
106 (*rxPsd4)[1] = 3.610582885110e-17;
109 (*theoreticalSinr2)[0] = 0.0743413124381667;
110 (*theoreticalSinr2)[1] = 0.1865697965291756;
115 "sdBm = [-63 -inf] and [-inf -61]"),
121 "sdBm = [-63 -inf] and [-inf -61]"),
135 :
TestCase(
"SINR calculation in uplink data frame: " + name),
138 m_sm(sv1->GetSpectrumModel()),
157 uint16_t cellId = 100;
158 dlPhy->SetCellId(cellId);
159 ulPhy->SetCellId(cellId);
163 chunkProcessor->AddCallback(
164 MakeCallback(&LteSpectrumValueCatcher::ReportValue, &actualSinrCatcher));
165 ulPhy->AddDataSinrChunkProcessor(chunkProcessor);
176 const int numOfDataPbs = 2;
177 const int numOfIntfPbs = 4;
178 const int numOfPbs = numOfDataPbs + numOfIntfPbs;
181 const int numOfPkts = 10;
190 uint16_t pbCellId[numOfPbs];
196 for (
int dataPb = 0; dataPb < numOfDataPbs; dataPb++, pb++)
199 packetBursts[pb] = CreateObject<PacketBurst>();
200 pbCellId[pb] = cellId;
202 for (
int i = 0; i < numOfPkts; i++)
204 pkt[pb][i] = Create<Packet>(1000);
206 packetBursts[pb]->AddPacket(pkt[pb][i]);
209 for (
int intfPb = 0; intfPb < numOfIntfPbs; intfPb++, pb++)
212 packetBursts[pb] = CreateObject<PacketBurst>();
213 pbCellId[pb] = cellId * (pb + 1);
216 for (
int i = 0; i < numOfPkts; i++)
218 pkt[pb][i] = Create<Packet>(1000);
220 packetBursts[pb]->AddPacket(pkt[pb][i]);
230 (*noisePsd)[0] = 5.000000000000e-19;
231 (*noisePsd)[1] = 4.545454545455e-19;
233 (*i1)[0] = 5.000000000000e-18;
234 (*i2)[0] = 5.000000000000e-16;
235 (*i3)[0] = 1.581138830084e-16;
236 (*i4)[0] = 7.924465962306e-17;
237 (*i1)[1] = 1.437398936440e-18;
238 (*i2)[1] = 5.722388235428e-16;
239 (*i3)[1] = 7.204059965732e-17;
240 (*i4)[1] = 5.722388235428e-17;
253 ulPhy->SetNoisePowerSpectralDensity(noisePsd);
262 sp1->txPhy =
nullptr;
264 sp1->packetBurst = packetBursts[0];
265 sp1->cellId = pbCellId[0];
266 Simulator::Schedule(ts, &LteSpectrumPhy::StartRx, ulPhy, sp1);
270 sp2->txPhy =
nullptr;
272 sp2->packetBurst = packetBursts[1];
273 sp2->cellId = pbCellId[1];
274 Simulator::Schedule(ts, &LteSpectrumPhy::StartRx, ulPhy, sp2);
278 ip1->txPhy =
nullptr;
280 ip1->packetBurst = packetBursts[2];
281 ip1->cellId = pbCellId[2];
282 Simulator::Schedule(ti1, &LteSpectrumPhy::StartRx, ulPhy, ip1);
286 ip2->txPhy =
nullptr;
288 ip2->packetBurst = packetBursts[3];
289 ip2->cellId = pbCellId[3];
290 Simulator::Schedule(ti2, &LteSpectrumPhy::StartRx, ulPhy, ip2);
294 ip3->txPhy =
nullptr;
296 ip3->packetBurst = packetBursts[4];
297 ip3->cellId = pbCellId[4];
298 Simulator::Schedule(ti3, &LteSpectrumPhy::StartRx, ulPhy, ip3);
302 ip4->txPhy =
nullptr;
304 ip4->packetBurst = packetBursts[5];
305 ip4->cellId = pbCellId[5];
306 Simulator::Schedule(ti4, &LteSpectrumPhy::StartRx, ulPhy, ip4);
319 "Data Frame - Wrong SINR !");
321 Simulator::Destroy();
332 :
TestCase(
"SINR calculation in uplink srs frame: " + name),
335 m_sm(sv1->GetSpectrumModel()),
363 uint16_t cellId = 100;
364 dlPhy->SetCellId(cellId);
365 ulPhy->SetCellId(cellId);
369 ulPhy->AddCtrlSinrChunkProcessor(chunkProcessor);
381 int numOfDataSignals = 2;
382 int numOfIntfSignals = 4;
383 int numOfSignals = numOfDataSignals + numOfIntfSignals;
385 uint16_t pbCellId[numOfSignals];
391 for (
int dataPb = 0; dataPb < numOfDataSignals; dataPb++, pb++)
393 pbCellId[pb] = cellId;
395 for (
int intfPb = 0; intfPb < numOfIntfSignals; intfPb++, pb++)
397 pbCellId[pb] = cellId * (pb + 1);
406 (*noisePsd)[0] = 5.000000000000e-19;
407 (*noisePsd)[1] = 4.545454545455e-19;
409 (*i1)[0] = 5.000000000000e-18;
410 (*i2)[0] = 5.000000000000e-16;
411 (*i3)[0] = 1.581138830084e-16;
412 (*i4)[0] = 7.924465962306e-17;
413 (*i1)[1] = 1.437398936440e-18;
414 (*i2)[1] = 5.722388235428e-16;
415 (*i3)[1] = 7.204059965732e-17;
416 (*i4)[1] = 5.722388235428e-17;
429 ulPhy->SetNoisePowerSpectralDensity(noisePsd);
437 Create<LteSpectrumSignalParametersUlSrsFrame>();
439 sp1->txPhy =
nullptr;
441 sp1->cellId = pbCellId[0];
442 Simulator::Schedule(ts, &LteSpectrumPhy::StartRx, ulPhy, sp1);
445 Create<LteSpectrumSignalParametersUlSrsFrame>();
447 sp2->txPhy =
nullptr;
449 sp2->cellId = pbCellId[1];
450 Simulator::Schedule(ts, &LteSpectrumPhy::StartRx, ulPhy, sp2);
453 Create<LteSpectrumSignalParametersUlSrsFrame>();
455 ip1->txPhy =
nullptr;
457 ip1->cellId = pbCellId[2];
458 Simulator::Schedule(ti1, &LteSpectrumPhy::StartRx, ulPhy, ip1);
461 Create<LteSpectrumSignalParametersUlSrsFrame>();
463 ip2->txPhy =
nullptr;
465 ip2->cellId = pbCellId[3];
466 Simulator::Schedule(ti2, &LteSpectrumPhy::StartRx, ulPhy, ip2);
469 Create<LteSpectrumSignalParametersUlSrsFrame>();
471 ip3->txPhy =
nullptr;
473 ip3->cellId = pbCellId[4];
474 Simulator::Schedule(ti3, &LteSpectrumPhy::StartRx, ulPhy, ip3);
477 Create<LteSpectrumSignalParametersUlSrsFrame>();
479 ip4->txPhy =
nullptr;
481 ip4->cellId = pbCellId[5];
482 Simulator::Schedule(ti4, &LteSpectrumPhy::StartRx, ulPhy, ip4);
495 "Data Frame - Wrong SINR !");
497 Simulator::Destroy();
Test generation of SINR in the uplink.
Ptr< SpectrumValue > m_sv1
the spectrum value #1
Ptr< SpectrumValue > m_sv2
the spectrum value #2
void DoRun() override
Implementation to actually run this TestCase.
Ptr< const SpectrumModel > m_sm
the spectrum model
Ptr< SpectrumValue > m_expectedSinr
the expected SINR
~LteUplinkDataSinrTestCase() override
LteUplinkDataSinrTestCase(Ptr< SpectrumValue > sv1, Ptr< SpectrumValue > sv2, Ptr< SpectrumValue > sinr, std::string name)
Constructor.
Test 1.2 SINR calculation in uplink.
LteUplinkSinrTestSuite()
Test 1.2 SINR calculation in uplink.
In this test one signal will be of interest, i.e., the SRS of the first signal will have the same Cel...
void ReportSinr(const SpectrumValue &sinr)
Callback to be connected to an LteChunkProcessor to collect the reported SINR.
~LteUplinkSrsSinrTestCase() override
Ptr< SpectrumValue > m_actualSinr
the actual SINR
Ptr< const SpectrumModel > m_sm
the spectrum model
Ptr< SpectrumValue > m_expectedSinr
the expected SINR
void DoRun() override
Implementation to actually run this TestCase.
LteUplinkSrsSinrTestCase(Ptr< SpectrumValue > sv1, Ptr< SpectrumValue > sv2, Ptr< SpectrumValue > sinr, std::string name)
Constructor.
Ptr< SpectrumValue > m_sv2
the spectrum value #2
Ptr< SpectrumValue > m_sv1
the spectrum value #1
A sink to be plugged to the callback of LteChunkProcessor allowing to save and later retrieve the lat...
Ptr< SpectrumValue > GetValue()
Set of values corresponding to a given SpectrumModel.
Ptr< SpectrumValue > Copy() const
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(actual, expected, tol, msg)
Test if two SpectrumValue instances are equal within a given tolerance.
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
static LteUplinkSinrTestSuite lteUplinkSinrTestSuite
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...
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