5G-LENA nr-v3.3-81-g75c7590d
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-test-l2sm-eesm.cc
Go to the documentation of this file.
1// Copyright (c) 2019 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#include <ns3/enum.h>
6#include <ns3/nr-eesm-cc-t1.h>
7#include <ns3/nr-eesm-cc-t2.h>
8#include <ns3/nr-eesm-error-model.h>
9#include <ns3/nr-eesm-ir-t1.h>
10#include <ns3/nr-eesm-ir-t2.h>
11#include <ns3/test.h>
12
23namespace ns3
24{
25
29class NrL2smEesmTestCase : public TestCase
30{
31 public:
32 NrL2smEesmTestCase(const std::string& name)
33 : TestCase(name)
34 {
35 }
36
40 ~NrL2smEesmTestCase() override
41 {
42 }
43
44 private:
45 void DoRun() override;
46
47 void TestMappingSinrBler1(const Ptr<NrEesmErrorModel>& em);
48 void TestMappingSinrBler2(const Ptr<NrEesmErrorModel>& em);
49 void TestBgType1(const Ptr<NrEesmErrorModel>& em);
50 void TestBgType2(const Ptr<NrEesmErrorModel>& em);
51
52 void TestEesmCcTable1();
53 void TestEesmCcTable2();
54 void TestEesmIrTable1();
55 void TestEesmIrTable2();
56};
57
58void
59NrL2smEesmTestCase::TestBgType1(const Ptr<NrEesmErrorModel>& em)
60{
61 NS_TEST_ASSERT_MSG_EQ(em->GetBaseGraphType(3200, 18),
62 NrEesmErrorModel::SECOND,
63 "TestBgType1-a: The calculated value differs from the 3GPP base graph "
64 "selection algorithm.");
65 NS_TEST_ASSERT_MSG_EQ(em->GetBaseGraphType(3900, 18),
66 NrEesmErrorModel::FIRST,
67 "TestBgType1-b: The calculated value differs from the 3GPP base graph "
68 "selection algorithm.");
69 NS_TEST_ASSERT_MSG_EQ(em->GetBaseGraphType(200, 18),
70 NrEesmErrorModel::SECOND,
71 "TestBgType1-c: The calculated value differs from the 3GPP base graph "
72 "selection algorithm.");
73 NS_TEST_ASSERT_MSG_EQ(em->GetBaseGraphType(4000, 0),
74 NrEesmErrorModel::SECOND,
75 "TestBgType1-d: The calculated value differs from the 3GPP base graph "
76 "selection algorithm.");
77 NS_TEST_ASSERT_MSG_EQ(em->GetBaseGraphType(3200, 28),
78 NrEesmErrorModel::FIRST,
79 "TestBgType1-e: The calculated value differs from the 3GPP base graph "
80 "selection algorithm.");
81 NS_TEST_ASSERT_MSG_EQ(em->GetBaseGraphType(3200, 2),
82 NrEesmErrorModel::SECOND,
83 "TestBgType2-f: The calculated value differs from the 3GPP base graph "
84 "selection algorithm.");
85 NS_TEST_ASSERT_MSG_EQ(em->GetBaseGraphType(3200, 16),
86 NrEesmErrorModel::SECOND,
87 "TestBgType2-g: The calculated value differs from the 3GPP base graph "
88 "selection algorithm.");
89 NS_TEST_ASSERT_MSG_EQ(em->GetBaseGraphType(3900, 14),
90 NrEesmErrorModel::FIRST,
91 "TestBgType2-h: The calculated value differs from the 3GPP base graph "
92 "selection algorithm.");
93}
94
95void
96NrL2smEesmTestCase::TestBgType2(const Ptr<NrEesmErrorModel>& em)
97{
98 NS_TEST_ASSERT_MSG_EQ(em->GetBaseGraphType(3200, 18),
99 NrEesmErrorModel::FIRST,
100 "TestBgType2-a: The calculated value differs from the 3GPP base graph "
101 "selection algorithm.");
102 NS_TEST_ASSERT_MSG_EQ(em->GetBaseGraphType(3900, 18),
103 NrEesmErrorModel::FIRST,
104 "TestBgType2-b: The calculated value differs from the 3GPP base graph "
105 "selection algorithm.");
106 NS_TEST_ASSERT_MSG_EQ(em->GetBaseGraphType(200, 18),
107 NrEesmErrorModel::SECOND,
108 "TestBgType2-c: The calculated value differs from the 3GPP base graph "
109 "selection algorithm.");
110 NS_TEST_ASSERT_MSG_EQ(em->GetBaseGraphType(4000, 0),
111 NrEesmErrorModel::SECOND,
112 "TestBgType2-d: The calculated value differs from the 3GPP base graph "
113 "selection algorithm.");
114 NS_TEST_ASSERT_MSG_EQ(em->GetBaseGraphType(3200, 27),
115 NrEesmErrorModel::FIRST,
116 "TestBgType2-e: The calculated value differs from the 3GPP base graph "
117 "selection algorithm.");
118 NS_TEST_ASSERT_MSG_EQ(em->GetBaseGraphType(3200, 2),
119 NrEesmErrorModel::SECOND,
120 "TestBgType2-f: The calculated value differs from the 3GPP base graph "
121 "selection algorithm.");
122 NS_TEST_ASSERT_MSG_EQ(em->GetBaseGraphType(3200, 16),
123 NrEesmErrorModel::FIRST,
124 "TestBgType2-g: The calculated value differs from the 3GPP base graph "
125 "selection algorithm.");
126 NS_TEST_ASSERT_MSG_EQ(em->GetBaseGraphType(3900, 14),
127 NrEesmErrorModel::FIRST,
128 "TestBgType2-h: The calculated value differs from the 3GPP base graph "
129 "selection algorithm.");
130}
131
132typedef std::tuple<double, uint8_t, uint32_t, double> MappingTable;
133
134static std::vector<MappingTable> resultTable1 = {
135 // sinr (lineal), mcs, cbsize, result
136
137 // MCS 18, all CBS in continuation use BGtype2
138 // CBS=3200, in table corresponds to 3104
139 MappingTable{19.95, 18, 3200, 0.023}, // sinr 13 db
140 MappingTable{15.849, 18, 3200, 0.7567365}, // sinr 12 db
141 MappingTable{10, 18, 3200, 1.00}, // sinr 10 db
142 // CBS=3500, in table corresponds to 3496
143 MappingTable{19.95, 18, 3500, 0.0735}, // sinr 13 db
144 MappingTable{15.849, 18, 3500, 0.7908951}, // sinr 12 db
145 MappingTable{10, 18, 3500, 1.00}, // sinr 10 db
146
147 // MCS 14, all CBS in continuation use BGtype1
148 // CBS=3900, in table corresponds to 3840
149 MappingTable{8.9125, 14, 3900, 0.3225703}, // sinr 9.5db
150 MappingTable{7.9433, 14, 3900, 0.8827055}, // sinr 9 db
151 MappingTable{6.3095, 14, 3900, 1.00}, // sinr 8 db
152 // CBS=6300, in table corresponds to 6272
153 MappingTable{8.9125, 14, 6300, 0.0237}, // sinr 9.5db
154 MappingTable{7.9433, 14, 6300, 0.9990385}, // sinr 9 db
155 MappingTable{6.3095, 14, 6300, 1.00} // sinr 8 db
156
157};
158static std::vector<MappingTable> resultTable2 = {
159 // sinr (lineal), mcs, cbsize, result
160
161 // MCS 11, all CBS in continuation use BGtype2
162 // CBS=3200, in table corresponds to 3104
163 MappingTable{19.95, 11, 3200, 0.023}, // sinr 13 db
164 MappingTable{15.849, 11, 3200, 0.7567365}, // sinr 12 db
165 MappingTable{10, 11, 3200, 1.00}, // sinr 10 db
166 // CBS=3500, in table corresponds to 3496
167 MappingTable{19.95, 11, 3500, 0.0735}, // sinr 13 db
168 MappingTable{15.849, 11, 3500, 0.7908951}, // sinr 12 db
169 MappingTable{10, 11, 3500, 1.00}, // sinr 10 db
170
171 // MCS 8, all CBS in continuation use BGtype1
172 // CBS=3900, in table corresponds to 3840
173 MappingTable{8.9125, 8, 3900, 0.3225703}, // sinr 9.5db
174 MappingTable{7.9433, 8, 3900, 0.8827055}, // sinr 9 db
175 MappingTable{6.3095, 8, 3900, 1.00}, // sinr 8 db
176 // CBS=6300, in table corresponds to 6272
177 MappingTable{8.9125, 8, 6300, 0.0237}, // sinr 9.5db
178 MappingTable{7.9433, 8, 6300, 0.9990385}, // sinr 9 db
179 MappingTable{6.3095, 8, 6300, 1.00} // sinr 8 db
180
181};
182
183void
184NrL2smEesmTestCase::TestMappingSinrBler1(const Ptr<NrEesmErrorModel>& em)
185{
186 for (auto result : resultTable1)
187 {
188 NS_TEST_ASSERT_MSG_EQ(
189 em->MappingSinrBler(std::get<0>(result), std::get<1>(result), std::get<2>(result)),
190 std::get<3>(result),
191 "TestMappingSinrBler1: The calculated value differs from "
192 " the SINR-BLER table. SINR="
193 << std::get<0>(result) << " MCS " << static_cast<uint32_t>(std::get<1>(result))
194 << " CBS " << std::get<2>(result));
195 }
196}
197
198void
199NrL2smEesmTestCase::TestMappingSinrBler2(const Ptr<NrEesmErrorModel>& em)
200{
201 for (auto result : resultTable2)
202 {
203 NS_TEST_ASSERT_MSG_EQ(
204 em->MappingSinrBler(std::get<0>(result), std::get<1>(result), std::get<2>(result)),
205 std::get<3>(result),
206 "TestMappingSinrBler2: The calculated value differs from "
207 " the SINR-BLER table. SINR="
208 << std::get<0>(result) << " MCS " << static_cast<uint32_t>(std::get<1>(result))
209 << " CBS " << std::get<2>(result));
210 }
211}
212
213void
214NrL2smEesmTestCase::TestEesmCcTable1()
215{
216 // Create an object of type NrEesmCcT1 and cast it to NrEesmErrorModel
217 Ptr<NrEesmErrorModel> em = CreateObject<NrEesmCcT1>();
218
219 // Check that the object was created
220 bool ret = em == nullptr;
221 NS_TEST_ASSERT_MSG_EQ(ret, false, "Could not create NrEesmCcT1 object");
222
223 // Test here the functions:
224 TestBgType1(em);
225 TestMappingSinrBler1(em);
226}
227
228void
229NrL2smEesmTestCase::TestEesmCcTable2()
230{
231 // Create an object of type NrEesmCcT2 and cast it to NrEesmErrorModel
232 Ptr<NrEesmErrorModel> em = CreateObject<NrEesmCcT2>();
233
234 // Check that the object was created
235 bool ret = em == nullptr;
236 NS_TEST_ASSERT_MSG_EQ(ret, false, "Could not create NrEesmCcT2 object");
237
238 // Test here the functions:
239 TestBgType2(em);
240 TestMappingSinrBler2(em);
241}
242
243void
244NrL2smEesmTestCase::TestEesmIrTable1()
245{
246 // Create an object of type NrEesmIrT1 and cast it to NrEesmErrorModel
247 Ptr<NrEesmErrorModel> em = CreateObject<NrEesmIrT1>();
248
249 // Check that the object was created
250 bool ret = em == nullptr;
251 NS_TEST_ASSERT_MSG_EQ(ret, false, "Could not create NrEesmIrT1 object");
252
253 // Test here the functions:
254 TestBgType1(em);
255 TestMappingSinrBler1(em);
256}
257
258void
259NrL2smEesmTestCase::TestEesmIrTable2()
260{
261 // Create an object of type NrEesmIrT2 and cast it to NrEesmErrorModel
262 Ptr<NrEesmErrorModel> em = CreateObject<NrEesmIrT2>();
263
264 // Check that the object was created
265 bool ret = em == nullptr;
266 NS_TEST_ASSERT_MSG_EQ(ret, false, "Could not create NrEesmIrT2 object");
267
268 // Test here the functions:
269 TestBgType2(em);
270 TestMappingSinrBler2(em);
271}
272
273void
274NrL2smEesmTestCase::DoRun()
275{
276 TestEesmCcTable1();
277 TestEesmCcTable2();
278 TestEesmIrTable1();
279 TestEesmIrTable2();
280}
281
282class NrTestL2smEesm : public TestSuite
283{
284 public:
285 NrTestL2smEesm()
286 : TestSuite("nr-test-l2sm-eesm", Type::UNIT)
287 {
288 AddTestCase(new NrL2smEesmTestCase("First test"), Duration::QUICK);
289 }
290};
291
292static NrTestL2smEesm NrTestL2smEesmTestSuite;
293
294} // namespace ns3
static NrTestL2smEesm NrTestL2smEesmTestSuite
Nr test suite.