5#include <ns3/nr-eesm-cc-t1.h>
6#include <ns3/nr-eesm-error-model.h>
7#include <ns3/nr-eesm-ir-t1.h>
8#include <ns3/nr-spectrum-value-helper.h>
10#include <ns3/spectrum-value.h>
31class TestHarqTestCase :
public TestCase
34 TestHarqTestCase(std::vector<std::vector<double>> rxSinrDb,
35 std::vector<double> refEffSinrPerRx,
38 const std::string& name)
41 m_refEffSinrPerRx(refEffSinrPerRx),
48 void DoRun()
override;
49 void ValidateHarqForTwoRx();
52 std::string harqType)
const;
53 std::vector<std::vector<double>> m_rxSinrDb;
55 std::vector<double> m_refEffSinrPerRx;
62TestHarqTestCase::GetTbDecodStats(std::vector<double> sinrRx,
64 std::string harqType)
const
66 uint8_t nRbsRx = sinrRx.size();
68 Ptr<const SpectrumModel> spectModelRx =
70 SpectrumValue sinrRxSpecVal(spectModelRx);
72 for (
size_t i = 0; i < sinrRx.size(); i++)
74 sinrRxSpecVal[i] = pow(10.0, sinrRx.at(i) / 10.0);
77 std::vector<int> rbMap;
79 for (uint8_t i = 0; i < sinrRx.size(); i++, rbIndex++)
81 rbMap.push_back(rbIndex);
84 Ptr<NrErrorModelOutput> output;
87 Ptr<NrEesmIrT1> errorModelIr = CreateObject<NrEesmIrT1>();
88 output = errorModelIr->GetTbDecodificationStats(sinrRxSpecVal,
94 else if (harqType ==
"CC")
96 Ptr<NrEesmCcT1> errorModelCc = CreateObject<NrEesmCcT1>();
97 output = errorModelCc->GetTbDecodificationStats(sinrRxSpecVal,
105 NS_FATAL_ERROR(
"Unknown HARQ type. Use IR or CC");
109 history.push_back(output);
114TestHarqTestCase::ValidateHarqForTwoRx()
116 std::vector<double> sinrRx1 = m_rxSinrDb.at(0);
117 std::vector<double> sinrRx2 = m_rxSinrDb.at(1);
121 history = GetTbDecodStats(sinrRx1, history,
"IR");
122 auto outputIr = history.at(0);
123 auto eesmOutputIr = DynamicCast<NrEesmErrorModelOutput>(outputIr);
124 double sinrEffIr = eesmOutputIr->m_sinrEff;
127 NS_TEST_ASSERT_MSG_EQ_TOL(sinrEffIr,
128 m_refEffSinrPerRx.at(0),
130 "Resulted effective SINR of IR for RX 1 should be equal to the test "
131 "value with tol +-0.001");
133 history = GetTbDecodStats(sinrRx2, history,
"IR");
134 outputIr = history.at(0);
135 eesmOutputIr = DynamicCast<NrEesmErrorModelOutput>(outputIr);
136 sinrEffIr = eesmOutputIr->m_sinrEff;
139 NS_TEST_ASSERT_MSG_EQ_TOL(sinrEffIr,
140 m_refEffSinrPerRx.at(1),
142 "Resulted effective SINR of IR for RX 2 should be equal to the test "
143 "value with tol +-0.001");
147 history = GetTbDecodStats(sinrRx1, history,
"CC");
148 auto outputCc = history.at(0);
149 auto eesmOutputCc = DynamicCast<NrEesmErrorModelOutput>(outputCc);
150 double sinrEffCc = eesmOutputCc->m_sinrEff;
153 NS_TEST_ASSERT_MSG_EQ_TOL(sinrEffCc,
154 m_refEffSinrPerRx.at(2),
156 "Resulted effective SINR of CC for RX 1 should be equal to the test "
157 "value with tol +-0.001");
159 history = GetTbDecodStats(sinrRx2, history,
"CC");
160 outputCc = history.at(0);
161 eesmOutputCc = DynamicCast<NrEesmErrorModelOutput>(outputCc);
162 sinrEffCc = eesmOutputCc->m_sinrEff;
165 NS_TEST_ASSERT_MSG_EQ_TOL(sinrEffCc,
166 m_refEffSinrPerRx.at(3),
168 "Resulted effective SINR of CC for RX 2 should be equal to the test "
169 "value with tol +-0.001");
173TestHarqTestCase::DoRun()
175 switch (m_rxSinrDb.size())
178 ValidateHarqForTwoRx();
181 NS_FATAL_ERROR(
"Unsupported number of RX given to test HARQ");
185class TestHarq :
public TestSuite
189 : TestSuite(
"nr-test-harq", Type::SYSTEM)
192 std::vector<std::vector<double>> rxSinrDb;
193 std::vector<double> sinrDbRx1 = {1.0, 3.5};
194 rxSinrDb.push_back(sinrDbRx1);
195 std::vector<double> sinrDbRx2 = {1.0, 1.5, 2.0, 2.5, 3.0, 3.5};
196 rxSinrDb.push_back(sinrDbRx2);
197 std::vector<double> refEffSinrPerRx;
199 refEffSinrPerRx.push_back(1.67919);
200 refEffSinrPerRx.push_back(1.67907);
202 refEffSinrPerRx.push_back(1.67919);
203 refEffSinrPerRx.push_back(3.3318);
205 uint16_t tbSize = 256;
206 AddTestCase(
new TestHarqTestCase(rxSinrDb,
210 "HARQ test with 2 receptions"),
std::vector< Ptr< NrErrorModelOutput > > NrErrorModelHistory
Vector of previous output.
static Ptr< const SpectrumModel > GetSpectrumModel(uint32_t numRbs, double centerFrequency, double subcarrierSpacing)
Creates or obtains from a global map a spectrum model with a given number of RBs, center frequency an...
static TestHarq testHarq
HARQ test.