src/lr-wpan/model/lr-wpan-spectrum-value-helper.cc
author Tommaso Pecorella <tommaso.pecorella@unifi.it>
Sun, 01 Feb 2015 21:08:32 -0800
changeset 11205 29b708f01eb1
parent 10968 2d29fee2b7b8
permissions -rw-r--r--
bug 1774: compute signal power around channel, not across whole band
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
10968
2d29fee2b7b8 [Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10875
diff changeset
    26
namespace ns3 {
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    27
10968
2d29fee2b7b8 [Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10875
diff changeset
    28
NS_LOG_COMPONENT_DEFINE ("LrWpanSpectrumValueHelper");
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    29
10875
632910874fa9 lr-wpan: remove dead code and add Doxygen
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10811
diff changeset
    30
Ptr<SpectrumModel> g_LrWpanSpectrumModel; //!< Global object used to initialize the LrWpan Spectrum Model
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    31
10875
632910874fa9 lr-wpan: remove dead code and add Doxygen
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10811
diff changeset
    32
/**
632910874fa9 lr-wpan: remove dead code and add Doxygen
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10811
diff changeset
    33
 * \ingroup lr-wpan
632910874fa9 lr-wpan: remove dead code and add Doxygen
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10811
diff changeset
    34
 * \brief Helper class used to automatically initialize the LrWpan Spectrum Model objects
632910874fa9 lr-wpan: remove dead code and add Doxygen
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10811
diff changeset
    35
 */
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    36
class LrWpanSpectrumModelInitializer
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    37
{
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    38
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
    39
  LrWpanSpectrumModelInitializer (void)
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    40
  {
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
    41
    NS_LOG_FUNCTION (this);
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    42
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    43
    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
    44
    // 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
    45
    // 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
    46
    for (int i = -1; i < 83; i++)
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    47
      {
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    48
        BandInfo bi;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    49
        bi.fl = 2400.5e6 + i * 1.0e6;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    50
        bi.fh = 2400.5e6 + (i + 1) * 1.0e6;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    51
        bi.fc = (bi.fl +  bi.fh) / 2;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    52
        bands.push_back (bi);
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    53
      }
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    54
    g_LrWpanSpectrumModel = Create<SpectrumModel> (bands);
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    55
  }
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    56
11205
29b708f01eb1 bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10968
diff changeset
    57
} g_LrWpanSpectrumModelInitializerInstance; //!< Global object used to initialize the LrWpan Spectrum Model
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    58
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
    59
LrWpanSpectrumValueHelper::LrWpanSpectrumValueHelper (void)
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    60
{
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
    61
  NS_LOG_FUNCTION (this);
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
    62
  m_noiseFactor = 1.0;
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    63
}
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    64
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
    65
LrWpanSpectrumValueHelper::~LrWpanSpectrumValueHelper (void)
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    66
{
10750
8a9e91fac9c0 First Doxygen documentation batch and code cleanups.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents: 10728
diff changeset
    67
  NS_LOG_FUNCTION (this);
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    68
}
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    69
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    70
Ptr<SpectrumValue>
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    71
LrWpanSpectrumValueHelper::CreateTxPowerSpectralDensity (double txPower, uint32_t channel)
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    72
{
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
    73
  NS_LOG_FUNCTION (this);
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    74
  Ptr<SpectrumValue> txPsd = Create <SpectrumValue> (g_LrWpanSpectrumModel);
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    75
10811
31dbab5c8a28 bug 1924 - sensing radius and CCA
Sascha Jopen <jopen@cs.uni-bonn.de>
parents: 10760
diff changeset
    76
  // 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
    77
  txPower = pow (10., (txPower - 30) / 10);
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    78
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
    79
  // 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
    80
  // 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
    81
  // 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
    82
  // 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
    83
  // The two outer side bands contain roughly 0.5%.
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    84
  double txPowerDensity = txPower / 2.0e6;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    85
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    86
  NS_ASSERT_MSG ((channel >= 11 && channel <= 26), "Invalid channel numbers");
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    87
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    88
  // 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
    89
  // 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
    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
  (*txPsd)[2405 + 5 * (channel - 11) - 2400 - 1] = txPowerDensity * 0.495;
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    92
  (*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
    93
  (*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
    94
  (*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
    95
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
    96
  // 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
    97
  // 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
    98
  // txPsd still equals txPower
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    99
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   100
  return txPsd;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   101
}
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   102
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   103
Ptr<SpectrumValue>
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   104
LrWpanSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t channel)
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   105
{
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
   106
  NS_LOG_FUNCTION (this);
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   107
  Ptr<SpectrumValue> noisePsd = Create <SpectrumValue> (g_LrWpanSpectrumModel);
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   108
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   109
  static const double BOLTZMANN = 1.3803e-23;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   110
  // Nt  is the power of thermal noise in W
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   111
  double Nt = BOLTZMANN * 290.0;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   112
  // 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
   113
  double noisePowerDensity = m_noiseFactor * Nt;
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   114
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   115
  NS_ASSERT_MSG ((channel >= 11 && channel <= 26), "Invalid channel numbers");
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   116
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
   117
  (*noisePsd)[2405 + 5 * (channel - 11) - 2400 - 2] = noisePowerDensity;
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   118
  (*noisePsd)[2405 + 5 * (channel - 11) - 2400 - 1] = noisePowerDensity;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   119
  (*noisePsd)[2405 + 5 * (channel - 11) - 2400] = noisePowerDensity;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   120
  (*noisePsd)[2405 + 5 * (channel - 11) - 2400 + 1] = noisePowerDensity;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   121
  (*noisePsd)[2405 + 5 * (channel - 11) - 2400 + 2] = noisePowerDensity;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   122
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   123
  return noisePsd;
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   124
}
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   125
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
   126
double
11205
29b708f01eb1 bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10968
diff changeset
   127
LrWpanSpectrumValueHelper::TotalAvgPower (Ptr<const SpectrumValue> psd, uint32_t channel)
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
   128
{
10728
62d4098c1c22 First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents: 10720
diff changeset
   129
  NS_LOG_FUNCTION (psd);
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
   130
  double totalAvgPower = 0.0;
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   131
11205
29b708f01eb1 bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10968
diff changeset
   132
  NS_ASSERT (psd->GetSpectrumModel () == g_LrWpanSpectrumModel);
29b708f01eb1 bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10968
diff changeset
   133
29b708f01eb1 bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10968
diff changeset
   134
  // numerically integrate to get area under psd using 1 MHz resolution
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   135
11205
29b708f01eb1 bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10968
diff changeset
   136
  totalAvgPower += (*psd)[2405 + 5 * (channel - 11) - 2400 - 2];
29b708f01eb1 bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10968
diff changeset
   137
  totalAvgPower += (*psd)[2405 + 5 * (channel - 11) - 2400 - 1];
29b708f01eb1 bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10968
diff changeset
   138
  totalAvgPower += (*psd)[2405 + 5 * (channel - 11) - 2400];
29b708f01eb1 bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10968
diff changeset
   139
  totalAvgPower += (*psd)[2405 + 5 * (channel - 11) - 2400 + 1];
29b708f01eb1 bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10968
diff changeset
   140
  totalAvgPower += (*psd)[2405 + 5 * (channel - 11) - 2400 + 2];
29b708f01eb1 bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10968
diff changeset
   141
  totalAvgPower *= 1.0e6;
29b708f01eb1 bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 10968
diff changeset
   142
10712
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
   143
  return totalAvgPower;
b953606d11fa roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents: 10711
diff changeset
   144
}
10711
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   145
a6dfe3e184c0 Initial lr-wpan checkin
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   146
} // namespace ns3