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-cqi-threshold.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 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/buildings-helper.h"
10
#include "ns3/config-store.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
// #include "ns3/gtk-config-store.h"
16
17
using namespace
ns3
;
18
19
/**
20
* Change the position of a node.
21
*
22
* This function will move a node with a x coordinate greater than 10 m
23
* to a x equal to 5 m, and less than or equal to 10 m to 10 Km
24
*
25
* @param node The node to move.
26
*/
27
static
void
28
ChangePosition
(
Ptr<Node>
node)
29
{
30
Ptr<MobilityModel>
mobility = node->GetObject<
MobilityModel
>();
31
Vector pos = mobility->GetPosition();
32
33
if
(pos.x <= 10.0)
34
{
35
pos.x = 100000.0;
// force CQI to 0
36
}
37
else
38
{
39
pos.x = 5.0;
40
}
41
mobility->SetPosition(pos);
42
}
43
44
int
45
main(
int
argc
,
char
*
argv
[])
46
{
47
CommandLine
cmd
(
__FILE__
);
48
cmd
.Parse(
argc
,
argv
);
49
50
// to save a template default attribute file run it like this:
51
// ./ns3 run src/lte/examples/lena-first-sim --command-template="%s
52
// --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Save
53
// --ns3::ConfigStore::FileFormat=RawText"
54
//
55
// to load a previously created default attribute file
56
// ./ns3 run src/lte/examples/lena-first-sim --command-template="%s
57
// --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Load
58
// --ns3::ConfigStore::FileFormat=RawText"
59
60
ConfigStore
inputConfig
;
61
inputConfig
.
ConfigureDefaults
();
62
63
// parse again so you can override default values from the command line
64
cmd
.Parse(
argc
,
argv
);
65
66
Ptr<LteHelper>
lteHelper
=
CreateObject<LteHelper>
();
67
lteHelper
->SetAttribute(
"PathlossModel"
,
StringValue
(
"ns3::FriisSpectrumPropagationLossModel"
));
68
// Uncomment to enable logging
69
// lteHelper->EnableLogComponents ();
70
71
// Create Nodes: eNodeB and UE
72
NodeContainer
enbNodes
;
73
NodeContainer
ueNodes
;
74
enbNodes
.
Create
(1);
75
ueNodes
.Create(1);
76
77
// Install Mobility Model
78
MobilityHelper
mobility
;
79
mobility
.SetMobilityModel(
"ns3::ConstantPositionMobilityModel"
);
80
mobility
.Install(
enbNodes
);
81
BuildingsHelper::Install
(
enbNodes
);
82
mobility
.SetMobilityModel(
"ns3::ConstantPositionMobilityModel"
);
83
mobility
.Install(
ueNodes
);
84
BuildingsHelper::Install
(
ueNodes
);
85
86
// Create Devices and install them in the Nodes (eNB and UE)
87
NetDeviceContainer
enbDevs
;
88
NetDeviceContainer
ueDevs
;
89
// lteHelper->SetSchedulerType ("ns3::RrFfMacScheduler");
90
lteHelper
->SetSchedulerType(
"ns3::PfFfMacScheduler"
);
91
lteHelper
->SetSchedulerAttribute(
"CqiTimerThreshold"
,
UintegerValue
(3));
92
enbDevs
=
lteHelper
->InstallEnbDevice(
enbNodes
);
93
ueDevs
=
lteHelper
->InstallUeDevice(
ueNodes
);
94
95
lteHelper
->EnableRlcTraces();
96
lteHelper
->EnableMacTraces();
97
98
// Attach a UE to a eNB
99
lteHelper
->Attach(
ueDevs
,
enbDevs
.Get(0));
100
101
Simulator::Schedule
(
Seconds
(0.010), &
ChangePosition
,
ueNodes
.Get(0));
102
Simulator::Schedule
(
Seconds
(0.020), &
ChangePosition
,
ueNodes
.Get(0));
103
104
// Activate a data radio bearer
105
EpsBearer::Qci
q =
EpsBearer::GBR_CONV_VOICE
;
106
EpsBearer
bearer(q);
107
lteHelper
->ActivateDataRadioBearer(
ueDevs
, bearer);
108
109
Simulator::Stop
(
Seconds
(0.030));
110
111
Simulator::Run
();
112
113
// GtkConfigStore config;
114
// config.ConfigureAttributes ();
115
116
Simulator::Destroy
();
117
return
0;
118
}
ns3::BuildingsHelper::Install
static void Install(Ptr< Node > node)
Install the MobilityBuildingInfo to a node.
Definition
buildings-helper.cc:34
ns3::CommandLine
Parse command-line arguments.
Definition
command-line.h:221
ns3::ConfigStore
Introspection did not find any typical Config paths.
Definition
config-store.h:50
ns3::ConfigStore::ConfigureDefaults
void ConfigureDefaults()
Configure the default values.
Definition
config-store.cc:181
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::MobilityModel
Keep track of the current position and velocity of an object.
Definition
mobility-model.h:29
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::Schedule
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition
simulator.h:560
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::StringValue
Hold variables of type string.
Definition
string.h:45
ns3::UintegerValue
Hold an unsigned integer type.
Definition
uinteger.h:34
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
ChangePosition
static void ChangePosition(Ptr< Node > node)
Change the position of a node.
Definition
lena-cqi-threshold.cc:28
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-cqi-threshold.cc
Generated on Mon Dec 15 2025 15:21:55 for ns-3 by
1.9.8