A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
test-lte-antenna.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011, 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Manuel Requena <manuel.requena@cttc.es>
7 * Nicola Baldo <nbaldo@cttc.es>
8 */
9
10#include "ns3/boolean.h"
11#include "ns3/double.h"
12#include "ns3/enum.h"
13#include "ns3/ff-mac-scheduler.h"
14#include "ns3/log.h"
15#include "ns3/lte-enb-net-device.h"
16#include "ns3/lte-enb-phy.h"
17#include "ns3/lte-global-pathloss-database.h"
18#include "ns3/lte-helper.h"
19#include "ns3/lte-ue-net-device.h"
20#include "ns3/lte-ue-phy.h"
21#include "ns3/mobility-helper.h"
22#include "ns3/simulator.h"
23#include "ns3/string.h"
24#include "ns3/test.h"
25#include <ns3/lte-chunk-processor.h>
26
27using namespace ns3;
28
29NS_LOG_COMPONENT_DEFINE("LteAntennaTest");
30
31/**
32 * \ingroup lte-test
33 *
34 * \brief Tests that the propagation model and the antenna parameters are
35 * generate the correct values. Different test cases are created by specifying different
36 * antenna configurations and it is tested if for the given information the pathloss
37 * value is as expected.
38 */
40{
41 public:
42 /**
43 * Build name string
44 * \param orientationDegrees the orientation in degrees
45 * \param beamwidthDegrees the beam width in degrees
46 * \param x position of UE
47 * \param y position of UE
48 * \returns the name string
49 */
50 static std::string BuildNameString(double orientationDegrees,
51 double beamwidthDegrees,
52 double x,
53 double y);
54 /**
55 * Constructor
56 *
57 * \param orientationDegrees the orientation in degrees
58 * \param beamwidthDegrees the beam width in degrees
59 * \param x position of UE
60 * \param y position of UE
61 * \param antennaGainDb the antenna gain in dB
62 */
63 LteEnbAntennaTestCase(double orientationDegrees,
64 double beamwidthDegrees,
65 double x,
66 double y,
67 double antennaGainDb);
69 ~LteEnbAntennaTestCase() override;
70
71 private:
72 void DoRun() override;
73
74 double m_orientationDegrees; ///< antenna orientation in degrees
75 double m_beamwidthDegrees; ///< antenna beamwidth in degrees
76 double m_x; ///< x position of the UE
77 double m_y; ///< y position of the UE
78 double m_antennaGainDb; ///< antenna gain in dB
79};
80
81std::string
83 double beamwidthDegrees,
84 double x,
85 double y)
86{
87 std::ostringstream oss;
88 oss << "o=" << orientationDegrees << ", bw=" << beamwidthDegrees << ", x=" << x << ", y=" << y;
89 return oss.str();
90}
91
93 double beamwidthDegrees,
94 double x,
95 double y,
96 double antennaGainDb)
97 : TestCase(BuildNameString(orientationDegrees, beamwidthDegrees, x, y)),
98 m_orientationDegrees(orientationDegrees),
99 m_beamwidthDegrees(beamwidthDegrees),
100 m_x(x),
101 m_y(y),
102 m_antennaGainDb(antennaGainDb)
103{
104 NS_LOG_FUNCTION(this);
105}
106
110
111void
113{
115 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
116 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
117 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
118
119 // Disable Uplink Power Control
120 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(false));
121
123
124 // use 0dB Pathloss, since we are testing only the antenna gain
125 lteHelper->SetAttribute("PathlossModel",
126 StringValue("ns3::ConstantSpectrumPropagationLossModel"));
127 lteHelper->SetPathlossModelAttribute("Loss", DoubleValue(0.0));
128
129 // Create Nodes: eNodeB and UE
130 NodeContainer enbNodes;
131 NodeContainer ueNodes;
132 enbNodes.Create(1);
133 ueNodes.Create(1);
134 NodeContainer allNodes = NodeContainer(enbNodes, ueNodes);
135
136 // Install Mobility Model
138 positionAlloc->Add(Vector(0.0, 0.0, 0.0)); // eNB
139 positionAlloc->Add(Vector(m_x, m_y, 0.0)); // UE
140 MobilityHelper mobility;
141 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
142 mobility.SetPositionAllocator(positionAlloc);
143 mobility.Install(allNodes);
144
145 // Create Devices and install them in the Nodes (eNB and UE)
146 NetDeviceContainer enbDevs;
147 NetDeviceContainer ueDevs;
148 lteHelper->SetSchedulerType("ns3::RrFfMacScheduler");
149 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::PUSCH_UL_CQI));
150 lteHelper->SetEnbAntennaModelType("ns3::CosineAntennaModel");
151 lteHelper->SetEnbAntennaModelAttribute("Orientation", DoubleValue(m_orientationDegrees));
152 lteHelper->SetEnbAntennaModelAttribute("HorizontalBeamwidth", DoubleValue(m_beamwidthDegrees));
153 lteHelper->SetEnbAntennaModelAttribute("MaxGain", DoubleValue(0.0));
154
155 // set DL and UL bandwidth.
156 lteHelper->SetEnbDeviceAttribute("DlBandwidth", UintegerValue(25));
157 lteHelper->SetEnbDeviceAttribute("UlBandwidth", UintegerValue(25));
158
159 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
160 ueDevs = lteHelper->InstallUeDevice(ueNodes);
161
162 // Attach a UE to a eNB
163 lteHelper->Attach(ueDevs, enbDevs.Get(0));
164
165 // Activate the default EPS bearer
167 EpsBearer bearer(q);
168 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
169
170 // Use testing chunk processor in the PHY layer
171 // It will be used to test that the SNR is as intended
172 Ptr<LtePhy> uePhy = ueDevs.Get(0)->GetObject<LteUeNetDevice>()->GetPhy()->GetObject<LtePhy>();
174 LteSpectrumValueCatcher dlSinrCatcher;
175 testDlSinr->AddCallback(MakeCallback(&LteSpectrumValueCatcher::ReportValue, &dlSinrCatcher));
176 uePhy->GetDownlinkSpectrumPhy()->AddDataSinrChunkProcessor(testDlSinr);
177
178 Ptr<LtePhy> enbphy =
179 enbDevs.Get(0)->GetObject<LteEnbNetDevice>()->GetPhy()->GetObject<LtePhy>();
181 LteSpectrumValueCatcher ulSinrCatcher;
182 testUlSinr->AddCallback(MakeCallback(&LteSpectrumValueCatcher::ReportValue, &ulSinrCatcher));
183 enbphy->GetUplinkSpectrumPhy()->AddDataSinrChunkProcessor(testUlSinr);
184
185 // keep track of all path loss values in two centralized objects
188 // we rely on the fact that LteHelper creates the DL channel object first, then the UL channel
189 // object, hence the former will have index 0 and the latter 1
191 "/ChannelList/0/PathLoss",
193 Config::Connect("/ChannelList/1/PathLoss",
195
196 Simulator::Stop(Seconds(0.035));
198
199 const double enbTxPowerDbm = 30; // default eNB TX power over whole bandwidth
200 const double ueTxPowerDbm = 10; // default UE TX power over whole bandwidth
201 const double ktDbm = -174; // reference LTE noise PSD
202 const double noisePowerDbm =
203 ktDbm + 10 * std::log10(25 * 180000); // corresponds to kT*bandwidth in linear units
204 const double ueNoiseFigureDb = 9.0; // default UE noise figure
205 const double enbNoiseFigureDb = 5.0; // default eNB noise figure
206 double tolerance = (m_antennaGainDb != 0) ? std::abs(m_antennaGainDb) * 0.001 : 0.001;
207
208 // first test with SINR from LteChunkProcessor
209 // this can only be done for not-too-bad SINR otherwise the measurement won't be available
210 double expectedSinrDl = enbTxPowerDbm + m_antennaGainDb - noisePowerDbm + ueNoiseFigureDb;
211 if (expectedSinrDl > 0)
212 {
213 double calculatedSinrDbDl = -INFINITY;
214 if (dlSinrCatcher.GetValue())
215 {
216 calculatedSinrDbDl = 10.0 * std::log10(dlSinrCatcher.GetValue()->operator[](0));
217 }
218 // remember that propagation loss is 0dB
219 double calculatedAntennaGainDbDl =
220 -(enbTxPowerDbm - calculatedSinrDbDl - noisePowerDbm - ueNoiseFigureDb);
221 NS_LOG_INFO("expected " << m_antennaGainDb << " actual " << calculatedAntennaGainDbDl
222 << " tol " << tolerance);
223 NS_TEST_ASSERT_MSG_EQ_TOL(calculatedAntennaGainDbDl,
225 tolerance,
226 "Wrong DL antenna gain!");
227 }
228 double expectedSinrUl = ueTxPowerDbm + m_antennaGainDb - noisePowerDbm + enbNoiseFigureDb;
229 if (expectedSinrUl > 0)
230 {
231 double calculatedSinrDbUl = -INFINITY;
232 if (ulSinrCatcher.GetValue())
233 {
234 calculatedSinrDbUl = 10.0 * std::log10(ulSinrCatcher.GetValue()->operator[](0));
235 }
236 double calculatedAntennaGainDbUl =
237 -(ueTxPowerDbm - calculatedSinrDbUl - noisePowerDbm - enbNoiseFigureDb);
238 NS_TEST_ASSERT_MSG_EQ_TOL(calculatedAntennaGainDbUl,
240 tolerance,
241 "Wrong UL antenna gain!");
242 }
243
244 // repeat the same tests with the LteGlobalPathlossDatabases
245 double measuredLossDl = dlPathlossDb.GetPathloss(1, 1);
246 NS_TEST_ASSERT_MSG_EQ_TOL(measuredLossDl, -m_antennaGainDb, tolerance, "Wrong DL loss!");
247 double measuredLossUl = ulPathlossDb.GetPathloss(1, 1);
248 NS_TEST_ASSERT_MSG_EQ_TOL(measuredLossUl, -m_antennaGainDb, tolerance, "Wrong UL loss!");
249
251}
252
253/**
254 * \ingroup lte-test
255 *
256 * \brief Lte Enb Antenna Test Suite
257 */
259{
260 public:
262};
263
265 : TestSuite("lte-antenna", Type::SYSTEM)
266{
267 NS_LOG_FUNCTION(this);
268
269 // orientation beamwidth x y gain
270 AddTestCase(new LteEnbAntennaTestCase(0.0, 90.0, 1.0, 0.0, 0.0), TestCase::Duration::QUICK);
271 AddTestCase(new LteEnbAntennaTestCase(0.0, 90.0, 1.0, 1.0, -3.0), TestCase::Duration::QUICK);
272 AddTestCase(new LteEnbAntennaTestCase(0.0, 90.0, 1.0, -1.0, -3.0), TestCase::Duration::QUICK);
273 AddTestCase(new LteEnbAntennaTestCase(0.0, 90.0, -1.0, -1.0, -36.396),
274 TestCase::Duration::QUICK);
275 AddTestCase(new LteEnbAntennaTestCase(0.0, 90.0, -1.0, -0.0, -1414.6),
276 TestCase::Duration::QUICK);
277 AddTestCase(new LteEnbAntennaTestCase(0.0, 90.0, -1.0, 1.0, -36.396),
278 TestCase::Duration::QUICK);
279 AddTestCase(new LteEnbAntennaTestCase(45.0, 90.0, 1.0, 1.0, 0.0), TestCase::Duration::QUICK);
280 AddTestCase(new LteEnbAntennaTestCase(-45.0, 90.0, 1.0, -1.0, 0.0), TestCase::Duration::QUICK);
281 AddTestCase(new LteEnbAntennaTestCase(90.0, 90.0, 1.0, 1.0, -3.0), TestCase::Duration::QUICK);
282 AddTestCase(new LteEnbAntennaTestCase(-90.0, 90.0, 1.0, -1.0, -3.0), TestCase::Duration::QUICK);
283
284 AddTestCase(new LteEnbAntennaTestCase(0.0, 120.0, 1.0, 0.0, 0.0), TestCase::Duration::QUICK);
285 AddTestCase(new LteEnbAntennaTestCase(0.0, 120.0, 0.5, sin(M_PI / 3), -3.0),
286 TestCase::Duration::QUICK);
287 AddTestCase(new LteEnbAntennaTestCase(0.0, 120.0, 0.5, -sin(M_PI / 3), -3.0),
288 TestCase::Duration::QUICK);
289 AddTestCase(new LteEnbAntennaTestCase(0.0, 120.0, -1.0, -2.0, -13.410),
290 TestCase::Duration::QUICK);
291 AddTestCase(new LteEnbAntennaTestCase(0.0, 120.0, -1.0, 1.0, -20.034),
292 TestCase::Duration::QUICK);
293 AddTestCase(new LteEnbAntennaTestCase(60.0, 120.0, 0.5, sin(M_PI / 3), 0.0),
294 TestCase::Duration::QUICK);
295 AddTestCase(new LteEnbAntennaTestCase(-60.0, 120.0, 0.5, -sin(M_PI / 3), 0.0),
296 TestCase::Duration::QUICK);
297 AddTestCase(new LteEnbAntennaTestCase(-60.0, 120.0, 0.5, -sin(M_PI / 3), 0.0),
298 TestCase::Duration::QUICK);
299 AddTestCase(new LteEnbAntennaTestCase(-120.0, 120.0, -0.5, -sin(M_PI / 3), 0.0),
300 TestCase::Duration::QUICK);
301 AddTestCase(new LteEnbAntennaTestCase(-120.0, 120.0, 0.5, -sin(M_PI / 3), -3.0),
302 TestCase::Duration::QUICK);
303 AddTestCase(new LteEnbAntennaTestCase(-120.0, 120.0, -1, 0, -3.0), TestCase::Duration::QUICK);
304 AddTestCase(new LteEnbAntennaTestCase(-120.0, 120.0, -1, 2, -15.578),
305 TestCase::Duration::QUICK);
306 AddTestCase(new LteEnbAntennaTestCase(-120.0, 120.0, 1, 0, -14.457), TestCase::Duration::QUICK);
307 AddTestCase(new LteEnbAntennaTestCase(-120.0, 120.0, 1, 2, -73.154), TestCase::Duration::QUICK);
308 AddTestCase(new LteEnbAntennaTestCase(-120.0, 120.0, 1, -0.1, -12.754),
309 TestCase::Duration::QUICK);
310}
311
312/**
313 * \ingroup lte-test
314 * Static variable for test initialization
315 */
Lte Enb Antenna Test Suite.
Tests that the propagation model and the antenna parameters are generate the correct values.
double m_orientationDegrees
antenna orientation in degrees
double m_antennaGainDb
antenna gain in dB
static std::string BuildNameString(double orientationDegrees, double beamwidthDegrees, double x, double y)
Build name string.
double m_x
x position of the UE
double m_beamwidthDegrees
antenna beamwidth in degrees
double m_y
y position of the UE
void DoRun() override
Implementation to actually run this TestCase.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Hold variables of type enum.
Definition enum.h:52
This class contains the specification of EPS Bearers.
Definition eps-bearer.h:80
Qci
QoS Class Indicator.
Definition eps-bearer.h:95
@ NGBR_VIDEO_TCP_DEFAULT
Non-GBR TCP-based Video (Buffered Streaming, e.g., www, e-mail...)
Definition eps-bearer.h:115
The eNodeB device implementation.
double GetPathloss(uint16_t cellId, uint64_t imsi)
The LtePhy models the physical layer of LTE.
Definition lte-phy.h:40
A sink to be plugged to the callback of LteChunkProcessor allowing to save and later retrieve the lat...
Ptr< SpectrumValue > GetValue()
void ReportValue(const SpectrumValue &value)
function to be plugged to LteChunkProcessor::AddCallback ()
The LteUeNetDevice class implements the UE net device.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition object.h:511
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
Hold variables of type string.
Definition string.h:45
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
Hold an unsigned integer type.
Definition uinteger.h:34
void Reset()
Reset the initial value of every attribute as well as the value of every global to what they were bef...
Definition config.cc:848
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:883
void Connect(std::string path, const CallbackBase &cb)
Definition config.cc:967
#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 ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
static LteAntennaTestSuite g_lteAntennaTestSuite
Static variable for test initialization.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
#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
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition callback.h:684