A Discrete-Event Network Simulator
API
lena-simple.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2018 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Manuel Requena <manuel.requena@cttc.es>
18  */
19 
20 #include "ns3/config-store.h"
21 #include "ns3/core-module.h"
22 #include "ns3/lte-module.h"
23 #include "ns3/mobility-module.h"
24 #include "ns3/network-module.h"
25 #include <ns3/buildings-helper.h>
26 // #include "ns3/gtk-config-store.h"
27 
28 using namespace ns3;
29 
30 int
31 main(int argc, char* argv[])
32 {
33  Time simTime = MilliSeconds(1050);
34  bool useCa = false;
35 
36  CommandLine cmd(__FILE__);
37  cmd.AddValue("simTime", "Total duration of the simulation", simTime);
38  cmd.AddValue("useCa", "Whether to use carrier aggregation.", useCa);
39  cmd.Parse(argc, argv);
40 
41  // to save a template default attribute file run it like this:
42  // ./ns3 run src/lte/examples/lena-first-sim --command-template="%s
43  // --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Save
44  // --ns3::ConfigStore::FileFormat=RawText"
45  //
46  // to load a previously created default attribute file
47  // ./ns3 run src/lte/examples/lena-first-sim --command-template="%s
48  // --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Load
49  // --ns3::ConfigStore::FileFormat=RawText"
50 
51  ConfigStore inputConfig;
52  inputConfig.ConfigureDefaults();
53 
54  // Parse again so you can override default values from the command line
55  cmd.Parse(argc, argv);
56 
57  if (useCa)
58  {
59  Config::SetDefault("ns3::LteHelper::UseCa", BooleanValue(useCa));
60  Config::SetDefault("ns3::LteHelper::NumberOfComponentCarriers", UintegerValue(2));
61  Config::SetDefault("ns3::LteHelper::EnbComponentCarrierManager",
62  StringValue("ns3::RrComponentCarrierManager"));
63  }
64 
65  Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
66 
67  // Uncomment to enable logging
68  // lteHelper->EnableLogComponents ();
69 
70  // Create Nodes: eNodeB and UE
71  NodeContainer enbNodes;
72  NodeContainer ueNodes;
73  enbNodes.Create(1);
74  ueNodes.Create(1);
75 
76  // Install Mobility Model
78  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
79  mobility.Install(enbNodes);
80  BuildingsHelper::Install(enbNodes);
81  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
82  mobility.Install(ueNodes);
83  BuildingsHelper::Install(ueNodes);
84 
85  // Create Devices and install them in the Nodes (eNB and UE)
86  NetDeviceContainer enbDevs;
87  NetDeviceContainer ueDevs;
88  // Default scheduler is PF, uncomment to use RR
89  // lteHelper->SetSchedulerType ("ns3::RrFfMacScheduler");
90 
91  enbDevs = lteHelper->InstallEnbDevice(enbNodes);
92  ueDevs = lteHelper->InstallUeDevice(ueNodes);
93 
94  // Attach a UE to a eNB
95  lteHelper->Attach(ueDevs, enbDevs.Get(0));
96 
97  // Activate a data radio bearer
99  EpsBearer bearer(q);
100  lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
101  lteHelper->EnableTraces();
102 
103  Simulator::Stop(simTime);
104  Simulator::Run();
105 
106  // GtkConfigStore config;
107  // config.ConfigureAttributes ();
108 
110  return 0;
111 }
static void Install(Ptr< Node > node)
Install the MobilityBuildingInfo to a node.
Parse command-line arguments.
Definition: command-line.h:232
void ConfigureDefaults()
Configure the default values.
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
Qci
QoS Class Indicator.
Definition: eps-bearer.h:106
@ GBR_CONV_VOICE
GBR Conversational Voice.
Definition: eps-bearer.h:107
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:485
void EnableTraces()
Enables trace sinks for PHY, MAC, RLC and PDCP.
Definition: lte-helper.cc:1549
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:1039
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1436
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:500
Helper class used to assign positions and mobility models to nodes.
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.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
Hold variables of type string.
Definition: string.h:56
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Hold an unsigned integer type.
Definition: uinteger.h:45
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:890
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1338
Every class exported by the ns3 library is enclosed in the ns3 namespace.
cmd
Definition: second.py:40
mobility
Definition: third.py:105