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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Nicola Baldo <nbaldo@cttc.es>
18 */
19
20#include "ns3/log.h"
21#include "ns3/lte-spectrum-value-helper.h"
22#include "ns3/test.h"
23
24using namespace ns3;
25
26NS_LOG_COMPONENT_DEFINE("LteTestEarfcn");
27
28/**
29 * \ingroup lte-test
30 *
31 * \brief Test case that is testing if the frequency is properly generated
32 * from provided EARFCN frequency.
33 */
34
36{
37 public:
38 /**
39 * Constructor
40 *
41 * \param str reference name
42 * \param earfcn EARFCN
43 * \param f frequency
44 */
45 LteEarfcnTestCase(const char* str, uint32_t earfcn, double f);
46 ~LteEarfcnTestCase() override;
47
48 protected:
49 uint32_t m_earfcn; ///< the EARFCN
50 double m_f; ///< the frequency
51
52 private:
53 void DoRun() override;
54};
55
56LteEarfcnTestCase::LteEarfcnTestCase(const char* str, uint32_t earfcn, double f)
57 : TestCase(str),
58 m_earfcn(earfcn),
59 m_f(f)
60{
61 NS_LOG_FUNCTION(this << str << earfcn << f);
62}
63
65{
66}
67
68void
70{
72 NS_TEST_ASSERT_MSG_EQ_TOL(f, m_f, 0.0000001, "wrong frequency");
73}
74
75/**
76 * \ingroup lte-test
77 *
78 * \brief
79 * Test case that is testing if the downlink frequency is properly
80 * converted from provided downlink EARFCN frequency value.
81 */
82
84{
85 public:
86 /**
87 * Constructor
88 *
89 * \param str reference name
90 * \param earfcn EARFCN
91 * \param f frequency
92 */
93 LteEarfcnDlTestCase(const char* str, uint32_t earfcn, double f);
94
95 private:
96 void DoRun() override;
97};
98
99LteEarfcnDlTestCase::LteEarfcnDlTestCase(const char* str, uint32_t earfcn, double f)
100 : LteEarfcnTestCase(str, earfcn, f)
101{
102}
103
104void
106{
107 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
108 // LogComponentEnable ("LteSpectrumValueHelper", logLevel);
109 // LogComponentEnable ("LteTestEarfcn", logLevel);
110
112 NS_TEST_ASSERT_MSG_EQ_TOL(f, m_f, 0.0000001, "wrong frequency");
113}
114
115/**
116 * \ingroup lte-test
117 *
118 * \brief Test case that is testing if the uplink frequency is properly
119 * converted from provided uplink EARFCN frequency value.
120 */
121
123{
124 public:
125 /**
126 * Constructor
127 *
128 * \param str reference name
129 * \param earfcn EARFCN
130 * \param f frequency
131 */
132 LteEarfcnUlTestCase(const char* str, uint32_t earfcn, double f);
133
134 private:
135 void DoRun() override;
136};
137
138LteEarfcnUlTestCase::LteEarfcnUlTestCase(const char* str, uint32_t earfcn, double f)
139 : LteEarfcnTestCase(str, earfcn, f)
140{
141}
142
143void
145{
147 NS_TEST_ASSERT_MSG_EQ_TOL(f, m_f, 0.0000001, "wrong frequency");
148}
149
150/**
151 * \ingroup lte-test
152 *
153 * \brief Test suite for testing correct conversion of frequencies in
154 * the downlink and the uplink, and general EARFCN frequencies.
155 */
157{
158 public:
160};
161
162/**
163 * \ingroup lte-test
164 * Static variable for test initialization
165 */
167
169 : TestSuite("lte-earfcn", Type::UNIT)
170{
171 NS_LOG_FUNCTION(this);
172
173 AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=500", 500, 2160e6), TestCase::Duration::QUICK);
174 AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=1000", 1000, 1970e6), TestCase::Duration::QUICK);
175 AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=1301", 1301, 1815.1e6),
176 TestCase::Duration::QUICK);
177 AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=7000", 7000, 0.0), TestCase::Duration::QUICK);
178 AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=20000", 20000, 0.0), TestCase::Duration::QUICK);
179 AddTestCase(new LteEarfcnDlTestCase("DL EARFCN=50000", 50000, 0.0), TestCase::Duration::QUICK);
180
181 AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=18100", 18100, 1930e6),
182 TestCase::Duration::QUICK);
183 AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=19000", 19000, 1890e6),
184 TestCase::Duration::QUICK);
185 AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=19400", 19400, 1730e6),
186 TestCase::Duration::QUICK);
187 AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=10", 10, 0.0), TestCase::Duration::QUICK);
188 AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=1000", 1000, 0.0), TestCase::Duration::QUICK);
189 AddTestCase(new LteEarfcnUlTestCase("UL EARFCN=50000", 50000, 0.0), TestCase::Duration::QUICK);
190
191 AddTestCase(new LteEarfcnTestCase("EARFCN=500", 500, 2160e6), TestCase::Duration::QUICK);
192 AddTestCase(new LteEarfcnTestCase("EARFCN=1000", 1000, 1970e6), TestCase::Duration::QUICK);
193 AddTestCase(new LteEarfcnTestCase("EARFCN=1301", 1301, 1815.1e6), TestCase::Duration::QUICK);
194 AddTestCase(new LteEarfcnTestCase("EARFCN=8000", 8000, 0.0), TestCase::Duration::QUICK);
195 AddTestCase(new LteEarfcnTestCase("EARFCN=50000", 50000, 0.0), TestCase::Duration::QUICK);
196 AddTestCase(new LteEarfcnTestCase("EARFCN=18100", 18100, 1930e6), TestCase::Duration::QUICK);
197 AddTestCase(new LteEarfcnTestCase("EARFCN=19000", 19000, 1890e6), TestCase::Duration::QUICK);
198 AddTestCase(new LteEarfcnTestCase("EARFCN=19400", 19400, 1730e6), TestCase::Duration::QUICK);
199 AddTestCase(new LteEarfcnTestCase("EARFCN=50000", 50000, 0.0), TestCase::Duration::QUICK);
200}
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:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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:338
Every class exported by the ns3 library is enclosed in the ns3 namespace.