5G-LENA nr-v3.0-33-g7aea1e4
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
node-distribution-scenario-interface.cc
1/* Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; */
2
3// Copyright (c) 2019 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4//
5// SPDX-License-Identifier: GPL-2.0-only
6
7#include "node-distribution-scenario-interface.h"
8
9#include <cmath> // cos, sin, M_PI (non-standard)
10
11namespace ns3
12{
13
17
18const NodeContainer&
23
24const NodeContainer&
29
30void
32{
33 NS_ASSERT_MSG(m_sectorization != SiteSectorizationType::NONE, "Must set sectorization first.");
34 m_numSites = n;
35 auto sectors = static_cast<std::size_t>(m_sectorization);
36 m_numBs = m_numSites * sectors;
37}
38
39void
41{
42 NS_ASSERT_MSG(m_sectorization != SiteSectorizationType::NONE, "Must set sectorization first.");
43 auto sectors = static_cast<std::size_t>(m_sectorization);
44 // Compute the number of sites, then set that,
45 // so m_numBs is consistent with sectorization
46 std::size_t sites = n / sectors;
47 SetSitesNumber(sites);
48}
49
50void
55
56std::size_t
61
62std::size_t
67
68double
70{
71 double orientation = 0.0;
73 {
74 auto sectors = static_cast<std::size_t>(m_sectorization);
75 std::size_t sector = cellId % sectors;
76 double sectorSize = 360.0 / sectors;
77 orientation = sectorSize * (sector + 0.25); // First sector starts at 0
78 }
79 return orientation;
80}
81
82double
84{
85 double orientationRads = GetAntennaOrientationDegrees(cellId) * M_PI / 180;
86 if (orientationRads > M_PI)
87 {
88 orientationRads -= 2 * M_PI;
89 }
90
91 return orientationRads;
92}
93
94uint16_t
96{
97 auto sectors = static_cast<std::size_t>(m_sectorization);
98 return cellId / sectors;
99}
100
101uint16_t
103{
104 auto sectors = static_cast<std::size_t>(m_sectorization);
105 return cellId % sectors;
106}
107
108uint16_t
110{
111 return ueId % m_numBs;
112}
113
114Vector
115NodeDistributionScenarioInterface::GetAntennaPosition(const Vector& sitePos, uint16_t cellId) const
116{
117 Vector pos(sitePos);
118
119 double angle = GetAntennaOrientationDegrees(cellId);
120 pos.x += m_antennaOffset * cos(angle * M_PI / 180);
121 pos.y += m_antennaOffset * sin(angle * M_PI / 180);
122 return pos;
123}
124
125} // 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.