A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
lena-pathloss-traces.cc
Go to the documentation of this file.
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Manuel Requena <manuel.requena@cttc.es>
19
* Nicola Baldo <nbaldo@cttc.es>
20
*/
21
22
23
#include "ns3/core-module.h"
24
#include "ns3/network-module.h"
25
#include "ns3/mobility-module.h"
26
#include "ns3/lte-module.h"
27
#include "ns3/config-store.h"
28
#include "ns3/radio-bearer-stats-calculator.h"
29
#include "ns3/lte-global-pathloss-database.h"
30
31
#include <iomanip>
32
#include <string>
33
34
#include <ns3/log.h>
35
36
using namespace
ns3;
37
38
39
NS_LOG_COMPONENT_DEFINE
(
"LenaPathlossTraces"
);
40
41
42
43
int
main
(
int
argc,
char
*argv[])
44
{
45
double
enbDist = 20.0;
46
double
radius = 10.0;
47
uint32_t numUes = 1;
48
49
50
CommandLine
cmd;
51
cmd.
AddValue
(
"enbDist"
,
"distance between the two eNBs"
, enbDist);
52
cmd.
AddValue
(
"radius"
,
"the radius of the disc where UEs are placed around an eNB"
, radius);
53
cmd.
AddValue
(
"numUes"
,
"how many UEs are attached to each eNB"
, numUes);
54
cmd.
Parse
(argc, argv);
55
56
ConfigStore
inputConfig;
57
inputConfig.
ConfigureDefaults
();
58
59
// parse again so you can override default values from the command line
60
cmd.
Parse
(argc, argv);
61
62
// determine the string tag that identifies this simulation run
63
// this tag is then appended to all filenames
64
65
IntegerValue
runValue;
66
GlobalValue::GetValueByName
(
"RngRun"
, runValue);
67
68
std::ostringstream tag;
69
tag <<
"_enbDist"
<< std::setw (3) << std::setfill (
'0'
) << std::fixed << std::setprecision (0) << enbDist
70
<<
"_radius"
<< std::setw (3) << std::setfill (
'0'
) << std::fixed << std::setprecision (0) << radius
71
<<
"_numUes"
<< std::setw (3) << std::setfill (
'0'
) << numUes
72
<<
"_rngRun"
<< std::setw (3) << std::setfill (
'0'
) << runValue.
Get
() ;
73
74
Ptr<LteHelper>
lteHelper = CreateObject<LteHelper> ();
75
76
77
// NOTE: the PropagationLoss trace source of the SpectrumChannel
78
// works only for single-frequency path loss model.
79
// e.g., it will work with the following models:
80
// ns3::FriisPropagationLossModel,
81
// ns3::TwoRayGroundPropagationLossModel,
82
// ns3::LogDistancePropagationLossModel,
83
// ns3::ThreeLogDistancePropagationLossModel,
84
// ns3::NakagamiPropagationLossModel
85
// ns3::BuildingsPropagationLossModel
86
// etc.
87
// but it WON'T work if you ONLY use SpectrumPropagationLossModels such as:
88
// ns3::FriisSpectrumPropagationLossModel
89
// ns3::ConstantSpectrumPropagationLossModel
90
lteHelper->
SetAttribute
(
"PathlossModel"
,
StringValue
(
"ns3::Cost231PropagationLossModel"
));
91
92
93
// Create Nodes: eNodeB and UE
94
NodeContainer
enbNodes;
95
NodeContainer
ueNodes1, ueNodes2;
96
enbNodes.
Create
(2);
97
ueNodes1.
Create
(numUes);
98
ueNodes2.
Create
(numUes);
99
100
// Position of eNBs
101
Ptr<ListPositionAllocator>
positionAlloc = CreateObject<ListPositionAllocator> ();
102
positionAlloc->
Add
(
Vector
(0.0, 0.0, 0.0));
103
positionAlloc->
Add
(
Vector
(enbDist, 0.0, 0.0));
104
MobilityHelper
enbMobility;
105
enbMobility.
SetMobilityModel
(
"ns3::ConstantPositionMobilityModel"
);
106
enbMobility.
SetPositionAllocator
(positionAlloc);
107
enbMobility.
Install
(enbNodes);
108
109
// Position of UEs attached to eNB 1
110
MobilityHelper
ue1mobility;
111
ue1mobility.
SetPositionAllocator
(
"ns3::UniformDiscPositionAllocator"
,
112
"X"
,
DoubleValue
(0.0),
113
"Y"
,
DoubleValue
(0.0),
114
"rho"
,
DoubleValue
(radius));
115
ue1mobility.
SetMobilityModel
(
"ns3::ConstantPositionMobilityModel"
);
116
ue1mobility.
Install
(ueNodes1);
117
118
// Position of UEs attached to eNB 2
119
MobilityHelper
ue2mobility;
120
ue2mobility.
SetPositionAllocator
(
"ns3::UniformDiscPositionAllocator"
,
121
"X"
,
DoubleValue
(enbDist),
122
"Y"
,
DoubleValue
(0.0),
123
"rho"
,
DoubleValue
(radius));
124
ue2mobility.
SetMobilityModel
(
"ns3::ConstantPositionMobilityModel"
);
125
ue2mobility.
Install
(ueNodes2);
126
127
// Create Devices and install them in the Nodes (eNB and UE)
128
NetDeviceContainer
enbDevs;
129
NetDeviceContainer
ueDevs1;
130
NetDeviceContainer
ueDevs2;
131
enbDevs = lteHelper->
InstallEnbDevice
(enbNodes);
132
ueDevs1 = lteHelper->
InstallUeDevice
(ueNodes1);
133
ueDevs2 = lteHelper->
InstallUeDevice
(ueNodes2);
134
135
// Attach UEs to a eNB
136
lteHelper->
Attach
(ueDevs1, enbDevs.
Get
(0));
137
lteHelper->
Attach
(ueDevs2, enbDevs.
Get
(1));
138
139
// Activate an EPS bearer on all UEs
140
enum
EpsBearer::Qci
q =
EpsBearer::GBR_CONV_VOICE
;
141
EpsBearer
bearer (q);
142
lteHelper->
ActivateDataRadioBearer
(ueDevs1, bearer);
143
lteHelper->
ActivateDataRadioBearer
(ueDevs2, bearer);
144
145
Simulator::Stop
(
Seconds
(0.5));
146
147
// Insert RLC Performance Calculator
148
std::string dlOutFname =
"DlRlcStats"
;
149
dlOutFname.append (tag.str ());
150
std::string ulOutFname =
"UlRlcStats"
;
151
ulOutFname.append (tag.str ());
152
153
lteHelper->
EnableMacTraces
();
154
lteHelper->
EnableRlcTraces
();
155
156
157
158
// keep track of all path loss values in two centralized objects
159
DownlinkLteGlobalPathlossDatabase
dlPathlossDb;
160
UplinkLteGlobalPathlossDatabase
ulPathlossDb;
161
// we rely on the fact that LteHelper creates the DL channel object first, then the UL channel object,
162
// hence the former will have index 0 and the latter 1
163
Config::Connect
(
"/ChannelList/0/PathLoss"
,
164
MakeCallback
(&
DownlinkLteGlobalPathlossDatabase::UpdatePathloss
, &dlPathlossDb));
165
Config::Connect
(
"/ChannelList/1/PathLoss"
,
166
MakeCallback
(&
UplinkLteGlobalPathlossDatabase::UpdatePathloss
, &ulPathlossDb));
167
168
Simulator::Run
();
169
170
171
// print the pathloss values at the end of the simulation
172
std::cout << std::endl <<
"Downlink pathloss:"
<< std::endl;
173
dlPathlossDb.
Print
();
174
std::cout << std::endl <<
"Uplink pathloss:"
<< std::endl;
175
ulPathlossDb.
Print
();
176
177
178
Simulator::Destroy
();
179
return
0;
180
}
src
lte
examples
lena-pathloss-traces.cc
Generated on Tue May 14 2013 11:08:24 for ns-3 by
1.8.1.2