162 NS_ASSERT_MSG(m_bsPositioner,
"Must Add() a position file before CreateScenario()");
168 NS_ASSERT_MSG(
m_bsHeight >= 0.0,
"Must SetBsHeight() before CreateScenario()");
169 NS_ASSERT_MSG(
m_utHeight >= 0.0,
"Must SetUtHeight() before CreateScenario()");
172 std::cout <<
" creating BS" << std::endl;
174 std::cout <<
" creating UE" << std::endl;
178 double maxRadius = 0;
181 std::cout <<
" reserving sitePositions" << std::endl;
182 std::vector<Vector> sitePositions;
186 std::cout <<
" creating bsPositions" << std::endl;
187 Ptr<ListPositionAllocator> bsPositions = CreateObject<ListPositionAllocator>();
188 std::size_t cellId = 0;
189 for (std::size_t siteId = 0; siteId <
m_numSites; ++siteId)
191 Vector site = m_bsPositioner->GetNext();
192 sitePositions.push_back(site);
194 maxRadius = std::max(maxRadius, std::abs(site.x));
195 maxRadius = std::max(maxRadius, std::abs(site.y));
197 std::cout <<
" sectors for site " << siteId << std::endl;
198 for (std::size_t sector = 0; sector < sectors; ++sector)
205 bsPositions->Add(bs);
211 NS_ASSERT_MSG(cellId ==
m_numBs,
212 "Computed positions for " << cellId <<
" cells, expected " <<
m_numBs);
214 std::cout <<
" BS mobility" << std::endl;
215 MobilityHelper mobility;
216 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
217 mobility.SetPositionAllocator(m_bsPositioner);
218 mobility.Install(
m_bs);
222 std::cout <<
" computing average Isd..." << std::flush;
223 for (
auto v = sitePositions.begin(); v != sitePositions.end(); ++v)
227 for (; w < sitePositions.end(); ++w)
230 double range = (*w - *v).GetLength();
237 std::cout << effIsd << std::endl;
240 std::cout <<
" UE positions" << std::endl;
243 std::cout <<
" radius rng..." << std::flush;
244 Ptr<UniformRandomVariable> r = CreateObject<UniformRandomVariable>();
245 std::cout <<
"setting stream..." << std::flush;
246 r->SetStream(RngSeedManager::GetNextStreamIndex());
247 std::cout <<
"done" << std::endl;
248 const double outerR = std::min(effIsd,
m_isd);
253 r->SetAttribute(
"Max", DoubleValue(outerR * outerR));
255 std::cout <<
" using effIsd " << outerR << std::endl;
257 std::cout <<
" theta rng..." << std::flush;
258 Ptr<UniformRandomVariable> theta = CreateObject<UniformRandomVariable>();
259 std::cout <<
"setting stream..." << std::flush;
260 theta->SetStream(RngSeedManager::GetNextStreamIndex());
261 std::cout <<
"done" << std::endl;
263 Ptr<ListPositionAllocator> utPositioner = CreateObject<ListPositionAllocator>();
265 for (uint32_t utId = 0; utId <
m_numUt; ++utId)
269 Vector cellPos = sitePositions[siteId];
273 double d = std::sqrt(r->GetValue());
275 double halfWidth = 2 * M_PI / sectors / 2;
276 theta->SetAttribute(
"Min", DoubleValue(boreSight - halfWidth));
277 theta->SetAttribute(
"Max", DoubleValue(boreSight + halfWidth));
278 double t = theta->GetValue();
280 Vector utPos(cellPos);
281 utPos.x += d * cos(t);
282 utPos.y += d * sin(t);
285 utPositioner->Add(utPos);
288 std::cout <<
" UE mobility" << std::endl;
289 mobility.SetPositionAllocator(utPositioner);
290 mobility.Install(
m_ut);
292 std::cout <<
" plot deployment" << std::endl;
293 PlotDeployment(m_bsPositioner, utPositioner, sectors, maxRadius, outerR);
295 m_scenarioCreated =
true;
void Add(const std::string filePath, char delimiter=',')
Add the positions listed in a file. The file should be a simple text file, with one position per line...
void PlotDeployment(const Ptr< const ListPositionAllocator > &sitePositioner, const Ptr< const ListPositionAllocator > &utPositioner, const std::size_t numSectors, const double maxRadius, const double effIsd)
Creates a GNUPLOT with the deployment including base stations (BS) and user terminals (UT)....