26 #include "ns3/boolean.h"
28 #include "ns3/lte-helper.h"
29 #include "ns3/lte-phy-tag.h"
30 #include "ns3/lte-spectrum-signal-parameters.h"
31 #include "ns3/simulator.h"
32 #include "ns3/spectrum-test.h"
33 #include <ns3/lte-chunk-processor.h>
34 #include <ns3/lte-control-messages.h>
69 sm = Create<SpectrumModel>(bands);
76 (*rxPsd1)[0] = 1.255943215755e-15;
77 (*rxPsd1)[1] = 7.204059965732e-16;
80 (*theoreticalSinr1)[0] = 3.72589167251055;
81 (*theoreticalSinr1)[1] = 3.72255684126076;
93 (*rxPsd2)[0] = 2.505936168136e-17;
94 (*rxPsd2)[1] = 3.610582885110e-17;
97 (*theoreticalSinr2)[0] = 0.0743413124381667;
98 (*theoreticalSinr2)[1] = 0.1865697965291756;
119 :
TestCase(
"SINR calculation in downlink Data frame: " + name),
121 m_sm(sv->GetSpectrumModel()),
141 uint16_t cellId = 100;
142 dlPhy->SetCellId(cellId);
143 ulPhy->SetCellId(cellId);
147 chunkProcessor->AddCallback(
148 MakeCallback(&LteSpectrumValueCatcher::ReportValue, &actualSinrCatcher));
149 dlPhy->AddDataSinrChunkProcessor(chunkProcessor);
160 const int numOfPbs = 5;
163 const int numOfPkts = 10;
172 uint16_t pbCellId[numOfPbs];
177 for (
int pb = 0; pb < numOfPbs; pb++)
180 packetBursts[pb] = CreateObject<PacketBurst>();
181 pbCellId[pb] = cellId * (pb + 1);
184 for (
int i = 0; i < numOfPkts; i++)
186 pkt[pb][i] = Create<Packet>(1000);
188 packetBursts[pb]->AddPacket(pkt[pb][i]);
198 (*noisePsd)[0] = 5.000000000000e-19;
199 (*noisePsd)[1] = 4.545454545455e-19;
201 (*i1)[0] = 5.000000000000e-18;
202 (*i2)[0] = 5.000000000000e-16;
203 (*i3)[0] = 1.581138830084e-16;
204 (*i4)[0] = 7.924465962306e-17;
205 (*i1)[1] = 1.437398936440e-18;
206 (*i2)[1] = 5.722388235428e-16;
207 (*i3)[1] = 7.204059965732e-17;
208 (*i4)[1] = 5.722388235428e-17;
221 dlPhy->SetNoisePowerSpectralDensity(noisePsd);
230 sp1->txPhy =
nullptr;
232 sp1->packetBurst = packetBursts[0];
233 sp1->cellId = pbCellId[0];
234 Simulator::Schedule(ts, &LteSpectrumPhy::StartRx, dlPhy, sp1);
238 ip1->txPhy =
nullptr;
240 ip1->packetBurst = packetBursts[1];
241 ip1->cellId = pbCellId[1];
242 Simulator::Schedule(ti1, &LteSpectrumPhy::StartRx, dlPhy, ip1);
246 ip2->txPhy =
nullptr;
248 ip2->packetBurst = packetBursts[2];
249 ip2->cellId = pbCellId[2];
250 Simulator::Schedule(ti2, &LteSpectrumPhy::StartRx, dlPhy, ip2);
254 ip3->txPhy =
nullptr;
256 ip3->packetBurst = packetBursts[3];
257 ip3->cellId = pbCellId[3];
258 Simulator::Schedule(ti3, &LteSpectrumPhy::StartRx, dlPhy, ip3);
262 ip4->txPhy =
nullptr;
264 ip4->packetBurst = packetBursts[4];
265 ip4->cellId = pbCellId[4];
266 Simulator::Schedule(ti4, &LteSpectrumPhy::StartRx, dlPhy, ip4);
277 "Data Frame - Wrong SINR !");
279 Simulator::Destroy();
289 :
TestCase(
"SINR calculation in downlink Ctrl Frame: " + name),
291 m_sm(sv->GetSpectrumModel()),
294 NS_LOG_INFO(
"Creating LenaDownlinkCtrlSinrTestCase");
311 uint16_t cellId = 100;
312 dlPhy->SetCellId(cellId);
313 ulPhy->SetCellId(cellId);
317 chunkProcessor->AddCallback(
318 MakeCallback(&LteSpectrumValueCatcher::ReportValue, &actualSinrCatcher));
319 dlPhy->AddCtrlSinrChunkProcessor(chunkProcessor);
329 const int numOfUes = 5;
332 const int numOfCtrlMsgs = 10;
335 std::list<Ptr<LteControlMessage>> ctrlMsgList[numOfUes];
338 uint16_t pbCellId[numOfUes];
343 for (
int pb = 0; pb < numOfUes; pb++)
345 pbCellId[pb] = cellId * (pb + 1);
348 for (
int i = 0; i < numOfCtrlMsgs; i++)
353 ctrlMsgList[pb].emplace_back(msg);
363 (*noisePsd)[0] = 5.000000000000e-19;
364 (*noisePsd)[1] = 4.545454545455e-19;
366 (*i1)[0] = 5.000000000000e-18;
367 (*i2)[0] = 5.000000000000e-16;
368 (*i3)[0] = 1.581138830084e-16;
369 (*i4)[0] = 7.924465962306e-17;
370 (*i1)[1] = 1.437398936440e-18;
371 (*i2)[1] = 5.722388235428e-16;
372 (*i3)[1] = 7.204059965732e-17;
373 (*i4)[1] = 5.722388235428e-17;
386 dlPhy->SetNoisePowerSpectralDensity(noisePsd);
394 Create<LteSpectrumSignalParametersDlCtrlFrame>();
396 sp1->txPhy =
nullptr;
398 sp1->ctrlMsgList = ctrlMsgList[0];
399 sp1->cellId = pbCellId[0];
401 Simulator::Schedule(ts, &LteSpectrumPhy::StartRx, dlPhy, sp1);
404 Create<LteSpectrumSignalParametersDlCtrlFrame>();
406 ip1->txPhy =
nullptr;
408 ip1->ctrlMsgList = ctrlMsgList[1];
409 ip1->cellId = pbCellId[1];
411 Simulator::Schedule(ti1, &LteSpectrumPhy::StartRx, dlPhy, ip1);
414 Create<LteSpectrumSignalParametersDlCtrlFrame>();
416 ip2->txPhy =
nullptr;
418 ip2->ctrlMsgList = ctrlMsgList[2];
419 ip2->cellId = pbCellId[2];
421 Simulator::Schedule(ti2, &LteSpectrumPhy::StartRx, dlPhy, ip2);
424 Create<LteSpectrumSignalParametersDlCtrlFrame>();
426 ip3->txPhy =
nullptr;
428 ip3->ctrlMsgList = ctrlMsgList[3];
429 ip3->cellId = pbCellId[3];
431 Simulator::Schedule(ti3, &LteSpectrumPhy::StartRx, dlPhy, ip3);
434 Create<LteSpectrumSignalParametersDlCtrlFrame>();
436 ip4->txPhy =
nullptr;
438 ip4->ctrlMsgList = ctrlMsgList[4];
439 ip4->cellId = pbCellId[4];
441 Simulator::Schedule(ti4, &LteSpectrumPhy::StartRx, dlPhy, ip4);
452 "Data Frame - Wrong SINR !");
454 Simulator::Destroy();
Test compares if the generated SINR is equal to estimated SINR value.
Ptr< SpectrumValue > m_expectedSinr
the expected SINR
LteDownlinkCtrlSinrTestCase(Ptr< SpectrumValue > sv, Ptr< SpectrumValue > sinr, std::string name)
Constructor.
Ptr< const SpectrumModel > m_sm
the spectrum model
void DoRun() override
Implementation to actually run this TestCase.
~LteDownlinkCtrlSinrTestCase() override
Ptr< SpectrumValue > m_sv
the spectrum value
Test compares if the generated SINR is equal to estimated SINR value.
~LteDownlinkDataSinrTestCase() override
Ptr< const SpectrumModel > m_sm
the spectrum model
Ptr< SpectrumValue > m_expectedSinr
the expected SINR
LteDownlinkDataSinrTestCase(Ptr< SpectrumValue > sv, Ptr< SpectrumValue > sinr, std::string name)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
Ptr< SpectrumValue > m_sv
the spectrum value
Test 1.1 SINR calculation in downlink.
LteDownlinkSinrTestSuite()
Test 1.1 SINR calculation in downlink.
A sink to be plugged to the callback of LteChunkProcessor allowing to save and later retrieve the lat...
Ptr< SpectrumValue > GetValue()
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
void SetDefault(std::string name, const AttributeValue &value)
#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 LteDownlinkSinrTestSuite lteDownlinkSinrTestSuite
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.
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
See section 4.3.1 dlDciListElement.