src/lr-wpan/model/lr-wpan-spectrum-value-helper.cc
author Sascha Jopen <jopen@cs.uni-bonn.de>
Thu, 12 Jun 2014 12:35:32 -0700
changeset 10811 31dbab5c8a28
parent 10760 d7d73e3ceb3c
child 10875 632910874fa9
permissions -rw-r--r--
bug 1924 - sensing radius and CCA
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     2
/*
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     3
 * Copyright (c) 2011 The Boeing Company
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     4
 *
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     8
 *
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    12
 * GNU General Public License for more details.
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    13
 *
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    17
 *
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    18
 * Author: Gary Pei <guangyu.pei@boeing.com>
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    19
 */
10720
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    20
#include "lr-wpan-spectrum-value-helper.h"
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    21
#include <ns3/log.h>
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    22
#include <ns3/spectrum-value.h>
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    23
10720
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    24
#include <cmath>
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    25
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
    26
NS_LOG_COMPONENT_DEFINE ("LrWpanSpectrumValueHelper");
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    27
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    28
namespace ns3 {
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    29
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    30
Ptr<SpectrumModel> g_LrWpanSpectrumModel;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    31
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    32
class LrWpanSpectrumModelInitializer
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    33
{
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    34
public:
10720
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    35
  LrWpanSpectrumModelInitializer (void)
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    36
  {
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
    37
    NS_LOG_FUNCTION (this);
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    38
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    39
    Bands bands;
10720
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    40
    // 1 MHz resolution, with center frequency of 2400, 2401, ... 2483
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    41
    // overall frequency span of 2399.5 MHz through 2483.5 MHz (83 bands)
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    42
    for (int i = -1; i < 83; i++)
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    43
      {
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    44
        BandInfo bi;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    45
        bi.fl = 2400.5e6 + i * 1.0e6;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    46
        bi.fh = 2400.5e6 + (i + 1) * 1.0e6;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    47
        bi.fc = (bi.fl +  bi.fh) / 2;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    48
        bands.push_back (bi);
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    49
      }
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    50
    g_LrWpanSpectrumModel = Create<SpectrumModel> (bands);
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    51
  }
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    52
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    53
} g_LrWpanSpectrumModelInitializerInstance;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    54
10720
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    55
LrWpanSpectrumValueHelper::LrWpanSpectrumValueHelper (void)
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    56
{
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
    57
  NS_LOG_FUNCTION (this);
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
    58
  m_noiseFactor = 1.0;
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    59
}
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    60
10720
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    61
LrWpanSpectrumValueHelper::~LrWpanSpectrumValueHelper (void)
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    62
{
10750
8a9e91fac9c0 First Doxygen documentation batch and code cleanups.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents: 10728
diff changeset
    63
  NS_LOG_FUNCTION (this);
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    64
}
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    65
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    66
Ptr<SpectrumValue>
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    67
LrWpanSpectrumValueHelper::CreateTxPowerSpectralDensity (double txPower, uint32_t channel)
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    68
{
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
    69
  NS_LOG_FUNCTION (this);
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    70
  Ptr<SpectrumValue> txPsd = Create <SpectrumValue> (g_LrWpanSpectrumModel);
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    71
10811
31dbab5c8a28 bug 1924 - sensing radius and CCA
Sascha Jopen <jopen@cs.uni-bonn.de>
parents: 10760
diff changeset
    72
  // txPower is expressed in dBm. We must convert it into natural unit (W).
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    73
  txPower = pow (10., (txPower - 30) / 10);
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    74
10720
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    75
  // The effective occupied bandwidth of the signal is modelled to be 2 MHz.
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    76
  // 99.5% of power is within +/- 1MHz of center frequency, and 0.5% is outside.
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    77
  // There are 5 bands containing signal power.  The middle (center) band
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    78
  // contains half of the power.  The two inner side bands contain 49.5%.
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    79
  // The two outer side bands contain roughly 0.5%.
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    80
  double txPowerDensity = txPower / 2.0e6;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    81
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    82
  NS_ASSERT_MSG ((channel >= 11 && channel <= 26), "Invalid channel numbers");
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    83
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    84
  // The channel assignment is in section 6.1.2.1
10720
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    85
  // Channel 11 centered at 2.405 GHz, 12 at 2.410 GHz, ... 26 at 2.480 GHz
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    86
  (*txPsd)[2405 + 5 * (channel - 11) - 2400 - 2] = txPowerDensity * 0.005;
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    87
  (*txPsd)[2405 + 5 * (channel - 11) - 2400 - 1] = txPowerDensity * 0.495;
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    88
  (*txPsd)[2405 + 5 * (channel - 11) - 2400] = txPowerDensity; // center
10720
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    89
  (*txPsd)[2405 + 5 * (channel - 11) - 2400 + 1 ] = txPowerDensity * 0.495;
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    90
  (*txPsd)[2405 + 5 * (channel - 11) - 2400 + 2 ] = txPowerDensity * 0.005;
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    91
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    92
  // If more power is allocated to more subbands in future revisions of
10760
d7d73e3ceb3c Apply utils/check-style.py script on lr-wpan source code again
Tom Henderson <tomh@tomh.org>
parents: 10750
diff changeset
    93
  // this model, make sure to renormalize so that the integral of the
10720
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
    94
  // txPsd still equals txPower
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    95
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    96
  return txPsd;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    97
}
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    98
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    99
Ptr<SpectrumValue>
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   100
LrWpanSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t channel)
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   101
{
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
   102
  NS_LOG_FUNCTION (this);
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   103
  Ptr<SpectrumValue> noisePsd = Create <SpectrumValue> (g_LrWpanSpectrumModel);
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   104
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   105
  static const double BOLTZMANN = 1.3803e-23;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   106
  // Nt  is the power of thermal noise in W
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   107
  double Nt = BOLTZMANN * 290.0;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   108
  // noise Floor (W) which accounts for thermal noise and non-idealities of the receiver
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
   109
  double noisePowerDensity = m_noiseFactor * Nt;
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   110
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   111
  NS_ASSERT_MSG ((channel >= 11 && channel <= 26), "Invalid channel numbers");
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   112
10720
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
   113
  (*noisePsd)[2405 + 5 * (channel - 11) - 2400 - 2] = noisePowerDensity;
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   114
  (*noisePsd)[2405 + 5 * (channel - 11) - 2400 - 1] = noisePowerDensity;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   115
  (*noisePsd)[2405 + 5 * (channel - 11) - 2400] = noisePowerDensity;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   116
  (*noisePsd)[2405 + 5 * (channel - 11) - 2400 + 1] = noisePowerDensity;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   117
  (*noisePsd)[2405 + 5 * (channel - 11) - 2400 + 2] = noisePowerDensity;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   118
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   119
  return noisePsd;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   120
}
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   121
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
   122
double
10720
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
   123
LrWpanSpectrumValueHelper::TotalAvgPower (Ptr<const SpectrumValue> psd)
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
   124
{
10728
62d4098c1c22 First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents: 10720
diff changeset
   125
  NS_LOG_FUNCTION (psd);
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
   126
  double totalAvgPower = 0.0;
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   127
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
   128
  // numerically integrate to get area under psd using
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
   129
  // 1 MHz resolution from 2400 to 2483 MHz (center freq)
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   130
10720
4e4a0de88982 ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10712
diff changeset
   131
  totalAvgPower = Sum (*psd * 1.0e6);
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
   132
  return totalAvgPower;
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
   133
}
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   134
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   135
} // namespace ns3