23 #include "ns3/simulator.h"
27 #include "ns3/spectrum-test.h"
29 #include "ns3/lte-phy-tag.h"
32 #include "ns3/lte-spectrum-signal-parameters.h"
36 #include <ns3/lte-helper.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 ()),
126 NS_LOG_INFO (
"Creating LteUplinkDataSinrTestCase");
142 uint16_t cellId = 100;
143 dlPhy->SetCellId (cellId);
144 ulPhy->SetCellId (cellId);
147 ulPhy->AddDataSinrChunkProcessor (chunkProcessor);
158 const int numOfDataPbs = 2;
159 const int numOfIntfPbs = 4;
160 const int numOfPbs = numOfDataPbs + numOfIntfPbs;
163 const int numOfPkts = 10;
172 uint16_t pbCellId[numOfPbs];
180 for (
int dataPb = 0 ; dataPb < numOfDataPbs ; dataPb++, pb++ )
183 packetBursts[pb] = CreateObject<PacketBurst> ();
184 pbCellId[pb] = cellId;
186 for (
int i = 0 ; i < numOfPkts ; i++ )
188 pkt[pb][i] = Create<Packet> (1000);
190 packetBursts[pb]->
AddPacket ( pkt[pb][i] );
193 for (
int intfPb = 0 ; intfPb < numOfIntfPbs ; intfPb++, pb++ )
196 packetBursts[pb] = CreateObject<PacketBurst> ();
197 pbCellId[pb] = cellId * (pb + 1);
200 for (
int i = 0 ; i < numOfPkts ; i++ )
202 pkt[pb][i] = Create<Packet> (1000);
204 packetBursts[pb]->
AddPacket ( pkt[pb][i] );
215 (*noisePsd)[0] = 5.000000000000e-19;
216 (*noisePsd)[1] = 4.545454545455e-19;
218 (*i1)[0] = 5.000000000000e-18;
219 (*i2)[0] = 5.000000000000e-16;
220 (*i3)[0] = 1.581138830084e-16;
221 (*i4)[0] = 7.924465962306e-17;
222 (*i1)[1] = 1.437398936440e-18;
223 (*i2)[1] = 5.722388235428e-16;
224 (*i3)[1] = 7.204059965732e-17;
225 (*i4)[1] = 5.722388235428e-17;
238 ulPhy->SetNoisePowerSpectralDensity (noisePsd);
250 sp1->
cellId = pbCellId[0];
251 Simulator::Schedule (ts, &LteSpectrumPhy::StartRx, ulPhy, sp1);
258 sp2->
cellId = pbCellId[1];
259 Simulator::Schedule (ts, &LteSpectrumPhy::StartRx, ulPhy, sp2);
267 ip1->
cellId = pbCellId[2];
268 Simulator::Schedule (ti1, &LteSpectrumPhy::StartRx, ulPhy, ip1);
275 ip2->
cellId = pbCellId[3];
276 Simulator::Schedule (ti2, &LteSpectrumPhy::StartRx, ulPhy, ip2);
283 ip3->
cellId = pbCellId[4];
284 Simulator::Schedule (ti3, &LteSpectrumPhy::StartRx, ulPhy, ip3);
291 ip4->
cellId = pbCellId[5];
292 Simulator::Schedule (ti4, &LteSpectrumPhy::StartRx, ulPhy, ip4);
294 Simulator::Stop (
Seconds (5.0));
304 NS_LOG_INFO (
"Data Frame - Calculated SINR: " << *calculatedSinr);
308 Simulator::Destroy ();
318 :
TestCase (
"SINR calculation in uplink srs frame: " + name),
321 m_sm (sv1->GetSpectrumModel ()),
343 uint16_t cellId = 100;
344 dlPhy->SetCellId (cellId);
345 ulPhy->SetCellId (cellId);
348 ulPhy->AddCtrlSinrChunkProcessor (chunkProcessor);
360 int numOfDataSignals = 2;
361 int numOfIntfSignals = 4;
362 int numOfSignals = numOfDataSignals + numOfIntfSignals;
364 uint16_t pbCellId[numOfSignals];
372 for (
int dataPb = 0 ; dataPb < numOfDataSignals ; dataPb++, pb++ )
374 pbCellId[pb] = cellId;
377 for (
int intfPb = 0 ; intfPb < numOfIntfSignals ; intfPb++, pb++ )
380 pbCellId[pb] = cellId * (pb + 1);
391 (*noisePsd)[0] = 5.000000000000e-19;
392 (*noisePsd)[1] = 4.545454545455e-19;
394 (*i1)[0] = 5.000000000000e-18;
395 (*i2)[0] = 5.000000000000e-16;
396 (*i3)[0] = 1.581138830084e-16;
397 (*i4)[0] = 7.924465962306e-17;
398 (*i1)[1] = 1.437398936440e-18;
399 (*i2)[1] = 5.722388235428e-16;
400 (*i3)[1] = 7.204059965732e-17;
401 (*i4)[1] = 5.722388235428e-17;
414 ulPhy->SetNoisePowerSpectralDensity (noisePsd);
425 sp1->
cellId = pbCellId[0];
426 Simulator::Schedule (ts, &LteSpectrumPhy::StartRx, ulPhy, sp1);
432 sp2->
cellId = pbCellId[1];
433 Simulator::Schedule (ts, &LteSpectrumPhy::StartRx, ulPhy, sp2);
440 ip1->
cellId = pbCellId[2];
441 Simulator::Schedule (ti1, &LteSpectrumPhy::StartRx, ulPhy, ip1);
447 ip2->
cellId = pbCellId[3];
448 Simulator::Schedule (ti2, &LteSpectrumPhy::StartRx, ulPhy, ip2);
454 ip3->
cellId = pbCellId[4];
455 Simulator::Schedule (ti3, &LteSpectrumPhy::StartRx, ulPhy, ip3);
461 ip4->
cellId = pbCellId[5];
462 Simulator::Schedule (ti4, &LteSpectrumPhy::StartRx, ulPhy, ip4);
464 Simulator::Stop (
Seconds (5.0));
474 NS_LOG_INFO (
"SRS Frame - Calculated SINR: " << *calculatedSinr);
478 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)
TestCase Srs.
Simulation virtual time values and global simulation resolution.
Ptr< SpectrumValue > m_sinr
Ptr< SpectrumValue > m_sv2
LteUplinkSinrTestSuite()
Test 1.2 SINR calculation in uplink.
Ptr< SpectrumValue > m_sv1
#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.
Ptr< const SpectrumModel > m_sm
std::vector< BandInfo > Bands
LteUplinkDataSinrTestCase(Ptr< SpectrumValue > sv1, Ptr< SpectrumValue > sv2, Ptr< SpectrumValue > sinr, std::string name)
TestCase Data.
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Ptr< SpectrumValue > m_sv2
double fc
center frequency
Ptr< SpectrumValue > GetSinr()
Ptr< SpectrumPhy > txPhy
The SpectrumPhy instance that is making the transmission.
void AddPacket(Ptr< Packet > packet)
add a packet to the list of packet
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_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
double fh
upper limit of subband
Ptr< const SpectrumModel > m_sm
The building block of a SpectrumModel.
Ptr< SpectrumValue > m_sinr