A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lena-uplink-power-control.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Piotr Gawlowicz
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Piotr Gawlowicz <gawlowicz.p@gmail.com>
7 *
8 */
9
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
16using namespace ns3;
17
18/*
19 * This example show how to configure and how Uplink Power Control works.
20 */
21
22int
23main(int argc, char* argv[])
24{
25 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(false));
26
27 double eNbTxPower = 30;
28 Config::SetDefault("ns3::LteEnbPhy::TxPower", DoubleValue(eNbTxPower));
29 Config::SetDefault("ns3::LteUePhy::TxPower", DoubleValue(10.0));
30 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(true));
31
32 Config::SetDefault("ns3::LteUePowerControl::ClosedLoop", BooleanValue(true));
33 Config::SetDefault("ns3::LteUePowerControl::AccumulationEnabled", BooleanValue(true));
34 Config::SetDefault("ns3::LteUePowerControl::Alpha", DoubleValue(1.0));
35
36 CommandLine cmd(__FILE__);
37 cmd.Parse(argc, argv);
38
40
41 uint16_t bandwidth = 25;
42 double d1 = 0;
43
44 // Create Nodes: eNodeB and UE
45 NodeContainer enbNodes;
46 NodeContainer ueNodes;
47 enbNodes.Create(1);
48 ueNodes.Create(1);
49 NodeContainer allNodes = NodeContainer(enbNodes, ueNodes);
50
51 /* the topology is the following:
52 *
53 * eNB1-------------------------UE
54 * d1
55 */
56
57 // Install Mobility Model
59 positionAlloc->Add(Vector(0.0, 0.0, 0.0)); // eNB1
60 positionAlloc->Add(Vector(d1, 0.0, 0.0)); // UE1
61
63 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
64 mobility.SetPositionAllocator(positionAlloc);
65 mobility.Install(allNodes);
66
67 // Create Devices and install them in the Nodes (eNB and UE)
68 NetDeviceContainer enbDevs;
69 NetDeviceContainer ueDevs;
70 lteHelper->SetSchedulerType("ns3::PfFfMacScheduler");
71
72 lteHelper->SetEnbDeviceAttribute("DlBandwidth", UintegerValue(bandwidth));
73 lteHelper->SetEnbDeviceAttribute("UlBandwidth", UintegerValue(bandwidth));
74
75 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
76 ueDevs = lteHelper->InstallUeDevice(ueNodes);
77
78 // Attach a UE to a eNB
79 lteHelper->Attach(ueDevs, enbDevs.Get(0));
80
81 // Activate a data radio bearer
83 EpsBearer bearer(q);
84 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
85
88
90 return 0;
91}
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
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 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 Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mobility
Definition third.py:92