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
jakes-propagation-model-example.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012 Telum (www.telum.ru)
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Kirill Andreev <andreev@telum.ru>
7
*/
8
#include "ns3/core-module.h"
9
#include "ns3/jakes-propagation-loss-model.h"
10
#include "ns3/mobility-module.h"
11
12
#include <cmath>
13
#include <vector>
14
15
using namespace
ns3
;
16
17
/**
18
* \ingroup propagation
19
* \brief Constructs a JakesPropagationlossModel and print the loss value as a function of time into
20
* std::cout. Distribution and correlation statistics is compared with a theoretical ones using R
21
* package (http://www.r-project.org/). Scripts are presented within comments.
22
*/
23
class
JakesPropagationExample
24
{
25
public
:
26
JakesPropagationExample
();
27
~JakesPropagationExample
();
28
29
private
:
30
Ptr<PropagationLossModel>
m_loss
;
//!< loss
31
Ptr<MobilityModel>
m_firstMobility
;
//!< first Mobility
32
Ptr<MobilityModel>
m_secondMobility
;
//!< second Mobility
33
Time
m_step
;
//!< step
34
EventId
m_nextEvent
;
//!< next event
35
/**
36
* Next function
37
* */
38
void
Next
();
39
};
40
41
JakesPropagationExample::JakesPropagationExample
()
42
: m_step(
Seconds
(0.0002))
// 1/5000 part of the second
43
{
44
m_loss
=
CreateObject<JakesPropagationLossModel>
();
45
m_firstMobility
=
CreateObject<ConstantPositionMobilityModel>
();
46
m_secondMobility
=
CreateObject<ConstantPositionMobilityModel>
();
47
m_firstMobility
->SetPosition(Vector(0, 0, 0));
48
m_secondMobility
->SetPosition(Vector(10, 0, 0));
49
m_nextEvent
=
Simulator::Schedule
(
m_step
, &
JakesPropagationExample::Next
,
this
);
50
}
51
52
JakesPropagationExample::~JakesPropagationExample
()
53
{
54
}
55
56
void
57
JakesPropagationExample::Next
()
58
{
59
m_nextEvent
=
Simulator::Schedule
(
m_step
, &
JakesPropagationExample::Next
,
this
);
60
std::cout <<
Simulator::Now
().
As
(
Time::MS
) <<
" "
61
<<
m_loss
->CalcRxPower(0,
m_firstMobility
,
m_secondMobility
) << std::endl;
62
}
63
64
int
65
main(
int
argc,
char
* argv[])
66
{
67
Config::SetDefault
(
"ns3::JakesProcess::NumberOfOscillators"
,
UintegerValue
(100));
68
CommandLine
cmd(__FILE__);
69
cmd.Parse(argc, argv);
70
JakesPropagationExample
example;
71
Simulator::Stop
(
Seconds
(1000));
72
Simulator::Run
();
73
Simulator::Destroy
();
74
/*
75
* R script for plotting a distribution:
76
data<-read.table ("data")
77
rayleigh<-(rnorm(1e6)^2+rnorm(1e6)^2)/2
78
qqplot(10*log10(rayleigh), data$V2, main="QQ-plot for improved Jakes model", xlab="Reference
79
Rayleigh distribution [power, dB]", ylab="Sum-of-sinusoids distribution [power, dB]",
80
xlim=c(-45, 10), ylim=c(-45, 10)) lines (c(-50, 50), c(-50, 50)) abline (v=-50:50*2,
81
h=-50:50*2, col="light grey")
82
*/
83
84
/*
85
* R script to plot autocorrelation function:
86
# Read amplitude distribution:
87
data<-10^(read.table ("data")$V2/20)
88
x<-1:2000/10
89
acf (data, lag.max=200, main="Autocorrelation function of the improved Jakes model", xlab="Time
90
x200 microseconds ", ylab="Autocorrelation") # If we have a delta T = 1/5000 part of the second
91
and doppler freq = 80 Hz lines (x, besselJ(x*80*2*pi/5000, 0)^2) abline (h=0:10/10, col="light
92
grey")
93
*/
94
return
0;
95
}
JakesPropagationExample
Constructs a JakesPropagationlossModel and print the loss value as a function of time into std::cout.
Definition
jakes-propagation-model-example.cc:24
JakesPropagationExample::~JakesPropagationExample
~JakesPropagationExample()
Definition
jakes-propagation-model-example.cc:52
JakesPropagationExample::m_secondMobility
Ptr< MobilityModel > m_secondMobility
second Mobility
Definition
jakes-propagation-model-example.cc:32
JakesPropagationExample::m_nextEvent
EventId m_nextEvent
next event
Definition
jakes-propagation-model-example.cc:34
JakesPropagationExample::Next
void Next()
Next function.
Definition
jakes-propagation-model-example.cc:57
JakesPropagationExample::m_firstMobility
Ptr< MobilityModel > m_firstMobility
first Mobility
Definition
jakes-propagation-model-example.cc:31
JakesPropagationExample::m_step
Time m_step
step
Definition
jakes-propagation-model-example.cc:33
JakesPropagationExample::m_loss
Ptr< PropagationLossModel > m_loss
loss
Definition
jakes-propagation-model-example.cc:30
JakesPropagationExample::JakesPropagationExample
JakesPropagationExample()
Definition
jakes-propagation-model-example.cc:41
ns3::CommandLine
Parse command-line arguments.
Definition
command-line.h:221
ns3::EventId
An identifier for simulation events.
Definition
event-id.h:45
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
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::Now
static Time Now()
Return the current simulation virtual time.
Definition
simulator.cc:197
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::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
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:404
ns3::Time::MS
@ MS
millisecond
Definition
nstime.h:106
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::CreateObject
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition
object.h:619
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition
nstime.h:1308
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
propagation
examples
jakes-propagation-model-example.cc
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0