A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
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
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2012 Telum (www.telum.ru)
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: Kirill Andreev <andreev@telum.ru>
19
*/
20
#include "ns3/core-module.h"
21
#include "ns3/mobility-module.h"
22
#include "ns3/jakes-propagation-loss-model.h"
23
#include <vector>
24
#include <cmath>
25
26
using namespace
ns3
;
33
class
JakesPropagationExample
34
{
35
public
:
36
JakesPropagationExample
();
37
~
JakesPropagationExample
();
38
private
:
39
Ptr<PropagationLossModel>
m_loss
;
40
Ptr<MobilityModel>
m_firstMobility
;
41
Ptr<MobilityModel>
m_secondMobility
;
42
Time
m_step
;
43
EventId
m_nextEvent
;
47
void
Next ();
48
49
};
50
51
JakesPropagationExample::JakesPropagationExample
() :
52
m_step (
Seconds
(0.0002))
//1/5000 part of the second
53
{
54
m_loss
= CreateObject<JakesPropagationLossModel> ();
55
m_firstMobility
= CreateObject<ConstantPositionMobilityModel> ();
56
m_secondMobility
= CreateObject<ConstantPositionMobilityModel> ();
57
m_firstMobility
->
SetPosition
(Vector (0, 0, 0));
58
m_secondMobility
->
SetPosition
(Vector (10, 0, 0));
59
m_nextEvent
= Simulator::Schedule (
m_step
, &
JakesPropagationExample::Next
,
this
);
60
}
61
62
JakesPropagationExample::~JakesPropagationExample
()
63
{
64
}
65
66
void
JakesPropagationExample::Next
()
67
{
68
m_nextEvent
= Simulator::Schedule (
m_step
, &
JakesPropagationExample::Next
,
this
);
69
std::cout <<
Simulator::Now
().
As
(Time::MS) <<
" "
<<
m_loss
->
CalcRxPower
(0,
m_firstMobility
,
m_secondMobility
) << std::endl;
70
}
71
72
int
main (
int
argc,
char
*argv[])
73
{
74
Config::SetDefault
(
"ns3::JakesProcess::NumberOfOscillators"
,
UintegerValue
(100));
75
CommandLine
cmd
(__FILE__);
76
cmd
.Parse (argc, argv);
77
JakesPropagationExample
example;
78
Simulator::Stop (
Seconds
(1000));
79
Simulator::Run ();
80
Simulator::Destroy ();
81
/*
82
* R script for plotting a distribution:
83
data<-read.table ("data")
84
rayleigh<-(rnorm(1e6)^2+rnorm(1e6)^2)/2
85
qqplot(10*log10(rayleigh), data$V2, main="QQ-plot for improved Jakes model", xlab="Reference Rayleigh distribution [power, dB]", ylab="Sum-of-sinusoids distribution [power, dB]", xlim=c(-45, 10), ylim=c(-45, 10))
86
lines (c(-50, 50), c(-50, 50))
87
abline (v=-50:50*2, h=-50:50*2, col="light grey")
88
*/
89
90
/*
91
* R script to plot autocorrelation function:
92
# Read amplitude distribution:
93
data<-10^(read.table ("data")$V2/20)
94
x<-1:2000/10
95
acf (data, lag.max=200, main="Autocorrelation function of the improved Jakes model", xlab="Time x200 microseconds ", ylab="Autocorrelation")
96
# If we have a delta T = 1/5000 part of the second and doppler freq = 80 Hz
97
lines (x, besselJ(x*80*2*pi/5000, 0)^2)
98
abline (h=0:10/10, col="light grey")
99
*/
100
return
0;
101
}
JakesPropagationExample
Constructs a JakesPropagationlossModel and print the loss value as a function of time into std::cout.
Definition:
jakes-propagation-model-example.cc:34
JakesPropagationExample::~JakesPropagationExample
~JakesPropagationExample()
Definition:
jakes-propagation-model-example.cc:62
JakesPropagationExample::m_secondMobility
Ptr< MobilityModel > m_secondMobility
second Mobility
Definition:
jakes-propagation-model-example.cc:41
JakesPropagationExample::m_nextEvent
EventId m_nextEvent
next event
Definition:
jakes-propagation-model-example.cc:43
JakesPropagationExample::Next
void Next()
Next function.
Definition:
jakes-propagation-model-example.cc:66
JakesPropagationExample::m_firstMobility
Ptr< MobilityModel > m_firstMobility
first Mobility
Definition:
jakes-propagation-model-example.cc:40
JakesPropagationExample::m_step
Time m_step
step
Definition:
jakes-propagation-model-example.cc:42
JakesPropagationExample::m_loss
Ptr< PropagationLossModel > m_loss
loss
Definition:
jakes-propagation-model-example.cc:39
JakesPropagationExample::JakesPropagationExample
JakesPropagationExample()
Definition:
jakes-propagation-model-example.cc:51
ns3::CommandLine
Parse command-line arguments.
Definition:
command-line.h:229
ns3::EventId
An identifier for simulation events.
Definition:
event-id.h:54
ns3::MobilityModel::SetPosition
void SetPosition(const Vector &position)
Definition:
mobility-model.cc:88
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:103
ns3::Time::As
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition:
time.cc:418
ns3::UintegerValue
Hold an unsigned integer type.
Definition:
uinteger.h:44
ns3::Config::SetDefault
void SetDefault(std::string name, const AttributeValue &value)
Definition:
config.cc:849
ns3::Now
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition:
simulator.cc:287
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition:
nstime.h:1244
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
second.cmd
cmd
Definition:
second.py:35
src
propagation
examples
jakes-propagation-model-example.cc
Generated on Tue Feb 6 2024 19:21:26 for ns-3 by
1.9.1