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