A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
lr-wpan-spectrum-value-helper-test.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 The Boeing Company
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Tom Henderson <thomas.r.henderson@boeing.com>
18
*/
19
#include <ns3/log.h>
20
#include <ns3/lr-wpan-spectrum-value-helper.h>
21
#include <ns3/spectrum-value.h>
22
#include <ns3/test.h>
23
24
#include <cmath>
25
26
using namespace
ns3
;
27
34
class
LrWpanSpectrumValueHelperTestCase
:
public
TestCase
35
{
36
public
:
37
LrWpanSpectrumValueHelperTestCase
();
38
~
LrWpanSpectrumValueHelperTestCase
()
override
;
39
40
private
:
41
void
DoRun()
override
;
42
};
43
44
LrWpanSpectrumValueHelperTestCase::LrWpanSpectrumValueHelperTestCase
()
45
:
TestCase
(
"Test the 802.15.4 SpectrumValue helper class"
)
46
{
47
}
48
49
LrWpanSpectrumValueHelperTestCase::~LrWpanSpectrumValueHelperTestCase
()
50
{
51
}
52
53
void
54
LrWpanSpectrumValueHelperTestCase::DoRun
()
55
{
56
LrWpanSpectrumValueHelper
helper;
57
Ptr<SpectrumValue>
value
;
58
double
pwrWatts;
59
for
(uint32_t chan = 11; chan <= 26; chan++)
60
{
61
// 50dBm = 100 W, -50dBm = 0.01 mW
62
for
(
double
pwrdBm = -50; pwrdBm < 50; pwrdBm += 10)
63
{
64
value
= helper.
CreateTxPowerSpectralDensity
(pwrdBm, chan);
65
pwrWatts = pow(10.0, pwrdBm / 10.0) / 1000;
66
// Test that average power calculation is within +/- 25% of expected
67
NS_TEST_ASSERT_MSG_EQ_TOL
(helper.
TotalAvgPower
(
value
, chan),
68
pwrWatts,
69
pwrWatts / 4.0,
70
"Not equal for channel "
<< chan <<
" pwrdBm "
<< pwrdBm);
71
}
72
}
73
}
74
81
class
LrWpanSpectrumValueHelperTestSuite
:
public
TestSuite
82
{
83
public
:
84
LrWpanSpectrumValueHelperTestSuite
();
85
};
86
87
LrWpanSpectrumValueHelperTestSuite::LrWpanSpectrumValueHelperTestSuite
()
88
:
TestSuite
(
"lr-wpan-spectrum-value-helper"
, UNIT)
89
{
90
AddTestCase
(
new
LrWpanSpectrumValueHelperTestCase
, TestCase::QUICK);
91
}
92
93
static
LrWpanSpectrumValueHelperTestSuite
94
g_lrWpanSpectrumValueHelperTestSuite
;
LrWpanSpectrumValueHelperTestCase
LrWpan SpectrumValue Helper TestSuite.
Definition:
lr-wpan-spectrum-value-helper-test.cc:35
LrWpanSpectrumValueHelperTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
lr-wpan-spectrum-value-helper-test.cc:54
LrWpanSpectrumValueHelperTestCase::LrWpanSpectrumValueHelperTestCase
LrWpanSpectrumValueHelperTestCase()
Definition:
lr-wpan-spectrum-value-helper-test.cc:44
LrWpanSpectrumValueHelperTestCase::~LrWpanSpectrumValueHelperTestCase
~LrWpanSpectrumValueHelperTestCase() override
Definition:
lr-wpan-spectrum-value-helper-test.cc:49
LrWpanSpectrumValueHelperTestSuite
LrWpan SpectrumValue Helper TestSuite.
Definition:
lr-wpan-spectrum-value-helper-test.cc:82
LrWpanSpectrumValueHelperTestSuite::LrWpanSpectrumValueHelperTestSuite
LrWpanSpectrumValueHelperTestSuite()
Definition:
lr-wpan-spectrum-value-helper-test.cc:87
ns3::LrWpanSpectrumValueHelper
This class defines all functions to create spectrum model for LrWpan.
Definition:
lr-wpan-spectrum-value-helper.h:35
ns3::LrWpanSpectrumValueHelper::TotalAvgPower
static double TotalAvgPower(Ptr< const SpectrumValue > psd, uint32_t channel)
total average power of the signal is the integral of the PSD using the limits of the given channel
Definition:
lr-wpan-spectrum-value-helper.cc:136
ns3::LrWpanSpectrumValueHelper::CreateTxPowerSpectralDensity
Ptr< SpectrumValue > CreateTxPowerSpectralDensity(double txPower, uint32_t channel)
create spectrum value
Definition:
lr-wpan-spectrum-value-helper.cc:74
ns3::Ptr< SpectrumValue >
ns3::TestCase
encapsulates test code
Definition:
test.h:1060
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:301
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1256
NS_TEST_ASSERT_MSG_EQ_TOL
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Definition:
test.h:337
g_lrWpanSpectrumValueHelperTestSuite
static LrWpanSpectrumValueHelperTestSuite g_lrWpanSpectrumValueHelperTestSuite
Static variable for test initialization.
Definition:
lr-wpan-spectrum-value-helper-test.cc:94
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
second.value
value
Definition:
second.py:48
src
lr-wpan
test
lr-wpan-spectrum-value-helper-test.cc
Generated on Sun Mar 3 2024 17:11:01 for ns-3 by
1.9.1