A Discrete-Event Network Simulator
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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Manuel Requena <manuel.requena@cttc.es>
7 */
8
9#include "ns3/config-store.h"
10#include "ns3/core-module.h"
11#include "ns3/lte-module.h"
12#include "ns3/mobility-module.h"
13#include "ns3/network-module.h"
14#include <ns3/buildings-helper.h>
15// #include "ns3/gtk-config-store.h"
16
17using namespace ns3;
18
19int
20main(int argc, char* argv[])
21{
22 Time simTime = MilliSeconds(1050);
23 bool useCa = false;
24
25 CommandLine cmd(__FILE__);
26 cmd.AddValue("simTime", "Total duration of the simulation", simTime);
27 cmd.AddValue("useCa", "Whether to use carrier aggregation.", useCa);
28 cmd.Parse(argc, argv);
29
30 // to save a template default attribute file run it like this:
31 // ./ns3 run src/lte/examples/lena-first-sim --command-template="%s
32 // --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Save
33 // --ns3::ConfigStore::FileFormat=RawText"
34 //
35 // to load a previously created default attribute file
36 // ./ns3 run src/lte/examples/lena-first-sim --command-template="%s
37 // --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Load
38 // --ns3::ConfigStore::FileFormat=RawText"
39
40 ConfigStore inputConfig;
41 inputConfig.ConfigureDefaults();
42
43 // Parse again so you can override default values from the command line
44 cmd.Parse(argc, argv);
45
46 if (useCa)
47 {
48 Config::SetDefault("ns3::LteHelper::UseCa", BooleanValue(useCa));
49 Config::SetDefault("ns3::LteHelper::NumberOfComponentCarriers", UintegerValue(2));
50 Config::SetDefault("ns3::LteHelper::EnbComponentCarrierManager",
51 StringValue("ns3::RrComponentCarrierManager"));
52 }
53
55
56 // Uncomment to enable logging
57 // lteHelper->EnableLogComponents ();
58
59 // Create Nodes: eNodeB and UE
60 NodeContainer enbNodes;
61 NodeContainer ueNodes;
62 enbNodes.Create(1);
63 ueNodes.Create(1);
64
65 // Install Mobility Model
67 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
68 mobility.Install(enbNodes);
70 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
71 mobility.Install(ueNodes);
73
74 // Create Devices and install them in the Nodes (eNB and UE)
75 NetDeviceContainer enbDevs;
76 NetDeviceContainer ueDevs;
77 // Default scheduler is PF, uncomment to use RR
78 // lteHelper->SetSchedulerType ("ns3::RrFfMacScheduler");
79
80 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
81 ueDevs = lteHelper->InstallUeDevice(ueNodes);
82
83 // Attach a UE to a eNB
84 lteHelper->Attach(ueDevs, enbDevs.Get(0));
85
86 // Activate a data radio bearer
88 EpsBearer bearer(q);
89 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
90 lteHelper->EnableTraces();
91
92 Simulator::Stop(simTime);
94
95 // GtkConfigStore config;
96 // config.ConfigureAttributes ();
97
99 return 0;
100}
static void Install(Ptr< Node > node)
Install the MobilityBuildingInfo to a node.
Parse command-line arguments.
void ConfigureDefaults()
Configure the default values.
This class contains the specification of EPS Bearers.
Definition eps-bearer.h:80
Qci
QoS Class Indicator.
Definition eps-bearer.h:95
@ GBR_CONV_VOICE
GBR Conversational Voice.
Definition eps-bearer.h:96
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.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
Hold variables of type string.
Definition string.h:45
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Hold an unsigned integer type.
Definition uinteger.h:34
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:883
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1320
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mobility
Definition third.py:92