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-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/buildings-helper.h"
11
#include "ns3/core-module.h"
12
#include "ns3/lte-module.h"
13
#include "ns3/mobility-module.h"
14
#include "ns3/network-module.h"
15
16
using namespace
ns3
;
17
18
/*
19
* This example show how to configure and how Uplink Power Control works.
20
*/
21
22
int
23
main(
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
39
Ptr<LteHelper>
lteHelper
=
CreateObject<LteHelper>
();
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
58
Ptr<ListPositionAllocator>
positionAlloc
=
CreateObject<ListPositionAllocator>
();
59
positionAlloc
->Add(Vector(0.0, 0.0, 0.0));
// eNB1
60
positionAlloc
->Add(Vector(
d1
, 0.0, 0.0));
// UE1
61
62
MobilityHelper
mobility
;
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
82
EpsBearer::Qci
q =
EpsBearer::GBR_CONV_VOICE
;
83
EpsBearer
bearer(q);
84
lteHelper
->ActivateDataRadioBearer(
ueDevs
, bearer);
85
86
Simulator::Stop
(
Seconds
(0.500));
87
Simulator::Run
();
88
89
Simulator::Destroy
();
90
return
0;
91
}
ns3::BooleanValue
AttributeValue implementation for Boolean.
Definition
boolean.h:26
ns3::CommandLine
Parse command-line arguments.
Definition
command-line.h:221
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition
double.h:31
ns3::EpsBearer
This class contains the specification of EPS Bearers.
Definition
eps-bearer.h:80
ns3::EpsBearer::Qci
Qci
QoS Class Indicator.
Definition
eps-bearer.h:95
ns3::EpsBearer::GBR_CONV_VOICE
@ GBR_CONV_VOICE
GBR Conversational Voice.
Definition
eps-bearer.h:96
ns3::MobilityHelper
Helper class used to assign positions and mobility models to nodes.
Definition
mobility-helper.h:33
ns3::NetDeviceContainer
holds a vector of ns3::NetDevice pointers
Definition
net-device-container.h:32
ns3::NodeContainer
keep track of a set of node pointers.
Definition
node-container.h:29
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:73
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:66
ns3::Simulator::Destroy
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition
simulator.cc:131
ns3::Simulator::Run
static void Run()
Run the simulation.
Definition
simulator.cc:167
ns3::Simulator::Stop
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition
simulator.cc:175
ns3::UintegerValue
Hold an unsigned integer type.
Definition
uinteger.h:34
ns3::Config::SetDefault
void SetDefault(std::string name, const AttributeValue &value)
Definition
config.cc:883
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition
nstime.h:1344
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
second.cmd
cmd
Definition
second.py:29
third.mobility
mobility
Definition
third.py:92
src
lte
examples
lena-uplink-power-control.cc
Generated on Mon Dec 15 2025 15:21:56 for ns-3 by
1.9.8