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]"),
139 :
TestCase(
"SINR calculation in uplink data frame: " + name),
142 m_sm(sv1->GetSpectrumModel()),
161 uint16_t cellId = 100;
162 dlPhy->SetCellId(cellId);
163 ulPhy->SetCellId(cellId);
167 chunkProcessor->AddCallback(
168 MakeCallback(&LteSpectrumValueCatcher::ReportValue, &actualSinrCatcher));
169 ulPhy->AddDataSinrChunkProcessor(chunkProcessor);
180 const int numOfDataPbs = 2;
181 const int numOfIntfPbs = 4;
182 const int numOfPbs = numOfDataPbs + numOfIntfPbs;
185 const int numOfPkts = 10;
194 uint16_t pbCellId[numOfPbs];
200 for (
int dataPb = 0; dataPb < numOfDataPbs; dataPb++, pb++)
203 packetBursts[pb] = CreateObject<PacketBurst>();
204 pbCellId[pb] = cellId;
206 for (
int i = 0; i < numOfPkts; i++)
208 pkt[pb][i] = Create<Packet>(1000);
210 packetBursts[pb]->AddPacket(pkt[pb][i]);
213 for (
int intfPb = 0; intfPb < numOfIntfPbs; intfPb++, pb++)
216 packetBursts[pb] = CreateObject<PacketBurst>();
217 pbCellId[pb] = cellId * (pb + 1);
220 for (
int i = 0; i < numOfPkts; i++)
222 pkt[pb][i] = Create<Packet>(1000);
224 packetBursts[pb]->AddPacket(pkt[pb][i]);
234 (*noisePsd)[0] = 5.000000000000e-19;
235 (*noisePsd)[1] = 4.545454545455e-19;
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;
257 ulPhy->SetNoisePowerSpectralDensity(noisePsd);
266 sp1->txPhy =
nullptr;
268 sp1->packetBurst = packetBursts[0];
269 sp1->cellId = pbCellId[0];
270 Simulator::Schedule(ts, &LteSpectrumPhy::StartRx, ulPhy, sp1);
274 sp2->txPhy =
nullptr;
276 sp2->packetBurst = packetBursts[1];
277 sp2->cellId = pbCellId[1];
278 Simulator::Schedule(ts, &LteSpectrumPhy::StartRx, ulPhy, sp2);
282 ip1->txPhy =
nullptr;
284 ip1->packetBurst = packetBursts[2];
285 ip1->cellId = pbCellId[2];
286 Simulator::Schedule(ti1, &LteSpectrumPhy::StartRx, ulPhy, ip1);
290 ip2->txPhy =
nullptr;
292 ip2->packetBurst = packetBursts[3];
293 ip2->cellId = pbCellId[3];
294 Simulator::Schedule(ti2, &LteSpectrumPhy::StartRx, ulPhy, ip2);
298 ip3->txPhy =
nullptr;
300 ip3->packetBurst = packetBursts[4];
301 ip3->cellId = pbCellId[4];
302 Simulator::Schedule(ti3, &LteSpectrumPhy::StartRx, ulPhy, ip3);
306 ip4->txPhy =
nullptr;
308 ip4->packetBurst = packetBursts[5];
309 ip4->cellId = pbCellId[5];
310 Simulator::Schedule(ti4, &LteSpectrumPhy::StartRx, ulPhy, ip4);
323 "Data Frame - Wrong SINR !");
325 Simulator::Destroy();
336 :
TestCase(
"SINR calculation in uplink srs frame: " + name),
339 m_sm(sv1->GetSpectrumModel()),
367 uint16_t cellId = 100;
368 dlPhy->SetCellId(cellId);
369 ulPhy->SetCellId(cellId);
373 ulPhy->AddCtrlSinrChunkProcessor(chunkProcessor);
385 int numOfDataSignals = 2;
386 int numOfIntfSignals = 4;
387 int numOfSignals = numOfDataSignals + numOfIntfSignals;
389 uint16_t pbCellId[numOfSignals];
395 for (
int dataPb = 0; dataPb < numOfDataSignals; dataPb++, pb++)
397 pbCellId[pb] = cellId;
399 for (
int intfPb = 0; intfPb < numOfIntfSignals; intfPb++, pb++)
401 pbCellId[pb] = cellId * (pb + 1);
410 (*noisePsd)[0] = 5.000000000000e-19;
411 (*noisePsd)[1] = 4.545454545455e-19;
413 (*i1)[0] = 5.000000000000e-18;
414 (*i2)[0] = 5.000000000000e-16;
415 (*i3)[0] = 1.581138830084e-16;
416 (*i4)[0] = 7.924465962306e-17;
417 (*i1)[1] = 1.437398936440e-18;
418 (*i2)[1] = 5.722388235428e-16;
419 (*i3)[1] = 7.204059965732e-17;
420 (*i4)[1] = 5.722388235428e-17;
433 ulPhy->SetNoisePowerSpectralDensity(noisePsd);
441 Create<LteSpectrumSignalParametersUlSrsFrame>();
443 sp1->txPhy =
nullptr;
445 sp1->cellId = pbCellId[0];
446 Simulator::Schedule(ts, &LteSpectrumPhy::StartRx, ulPhy, sp1);
449 Create<LteSpectrumSignalParametersUlSrsFrame>();
451 sp2->txPhy =
nullptr;
453 sp2->cellId = pbCellId[1];
454 Simulator::Schedule(ts, &LteSpectrumPhy::StartRx, ulPhy, sp2);
457 Create<LteSpectrumSignalParametersUlSrsFrame>();
459 ip1->txPhy =
nullptr;
461 ip1->cellId = pbCellId[2];
462 Simulator::Schedule(ti1, &LteSpectrumPhy::StartRx, ulPhy, ip1);
465 Create<LteSpectrumSignalParametersUlSrsFrame>();
467 ip2->txPhy =
nullptr;
469 ip2->cellId = pbCellId[3];
470 Simulator::Schedule(ti2, &LteSpectrumPhy::StartRx, ulPhy, ip2);
473 Create<LteSpectrumSignalParametersUlSrsFrame>();
475 ip3->txPhy =
nullptr;
477 ip3->cellId = pbCellId[4];
478 Simulator::Schedule(ti3, &LteSpectrumPhy::StartRx, ulPhy, ip3);
481 Create<LteSpectrumSignalParametersUlSrsFrame>();
483 ip4->txPhy =
nullptr;
485 ip4->cellId = pbCellId[5];
486 Simulator::Schedule(ti4, &LteSpectrumPhy::StartRx, ulPhy, ip4);
499 "Data Frame - Wrong SINR !");
501 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.
static LteUplinkSinrTestSuite lteUplinkSinrTestSuite
Static variable for test initialization.
#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.
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