A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
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
77
MobilityHelper
mobility
;
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
98
EpsBearer::Qci
q =
EpsBearer::GBR_CONV_VOICE
;
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
109
Simulator::Destroy
();
110
return
0;
111
}
ns3::BooleanValue
Definition:
boolean.h:37
ns3::BuildingsHelper::Install
static void Install(Ptr< Node > node)
Install the MobilityBuildingInfo to a node.
Definition:
buildings-helper.cc:45
ns3::CommandLine
Parse command-line arguments.
Definition:
command-line.h:232
ns3::ConfigStore
Definition:
config-store.h:61
ns3::ConfigStore::ConfigureDefaults
void ConfigureDefaults()
Configure the default values.
Definition:
config-store.cc:192
ns3::EpsBearer
This class contains the specification of EPS Bearers.
Definition:
eps-bearer.h:91
ns3::EpsBearer::Qci
Qci
QoS Class Indicator.
Definition:
eps-bearer.h:106
ns3::EpsBearer::GBR_CONV_VOICE
@ GBR_CONV_VOICE
GBR Conversational Voice.
Definition:
eps-bearer.h:107
ns3::MobilityHelper
Helper class used to assign positions and mobility models to nodes.
Definition:
mobility-helper.h:44
ns3::NetDeviceContainer
holds a vector of ns3::NetDevice pointers
Definition:
net-device-container.h:43
ns3::NetDeviceContainer::Get
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Definition:
net-device-container.cc:67
ns3::NodeContainer
keep track of a set of node pointers.
Definition:
node-container.h:40
ns3::NodeContainer::Create
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Definition:
node-container.cc:84
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::Simulator::Destroy
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition:
simulator.cc:142
ns3::Simulator::Run
static void Run()
Run the simulation.
Definition:
simulator.cc:178
ns3::Simulator::Stop
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition:
simulator.cc:186
ns3::StringValue
Hold variables of type string.
Definition:
string.h:56
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:105
ns3::UintegerValue
Hold an unsigned integer type.
Definition:
uinteger.h:45
ns3::Config::SetDefault
void SetDefault(std::string name, const AttributeValue &value)
Definition:
config.cc:894
ns3::MilliSeconds
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition:
nstime.h:1331
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
second.cmd
ns cmd
Definition:
second.py:40
third.mobility
ns mobility
Definition:
third.py:103
src
lte
examples
lena-simple.cc
Generated on Mon Aug 12 2024 11:16:15 for ns-3 by
1.9.6