src/propagation/examples/main-propagation-loss.cc
author Mitch Watrous
Wed, 15 Aug 2012 18:08:46 -0700
changeset 8985 7752dc4ce7e9
parent 8786 8f366d5eee06
permissions -rw-r--r--
Replace src/buildings and src/propagation usage of RandomVariable with RandomVariableStream
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7385
10beb0e53130 standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents: 7256
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2066
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
     3
 * Copyright (c) 2008 Timo Bingmann
2066
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 *
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    18
 * Author: Timo Bingmann <timo.bingmann@student.kit.edu>
2066
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 */
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    20
2066
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
#include "ns3/propagation-loss-model.h"
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    22
#include "ns3/jakes-propagation-loss-model.h"
4257
3e8f8052e155 StaticMobilityModel -> ConstantPositionMobilityModel, StaticSpeedMobilityModel -> ConstantVelocityMobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4059
diff changeset
    23
#include "ns3/constant-position-mobility-model.h"
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    24
2577
5b41cb5c3fcf kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2549
diff changeset
    25
#include "ns3/config.h"
5b41cb5c3fcf kill DefaultValue
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2549
diff changeset
    26
#include "ns3/string.h"
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    27
#include "ns3/boolean.h"
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    28
#include "ns3/double.h"
8985
7752dc4ce7e9 Replace src/buildings and src/propagation usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 8786
diff changeset
    29
#include "ns3/pointer.h"
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    30
#include "ns3/gnuplot.h"
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    31
#include "ns3/simulator.h"
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    32
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    33
#include <map>
2066
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
using namespace ns3;
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    37
/// Round a double number to the given precision. e.g. dround(0.234, 0.1) = 0.2
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    38
/// and dround(0.257, 0.1) = 0.3
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
    39
static double dround (double number, double precision)
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    40
{
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    41
  number /= precision;
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    42
  if (number >= 0)
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    43
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
    44
      number = floor (number + 0.5);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    45
    }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    46
  else
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    47
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
    48
      number = ceil (number - 0.5);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    49
    }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    50
  number *= precision;
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    51
  return number;
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    52
}
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    53
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    54
static Gnuplot
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    55
TestDeterministic (Ptr<PropagationLossModel> model)
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    56
{
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    57
  Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    58
  Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    59
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    60
  Gnuplot plot;
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    61
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
    62
  plot.AppendExtra ("set xlabel 'Distance'");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
    63
  plot.AppendExtra ("set ylabel 'rxPower (dBm)'");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
    64
  plot.AppendExtra ("set key top right");
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    65
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    66
  double txPowerDbm = +20; // dBm
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    67
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    68
  Gnuplot2dDataset dataset;
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    69
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
    70
  dataset.SetStyle (Gnuplot2dDataset::LINES);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    71
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    72
  {
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    73
    a->SetPosition (Vector (0.0, 0.0, 0.0));
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    74
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    75
    for (double distance = 0.0; distance < 2500.0; distance += 10.0)
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    76
      {
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    77
        b->SetPosition (Vector (distance, 0.0, 0.0));
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    78
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    79
        // CalcRxPower() returns dBm.
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    80
        double rxPowerDbm = model->CalcRxPower (txPowerDbm, a, b);
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    81
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
    82
        dataset.Add (distance, rxPowerDbm);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    83
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    84
        Simulator::Stop (Seconds (1.0));
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    85
        Simulator::Run ();
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    86
      }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    87
  }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    88
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    89
  std::ostringstream os;
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    90
  os << "txPower " << txPowerDbm << "dBm";
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
    91
  dataset.SetTitle (os.str ());
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    92
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
    93
  plot.AddDataset (dataset);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    94
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
    95
  plot.AddDataset ( Gnuplot2dFunction ("-94 dBm CSThreshold", "-94.0") );
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    96
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    97
  return plot;
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    98
}
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
    99
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   100
static Gnuplot
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   101
TestProbabilistic (Ptr<PropagationLossModel> model, unsigned int samples = 100000)
2066
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
{
4257
3e8f8052e155 StaticMobilityModel -> ConstantPositionMobilityModel, StaticSpeedMobilityModel -> ConstantVelocityMobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4059
diff changeset
   103
  Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
3e8f8052e155 StaticMobilityModel -> ConstantPositionMobilityModel, StaticSpeedMobilityModel -> ConstantVelocityMobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4059
diff changeset
   104
  Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   105
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   106
  Gnuplot plot;
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   107
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   108
  plot.AppendExtra ("set xlabel 'Distance'");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   109
  plot.AppendExtra ("set ylabel 'rxPower (dBm)'");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   110
  plot.AppendExtra ("set zlabel 'Probability' offset 0,+10");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   111
  plot.AppendExtra ("set view 50, 120, 1.0, 1.0");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   112
  plot.AppendExtra ("set key top right");
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   113
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   114
  plot.AppendExtra ("set ticslevel 0");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   115
  plot.AppendExtra ("set xtics offset -0.5,0");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   116
  plot.AppendExtra ("set ytics offset 0,-0.5");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   117
  plot.AppendExtra ("set xrange [100:]");
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   118
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   119
  double txPowerDbm = +20; // dBm
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   120
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   121
  Gnuplot3dDataset dataset;
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   122
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   123
  dataset.SetStyle ("with linespoints");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   124
  dataset.SetExtra ("pointtype 3 pointsize 0.5");
7188
ea48206d68bd propagation coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7076
diff changeset
   125
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   126
  typedef std::map<double, unsigned int> rxPowerMapType;
2549
fe90cf0b2c63 port propagation models and channel to attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2230
diff changeset
   127
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   128
  // Take given number of samples from CalcRxPower() and show probability
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   129
  // density for discrete distances.
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   130
  {
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   131
    a->SetPosition (Vector (0.0, 0.0, 0.0));
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   132
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   133
    for (double distance = 100.0; distance < 2500.0; distance += 100.0)
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   134
      {
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   135
        b->SetPosition (Vector (distance, 0.0, 0.0));
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   136
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   137
        rxPowerMapType rxPowerMap;
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   138
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   139
        for (unsigned int samp = 0; samp < samples; ++samp)
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   140
          {
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   141
            // CalcRxPower() returns dBm.
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   142
            double rxPowerDbm = model->CalcRxPower (txPowerDbm, a, b);
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   143
            rxPowerDbm = dround (rxPowerDbm, 1.0);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   144
7188
ea48206d68bd propagation coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7076
diff changeset
   145
            rxPowerMap[ rxPowerDbm ]++;
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   146
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   147
            Simulator::Stop (Seconds (0.01));
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   148
            Simulator::Run ();
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   149
          }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   150
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   151
        for (rxPowerMapType::const_iterator i = rxPowerMap.begin ();
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   152
             i != rxPowerMap.end (); ++i)
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   153
          {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   154
            dataset.Add (distance, i->first, (double)i->second / (double)samples);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   155
          }
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   156
        dataset.AddEmptyLine ();
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   157
      }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   158
  }
2066
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   159
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   160
  std::ostringstream os;
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   161
  os << "txPower " << txPowerDbm << "dBm";
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   162
  dataset.SetTitle (os.str ());
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   163
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   164
  plot.AddDataset (dataset);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   165
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   166
  return plot;
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   167
}
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   168
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   169
static Gnuplot
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   170
TestDeterministicByTime (Ptr<PropagationLossModel> model,
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   171
                         Time timeStep = Seconds (0.001),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   172
                         Time timeTotal = Seconds (1.0),
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   173
                         double distance = 100.0)
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   174
{
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   175
  Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   176
  Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   177
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   178
  Gnuplot plot;
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   179
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   180
  plot.AppendExtra ("set xlabel 'Time (s)'");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   181
  plot.AppendExtra ("set ylabel 'rxPower (dBm)'");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   182
  plot.AppendExtra ("set key center right");
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   183
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   184
  double txPowerDbm = +20; // dBm
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   185
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   186
  Gnuplot2dDataset dataset;
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   187
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   188
  dataset.SetStyle (Gnuplot2dDataset::LINES);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   189
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   190
  {
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   191
    a->SetPosition (Vector (0.0, 0.0, 0.0));
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   192
    b->SetPosition (Vector (distance, 0.0, 0.0));
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   193
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   194
    Time start = Simulator::Now ();
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   195
    while( Simulator::Now () < start + timeTotal )
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   196
      {
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   197
        // CalcRxPower() returns dBm.
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   198
        double rxPowerDbm = model->CalcRxPower (txPowerDbm, a, b);
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   199
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   200
        Time elapsed = Simulator::Now () - start;
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   201
        dataset.Add (elapsed.GetSeconds (), rxPowerDbm);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   202
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   203
        Simulator::Stop (timeStep);
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   204
        Simulator::Run ();
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   205
      }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   206
  }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   207
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   208
  std::ostringstream os;
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   209
  os << "txPower " << txPowerDbm << "dBm";
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   210
  dataset.SetTitle (os.str ());
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   211
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   212
  plot.AddDataset (dataset);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   213
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   214
  plot.AddDataset ( Gnuplot2dFunction ("-94 dBm CSThreshold", "-94.0") );
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   215
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   216
  return plot;
2066
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   217
}
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   218
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   219
int main (int argc, char *argv[])
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   220
{
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   221
  GnuplotCollection gnuplots ("main-propagation-loss.pdf");
2066
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   222
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   223
  {
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   224
    Ptr<FriisPropagationLossModel> friis = CreateObject<FriisPropagationLossModel> ();
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   225
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   226
    Gnuplot plot = TestDeterministic (friis);
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   227
    plot.SetTitle ("ns3::FriisPropagationLossModel (Default Parameters)");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   228
    gnuplots.AddPlot (plot);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   229
  }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   230
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   231
  {
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   232
    Ptr<LogDistancePropagationLossModel> log = CreateObject<LogDistancePropagationLossModel> ();
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   233
    log->SetAttribute ("Exponent", DoubleValue (2.5));
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   234
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   235
    Gnuplot plot = TestDeterministic (log);
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   236
    plot.SetTitle ("ns3::LogDistancePropagationLossModel (Exponent = 2.5)");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   237
    gnuplots.AddPlot (plot);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   238
  }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   239
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   240
  {
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   241
    Ptr<RandomPropagationLossModel> random = CreateObject<RandomPropagationLossModel> ();
8985
7752dc4ce7e9 Replace src/buildings and src/propagation usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 8786
diff changeset
   242
    Ptr<ExponentialRandomVariable> expVar = CreateObjectWithAttributes<ExponentialRandomVariable> ("Mean", DoubleValue (50.0));
7752dc4ce7e9 Replace src/buildings and src/propagation usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 8786
diff changeset
   243
    random->SetAttribute ("Variable", PointerValue (expVar));
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   244
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   245
    Gnuplot plot = TestDeterministic (random);
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   246
    plot.SetTitle ("ns3::RandomPropagationLossModel with Exponential Distribution");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   247
    gnuplots.AddPlot (plot);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   248
  }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   249
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   250
  {
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   251
    Ptr<JakesPropagationLossModel> jakes = CreateObject<JakesPropagationLossModel> ();
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   252
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   253
    // doppler frequency shift for 5.15 GHz at 100 km/h
8786
8f366d5eee06 Bug 1140: fixed. New Jakes model has been implemented.
Kirill Andreev <andreev@telum.ru>
parents: 7385
diff changeset
   254
    Config::SetDefault ("ns3::JakesProcess::DopplerFrequencyHz", DoubleValue (477.9));
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   255
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   256
    Gnuplot plot = TestDeterministicByTime (jakes, Seconds (0.001), Seconds (1.0));
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   257
    plot.SetTitle ("ns3::JakesPropagationLossModel (with 477.9 Hz shift and 1 millisec resolution)");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   258
    gnuplots.AddPlot (plot);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   259
  }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   260
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   261
  {
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   262
    Ptr<JakesPropagationLossModel> jakes = CreateObject<JakesPropagationLossModel> ();
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   263
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   264
    // doppler frequency shift for 5.15 GHz at 100 km/h
8786
8f366d5eee06 Bug 1140: fixed. New Jakes model has been implemented.
Kirill Andreev <andreev@telum.ru>
parents: 7385
diff changeset
   265
    Config::SetDefault ("ns3::JakesProcess::DopplerFrequencyHz", DoubleValue (477.9));
2066
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   266
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   267
    Gnuplot plot = TestDeterministicByTime (jakes, Seconds (0.0001), Seconds (0.1));
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   268
    plot.SetTitle ("ns3::JakesPropagationLossModel (with 477.9 Hz shift and 0.1 millisec resolution)");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   269
    gnuplots.AddPlot (plot);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   270
  }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   271
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   272
  {
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   273
    Ptr<ThreeLogDistancePropagationLossModel> log3 = CreateObject<ThreeLogDistancePropagationLossModel> ();
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   274
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   275
    Gnuplot plot = TestDeterministic (log3);
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   276
    plot.SetTitle ("ns3::ThreeLogDistancePropagationLossModel (Defaults)");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   277
    gnuplots.AddPlot (plot);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   278
  }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   279
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   280
  {
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   281
    Ptr<ThreeLogDistancePropagationLossModel> log3 = CreateObject<ThreeLogDistancePropagationLossModel> ();
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   282
    // more prominent example values:
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   283
    log3->SetAttribute ("Exponent0", DoubleValue (1.0));
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   284
    log3->SetAttribute ("Exponent1", DoubleValue (3.0));
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   285
    log3->SetAttribute ("Exponent2", DoubleValue (10.0));
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   286
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   287
    Gnuplot plot = TestDeterministic (log3);
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   288
    plot.SetTitle ("ns3::ThreeLogDistancePropagationLossModel (Exponents 1.0, 3.0 and 10.0)");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   289
    gnuplots.AddPlot (plot);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   290
  }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   291
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   292
  {
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   293
    Ptr<NakagamiPropagationLossModel> nak = CreateObject<NakagamiPropagationLossModel> ();
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   294
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   295
    Gnuplot plot = TestProbabilistic (nak);
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   296
    plot.SetTitle ("ns3::NakagamiPropagationLossModel (Default Parameters)");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   297
    gnuplots.AddPlot (plot);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   298
  }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   299
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   300
  {
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   301
    Ptr<ThreeLogDistancePropagationLossModel> log3 = CreateObject<ThreeLogDistancePropagationLossModel> ();
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   302
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   303
    Ptr<NakagamiPropagationLossModel> nak = CreateObject<NakagamiPropagationLossModel> ();
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   304
    log3->SetNext (nak);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   305
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   306
    Gnuplot plot = TestProbabilistic (log3);
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   307
    plot.SetTitle ("ns3::ThreeLogDistancePropagationLossModel and ns3::NakagamiPropagationLossModel (Default Parameters)");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   308
    gnuplots.AddPlot (plot);
4465
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   309
  }
de0995fde236 test propagation loss models
Timo Bingmann <timo.bingmann@student.kit.edu>
parents: 4257
diff changeset
   310
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7188
diff changeset
   311
  gnuplots.GenerateOutput (std::cout);
2066
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   312
7076
6a0cbbce8f67 clean valgrind report for main-propagation-loss.cc example
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   313
  // produce clean valgrind
6a0cbbce8f67 clean valgrind report for main-propagation-loss.cc example
Tom Henderson <tomh@tomh.org>
parents: 7025
diff changeset
   314
  Simulator::Destroy ();
2066
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   315
  return 0;
4477ee7d0798 test propagation losses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   316
}