A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
jakes-propagation-model-example.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012 Telum (www.telum.ru)
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Kirill Andreev <andreev@telum.ru>
18
*/
19
#include "ns3/core-module.h"
20
#include "ns3/jakes-propagation-loss-model.h"
21
#include "ns3/mobility-module.h"
22
23
#include <cmath>
24
#include <vector>
25
26
using namespace
ns3
;
27
34
class
JakesPropagationExample
35
{
36
public
:
37
JakesPropagationExample
();
38
~
JakesPropagationExample
();
39
40
private
:
41
Ptr<PropagationLossModel>
m_loss
;
42
Ptr<MobilityModel>
m_firstMobility
;
43
Ptr<MobilityModel>
m_secondMobility
;
44
Time
m_step
;
45
EventId
m_nextEvent
;
49
void
Next();
50
};
51
52
JakesPropagationExample::JakesPropagationExample
()
53
: m_step(
Seconds
(0.0002))
// 1/5000 part of the second
54
{
55
m_loss
= CreateObject<JakesPropagationLossModel>();
56
m_firstMobility
= CreateObject<ConstantPositionMobilityModel>();
57
m_secondMobility
= CreateObject<ConstantPositionMobilityModel>();
58
m_firstMobility
->
SetPosition
(Vector(0, 0, 0));
59
m_secondMobility
->
SetPosition
(Vector(10, 0, 0));
60
m_nextEvent
= Simulator::Schedule(
m_step
, &
JakesPropagationExample::Next
,
this
);
61
}
62
63
JakesPropagationExample::~JakesPropagationExample
()
64
{
65
}
66
67
void
68
JakesPropagationExample::Next
()
69
{
70
m_nextEvent
= Simulator::Schedule(
m_step
, &
JakesPropagationExample::Next
,
this
);
71
std::cout <<
Simulator::Now
().
As
(Time::MS) <<
" "
72
<<
m_loss
->
CalcRxPower
(0,
m_firstMobility
,
m_secondMobility
) << std::endl;
73
}
74
75
int
76
main(
int
argc,
char
* argv[])
77
{
78
Config::SetDefault
(
"ns3::JakesProcess::NumberOfOscillators"
,
UintegerValue
(100));
79
CommandLine
cmd
(__FILE__);
80
cmd
.Parse(argc, argv);
81
JakesPropagationExample
example;
82
Simulator::Stop(
Seconds
(1000));
83
Simulator::Run();
84
Simulator::Destroy();
85
/*
86
* R script for plotting a distribution:
87
data<-read.table ("data")
88
rayleigh<-(rnorm(1e6)^2+rnorm(1e6)^2)/2
89
qqplot(10*log10(rayleigh), data$V2, main="QQ-plot for improved Jakes model", xlab="Reference
90
Rayleigh distribution [power, dB]", ylab="Sum-of-sinusoids distribution [power, dB]",
91
xlim=c(-45, 10), ylim=c(-45, 10)) lines (c(-50, 50), c(-50, 50)) abline (v=-50:50*2,
92
h=-50:50*2, col="light grey")
93
*/
94
95
/*
96
* R script to plot autocorrelation function:
97
# Read amplitude distribution:
98
data<-10^(read.table ("data")$V2/20)
99
x<-1:2000/10
100
acf (data, lag.max=200, main="Autocorrelation function of the improved Jakes model", xlab="Time
101
x200 microseconds ", ylab="Autocorrelation") # If we have a delta T = 1/5000 part of the second
102
and doppler freq = 80 Hz lines (x, besselJ(x*80*2*pi/5000, 0)^2) abline (h=0:10/10, col="light
103
grey")
104
*/
105
return
0;
106
}
JakesPropagationExample
Constructs a JakesPropagationlossModel and print the loss value as a function of time into std::cout.
Definition:
jakes-propagation-model-example.cc:35
JakesPropagationExample::~JakesPropagationExample
~JakesPropagationExample()
Definition:
jakes-propagation-model-example.cc:63
JakesPropagationExample::m_secondMobility
Ptr< MobilityModel > m_secondMobility
second Mobility
Definition:
jakes-propagation-model-example.cc:43
JakesPropagationExample::m_nextEvent
EventId m_nextEvent
next event
Definition:
jakes-propagation-model-example.cc:45
JakesPropagationExample::Next
void Next()
Next function.
Definition:
jakes-propagation-model-example.cc:68
JakesPropagationExample::m_firstMobility
Ptr< MobilityModel > m_firstMobility
first Mobility
Definition:
jakes-propagation-model-example.cc:42
JakesPropagationExample::m_step
Time m_step
step
Definition:
jakes-propagation-model-example.cc:44
JakesPropagationExample::m_loss
Ptr< PropagationLossModel > m_loss
loss
Definition:
jakes-propagation-model-example.cc:41
JakesPropagationExample::JakesPropagationExample
JakesPropagationExample()
Definition:
jakes-propagation-model-example.cc:52
ns3::CommandLine
Parse command-line arguments.
Definition:
command-line.h:232
ns3::EventId
An identifier for simulation events.
Definition:
event-id.h:55
ns3::MobilityModel::SetPosition
void SetPosition(const Vector &position)
Definition:
mobility-model.cc:92
ns3::PropagationLossModel::CalcRxPower
double CalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account all the PropagationLossModel(s) chained to the current one.
Definition:
propagation-loss-model.cc:73
ns3::Ptr< PropagationLossModel >
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:105
ns3::Time::As
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition:
time.cc:415
ns3::UintegerValue
Hold an unsigned integer type.
Definition:
uinteger.h:45
ns3::Config::SetDefault
void SetDefault(std::string name, const AttributeValue &value)
Definition:
config.cc:890
ns3::Now
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition:
simulator.cc:305
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition:
nstime.h:1326
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
second.cmd
cmd
Definition:
second.py:40
src
propagation
examples
jakes-propagation-model-example.cc
Generated on Sun Mar 3 2024 17:11:07 for ns-3 by
1.9.1