A Discrete-Event Network Simulator
API
lena-rem-sector-antenna.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Jaume Nin <jnin@cttc.es>
19  */
20 
21 #include "ns3/core-module.h"
22 #include "ns3/network-module.h"
23 #include "ns3/mobility-module.h"
24 #include "ns3/lte-module.h"
25 #include "ns3/config-store.h"
26 #include <ns3/buildings-propagation-loss-model.h>
27 #include <ns3/buildings-helper.h>
28 #include <ns3/radio-environment-map-helper.h>
29 #include <iomanip>
30 #include <string>
31 #include <vector>
32 //#include "ns3/gtk-config-store.h"
33 
34 using namespace ns3;
35 using std::vector;
36 
37 int
38 main (int argc, char *argv[])
39 {
40  CommandLine cmd (__FILE__);
41  cmd.Parse (argc, argv);
42 
43  ConfigStore inputConfig;
44  inputConfig.ConfigureDefaults ();
45 
46  cmd.Parse (argc, argv);
47 
48  // Geometry of the scenario (in meters)
49  // Assume squared building
50  double nodeHeight = 1.5;
51  double roomHeight = 3;
52  double roomLength = 500;
53  uint32_t nRooms = 2;
54  // Create one eNodeB per room + one 3 sector eNodeB (i.e. 3 eNodeB) + one regular eNodeB
55  uint32_t nEnb = nRooms*nRooms + 4;
56  uint32_t nUe = 1;
57 
58  Ptr < LteHelper > lteHelper = CreateObject<LteHelper> ();
59  //lteHelper->EnableLogComponents ();
60  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisPropagationLossModel"));
61 
62  // Create Nodes: eNodeB and UE
63  NodeContainer enbNodes;
64  NodeContainer oneSectorNodes;
65  NodeContainer threeSectorNodes;
66  vector < NodeContainer > ueNodes;
67 
68  oneSectorNodes.Create (nEnb-3);
69  threeSectorNodes.Create (3);
70 
71  enbNodes.Add (oneSectorNodes);
72  enbNodes.Add (threeSectorNodes);
73 
74  for (uint32_t i = 0; i < nEnb; i++)
75  {
76  NodeContainer ueNode;
77  ueNode.Create (nUe);
78  ueNodes.push_back (ueNode);
79  }
80 
82  vector<Vector> enbPosition;
83  Ptr < ListPositionAllocator > positionAlloc = CreateObject<ListPositionAllocator> ();
84  Ptr < Building > building;
85  building = Create<Building> ();
86  building->SetBoundaries (Box (0.0, nRooms * roomLength,
87  0.0, nRooms * roomLength,
88  0.0, roomHeight));
89  building->SetBuildingType (Building::Residential);
90  building->SetExtWallsType (Building::ConcreteWithWindows);
91  building->SetNFloors (1);
92  building->SetNRoomsX (nRooms);
93  building->SetNRoomsY (nRooms);
94  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
95  mobility.Install (enbNodes);
96  BuildingsHelper::Install (enbNodes);
97  uint32_t plantedEnb = 0;
98  for (uint32_t row = 0; row < nRooms; row++)
99  {
100  for (uint32_t column = 0; column < nRooms; column++, plantedEnb++)
101  {
102  Vector v (roomLength * (column + 0.5),
103  roomLength * (row + 0.5),
104  nodeHeight );
105  positionAlloc->Add (v);
106  enbPosition.push_back (v);
107  Ptr<MobilityModel> mmEnb = enbNodes.Get (plantedEnb)->GetObject<MobilityModel> ();
108  mmEnb->SetPosition (v);
109  }
110  }
111 
112  // Add a 1-sector site
113  Vector v (500, 3000, nodeHeight);
114  positionAlloc->Add (v);
115  enbPosition.push_back (v);
116  mobility.Install (ueNodes.at(plantedEnb));
117  plantedEnb++;
118 
119  // Add the 3-sector site
120  for (uint32_t index = 0; index < 3; index++, plantedEnb++)
121  {
122  Vector v (500, 2000, nodeHeight);
123  positionAlloc->Add (v);
124  enbPosition.push_back (v);
125  mobility.Install (ueNodes.at(plantedEnb));
126  }
127 
128 
129  mobility.SetPositionAllocator (positionAlloc);
130  mobility.Install (enbNodes);
131 
132  // Position of UEs attached to eNB
133  for (uint32_t i = 0; i < nEnb; i++)
134  {
135  Ptr<UniformRandomVariable> posX = CreateObject<UniformRandomVariable> ();
136  posX->SetAttribute ("Min", DoubleValue (enbPosition.at(i).x - roomLength * 0));
137  posX->SetAttribute ("Max", DoubleValue (enbPosition.at(i).x + roomLength * 0));
138  Ptr<UniformRandomVariable> posY = CreateObject<UniformRandomVariable> ();
139  posY->SetAttribute ("Min", DoubleValue (enbPosition.at(i).y - roomLength * 0));
140  posY->SetAttribute ("Max", DoubleValue (enbPosition.at(i).y + roomLength * 0));
141  positionAlloc = CreateObject<ListPositionAllocator> ();
142  for (uint32_t j = 0; j < nUe; j++)
143  {
144  if ( i == nEnb - 3 )
145  {
146  positionAlloc->Add (Vector (enbPosition.at(i).x + 10, enbPosition.at(i).y, nodeHeight));
147  }
148  else if ( i == nEnb - 2 )
149  {
150  positionAlloc->Add (Vector (enbPosition.at(i).x - std::sqrt (10), enbPosition.at(i).y + std::sqrt (10), nodeHeight));
151  }
152  else if ( i == nEnb - 1 )
153  {
154  positionAlloc->Add (Vector (enbPosition.at(i).x - std::sqrt (10), enbPosition.at(i).y - std::sqrt (10), nodeHeight));
155  }
156  else
157  {
158  positionAlloc->Add (Vector (posX->GetValue (), posY->GetValue (), nodeHeight));
159  }
160  mobility.SetPositionAllocator (positionAlloc);
161  }
162  mobility.Install (ueNodes.at(i));
163  BuildingsHelper::Install (ueNodes.at(i));
164  }
165 
166  // Create Devices and install them in the Nodes (eNB and UE)
167  NetDeviceContainer enbDevs;
168  vector < NetDeviceContainer > ueDevs;
169 
170  // power setting in dBm for small cells
171  Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (20.0));
172  enbDevs = lteHelper->InstallEnbDevice (oneSectorNodes);
173 
174 
175  // power setting for three-sector macrocell
176  Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (43.0));
177 
178  // Beam width is made quite narrow so sectors can be noticed in the REM
179  lteHelper->SetEnbAntennaModelType ("ns3::CosineAntennaModel");
180  lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (0));
181  lteHelper->SetEnbAntennaModelAttribute ("HorizontalBeamwidth", DoubleValue (100));
182  lteHelper->SetEnbAntennaModelAttribute ("MaxGain", DoubleValue (0.0));
183  enbDevs.Add ( lteHelper->InstallEnbDevice (threeSectorNodes.Get (0)));
184 
185  lteHelper->SetEnbAntennaModelType ("ns3::CosineAntennaModel");
186  lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (360/3));
187  lteHelper->SetEnbAntennaModelAttribute ("HorizontalBeamwidth", DoubleValue (100));
188  lteHelper->SetEnbAntennaModelAttribute ("MaxGain", DoubleValue (0.0));
189  enbDevs.Add ( lteHelper->InstallEnbDevice (threeSectorNodes.Get (1)));
190 
191  lteHelper->SetEnbAntennaModelType ("ns3::CosineAntennaModel");
192  lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (2*360/3));
193  lteHelper->SetEnbAntennaModelAttribute ("HorizontalBeamwidth", DoubleValue (100));
194  lteHelper->SetEnbAntennaModelAttribute ("MaxGain", DoubleValue (0.0));
195  enbDevs.Add ( lteHelper->InstallEnbDevice (threeSectorNodes.Get (2)));
196 
197  for (uint32_t i = 0; i < nEnb; i++)
198  {
199  NetDeviceContainer ueDev = lteHelper->InstallUeDevice (ueNodes.at(i));
200  ueDevs.push_back (ueDev);
201  lteHelper->Attach (ueDev, enbDevs.Get (i));
203  EpsBearer bearer (q);
204  lteHelper->ActivateDataRadioBearer (ueDev, bearer);
205  }
206 
207  // by default, simulation will anyway stop right after the REM has been generated
208  Simulator::Stop (Seconds (0.0069));
209 
210  Ptr<RadioEnvironmentMapHelper> remHelper = CreateObject<RadioEnvironmentMapHelper> ();
211  remHelper->SetAttribute ("ChannelPath", StringValue ("/ChannelList/0"));
212  remHelper->SetAttribute ("OutputFile", StringValue ("rem.out"));
213  remHelper->SetAttribute ("XMin", DoubleValue (-2000.0));
214  remHelper->SetAttribute ("XMax", DoubleValue (+2000.0));
215  remHelper->SetAttribute ("YMin", DoubleValue (-500.0));
216  remHelper->SetAttribute ("YMax", DoubleValue (+3500.0));
217  remHelper->SetAttribute ("Z", DoubleValue (1.5));
218  remHelper->Install ();
219 
220  Simulator::Run ();
221 
222 // GtkConfigStore config;
223 // config.ConfigureAttributes ();
224 
225  lteHelper = 0;
227  return 0;
228 }
a 3d box
Definition: box.h:35
@ ConcreteWithWindows
Definition: building.h:60
static void Install(Ptr< Node > node)
Install the MobilityBuildingInfo to a node.
Parse command-line arguments.
Definition: command-line.h:229
Introspection did not find any typical Config paths.
Definition: config-store.h:60
void ConfigureDefaults(void)
Configure the default values.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:92
Qci
QoS Class Indicator.
Definition: eps-bearer.h:107
@ GBR_CONV_VOICE
GBR Conversational Voice.
Definition: eps-bearer.h:108
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:474
void SetEnbAntennaModelType(std::string type)
Set the type of antenna model to be used by eNodeB devices.
Definition: lte-helper.cc:408
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
Definition: lte-helper.cc:959
void SetEnbAntennaModelAttribute(std::string n, const AttributeValue &v)
Set an attribute for the eNodeB antenna model to be created.
Definition: lte-helper.cc:415
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1313
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:489
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
void SetPosition(const Vector &position)
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
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.
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:256
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:180
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:136
static void Run(void)
Run the simulation.
Definition: simulator.cc:172
Hold variables of type string.
Definition: string.h:41
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:849
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
Every class exported by the ns3 library is enclosed in the ns3 namespace.
cmd
Definition: second.py:35
mobility
Definition: third.py:108