5G-LENA nr-v3.1-14-g738b08bc
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
node-distribution-scenario-interface.cc
1// Copyright (c) 2019 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#include "node-distribution-scenario-interface.h"
6
7#include <cmath> // cos, sin, M_PI (non-standard)
8
9namespace ns3
10{
11
15
16const NodeContainer&
21
22const NodeContainer&
27
28void
30{
31 NS_ASSERT_MSG(m_sectorization != SiteSectorizationType::NONE, "Must set sectorization first.");
32 m_numSites = n;
33 auto sectors = static_cast<std::size_t>(m_sectorization);
34 m_numBs = m_numSites * sectors;
35}
36
37void
39{
40 NS_ASSERT_MSG(m_sectorization != SiteSectorizationType::NONE, "Must set sectorization first.");
41 auto sectors = static_cast<std::size_t>(m_sectorization);
42 // Compute the number of sites, then set that,
43 // so m_numBs is consistent with sectorization
44 std::size_t sites = n / sectors;
45 SetSitesNumber(sites);
46}
47
48void
53
54std::size_t
59
60std::size_t
65
66double
68{
69 double orientation = 0.0;
71 {
72 auto sectors = static_cast<std::size_t>(m_sectorization);
73 std::size_t sector = cellId % sectors;
74 double sectorSize = 360.0 / sectors;
75 orientation = sectorSize * (sector + 0.25); // First sector starts at 0
76 }
77 return orientation;
78}
79
80double
82{
83 double orientationRads = GetAntennaOrientationDegrees(cellId) * M_PI / 180;
84 if (orientationRads > M_PI)
85 {
86 orientationRads -= 2 * M_PI;
87 }
88
89 return orientationRads;
90}
91
92uint16_t
94{
95 auto sectors = static_cast<std::size_t>(m_sectorization);
96 return cellId / sectors;
97}
98
99uint16_t
101{
102 auto sectors = static_cast<std::size_t>(m_sectorization);
103 return cellId % sectors;
104}
105
106uint16_t
108{
109 return ueId % m_numBs;
110}
111
112Vector
113NodeDistributionScenarioInterface::GetAntennaPosition(const Vector& sitePos, uint16_t cellId) const
114{
115 Vector pos(sitePos);
116
117 double angle = GetAntennaOrientationDegrees(cellId);
118 pos.x += m_antennaOffset * cos(angle * M_PI / 180);
119 pos.y += m_antennaOffset * sin(angle * M_PI / 180);
120 return pos;
121}
122
123} // namespace ns3
const NodeContainer & GetUserTerminals() const
Get the list of user nodes.
std::size_t GetNumSites() const
Gets the number of sites with cell base stations.
std::size_t m_numBs
Number of base stations to create.
uint16_t GetSiteIndex(std::size_t cellId) const
Gets the site index the queried cell id belongs to.
void SetBsNumber(std::size_t n)
Set the number of base stations.
uint16_t GetCellIndex(std::size_t ueId) const
Get the cell (base station) index the queried UE id belongs to.
Vector GetAntennaPosition(const Vector &sitePos, uint16_t cellId) const
Returns the position of the cell antenna.
std::size_t m_numUt
Number of user terminals to create.
void SetUtNumber(std::size_t n)
Set the number of UT/UE.
std::size_t m_numSites
Number of sites with base stations.
void SetSitesNumber(std::size_t n)
Set number of sites/towers.
~NodeDistributionScenarioInterface() override
~NodeDistributionScenarioInterface
double GetAntennaOrientationDegrees(std::size_t cellId) const
Returns the orientation in degrees of the antenna array for the given cellId. The orientation is the ...
uint16_t GetSectorIndex(std::size_t cellId) const
Get the sector index the queried cell id belongs to.
std::size_t GetNumCells() const
Gets the total number of cells deployed.
const NodeContainer & GetBaseStations() const
Get the list of gnb/base station nodes.
double GetAntennaOrientationRadians(std::size_t cellId) const
Returns the orientation in radians of the antenna array for the given cellId.
SiteSectorizationType m_sectorization
Number of sectors per site.
@ NONE
Unconfigured value.
@ TRIPLE
Site with 3 120ยบ-width sectors.
double m_antennaOffset
Cell antenna offset in meters w.r.t. site location.