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 * 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
15using 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 */
24{
25 public:
28
29 private:
33 Time m_step; //!< step
34 EventId m_nextEvent; //!< next event
35 /**
36 * Next function
37 * */
38 void Next();
39};
40
51
55
56void
63
64int
65main(int argc, char* argv[])
66{
67 Config::SetDefault("ns3::JakesProcess::NumberOfOscillators", UintegerValue(100));
68 CommandLine cmd(__FILE__);
69 cmd.Parse(argc, argv);
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}
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.
An identifier for simulation events.
Definition event-id.h:45
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
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
@ MS
millisecond
Definition nstime.h:106
Hold an unsigned integer type.
Definition uinteger.h:34
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:883
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.