23 #include "ns3/simulator.h"
27 #include "ns3/spectrum-test.h"
28 #include "ns3/boolean.h"
29 #include "ns3/lte-phy-tag.h"
31 #include "ns3/lte-spectrum-signal-parameters.h"
34 #include <ns3/lte-control-messages.h>
35 #include "ns3/lte-helper.h"
36 #include <ns3/lte-chunk-processor.h>
71 sm = Create<SpectrumModel> (bands);
77 (*rxPsd1)[0] = 1.255943215755e-15;
78 (*rxPsd1)[1] = 7.204059965732e-16;
81 (*theoreticalSinr1)[0] = 3.72589167251055;
82 (*theoreticalSinr1)[1] = 3.72255684126076;
91 (*rxPsd2)[0] = 2.505936168136e-17;
92 (*rxPsd2)[1] = 3.610582885110e-17;
95 (*theoreticalSinr2)[0] = 0.0743413124381667;
96 (*theoreticalSinr2)[1] = 0.1865697965291756;
112 :
TestCase (
"SINR calculation in downlink Data frame: " + name),
114 m_sm (sv->GetSpectrumModel ()),
115 m_expectedSinr (sinr)
135 uint16_t cellId = 100;
136 dlPhy->SetCellId (cellId);
137 ulPhy->SetCellId (cellId);
141 chunkProcessor->AddCallback (
MakeCallback (&LteSpectrumValueCatcher::ReportValue, &actualSinrCatcher));
142 dlPhy->AddDataSinrChunkProcessor (chunkProcessor);
153 const int numOfPbs = 5;
156 const int numOfPkts = 10;
165 uint16_t pbCellId[numOfPbs];
170 for (
int pb = 0 ; pb < numOfPbs ; pb++ )
173 packetBursts[pb] = CreateObject<PacketBurst> ();
174 pbCellId[pb] = cellId * (pb + 1);
177 for (
int i = 0 ; i < numOfPkts ; i++ )
179 pkt[pb][i] = Create<Packet> (1000);
181 packetBursts[pb]->AddPacket ( pkt[pb][i] );
192 (*noisePsd)[0] = 5.000000000000e-19;
193 (*noisePsd)[1] = 4.545454545455e-19;
195 (*i1)[0] = 5.000000000000e-18;
196 (*i2)[0] = 5.000000000000e-16;
197 (*i3)[0] = 1.581138830084e-16;
198 (*i4)[0] = 7.924465962306e-17;
199 (*i1)[1] = 1.437398936440e-18;
200 (*i2)[1] = 5.722388235428e-16;
201 (*i3)[1] = 7.204059965732e-17;
202 (*i4)[1] = 5.722388235428e-17;
215 dlPhy->SetNoisePowerSpectralDensity (noisePsd);
226 sp1->packetBurst = packetBursts[0];
227 sp1->cellId = pbCellId[0];
228 Simulator::Schedule (ts, &LteSpectrumPhy::StartRx, dlPhy, sp1);
235 ip1->packetBurst = packetBursts[1];
236 ip1->cellId = pbCellId[1];
237 Simulator::Schedule (ti1, &LteSpectrumPhy::StartRx, dlPhy, ip1);
243 ip2->packetBurst = packetBursts[2];
244 ip2->cellId = pbCellId[2];
245 Simulator::Schedule (ti2, &LteSpectrumPhy::StartRx, dlPhy, ip2);
251 ip3->packetBurst = packetBursts[3];
252 ip3->cellId = pbCellId[3];
253 Simulator::Schedule (ti3, &LteSpectrumPhy::StartRx, dlPhy, ip3);
259 ip4->packetBurst = packetBursts[4];
260 ip4->cellId = pbCellId[4];
261 Simulator::Schedule (ti4, &LteSpectrumPhy::StartRx, dlPhy, ip4);
263 Simulator::Stop (
Seconds (5.0));
271 Simulator::Destroy ();
281 :
TestCase (
"SINR calculation in downlink Ctrl Frame: " + name),
283 m_sm (sv->GetSpectrumModel ()),
284 m_expectedSinr (sinr)
286 NS_LOG_INFO (
"Creating LenaDownlinkCtrlSinrTestCase");
303 uint16_t cellId = 100;
304 dlPhy->SetCellId (cellId);
305 ulPhy->SetCellId (cellId);
309 chunkProcessor->AddCallback (
MakeCallback (&LteSpectrumValueCatcher::ReportValue, &actualSinrCatcher));
310 dlPhy->AddCtrlSinrChunkProcessor (chunkProcessor);
320 const int numOfUes = 5;
323 const int numOfCtrlMsgs = 10;
326 std::list<Ptr<LteControlMessage> > ctrlMsgList[numOfUes];
329 uint16_t pbCellId[numOfUes];
334 for (
int pb = 0 ; pb < numOfUes ; pb++ )
336 pbCellId[pb] = cellId * (pb + 1);
339 for (
int i = 0 ; i < numOfCtrlMsgs ; i++ )
344 ctrlMsgList[pb].push_back (msg);
355 (*noisePsd)[0] = 5.000000000000e-19;
356 (*noisePsd)[1] = 4.545454545455e-19;
358 (*i1)[0] = 5.000000000000e-18;
359 (*i2)[0] = 5.000000000000e-16;
360 (*i3)[0] = 1.581138830084e-16;
361 (*i4)[0] = 7.924465962306e-17;
362 (*i1)[1] = 1.437398936440e-18;
363 (*i2)[1] = 5.722388235428e-16;
364 (*i3)[1] = 7.204059965732e-17;
365 (*i4)[1] = 5.722388235428e-17;
378 dlPhy->SetNoisePowerSpectralDensity (noisePsd);
389 sp1->ctrlMsgList = ctrlMsgList[0];
390 sp1->cellId = pbCellId[0];
392 Simulator::Schedule (ts, &LteSpectrumPhy::StartRx, dlPhy, sp1);
399 ip1->ctrlMsgList = ctrlMsgList[1];
400 ip1->cellId = pbCellId[1];
402 Simulator::Schedule (ti1, &LteSpectrumPhy::StartRx, dlPhy, ip1);
408 ip2->ctrlMsgList = ctrlMsgList[2];
409 ip2->cellId = pbCellId[2];
411 Simulator::Schedule (ti2, &LteSpectrumPhy::StartRx, dlPhy, ip2);
417 ip3->ctrlMsgList = ctrlMsgList[3];
418 ip3->cellId = pbCellId[3];
420 Simulator::Schedule (ti3, &LteSpectrumPhy::StartRx, dlPhy, ip3);
426 ip4->ctrlMsgList = ctrlMsgList[4];
427 ip4->cellId = pbCellId[4];
429 Simulator::Schedule (ti4, &LteSpectrumPhy::StartRx, dlPhy, ip4);
431 Simulator::Stop (
Seconds (5.0));
439 Simulator::Destroy ();
Test compares if the generated SINR is equal to estimated SINR value.
Ptr< SpectrumValue > m_expectedSinr
the expected SINR
virtual void DoRun(void)
Implementation to actually run this TestCase.
LteDownlinkCtrlSinrTestCase(Ptr< SpectrumValue > sv, Ptr< SpectrumValue > sinr, std::string name)
Constructor.
Ptr< const SpectrumModel > m_sm
the spectrum model
Ptr< SpectrumValue > m_sv
the spectrum value
virtual ~LteDownlinkCtrlSinrTestCase()
Test compares if the generated SINR is equal to estimated SINR value.
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.
virtual ~LteDownlinkDataSinrTestCase()
virtual void DoRun(void)
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.
AttributeValue implementation for Boolean.
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.
#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.
static LteDownlinkSinrTestSuite lteDownlinkSinrTestSuite
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::vector< BandInfo > Bands
Container of BandInfo.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
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.