A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
24
using namespace
ns3
;
25
26
NS_LOG_COMPONENT_DEFINE
(
"LteTestEarfcn"
);
27
35
class
LteEarfcnTestCase
:
public
TestCase
36
{
37
public
:
45
LteEarfcnTestCase
(
const
char
* str,
uint32_t
earfcn,
double
f
);
46
~LteEarfcnTestCase
()
override
;
47
48
protected
:
49
uint32_t
m_earfcn
;
50
double
m_f
;
51
52
private
:
53
void
DoRun
()
override
;
54
};
55
56
LteEarfcnTestCase::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
64
LteEarfcnTestCase::~LteEarfcnTestCase
()
65
{
66
}
67
68
void
69
LteEarfcnTestCase::DoRun
()
70
{
71
double
f
=
LteSpectrumValueHelper::GetCarrierFrequency
(
m_earfcn
);
72
NS_TEST_ASSERT_MSG_EQ_TOL
(
f
,
m_f
, 0.0000001,
"wrong frequency"
);
73
}
74
83
class
LteEarfcnDlTestCase
:
public
LteEarfcnTestCase
84
{
85
public
:
93
LteEarfcnDlTestCase
(
const
char
* str,
uint32_t
earfcn,
double
f
);
94
95
private
:
96
void
DoRun
()
override
;
97
};
98
99
LteEarfcnDlTestCase::LteEarfcnDlTestCase
(
const
char
* str,
uint32_t
earfcn,
double
f
)
100
:
LteEarfcnTestCase
(str, earfcn,
f
)
101
{
102
}
103
104
void
105
LteEarfcnDlTestCase::DoRun
()
106
{
107
// LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
108
// LogComponentEnable ("LteSpectrumValueHelper", logLevel);
109
// LogComponentEnable ("LteTestEarfcn", logLevel);
110
111
double
f
=
LteSpectrumValueHelper::GetDownlinkCarrierFrequency
(
m_earfcn
);
112
NS_TEST_ASSERT_MSG_EQ_TOL
(
f
,
m_f
, 0.0000001,
"wrong frequency"
);
113
}
114
122
class
LteEarfcnUlTestCase
:
public
LteEarfcnTestCase
123
{
124
public
:
132
LteEarfcnUlTestCase
(
const
char
* str,
uint32_t
earfcn,
double
f
);
133
134
private
:
135
void
DoRun
()
override
;
136
};
137
138
LteEarfcnUlTestCase::LteEarfcnUlTestCase
(
const
char
* str,
uint32_t
earfcn,
double
f
)
139
:
LteEarfcnTestCase
(str, earfcn,
f
)
140
{
141
}
142
143
void
144
LteEarfcnUlTestCase::DoRun
()
145
{
146
double
f
=
LteSpectrumValueHelper::GetUplinkCarrierFrequency
(
m_earfcn
);
147
NS_TEST_ASSERT_MSG_EQ_TOL
(
f
,
m_f
, 0.0000001,
"wrong frequency"
);
148
}
149
156
class
LteEarfcnTestSuite
:
public
TestSuite
157
{
158
public
:
159
LteEarfcnTestSuite
();
160
};
161
166
static
LteEarfcnTestSuite
g_lteEarfcnTestSuite
;
167
168
LteEarfcnTestSuite::LteEarfcnTestSuite
()
169
:
TestSuite
(
"lte-earfcn"
, UNIT)
170
{
171
NS_LOG_FUNCTION
(
this
);
172
173
AddTestCase
(
new
LteEarfcnDlTestCase
(
"DL EARFCN=500"
, 500, 2160e6),
TestCase::QUICK
);
174
AddTestCase
(
new
LteEarfcnDlTestCase
(
"DL EARFCN=1000"
, 1000, 1970e6),
TestCase::QUICK
);
175
AddTestCase
(
new
LteEarfcnDlTestCase
(
"DL EARFCN=1301"
, 1301, 1815.1e6),
TestCase::QUICK
);
176
AddTestCase
(
new
LteEarfcnDlTestCase
(
"DL EARFCN=7000"
, 7000, 0.0),
TestCase::QUICK
);
177
AddTestCase
(
new
LteEarfcnDlTestCase
(
"DL EARFCN=20000"
, 20000, 0.0),
TestCase::QUICK
);
178
AddTestCase
(
new
LteEarfcnDlTestCase
(
"DL EARFCN=50000"
, 50000, 0.0),
TestCase::QUICK
);
179
180
AddTestCase
(
new
LteEarfcnUlTestCase
(
"UL EARFCN=18100"
, 18100, 1930e6),
TestCase::QUICK
);
181
AddTestCase
(
new
LteEarfcnUlTestCase
(
"UL EARFCN=19000"
, 19000, 1890e6),
TestCase::QUICK
);
182
AddTestCase
(
new
LteEarfcnUlTestCase
(
"UL EARFCN=19400"
, 19400, 1730e6),
TestCase::QUICK
);
183
AddTestCase
(
new
LteEarfcnUlTestCase
(
"UL EARFCN=10"
, 10, 0.0),
TestCase::QUICK
);
184
AddTestCase
(
new
LteEarfcnUlTestCase
(
"UL EARFCN=1000"
, 1000, 0.0),
TestCase::QUICK
);
185
AddTestCase
(
new
LteEarfcnUlTestCase
(
"UL EARFCN=50000"
, 50000, 0.0),
TestCase::QUICK
);
186
187
AddTestCase
(
new
LteEarfcnTestCase
(
"EARFCN=500"
, 500, 2160e6),
TestCase::QUICK
);
188
AddTestCase
(
new
LteEarfcnTestCase
(
"EARFCN=1000"
, 1000, 1970e6),
TestCase::QUICK
);
189
AddTestCase
(
new
LteEarfcnTestCase
(
"EARFCN=1301"
, 1301, 1815.1e6),
TestCase::QUICK
);
190
AddTestCase
(
new
LteEarfcnTestCase
(
"EARFCN=8000"
, 8000, 0.0),
TestCase::QUICK
);
191
AddTestCase
(
new
LteEarfcnTestCase
(
"EARFCN=50000"
, 50000, 0.0),
TestCase::QUICK
);
192
AddTestCase
(
new
LteEarfcnTestCase
(
"EARFCN=18100"
, 18100, 1930e6),
TestCase::QUICK
);
193
AddTestCase
(
new
LteEarfcnTestCase
(
"EARFCN=19000"
, 19000, 1890e6),
TestCase::QUICK
);
194
AddTestCase
(
new
LteEarfcnTestCase
(
"EARFCN=19400"
, 19400, 1730e6),
TestCase::QUICK
);
195
AddTestCase
(
new
LteEarfcnTestCase
(
"EARFCN=50000"
, 50000, 0.0),
TestCase::QUICK
);
196
}
f
double f(double x, void *params)
Definition:
80211b.c:70
LteEarfcnDlTestCase
Test case that is testing if the downlink frequency is properly converted from provided downlink EARF...
Definition:
lte-test-earfcn.cc:84
LteEarfcnDlTestCase::LteEarfcnDlTestCase
LteEarfcnDlTestCase(const char *str, uint32_t earfcn, double f)
Constructor.
Definition:
lte-test-earfcn.cc:99
LteEarfcnDlTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
lte-test-earfcn.cc:105
LteEarfcnTestCase
Test case that is testing if the frequency is properly generated from provided EARFCN frequency.
Definition:
lte-test-earfcn.cc:36
LteEarfcnTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
lte-test-earfcn.cc:69
LteEarfcnTestCase::~LteEarfcnTestCase
~LteEarfcnTestCase() override
Definition:
lte-test-earfcn.cc:64
LteEarfcnTestCase::m_earfcn
uint32_t m_earfcn
the EARFCN
Definition:
lte-test-earfcn.cc:49
LteEarfcnTestCase::m_f
double m_f
the frequency
Definition:
lte-test-earfcn.cc:50
LteEarfcnTestCase::LteEarfcnTestCase
LteEarfcnTestCase(const char *str, uint32_t earfcn, double f)
Constructor.
Definition:
lte-test-earfcn.cc:56
LteEarfcnTestSuite
Test suite for testing correct conversion of frequencies in the downlink and the uplink,...
Definition:
lte-test-earfcn.cc:157
LteEarfcnTestSuite::LteEarfcnTestSuite
LteEarfcnTestSuite()
Definition:
lte-test-earfcn.cc:168
LteEarfcnUlTestCase
Test case that is testing if the uplink frequency is properly converted from provided uplink EARFCN f...
Definition:
lte-test-earfcn.cc:123
LteEarfcnUlTestCase::LteEarfcnUlTestCase
LteEarfcnUlTestCase(const char *str, uint32_t earfcn, double f)
Constructor.
Definition:
lte-test-earfcn.cc:138
LteEarfcnUlTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
lte-test-earfcn.cc:144
ns3::LteSpectrumValueHelper::GetUplinkCarrierFrequency
static double GetUplinkCarrierFrequency(uint32_t earfcn)
Calculates the uplink carrier frequency from the E-UTRA Absolute Radio Frequency Channel Number (EARF...
Definition:
lte-spectrum-value-helper.cc:178
ns3::LteSpectrumValueHelper::GetCarrierFrequency
static double GetCarrierFrequency(uint32_t earfcn)
Calculates the carrier frequency from the E-UTRA Absolute Radio Frequency Channel Number (EARFCN) acc...
Definition:
lte-spectrum-value-helper.cc:117
ns3::LteSpectrumValueHelper::GetDownlinkCarrierFrequency
static double GetDownlinkCarrierFrequency(uint32_t earfcn)
Calculates the downlink carrier frequency from the E-UTRA Absolute Radio Frequency Channel Number (EA...
Definition:
lte-spectrum-value-helper.cc:165
ns3::TestCase
encapsulates test code
Definition:
test.h:1060
ns3::TestCase::QUICK
@ QUICK
Fast test.
Definition:
test.h:1065
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:301
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1256
uint32_t
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition:
log-macros-enabled.h:238
g_lteEarfcnTestSuite
static LteEarfcnTestSuite g_lteEarfcnTestSuite
Static variable for test initialization.
Definition:
lte-test-earfcn.cc:166
NS_TEST_ASSERT_MSG_EQ_TOL
#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:337
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
lte
test
lte-test-earfcn.cc
Generated on Sun Jul 2 2023 18:21:52 for ns-3 by
1.9.6