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);
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);
253 sp1->
cellId = pbCellId[0];
254 Simulator::Schedule (ts, &LteSpectrumPhy::StartRx, ulPhy, sp1);
261 sp2->
cellId = pbCellId[1];
262 Simulator::Schedule (ts, &LteSpectrumPhy::StartRx, ulPhy, sp2);
270 ip1->
cellId = pbCellId[2];
271 Simulator::Schedule (ti1, &LteSpectrumPhy::StartRx, ulPhy, ip1);
278 ip2->
cellId = pbCellId[3];
279 Simulator::Schedule (ti2, &LteSpectrumPhy::StartRx, ulPhy, ip2);
286 ip3->
cellId = pbCellId[4];
287 Simulator::Schedule (ti3, &LteSpectrumPhy::StartRx, ulPhy, ip3);
294 ip4->
cellId = pbCellId[5];
295 Simulator::Schedule (ti4, &LteSpectrumPhy::StartRx, ulPhy, ip4);
297 Simulator::Stop (
Seconds (5.0));
301 NS_LOG_INFO (
"Data Frame - Calculated SINR: " << *(actualSinrCatcher.GetValue ()));
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 ();
virtual void DoRun(void)
Implementation to actually run this TestCase.
static LteUplinkSinrTestSuite lteUplinkSinrTestSuite
LteUplinkSrsSinrTestCase(Ptr< SpectrumValue > sv1, Ptr< SpectrumValue > sv2, Ptr< SpectrumValue > sinr, std::string name)
Constructor.
Simulation virtual time values and global simulation resolution.
Ptr< SpectrumValue > m_sv2
the spectrum value #2
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
Ptr< SpectrumValue > m_expectedSinr
the expected SINR
LteUplinkSinrTestSuite()
Test 1.2 SINR calculation in uplink.
Ptr< SpectrumValue > m_sv1
the spectrum value #1
#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.
void ReportSinr(const SpectrumValue &sinr)
Callback to be connected to an LteChunkProcessor to collect the reported SINR.
In this test one signal will be of interest, i.e., the SRS of the first signal will have the same Cel...
Ptr< const SpectrumModel > m_sm
the spectrum model
std::vector< BandInfo > Bands
Container of BandInfo.
LteUplinkDataSinrTestCase(Ptr< SpectrumValue > sv1, Ptr< SpectrumValue > sv2, Ptr< SpectrumValue > sinr, std::string name)
Constructor.
virtual void AddCallback(LteChunkProcessorCallback c)
Add callback to list.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Ptr< SpectrumValue > m_sv2
the spectrum value #2
double fc
center frequency
Test generation of SINR in the uplink.
Ptr< SpectrumPhy > txPhy
The SpectrumPhy instance that is making the transmission.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
A sink to be plugged to the callback of LteChunkProcessor allowing to save and later retrieve the lat...
Ptr< SpectrumValue > Copy() const
void AddPacket(Ptr< Packet > packet)
add a packet to the list of packet
Ptr< SpectrumValue > m_expectedSinr
the expected SINR
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double fl
lower limit of subband
Ptr< PacketBurst > packetBurst
The packet burst being transmitted with this signal.
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report if not.
Ptr< SpectrumValue > m_actualSinr
the actual SINR
#define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(actual, expected, tol, msg)
Test if two SpectrumValue instances are equal within a given tolerance.
Test 1.2 SINR calculation in uplink.
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
virtual ~LteUplinkSrsSinrTestCase()
Time Seconds(double value)
Construct a Time in the indicated unit.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~LteUplinkDataSinrTestCase()
Time duration
The duration of the packet transmission.
Ptr< SpectrumValue > m_sv1
the spectrum value #1
double fh
upper limit of subband
Ptr< const SpectrumModel > m_sm
the spectrum model
Set of values corresponding to a given SpectrumModel.
The building block of a SpectrumModel.