A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
lena-rem-sector-antenna.cc
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;
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 
81  MobilityHelper mobility;
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::BuildingsMobilityModel");
95  mobility.Install (enbNodes);
96  uint32_t plantedEnb = 0;
97  for (uint32_t row = 0; row < nRooms; row++)
98  {
99  for (uint32_t column = 0; column < nRooms; column++, plantedEnb++)
100  {
101  Vector v (roomLength * (column + 0.5),
102  roomLength * (row + 0.5),
103  nodeHeight );
104  positionAlloc->Add (v);
105  enbPosition.push_back (v);
106  Ptr<BuildingsMobilityModel> mmEnb = enbNodes.Get (plantedEnb)->GetObject<BuildingsMobilityModel> ();
107  mmEnb->SetPosition (v);
108  }
109  }
110 
111  // Add a 1-sector site
112  Vector v (500, 3000, nodeHeight);
113  positionAlloc->Add (v);
114  enbPosition.push_back (v);
115  mobility.Install (ueNodes.at(plantedEnb));
116  plantedEnb++;
117 
118  // Add the 3-sector site
119  for (uint32_t index = 0; index < 3; index++, plantedEnb++)
120  {
121  Vector v (500, 2000, nodeHeight);
122  positionAlloc->Add (v);
123  enbPosition.push_back (v);
124  mobility.Install (ueNodes.at(plantedEnb));
125  }
126 
127 
128  mobility.SetPositionAllocator (positionAlloc);
129  mobility.Install (enbNodes);
130 
131  // Position of UEs attached to eNB
132  for (uint32_t i = 0; i < nEnb; i++)
133  {
134  Ptr<UniformRandomVariable> posX = CreateObject<UniformRandomVariable> ();
135  posX->SetAttribute ("Min", DoubleValue (enbPosition.at(i).x - roomLength * 0));
136  posX->SetAttribute ("Max", DoubleValue (enbPosition.at(i).x + roomLength * 0));
137  Ptr<UniformRandomVariable> posY = CreateObject<UniformRandomVariable> ();
138  posY->SetAttribute ("Min", DoubleValue (enbPosition.at(i).y - roomLength * 0));
139  posY->SetAttribute ("Max", DoubleValue (enbPosition.at(i).y + roomLength * 0));
140  positionAlloc = CreateObject<ListPositionAllocator> ();
141  for (uint32_t j = 0; j < nUe; j++)
142  {
143  if ( i == nEnb - 3 )
144  {
145  positionAlloc->Add (Vector (enbPosition.at(i).x + 10, enbPosition.at(i).y, nodeHeight));
146  }
147  else if ( i == nEnb - 2 )
148  {
149  positionAlloc->Add (Vector (enbPosition.at(i).x - std::sqrt (10), enbPosition.at(i).y + std::sqrt (10), nodeHeight));
150  }
151  else if ( i == nEnb - 1 )
152  {
153  positionAlloc->Add (Vector (enbPosition.at(i).x - std::sqrt (10), enbPosition.at(i).y - std::sqrt (10), nodeHeight));
154  }
155  else
156  {
157  positionAlloc->Add (Vector (posX->GetValue (), posY->GetValue (), nodeHeight));
158  }
159  mobility.SetPositionAllocator (positionAlloc);
160  }
161  mobility.Install (ueNodes.at(i));
162  }
163 
164  // Create Devices and install them in the Nodes (eNB and UE)
165  NetDeviceContainer enbDevs;
166  vector < NetDeviceContainer > ueDevs;
167 
168  // power setting in dBm for small cells
169  Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (20.0));
170  enbDevs = lteHelper->InstallEnbDevice (oneSectorNodes);
171 
172 
173  // power setting for three-sector macrocell
174  Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (43.0));
175 
176  // Beam width is made quite narrow so sectors can be noticed in the REM
177  lteHelper->SetEnbAntennaModelType ("ns3::CosineAntennaModel");
178  lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (0));
179  lteHelper->SetEnbAntennaModelAttribute ("Beamwidth", DoubleValue (100));
180  lteHelper->SetEnbAntennaModelAttribute ("MaxGain", DoubleValue (0.0));
181  enbDevs.Add ( lteHelper->InstallEnbDevice (threeSectorNodes.Get (0)));
182 
183  lteHelper->SetEnbAntennaModelType ("ns3::CosineAntennaModel");
184  lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (360/3));
185  lteHelper->SetEnbAntennaModelAttribute ("Beamwidth", DoubleValue (100));
186  lteHelper->SetEnbAntennaModelAttribute ("MaxGain", DoubleValue (0.0));
187  enbDevs.Add ( lteHelper->InstallEnbDevice (threeSectorNodes.Get (1)));
188 
189  lteHelper->SetEnbAntennaModelType ("ns3::CosineAntennaModel");
190  lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (2*360/3));
191  lteHelper->SetEnbAntennaModelAttribute ("Beamwidth", DoubleValue (100));
192  lteHelper->SetEnbAntennaModelAttribute ("MaxGain", DoubleValue (0.0));
193  enbDevs.Add ( lteHelper->InstallEnbDevice (threeSectorNodes.Get (2)));
194 
195  for (uint32_t i = 0; i < nEnb; i++)
196  {
197  NetDeviceContainer ueDev = lteHelper->InstallUeDevice (ueNodes.at(i));
198  ueDevs.push_back (ueDev);
199  lteHelper->Attach (ueDev, enbDevs.Get (i));
200  enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
201  EpsBearer bearer (q);
202  lteHelper->ActivateDataRadioBearer (ueDev, bearer);
203  }
204 
205 
206  BuildingsHelper::MakeMobilityModelConsistent ();
207 
208  // by default, simulation will anyway stop right after the REM has been generated
209  Simulator::Stop (Seconds (0.0069));
210 
211  Ptr<RadioEnvironmentMapHelper> remHelper = CreateObject<RadioEnvironmentMapHelper> ();
212  remHelper->SetAttribute ("ChannelPath", StringValue ("/ChannelList/0"));
213  remHelper->SetAttribute ("OutputFile", StringValue ("rem.out"));
214  remHelper->SetAttribute ("XMin", DoubleValue (-2000.0));
215  remHelper->SetAttribute ("XMax", DoubleValue (+2000.0));
216  remHelper->SetAttribute ("YMin", DoubleValue (-500.0));
217  remHelper->SetAttribute ("YMax", DoubleValue (+3500.0));
218  remHelper->SetAttribute ("Z", DoubleValue (1.5));
219  remHelper->Install ();
220 
221  Simulator::Run ();
222 
223 // GtkConfigStore config;
224 // config.ConfigureAttributes ();
225 
226  lteHelper = 0;
228  return 0;
229 }
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Definition: lte-helper.cc:285
hold variables of type string
Definition: string.h:19
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
static void Run(void)
Definition: simulator.cc:157
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Definition: lte-helper.cc:773
a 3d vector
Definition: vector.h:31
a 3d box
Definition: box.h:33
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
void Attach(NetDeviceContainer ueDevices, Ptr< NetDevice > enbDevice)
Definition: lte-helper.cc:562
Buildings mobility model.
holds a vector of ns3::NetDevice pointers
parse command-line argumentsInstances of this class can be used to parse command-line arguments: user...
Definition: command-line.h:50
void SetEnbAntennaModelType(std::string type)
Definition: lte-helper.cc:225
static void Destroy(void)
Definition: simulator.cc:121
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:667
keep track of a set of node pointers.
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
double GetValue(double min, double max)
Returns a random double from the uniform distribution with the specified range.
void SetPosition(const Vector &position)
NetDeviceContainer InstallUeDevice(NodeContainer c)
Definition: lte-helper.cc:300
Helper class used to assign positions and mobility models to nodes.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Definition: nstime.h:586
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
static void Stop(void)
Definition: simulator.cc:164
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void Parse(int argc, char *argv[]) const
Definition: command-line.cc:84
void SetEnbAntennaModelAttribute(std::string n, const AttributeValue &v)
Definition: lte-helper.cc:232
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Hold an floating point type.
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Definition: object-base.cc:160
Ptr< T > GetObject(void) const
Definition: object.h:332