23 #include "ns3/simulator.h"
27 #include "ns3/spectrum-test.h"
29 #include "ns3/lte-phy-tag.h"
31 #include "ns3/lte-spectrum-signal-parameters.h"
35 #include <ns3/lte-helper.h>
36 #include <ns3/lte-chunk-processor.h>
70 sm = Create<SpectrumModel> (bands);
76 (*rxPsd1)[0] = 1.255943215755e-15;
81 (*rxPsd2)[1] = 7.204059965732e-16;
84 (*theoreticalSinr1)[0] = 3.72589167251055;
85 (*theoreticalSinr1)[1] = 3.72255684126076;
95 (*rxPsd3)[0] = 2.505936168136e-17;
100 (*rxPsd4)[1] = 3.610582885110e-17;
103 (*theoreticalSinr2)[0] = 0.0743413124381667;
104 (*theoreticalSinr2)[1] = 0.1865697965291756;
120 :
TestCase (
"SINR calculation in uplink data frame: " + name),
123 m_sm (sv1->GetSpectrumModel ()),
124 m_expectedSinr (sinr)
126 NS_LOG_INFO (
"Creating LteUplinkDataSinrTestCase");
143 uint16_t cellId = 100;
144 dlPhy->SetCellId (cellId);
145 ulPhy->SetCellId (cellId);
149 chunkProcessor->AddCallback (
MakeCallback (&LteSpectrumValueCatcher::ReportValue, &actualSinrCatcher));
150 ulPhy->AddDataSinrChunkProcessor (chunkProcessor);
161 const int numOfDataPbs = 2;
162 const int numOfIntfPbs = 4;
163 const int numOfPbs = numOfDataPbs + numOfIntfPbs;
166 const int numOfPkts = 10;
175 uint16_t pbCellId[numOfPbs];
183 for (
int dataPb = 0 ; dataPb < numOfDataPbs ; dataPb++, pb++ )
186 packetBursts[pb] = CreateObject<PacketBurst> ();
187 pbCellId[pb] = cellId;
189 for (
int i = 0 ; i < numOfPkts ; i++ )
191 pkt[pb][i] = Create<Packet> (1000);
193 packetBursts[pb]->AddPacket ( pkt[pb][i] );
196 for (
int intfPb = 0 ; intfPb < numOfIntfPbs ; intfPb++, pb++ )
199 packetBursts[pb] = CreateObject<PacketBurst> ();
200 pbCellId[pb] = cellId * (pb + 1);
203 for (
int i = 0 ; i < numOfPkts ; i++ )
205 pkt[pb][i] = Create<Packet> (1000);
207 packetBursts[pb]->AddPacket ( pkt[pb][i] );
218 (*noisePsd)[0] = 5.000000000000e-19;
219 (*noisePsd)[1] = 4.545454545455e-19;
221 (*i1)[0] = 5.000000000000e-18;
222 (*i2)[0] = 5.000000000000e-16;
223 (*i3)[0] = 1.581138830084e-16;
224 (*i4)[0] = 7.924465962306e-17;
225 (*i1)[1] = 1.437398936440e-18;
226 (*i2)[1] = 5.722388235428e-16;
227 (*i3)[1] = 7.204059965732e-17;
228 (*i4)[1] = 5.722388235428e-17;
241 ulPhy->SetNoisePowerSpectralDensity (noisePsd);
252 sp1->packetBurst = packetBursts[0];
253 sp1->cellId = pbCellId[0];
254 Simulator::Schedule (ts, &LteSpectrumPhy::StartRx, ulPhy, sp1);
260 sp2->packetBurst = packetBursts[1];
261 sp2->cellId = pbCellId[1];
262 Simulator::Schedule (ts, &LteSpectrumPhy::StartRx, ulPhy, sp2);
269 ip1->packetBurst = packetBursts[2];
270 ip1->cellId = pbCellId[2];
271 Simulator::Schedule (ti1, &LteSpectrumPhy::StartRx, ulPhy, ip1);
277 ip2->packetBurst = packetBursts[3];
278 ip2->cellId = pbCellId[3];
279 Simulator::Schedule (ti2, &LteSpectrumPhy::StartRx, ulPhy, ip2);
285 ip3->packetBurst = packetBursts[4];
286 ip3->cellId = pbCellId[4];
287 Simulator::Schedule (ti3, &LteSpectrumPhy::StartRx, ulPhy, ip3);
293 ip4->packetBurst = packetBursts[5];
294 ip4->cellId = pbCellId[5];
295 Simulator::Schedule (ti4, &LteSpectrumPhy::StartRx, ulPhy, ip4);
297 Simulator::Stop (
Seconds (5.0));
307 Simulator::Destroy ();
317 :
TestCase (
"SINR calculation in uplink srs frame: " + name),
320 m_sm (sv1->GetSpectrumModel ()),
321 m_expectedSinr (sinr)
348 uint16_t cellId = 100;
349 dlPhy->SetCellId (cellId);
350 ulPhy->SetCellId (cellId);
354 ulPhy->AddCtrlSinrChunkProcessor (chunkProcessor);
366 int numOfDataSignals = 2;
367 int numOfIntfSignals = 4;
368 int numOfSignals = numOfDataSignals + numOfIntfSignals;
370 uint16_t pbCellId[numOfSignals];
378 for (
int dataPb = 0 ; dataPb < numOfDataSignals ; dataPb++, pb++ )
380 pbCellId[pb] = cellId;
383 for (
int intfPb = 0 ; intfPb < numOfIntfSignals ; intfPb++, pb++ )
386 pbCellId[pb] = cellId * (pb + 1);
397 (*noisePsd)[0] = 5.000000000000e-19;
398 (*noisePsd)[1] = 4.545454545455e-19;
400 (*i1)[0] = 5.000000000000e-18;
401 (*i2)[0] = 5.000000000000e-16;
402 (*i3)[0] = 1.581138830084e-16;
403 (*i4)[0] = 7.924465962306e-17;
404 (*i1)[1] = 1.437398936440e-18;
405 (*i2)[1] = 5.722388235428e-16;
406 (*i3)[1] = 7.204059965732e-17;
407 (*i4)[1] = 5.722388235428e-17;
420 ulPhy->SetNoisePowerSpectralDensity (noisePsd);
431 sp1->cellId = pbCellId[0];
432 Simulator::Schedule (ts, &LteSpectrumPhy::StartRx, ulPhy, sp1);
438 sp2->cellId = pbCellId[1];
439 Simulator::Schedule (ts, &LteSpectrumPhy::StartRx, ulPhy, sp2);
446 ip1->cellId = pbCellId[2];
447 Simulator::Schedule (ti1, &LteSpectrumPhy::StartRx, ulPhy, ip1);
453 ip2->cellId = pbCellId[3];
454 Simulator::Schedule (ti2, &LteSpectrumPhy::StartRx, ulPhy, ip2);
460 ip3->cellId = pbCellId[4];
461 Simulator::Schedule (ti3, &LteSpectrumPhy::StartRx, ulPhy, ip3);
467 ip4->cellId = pbCellId[5];
468 Simulator::Schedule (ti4, &LteSpectrumPhy::StartRx, ulPhy, ip4);
470 Simulator::Stop (
Seconds (5.0));
480 Simulator::Destroy ();
Test generation of SINR in the uplink.
Ptr< SpectrumValue > m_sv1
the spectrum value #1
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~LteUplinkDataSinrTestCase()
Ptr< SpectrumValue > m_sv2
the spectrum value #2
Ptr< const SpectrumModel > m_sm
the spectrum model
Ptr< SpectrumValue > m_expectedSinr
the expected SINR
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.
Ptr< SpectrumValue > m_actualSinr
the actual SINR
virtual ~LteUplinkSrsSinrTestCase()
Ptr< const SpectrumModel > m_sm
the spectrum model
Ptr< SpectrumValue > m_expectedSinr
the expected SINR
LteUplinkSrsSinrTestCase(Ptr< SpectrumValue > sv1, Ptr< SpectrumValue > sv2, Ptr< SpectrumValue > sinr, std::string name)
Constructor.
Ptr< SpectrumValue > m_sv2
the spectrum value #2
virtual void DoRun(void)
Implementation to actually run this TestCase.
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.
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