A Discrete-Event Network Simulator
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 * 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
26using namespace ns3;
27
28/**
29 * \ingroup propagation
30 * \brief Constructs a JakesPropagationlossModel and print the loss value as a function of time into
31 * std::cout. Distribution and correlation statistics is compared with a theoretical ones using R
32 * package (http://www.r-project.org/). Scripts are presented within comments.
33 */
35{
36 public:
39
40 private:
44 Time m_step; //!< step
45 EventId m_nextEvent; //!< next event
46 /**
47 * Next function
48 * */
49 void Next();
50};
51
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));
61}
62
64{
65}
66
67void
69{
71 std::cout << Simulator::Now().As(Time::MS) << " "
73}
74
75int
76main(int argc, char* argv[])
77{
78 Config::SetDefault("ns3::JakesProcess::NumberOfOscillators", UintegerValue(100));
79 CommandLine cmd(__FILE__);
80 cmd.Parse(argc, argv);
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}
Constructs a JakesPropagationlossModel and print the loss value as a function of time into std::cout.
Ptr< MobilityModel > m_secondMobility
second Mobility
Ptr< MobilityModel > m_firstMobility
first Mobility
Ptr< PropagationLossModel > m_loss
loss
Parse command-line arguments.
Definition: command-line.h:232
An identifier for simulation events.
Definition: event-id.h:55
void SetPosition(const Vector &position)
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.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
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
@ MS
millisecond
Definition: nstime.h:117
Hold an unsigned integer type.
Definition: uinteger.h:45
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:894
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Every class exported by the ns3 library is enclosed in the ns3 namespace.