5G-LENA nr-v3.0-32-g83aee33
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-lte-cc-bwp-configuration.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/nr-module.h"
8#include <ns3/cc-bwp-helper.h>
9#include <ns3/object-factory.h>
10#include <ns3/test.h>
11
12#include <memory>
13
25namespace ns3
26{
27
28class CcBwpTestCase : public TestCase
29{
30 public:
31 enum OperationMode
32 {
33 UNCONF = 0,
34 TDD = 1,
35 FDD = 2
36 };
37
42 CcBwpTestCase(const std::string& name)
43 : TestCase(name)
44 {
45 }
46
47 private:
48 void DoRun() override;
49
61 void TestBandConfiguration(double centralFrequency,
62 uint32_t bandwidth,
63 uint8_t numBandCcs,
64 OperationMode mode);
65
75 void TestMultiBandConfiguration(
76 const std::vector<std::reference_wrapper<OperationBandInfo>>& operationBands);
77
85 void TestCcBwpNumbers(
86 std::vector<std::reference_wrapper<CcBwpCreator::SimpleOperationBandConf>>&
87 operationBandConfigs);
88
89 void TestUeBwps(double centralFrequency,
90 uint32_t bandwidth,
91 uint8_t numerology,
92 uint8_t numCcs,
93 OperationMode mode,
94 std::vector<uint8_t> activeBwp);
95
105 bool ValidateCaBwpConfiguration(
106 const std::vector<std::reference_wrapper<OperationBandInfo>>& operationBands);
107
116 bool ValidateOperationBand(const OperationBandInfo& band);
117
126 bool CheckBwpsInCc(const ComponentCarrierInfoPtr& cc);
127};
128
132class NrLteCcBwpTestSuite : public TestSuite
133{
134 public:
135 NrLteCcBwpTestSuite()
136 : TestSuite("nr-lte-cc-bwp-configuration", Type::UNIT)
137 {
138 AddTestCase(new CcBwpTestCase("CC and BWP test"), Duration::QUICK);
139 }
140};
141
142static NrLteCcBwpTestSuite nrLteCcBwpTestSuite;
143
144void
145CcBwpTestCase::DoRun()
146{
147 CcBwpCreator creator;
148
152 double centralFrequency1 = 27e9;
153 double bandwidth1 = 1e9;
154 uint8_t numCcPerBand1 = 4;
155 OperationMode mode1 = TDD;
156
157 double centralFrequency2 = 28e9;
158 double bandwidth2 = 1e9;
159 uint8_t numCcPerBand2 = 4;
160 OperationMode mode2 = FDD;
161
167 TestBandConfiguration(centralFrequency1,
168 bandwidth1,
169 numCcPerBand1 * static_cast<uint8_t>(mode1),
170 mode1);
171
172 TestBandConfiguration(centralFrequency2,
173 bandwidth2,
174 numCcPerBand2 * static_cast<uint8_t>(mode2),
175 mode2);
176
177 CcBwpCreator::SimpleOperationBandConf bandConf1(centralFrequency1,
178 bandwidth1,
179 numCcPerBand1 * static_cast<uint8_t>(mode1),
181
182 CcBwpCreator::SimpleOperationBandConf bandConf2(centralFrequency2,
183 bandwidth2,
184 numCcPerBand2 * static_cast<uint8_t>(mode2),
186
187 OperationBandInfo band1 = creator.CreateOperationBandContiguousCc(bandConf1);
188 OperationBandInfo band2 = creator.CreateOperationBandContiguousCc(bandConf2);
189
190 TestMultiBandConfiguration({band1, band2});
191
192 std::vector<std::reference_wrapper<CcBwpCreator::SimpleOperationBandConf>>
193 operationBandConfigs = {bandConf1, bandConf2};
194 TestCcBwpNumbers(operationBandConfigs);
195}
196
197void
198CcBwpTestCase::TestBandConfiguration(double centralFrequency,
199 uint32_t bandwidth,
200 uint8_t numBandCcs,
201 OperationMode mode)
202{
203 CcBwpCreator creator;
204
205 CcBwpCreator::SimpleOperationBandConf bandConf(centralFrequency,
206 bandwidth,
207 numBandCcs * static_cast<uint8_t>(mode),
209
210 OperationBandInfo band = creator.CreateOperationBandContiguousCc(bandConf);
211
212 bool ret = ValidateOperationBand(band);
213 NS_TEST_ASSERT_MSG_EQ(ret, true, "Frequency configuration is not valid");
214}
215
216void
217CcBwpTestCase::TestMultiBandConfiguration(
218 const std::vector<std::reference_wrapper<OperationBandInfo>>& operationBands)
219{
220 bool ret = ValidateCaBwpConfiguration(operationBands);
221 NS_TEST_ASSERT_MSG_EQ(ret, true, "Frequency configuration is not valid");
222}
223
224void
225CcBwpTestCase::TestCcBwpNumbers(
226 std::vector<std::reference_wrapper<CcBwpCreator::SimpleOperationBandConf>>&
227 operationBandConfigs)
228{
229 NS_TEST_ASSERT_MSG_GT(operationBandConfigs.size(), 0, "No operation band info");
230
231 CcBwpCreator creator;
232
233 for (auto& operationBandConfig : operationBandConfigs)
234 {
235 CcBwpCreator::SimpleOperationBandConf bandConfig = operationBandConfig;
236 OperationBandInfo band = creator.CreateOperationBandContiguousCc(bandConfig);
237
238 NS_TEST_ASSERT_MSG_EQ(band.m_cc.size(), bandConfig.m_numCc, "Unexpected number of CCs");
239
240 uint16_t numBwp = 0;
241 for (const auto& cc : band.m_cc)
242 {
243 numBwp += cc->m_bwp.size();
244 }
245
246 NS_TEST_ASSERT_MSG_EQ(numBwp, bandConfig.m_numCc, "Unexpected number of BWPs");
247 }
248}
249
250bool
251CcBwpTestCase::ValidateCaBwpConfiguration(
252 const std::vector<std::reference_wrapper<OperationBandInfo>>& operationBands)
253{
254 if (operationBands.empty())
255 {
256 std::cout << "No band information has been provided" << std::endl;
257 return false;
258 }
259
260 uint16_t numBands = operationBands.size();
261
262 /*
263 * First validation: Operation bands shall not overlap
264 */
265 if (numBands > 1)
266 {
267 for (uint16_t i = 0; i < numBands - 1; ++i)
268 {
269 if (operationBands.at(i).get().m_higherFrequency >
270 operationBands.at(i + 1).get().m_lowerFrequency)
271 {
272 std::cout << "Bands overlap" << std::endl;
273 return false;
274 }
275 }
276 }
277
278 /*
279 * Second validation: Check that the CC configuration is valid (assume bands
280 * are sorted by increasing operation frequency)
281 */
282 for (const auto& band : operationBands)
283 {
284 ValidateOperationBand(band.get());
285 }
286
287 return true;
288}
289
290bool
291CcBwpTestCase::ValidateOperationBand(const OperationBandInfo& band)
292{
293 NS_ABORT_MSG_IF(band.m_cc.empty(), "No CC information provided");
294 uint8_t numCcs = band.m_cc.size();
295
296 // Loop checks if CCs are overlap and contiguous or not
297 uint8_t c = 0;
298 while (c < numCcs - 1)
299 {
300 double freqSeparation =
301 band.m_cc.at(c + 1)->m_lowerFrequency - band.m_cc.at(c)->m_higherFrequency < 0;
302 if (freqSeparation < 0)
303 {
304 std::cout << "CCs overlap" << std::endl;
305 // NS_TEST_ASSERT_MSG_EQ (freqSeparation, 1.0, "CCs overlap");
306 return false;
307 }
308 ++c;
309 }
310
311 // Check if each CC has BWP configuration and validate them
312 for (const auto& cc : band.m_cc)
313 {
314 if (!CheckBwpsInCc(cc))
315 {
316 return false;
317 }
318 }
319
320 return true;
321}
322
323bool
324CcBwpTestCase::CheckBwpsInCc(const ComponentCarrierInfoPtr& cc)
325{
326 // //First check: number of BWP shall be larger than 0
327 if (cc->m_bwp.empty())
328 {
329 std::cout << "No BWPs inside the CC" << std::endl;
330 return false;
331 }
332
333 // Second check: BWP shall not exceed CC limits and the sum of BWPs cannot be larger than the CC
334 // bandwidth
335 double totalBandwidth = 0;
336 for (const auto& bwp : cc->m_bwp)
337 {
338 if (bwp->m_higherFrequency > cc->m_higherFrequency ||
339 bwp->m_lowerFrequency < cc->m_lowerFrequency)
340 {
341 std::cout << "BWP part is out of the CC bounds" << std::endl;
342 return false;
343 }
344 totalBandwidth += bwp->m_channelBandwidth;
345 }
346
347 if (totalBandwidth > cc->m_channelBandwidth)
348 {
349 std::cout << "Aggregated BWP is larger than carrier bandwidth" << std::endl;
350 return false;
351 }
352
353 // Third check: BWPs shall not overlap in frequency
354 uint16_t numBwps = cc->m_bwp.size();
355 for (uint16_t a = 0; a < numBwps - 1; a++)
356 {
357 if (cc->m_bwp.at(a)->m_higherFrequency > cc->m_bwp.at(a + 1)->m_lowerFrequency)
358 {
359 std::cout << "BWPs shall not overlap" << std::endl;
360 return false;
361 }
362 }
363
364 return true;
365}
366
367} // namespace ns3
Manages the correct creation of operation bands, component carriers and bandwidth parts.
OperationBandInfo CreateOperationBandContiguousCc(const SimpleOperationBandConf &conf)
Create an operation band with the CC specified.
std::unique_ptr< ComponentCarrierInfo > ComponentCarrierInfoPtr
unique_ptr of ComponentCarrierInfo
static NrLteCcBwpTestSuite nrLteCcBwpTestSuite
CC BWP test suite.
@ UMi_StreetCanyon
UMi_StreetCanyon.
Minimum configuration requirements for a OperationBand.
Operation band information structure.