src/common/propagation-loss-model-test-suite.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 25 Feb 2010 14:17:21 +0100
changeset 6068 a2127017ecb4
parent 5972 def0efbb0fd5
child 6115 edc1648e5ad4
permissions -rw-r--r--
merge with HEAD
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5944
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     2
/*
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2009 The Boeing Company
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     4
 *
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     8
 *
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    13
 *
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    17
 */
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    18
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    19
#include "ns3/log.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    20
#include "ns3/abort.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    21
#include "ns3/test.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    22
#include "ns3/pcap-file.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    23
#include "ns3/config.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    24
#include "ns3/string.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    25
#include "ns3/uinteger.h"
6068
a2127017ecb4 merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5972
diff changeset
    26
#include "ns3/double.h"
5944
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    27
#include "ns3/data-rate.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    28
#include "ns3/inet-socket-address.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    29
#include "ns3/internet-stack-helper.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    30
#include "ns3/ipv4-address-helper.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    31
#include "ns3/tcp-socket-factory.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    32
#include "ns3/yans-wifi-helper.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    33
#include "ns3/propagation-loss-model.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    34
#include "ns3/propagation-delay-model.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    35
#include "ns3/yans-wifi-channel.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    36
#include "ns3/yans-wifi-phy.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    37
#include "ns3/wifi-net-device.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    38
#include "ns3/mobility-helper.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    39
#include "ns3/constant-position-mobility-model.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    40
#include "ns3/nqos-wifi-mac-helper.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    41
#include "ns3/simulator.h"
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    42
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    43
using namespace ns3;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    44
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    45
NS_LOG_COMPONENT_DEFINE ("PropagationLossModelsTest");
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    46
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    47
// ===========================================================================
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    48
// This is a simple test to validate propagation loss models of ns-3 wifi.
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    49
// See the chapter in the ns-3 testing and validation guide for more detail
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    50
// ===========================================================================
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    51
//
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    52
class FriisPropagationLossModelTestCase : public TestCase
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    53
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    54
public:
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    55
  FriisPropagationLossModelTestCase ();
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    56
  virtual ~FriisPropagationLossModelTestCase ();
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    57
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    58
private:
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    59
  virtual bool DoRun (void);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    60
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    61
  typedef struct {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    62
    Vector m_position;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    63
    double m_pt;  // dBm
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    64
    double m_pr;  // W
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    65
    double m_tolerance;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    66
  } TestVector;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    67
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    68
  TestVectors<TestVector> m_testVectors;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    69
};
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    70
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    71
FriisPropagationLossModelTestCase::FriisPropagationLossModelTestCase ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    72
  : TestCase ("Check to see that the ns-3 Friis propagation loss model provides correct received power"), m_testVectors ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    73
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    74
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    75
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    76
FriisPropagationLossModelTestCase::~FriisPropagationLossModelTestCase ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    77
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    78
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    79
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    80
bool
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    81
FriisPropagationLossModelTestCase::DoRun (void)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    82
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    83
  // The ns-3 testing manual gives more background on the values selected
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    84
  // for this test.  First, set a few defaults. 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    85
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    86
  // wavelength at 2.4 GHz is 0.125m
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    87
  Config::SetDefault ("ns3::FriisPropagationLossModel::Lambda", DoubleValue (0.125));
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    88
  Config::SetDefault ("ns3::FriisPropagationLossModel::SystemLoss", DoubleValue (1.0));
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    89
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    90
  // Select a reference transmit power
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    91
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    92
  double txPowerW = 0.05035702;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    93
  double txPowerdBm = 10 * log10 (txPowerW) + 30;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    94
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    95
  //
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    96
  // We want to test the propagation loss model calculations at a few chosen 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    97
  // distances and compare the results to those we have manually calculated
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    98
  // according to the model documentation.  The model reference specifies, 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
    99
  // for instance, that the received power at 100m according to the provided
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   100
  // input power will be 4.98265e-10 W.  Since this value specifies the power
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   101
  // to 1e-15 significance, we test the ns-3 calculated value for agreement 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   102
  // within 5e-16.
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   103
  //
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   104
  TestVector testVector;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   105
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   106
  testVector.m_position = Vector (100, 0, 0);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   107
  testVector.m_pt = txPowerdBm;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   108
  testVector.m_pr = 4.98265e-10;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   109
  testVector.m_tolerance = 5e-16;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   110
  m_testVectors.Add (testVector);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   111
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   112
  testVector.m_position = Vector (500, 0, 0);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   113
  testVector.m_pt = txPowerdBm;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   114
  testVector.m_pr = 1.99306e-11;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   115
  testVector.m_tolerance = 5e-17;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   116
  m_testVectors.Add (testVector);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   117
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   118
  testVector.m_position = Vector (1000, 0, 0);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   119
  testVector.m_pt = txPowerdBm;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   120
  testVector.m_pr = 4.98265e-12;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   121
  testVector.m_tolerance = 5e-18;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   122
  m_testVectors.Add (testVector);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   123
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   124
  testVector.m_position = Vector (2000, 0, 0);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   125
  testVector.m_pt = txPowerdBm;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   126
  testVector.m_pr = 1.24566e-12;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   127
  testVector.m_tolerance = 5e-18;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   128
  m_testVectors.Add (testVector);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   129
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   130
  // Now, check that the received power values are expected
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   131
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   132
  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   133
  a->SetPosition (Vector (0,0,0));
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   134
  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   135
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   136
  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> (); 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   137
  for (uint32_t i = 0; i < m_testVectors.GetN (); ++i)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   138
    {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   139
      testVector = m_testVectors.Get (i);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   140
      b->SetPosition (testVector.m_position);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   141
      double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   142
      double resultW =   pow (10.0, resultdBm/10.0)/1000;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   143
      NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power");
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   144
    }
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   145
	
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   146
  return GetErrorStatus ();
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   147
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   148
5972
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   149
// Added for Two-Ray Ground Model - tomhewer@mac.com
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   150
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   151
class TwoRayGroundPropagationLossModelTestCase : public TestCase
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   152
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   153
public:
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   154
  TwoRayGroundPropagationLossModelTestCase ();
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   155
  virtual ~TwoRayGroundPropagationLossModelTestCase ();
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   156
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   157
private:
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   158
  virtual bool DoRun (void);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   159
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   160
  typedef struct
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   161
  {
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   162
    Vector m_position;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   163
    double m_pt;  // dBm
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   164
    double m_pr;  // W
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   165
    double m_tolerance;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   166
  } TestVector;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   167
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   168
  TestVectors<TestVector> m_testVectors;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   169
};
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   170
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   171
TwoRayGroundPropagationLossModelTestCase::TwoRayGroundPropagationLossModelTestCase ()
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   172
: TestCase ("Check to see that the ns-3 TwoRayGround propagation loss model provides correct received power"),
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   173
m_testVectors ()
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   174
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   175
}
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   176
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   177
TwoRayGroundPropagationLossModelTestCase::~TwoRayGroundPropagationLossModelTestCase ()
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   178
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   179
}
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   180
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   181
bool
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   182
TwoRayGroundPropagationLossModelTestCase::DoRun (void)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   183
{
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   184
  // wavelength at 2.4 GHz is 0.125m
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   185
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::Lambda", DoubleValue (0.125));
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   186
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::SystemLoss", DoubleValue (1.0));
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   187
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   188
  // set antenna height to 1.5m above z coordinate
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   189
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::HeightAboveZ", DoubleValue (1.5));
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   190
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   191
  // Select a reference transmit power of 17.0206 dBm
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   192
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   193
  double txPowerW = 0.05035702;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   194
  double txPowerdBm = 10 * log10 (txPowerW) + 30;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   195
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   196
  //
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   197
  // As with the Friis tests above, we want to test the propagation loss 
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   198
  // model calculations at a few chosen distances and compare the results 
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   199
  // to those we can manually calculate. Let us test the ns-3 calculated 
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   200
  // value for agreement to be within 5e-16, as above.
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   201
  //
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   202
  TestVector testVector;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   203
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   204
  // Below the Crossover distance use Friis so this test should be the same as that above
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   205
  // Crossover = (4 * PI * TxAntennaHeight * RxAntennaHeight) / Lamdba
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   206
  // Crossover = (4 * PI * 1.5 * 1.5) / 0.125 = 226.1946m
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   207
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   208
  testVector.m_position = Vector (100, 0, 0);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   209
  testVector.m_pt = txPowerdBm;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   210
  testVector.m_pr = 4.98265e-10;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   211
  testVector.m_tolerance = 5e-16;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   212
  m_testVectors.Add (testVector);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   213
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   214
  // These values are above the crossover distance and therefore use the Two Ray calculation
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   215
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   216
  testVector.m_position = Vector (500, 0, 0);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   217
  testVector.m_pt = txPowerdBm;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   218
  testVector.m_pr = 4.07891862e-12;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   219
  testVector.m_tolerance = 5e-16;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   220
  m_testVectors.Add (testVector);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   221
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   222
  testVector.m_position = Vector (1000, 0, 0);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   223
  testVector.m_pt = txPowerdBm;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   224
  testVector.m_pr = 2.5493241375e-13;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   225
  testVector.m_tolerance = 5e-16;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   226
  m_testVectors.Add (testVector);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   227
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   228
  testVector.m_position = Vector (2000, 0, 0);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   229
  testVector.m_pt = txPowerdBm;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   230
  testVector.m_pr = 1.593327585938e-14;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   231
  testVector.m_tolerance = 5e-16;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   232
  m_testVectors.Add (testVector);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   233
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   234
  // Repeat the tests for non-zero z coordinates
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   235
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   236
  // Pr = (0.05035702 * (1.5*1.5) * (2.5*2.5)) / (500*500*500*500) = 1.13303295e-11
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   237
  // dCross = (4 * pi * 1.5 * 2.5) / 0.125 = 376.99m
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   238
  testVector.m_position = Vector (500, 0, 1);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   239
  testVector.m_pt = txPowerdBm;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   240
  testVector.m_pr = 1.13303295e-11;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   241
  testVector.m_tolerance = 5e-16;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   242
  m_testVectors.Add (testVector);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   243
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   244
  // Pr = (0.05035702 * (1.5*1.5) * (5.5*5.5)) / (1000*1000*1000*1000) = 3.42742467375e-12
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   245
  // dCross = (4 * pi * 1.5 * 5.5) / 0.125 = 829.38m
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   246
  testVector.m_position = Vector (1000, 0, 4);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   247
  testVector.m_pt = txPowerdBm;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   248
  testVector.m_pr = 3.42742467375e-12;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   249
  testVector.m_tolerance = 5e-16;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   250
  m_testVectors.Add (testVector);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   251
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   252
  // Pr = (0.05035702 * (1.5*1.5) * (11.5*11.5)) / (2000*2000*2000*2000) = 9.36522547734e-13
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   253
  // dCross = (4 * pi * 1.5 * 11.5) / 0.125 = 1734.15m
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   254
  testVector.m_position = Vector (2000, 0, 10);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   255
  testVector.m_pt = txPowerdBm;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   256
  testVector.m_pr = 9.36522547734e-13;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   257
  testVector.m_tolerance = 5e-16;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   258
  m_testVectors.Add (testVector);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   259
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   260
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   261
  // Now, check that the received power values are expected
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   262
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   263
  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   264
  a->SetPosition (Vector (0,0,0));
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   265
  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   266
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   267
  Ptr<TwoRayGroundPropagationLossModel> lossModel = CreateObject<TwoRayGroundPropagationLossModel> (); 
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   268
  for (uint32_t i = 0; i < m_testVectors.GetN (); ++i)
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   269
  {
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   270
    testVector = m_testVectors.Get (i);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   271
    b->SetPosition (testVector.m_position);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   272
    double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b);
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   273
    double resultW =   pow (10.0, resultdBm / 10.0) / 1000;
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   274
    NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power");
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   275
  }
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   276
  
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   277
  return GetErrorStatus ();
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   278
}
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   279
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   280
5944
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   281
class LogDistancePropagationLossModelTestCase : public TestCase
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   282
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   283
public:
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   284
  LogDistancePropagationLossModelTestCase ();
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   285
  virtual ~LogDistancePropagationLossModelTestCase ();
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   286
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   287
private:
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   288
  virtual bool DoRun (void);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   289
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   290
  typedef struct {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   291
    Vector m_position;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   292
    double m_pt;  // dBm
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   293
    double m_pr;  // W
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   294
    double m_tolerance;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   295
  } TestVector;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   296
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   297
  TestVectors<TestVector> m_testVectors;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   298
};
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   299
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   300
LogDistancePropagationLossModelTestCase::LogDistancePropagationLossModelTestCase ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   301
  : TestCase ("Check to see that the ns-3 Log Distance propagation loss model provides correct received power"), m_testVectors ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   302
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   303
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   304
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   305
LogDistancePropagationLossModelTestCase::~LogDistancePropagationLossModelTestCase ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   306
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   307
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   308
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   309
bool
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   310
LogDistancePropagationLossModelTestCase::DoRun (void)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   311
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   312
  // reference loss at 2.4 GHz is 40.045997
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   313
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::ReferenceLoss", DoubleValue (40.045997));
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   314
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::Exponent", DoubleValue (3));
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   315
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   316
  // Select a reference transmit power
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   317
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   318
  double txPowerW = 0.05035702;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   319
  double txPowerdBm = 10 * log10 (txPowerW) + 30;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   320
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   321
  //
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   322
  // We want to test the propagation loss model calculations at a few chosen 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   323
  // distances and compare the results to those we have manually calculated
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   324
  // according to the model documentation.  The following "TestVector" objects
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   325
  // will drive the test.
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   326
  //
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   327
  TestVector testVector;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   328
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   329
  testVector.m_position = Vector (10, 0, 0);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   330
  testVector.m_pt = txPowerdBm;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   331
  testVector.m_pr = 4.98265e-9;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   332
  testVector.m_tolerance = 5e-15; 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   333
  m_testVectors.Add (testVector);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   334
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   335
  testVector.m_position = Vector (20, 0, 0);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   336
  testVector.m_pt = txPowerdBm;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   337
  testVector.m_pr = 6.22831e-10;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   338
  testVector.m_tolerance = 5e-16;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   339
  m_testVectors.Add (testVector);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   340
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   341
  testVector.m_position = Vector (40, 0, 0);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   342
  testVector.m_pt = txPowerdBm;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   343
  testVector.m_pr = 7.78539e-11;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   344
  testVector.m_tolerance = 5e-17;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   345
  m_testVectors.Add (testVector);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   346
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   347
  testVector.m_position = Vector (80, 0, 0);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   348
  testVector.m_pt = txPowerdBm;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   349
  testVector.m_pr = 9.73173e-12;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   350
  testVector.m_tolerance = 5e-17;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   351
  m_testVectors.Add (testVector);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   352
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   353
  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   354
  a->SetPosition (Vector (0,0,0));
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   355
  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   356
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   357
  Ptr<LogDistancePropagationLossModel> lossModel = CreateObject<LogDistancePropagationLossModel> (); 
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   358
  for (uint32_t i = 0; i < m_testVectors.GetN (); ++i)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   359
    {
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   360
      testVector = m_testVectors.Get (i);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   361
      b->SetPosition (testVector.m_position);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   362
      double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   363
      double resultW =   pow (10.0, resultdBm/10.0)/1000;
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   364
      NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power");
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   365
    }
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   366
	
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   367
  return GetErrorStatus ();
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   368
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   369
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   370
class PropagationLossModelsTestSuite : public TestSuite
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   371
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   372
public:
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   373
  PropagationLossModelsTestSuite ();
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   374
};
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   375
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   376
PropagationLossModelsTestSuite::PropagationLossModelsTestSuite ()
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   377
  : TestSuite ("propagation-loss-model", UNIT)
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   378
{
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   379
  AddTestCase (new FriisPropagationLossModelTestCase);
5972
def0efbb0fd5 addition of two ray ground model and tests
tomhewer@blackbook.local
parents: 5944
diff changeset
   380
  AddTestCase (new TwoRayGroundPropagationLossModelTestCase);
5944
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   381
  AddTestCase (new LogDistancePropagationLossModelTestCase);
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   382
}
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   383
b1a245ae00d4 Moving the propagation models of wifi from src/devices/wifi to src/common. The idea is to share them with the other wireless devices.
Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
parents:
diff changeset
   384
PropagationLossModelsTestSuite WifiPropagationLossModelsTestSuite;