A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-test-earfcn.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 */
8
9#include "ns3/log.h"
10#include "ns3/lte-spectrum-value-helper.h"
11#include "ns3/test.h"
12
13using namespace ns3;
14
15NS_LOG_COMPONENT_DEFINE("LteTestEarfcn");
16
17/**
18 * @ingroup lte-test
19 *
20 * @brief Test case that is testing if the frequency is properly generated
21 * from provided EARFCN frequency.
22 */
23
25{
26 public:
27 /**
28 * Constructor
29 *
30 * @param str reference name
31 * @param earfcn EARFCN
32 * @param f frequency
33 */
34 LteEarfcnTestCase(const char* str, uint32_t earfcn, double f);
35 ~LteEarfcnTestCase() override;
36
37 protected:
38 uint32_t m_earfcn; ///< the EARFCN
39 double m_f; ///< the frequency
40
41 private:
42 void DoRun() override;
43};
44
45LteEarfcnTestCase::LteEarfcnTestCase(const char* str, uint32_t earfcn, double f)
46 : TestCase(str),
47 m_earfcn(earfcn),
48 m_f(f)
49{
50 NS_LOG_FUNCTION(this << str << earfcn << f);
51}
52
56
57void
63
64/**
65 * @ingroup lte-test
66 *
67 * @brief
68 * Test case that is testing if the downlink frequency is properly
69 * converted from provided downlink EARFCN frequency value.
70 */
71
73{
74 public:
75 /**
76 * Constructor
77 *
78 * @param str reference name
79 * @param earfcn EARFCN
80 * @param f frequency
81 */
82 LteEarfcnDlTestCase(const char* str, uint32_t earfcn, double f);
83
84 private:
85 void DoRun() override;
86};
87
88LteEarfcnDlTestCase::LteEarfcnDlTestCase(const char* str, uint32_t earfcn, double f)
89 : LteEarfcnTestCase(str, earfcn, f)
90{
91}
92
93void
95{
96 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
97 // LogComponentEnable ("LteSpectrumValueHelper", logLevel);
98 // LogComponentEnable ("LteTestEarfcn", logLevel);
99
101 NS_TEST_ASSERT_MSG_EQ_TOL(f, m_f, 0.0000001, "wrong frequency");
102}
103
104/**
105 * @ingroup lte-test
106 *
107 * @brief Test case that is testing if the uplink frequency is properly
108 * converted from provided uplink EARFCN frequency value.
109 */
110
112{
113 public:
114 /**
115 * Constructor
116 *
117 * @param str reference name
118 * @param earfcn EARFCN
119 * @param f frequency
120 */
121 LteEarfcnUlTestCase(const char* str, uint32_t earfcn, double f);
122
123 private:
124 void DoRun() override;
125};
126
127LteEarfcnUlTestCase::LteEarfcnUlTestCase(const char* str, uint32_t earfcn, double f)
128 : LteEarfcnTestCase(str, earfcn, f)
129{
130}
131
132void
138
139/**
140 * @ingroup lte-test
141 *
142 * @brief Test suite for testing correct conversion of frequencies in
143 * the downlink and the uplink, and general EARFCN frequencies.
144 */
146{
147 public:
149};
150
151/**
152 * @ingroup lte-test
153 * Static variable for test initialization
154 */
156
158 : TestSuite("lte-earfcn", Type::UNIT)
159{
160 NS_LOG_FUNCTION(this);
161
162 AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=500", 500, 2160e6), TestCase::Duration::QUICK);
163 AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=1000", 1000, 1970e6), TestCase::Duration::QUICK);
164 AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=1301", 1301, 1815.1e6),
165 TestCase::Duration::QUICK);
166 AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=7000", 7000, 0.0), TestCase::Duration::QUICK);
167 AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=20000", 20000, 0.0), TestCase::Duration::QUICK);
168 AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=50000", 50000, 0.0), TestCase::Duration::QUICK);
169
170 AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=18100", 18100, 1930e6),
171 TestCase::Duration::QUICK);
172 AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=19000", 19000, 1890e6),
173 TestCase::Duration::QUICK);
174 AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=19400", 19400, 1730e6),
175 TestCase::Duration::QUICK);
176 AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=10", 10, 0.0), TestCase::Duration::QUICK);
177 AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=1000", 1000, 0.0), TestCase::Duration::QUICK);
178 AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=50000", 50000, 0.0), TestCase::Duration::QUICK);
179
180 AddTestCase(new LteEarfcnTestCase("EARFCN=500", 500, 2160e6), TestCase::Duration::QUICK);
181 AddTestCase(new LteEarfcnTestCase("EARFCN=1000", 1000, 1970e6), TestCase::Duration::QUICK);
182 AddTestCase(new LteEarfcnTestCase("EARFCN=1301", 1301, 1815.1e6), TestCase::Duration::QUICK);
183 AddTestCase(new LteEarfcnTestCase("EARFCN=8000", 8000, 0.0), TestCase::Duration::QUICK);
184 AddTestCase(new LteEarfcnTestCase("EARFCN=50000", 50000, 0.0), TestCase::Duration::QUICK);
185 AddTestCase(new LteEarfcnTestCase("EARFCN=18100", 18100, 1930e6), TestCase::Duration::QUICK);
186 AddTestCase(new LteEarfcnTestCase("EARFCN=19000", 19000, 1890e6), TestCase::Duration::QUICK);
187 AddTestCase(new LteEarfcnTestCase("EARFCN=19400", 19400, 1730e6), TestCase::Duration::QUICK);
188 AddTestCase(new LteEarfcnTestCase("EARFCN=50000", 50000, 0.0), TestCase::Duration::QUICK);
189}
Test case that is testing if the downlink frequency is properly converted from provided downlink EARF...
LteEarfcnDlTestCase(const char *str, uint32_t earfcn, double f)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
Test case that is testing if the frequency is properly generated from provided EARFCN frequency.
void DoRun() override
Implementation to actually run this TestCase.
~LteEarfcnTestCase() override
uint32_t m_earfcn
the EARFCN
double m_f
the frequency
LteEarfcnTestCase(const char *str, uint32_t earfcn, double f)
Constructor.
Test suite for testing correct conversion of frequencies in the downlink and the uplink,...
Test case that is testing if the uplink frequency is properly converted from provided uplink EARFCN f...
LteEarfcnUlTestCase(const char *str, uint32_t earfcn, double f)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
static double GetUplinkCarrierFrequency(uint32_t earfcn)
Calculates the uplink carrier frequency from the E-UTRA Absolute Radio Frequency Channel Number (EARF...
static double GetCarrierFrequency(uint32_t earfcn)
Calculates the carrier frequency from the E-UTRA Absolute Radio Frequency Channel Number (EARFCN) acc...
static double GetDownlinkCarrierFrequency(uint32_t earfcn)
Calculates the downlink carrier frequency from the E-UTRA Absolute Radio Frequency Channel Number (EA...
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
static LteEarfcnTestSuite g_lteEarfcnTestSuite
Static variable for test initialization.
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Definition test.h:327
Every class exported by the ns3 library is enclosed in the ns3 namespace.