A Discrete-Event Network Simulator
API
lena-simple.cc
Go to the documentation of this file.
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011-2018 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: Manuel Requena <manuel.requena@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-helper.h>
27//#include "ns3/gtk-config-store.h"
28
29using namespace ns3;
30
31int 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 --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Save --ns3::ConfigStore::FileFormat=RawText"
43 //
44 // to load a previously created default attribute file
45 // ./ns3 run src/lte/examples/lena-first-sim --command-template="%s --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Load --ns3::ConfigStore::FileFormat=RawText"
46
47 ConfigStore inputConfig;
48 inputConfig.ConfigureDefaults ();
49
50 // Parse again so you can override default values from the command line
51 cmd.Parse (argc, argv);
52
53 if (useCa)
54 {
55 Config::SetDefault ("ns3::LteHelper::UseCa", BooleanValue (useCa));
56 Config::SetDefault ("ns3::LteHelper::NumberOfComponentCarriers", UintegerValue (2));
57 Config::SetDefault ("ns3::LteHelper::EnbComponentCarrierManager", StringValue ("ns3::RrComponentCarrierManager"));
58 }
59
60 Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
61
62 // Uncomment to enable logging
63// lteHelper->EnableLogComponents ();
64
65 // Create Nodes: eNodeB and UE
66 NodeContainer enbNodes;
67 NodeContainer ueNodes;
68 enbNodes.Create (1);
69 ueNodes.Create (1);
70
71 // Install Mobility Model
73 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
74 mobility.Install (enbNodes);
75 BuildingsHelper::Install (enbNodes);
76 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
77 mobility.Install (ueNodes);
78 BuildingsHelper::Install (ueNodes);
79
80 // Create Devices and install them in the Nodes (eNB and UE)
81 NetDeviceContainer enbDevs;
82 NetDeviceContainer ueDevs;
83 // Default scheduler is PF, uncomment to use RR
84 //lteHelper->SetSchedulerType ("ns3::RrFfMacScheduler");
85
86 enbDevs = lteHelper->InstallEnbDevice (enbNodes);
87 ueDevs = lteHelper->InstallUeDevice (ueNodes);
88
89 // Attach a UE to a eNB
90 lteHelper->Attach (ueDevs, enbDevs.Get (0));
91
92 // Activate a data radio bearer
93 enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
94 EpsBearer bearer (q);
95 lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
96 lteHelper->EnableTraces ();
97
98 Simulator::Stop (simTime);
99 Simulator::Run ();
100
101 // GtkConfigStore config;
102 // config.ConfigureAttributes ();
103
104 Simulator::Destroy ();
105 return 0;
106}
AttributeValue implementation for Boolean.
Definition: boolean.h:37
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 contains the specification of EPS Bearers.
Definition: eps-bearer.h:92
Qci
QoS Class Indicator.
Definition: eps-bearer.h:107
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:474
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 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
void EnableTraces(void)
Enables trace sinks for PHY, MAC, RLC and PDCP.
Definition: lte-helper.cc:1426
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.
Hold variables of type string.
Definition: string.h:41
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Hold an unsigned integer type.
Definition: uinteger.h:44
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:849
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1252
Every class exported by the ns3 library is enclosed in the ns3 namespace.
cmd
Definition: second.py:35
mobility
Definition: third.py:107