A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lena-profiling.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Jaume Nin <jnin@cttc.es>
7 */
8
9#include "ns3/config-store.h"
10#include "ns3/core-module.h"
11#include "ns3/lte-module.h"
12#include "ns3/mobility-module.h"
13#include "ns3/network-module.h"
14#include <ns3/buildings-module.h>
15
16#include <iomanip>
17#include <string>
18#include <vector>
19// #include "ns3/gtk-config-store.h"
20
21using namespace ns3;
22
23int
24main(int argc, char* argv[])
25{
26 uint32_t nEnbPerFloor = 1;
27 uint32_t nUe = 1;
28 uint32_t nFloors = 0;
29 double simTime = 1.0;
30 CommandLine cmd(__FILE__);
31
32 cmd.AddValue("nEnb", "Number of eNodeBs per floor", nEnbPerFloor);
33 cmd.AddValue("nUe", "Number of UEs", nUe);
34 cmd.AddValue("nFloors", "Number of floors, 0 for Friis propagation model", nFloors);
35 cmd.AddValue("simTime", "Total duration of the simulation (in seconds)", simTime);
36 cmd.Parse(argc, argv);
37
38 ConfigStore inputConfig;
39 inputConfig.ConfigureDefaults();
40
41 // parse again so you can override default values from the command line
42 cmd.Parse(argc, argv);
43
44 // Geometry of the scenario (in meters)
45 // Assume squared building
46 double nodeHeight = 1.5;
47 double roomHeight = 3;
48 double roomLength = 8;
49 uint32_t nRooms = std::ceil(std::sqrt(nEnbPerFloor));
50 uint32_t nEnb;
51
53 // lteHelper->EnableLogComponents ();
54 // LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL);
55 if (nFloors == 0)
56 {
57 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisPropagationLossModel"));
58 nEnb = nEnbPerFloor;
59 }
60 else
61 {
62 lteHelper->SetAttribute("PathlossModel",
63 StringValue("ns3::HybridBuildingsPropagationLossModel"));
64 nEnb = nFloors * nEnbPerFloor;
65 }
66
67 // Create Nodes: eNodeB and UE
68 NodeContainer enbNodes;
69 std::vector<NodeContainer> ueNodes;
70
71 enbNodes.Create(nEnb);
72 for (uint32_t i = 0; i < nEnb; i++)
73 {
74 NodeContainer ueNode;
75 ueNode.Create(nUe);
76 ueNodes.push_back(ueNode);
77 }
78
80 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
81 std::vector<Vector> enbPosition;
83 Ptr<Building> building;
84
85 if (nFloors == 0)
86 {
87 // Position of eNBs
88 uint32_t plantedEnb = 0;
89 for (uint32_t row = 0; row < nRooms; row++)
90 {
91 for (uint32_t column = 0; column < nRooms && plantedEnb < nEnbPerFloor;
92 column++, plantedEnb++)
93 {
94 Vector v(roomLength * (column + 0.5), roomLength * (row + 0.5), nodeHeight);
95 positionAlloc->Add(v);
96 enbPosition.push_back(v);
97 mobility.Install(ueNodes.at(plantedEnb));
98 }
99 }
100 mobility.SetPositionAllocator(positionAlloc);
101 mobility.Install(enbNodes);
102 BuildingsHelper::Install(enbNodes);
103
104 // Position of UEs attached to eNB
105 for (uint32_t i = 0; i < nEnb; i++)
106 {
108 posX->SetAttribute("Min", DoubleValue(enbPosition.at(i).x - roomLength * 0.5));
109 posX->SetAttribute("Max", DoubleValue(enbPosition.at(i).x + roomLength * 0.5));
111 posY->SetAttribute("Min", DoubleValue(enbPosition.at(i).y - roomLength * 0.5));
112 posY->SetAttribute("Max", DoubleValue(enbPosition.at(i).y + roomLength * 0.5));
113 positionAlloc = CreateObject<ListPositionAllocator>();
114 for (uint32_t j = 0; j < nUe; j++)
115 {
116 positionAlloc->Add(Vector(posX->GetValue(), posY->GetValue(), nodeHeight));
117 mobility.SetPositionAllocator(positionAlloc);
118 }
119 mobility.Install(ueNodes.at(i));
120 BuildingsHelper::Install(ueNodes.at(i));
121 }
122 }
123 else
124 {
125 building = CreateObject<Building>();
126 building->SetBoundaries(
127 Box(0.0, nRooms * roomLength, 0.0, nRooms * roomLength, 0.0, nFloors * roomHeight));
128 building->SetBuildingType(Building::Residential);
129 building->SetExtWallsType(Building::ConcreteWithWindows);
130 building->SetNFloors(nFloors);
131 building->SetNRoomsX(nRooms);
132 building->SetNRoomsY(nRooms);
133 mobility.Install(enbNodes);
134 BuildingsHelper::Install(enbNodes);
135 uint32_t plantedEnb = 0;
136 for (uint32_t floor = 0; floor < nFloors; floor++)
137 {
138 uint32_t plantedEnbPerFloor = 0;
139 for (uint32_t row = 0; row < nRooms; row++)
140 {
141 for (uint32_t column = 0; column < nRooms && plantedEnbPerFloor < nEnbPerFloor;
142 column++, plantedEnb++, plantedEnbPerFloor++)
143 {
144 Vector v(roomLength * (column + 0.5),
145 roomLength * (row + 0.5),
146 nodeHeight + roomHeight * floor);
147 positionAlloc->Add(v);
148 enbPosition.push_back(v);
149 Ptr<MobilityModel> mmEnb = enbNodes.Get(plantedEnb)->GetObject<MobilityModel>();
150 mmEnb->SetPosition(v);
151
152 // Positioning UEs attached to eNB
153 mobility.Install(ueNodes.at(plantedEnb));
154 BuildingsHelper::Install(ueNodes.at(plantedEnb));
155 for (uint32_t ue = 0; ue < nUe; ue++)
156 {
157 Ptr<MobilityModel> mmUe =
158 ueNodes.at(plantedEnb).Get(ue)->GetObject<MobilityModel>();
159 Vector vUe(v.x, v.y, v.z);
160 mmUe->SetPosition(vUe);
161 }
162 }
163 }
164 }
165 }
166
167 // Create Devices and install them in the Nodes (eNB and UE)
168 NetDeviceContainer enbDevs;
169 std::vector<NetDeviceContainer> ueDevs;
170 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
171 for (uint32_t i = 0; i < nEnb; i++)
172 {
173 NetDeviceContainer ueDev = lteHelper->InstallUeDevice(ueNodes.at(i));
174 ueDevs.push_back(ueDev);
175 lteHelper->Attach(ueDev, enbDevs.Get(i));
177 EpsBearer bearer(q);
178 lteHelper->ActivateDataRadioBearer(ueDev, bearer);
179 }
180
181 Simulator::Stop(Seconds(simTime));
182 lteHelper->EnableTraces();
183
185
186 /*GtkConfigStore config;
187 config.ConfigureAttributes ();*/
188
190 return 0;
191}
a 3d box
Definition box.h:24
@ ConcreteWithWindows
Definition building.h:58
static void Install(Ptr< Node > node)
Install the MobilityBuildingInfo to a node.
Parse command-line arguments.
void ConfigureDefaults()
Configure the default values.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
This class contains the specification of EPS Bearers.
Definition eps-bearer.h:80
Qci
QoS Class Indicator.
Definition eps-bearer.h:95
@ GBR_CONV_VOICE
GBR Conversational Voice.
Definition eps-bearer.h:96
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
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< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
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
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
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.
mobility
Definition third.py:92