A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
lr-wpan-pd-plme-sap-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: Gary Pei <guangyu.pei@boeing.com>
18
*/
19
#include <ns3/log.h>
20
#include <ns3/lr-wpan-mac.h>
21
#include <ns3/lr-wpan-phy.h>
22
#include <ns3/packet.h>
23
#include <ns3/simulator.h>
24
#include <ns3/single-model-spectrum-channel.h>
25
#include <ns3/test.h>
26
27
using namespace
ns3
;
28
using namespace
ns3::lrwpan
;
29
30
/**
31
* \ingroup lr-wpan-test
32
* \ingroup tests
33
*
34
* \brief LrWpan PLME and PD Interfaces Test
35
*/
36
class
LrWpanPlmeAndPdInterfaceTestCase
:
public
TestCase
37
{
38
public
:
39
LrWpanPlmeAndPdInterfaceTestCase
();
40
~LrWpanPlmeAndPdInterfaceTestCase
()
override
;
41
42
private
:
43
void
DoRun
()
override
;
44
45
/**
46
* \brief Receives a PdData indication
47
* \param psduLength The PSDU length.
48
* \param p The packet.
49
* \param lqi The LQI.
50
*/
51
void
ReceivePdDataIndication
(
uint32_t
psduLength,
Ptr<Packet>
p, uint8_t lqi);
52
};
53
54
LrWpanPlmeAndPdInterfaceTestCase::LrWpanPlmeAndPdInterfaceTestCase
()
55
:
TestCase
(
"Test the PLME and PD SAP per IEEE 802.15.4"
)
56
{
57
}
58
59
LrWpanPlmeAndPdInterfaceTestCase::~LrWpanPlmeAndPdInterfaceTestCase
()
60
{
61
}
62
63
void
64
LrWpanPlmeAndPdInterfaceTestCase::ReceivePdDataIndication
(
uint32_t
psduLength,
65
Ptr<Packet>
p,
66
uint8_t lqi)
67
{
68
NS_LOG_UNCOND
(
"At: "
<<
Simulator::Now
() <<
" Received frame size: "
<< psduLength
69
<<
" LQI: "
<< lqi);
70
}
71
72
void
73
LrWpanPlmeAndPdInterfaceTestCase::DoRun
()
74
{
75
LogComponentEnableAll
(
LOG_PREFIX_FUNC
);
76
LogComponentEnable
(
"LrWpanPhy"
,
LOG_LEVEL_ALL
);
77
78
Ptr<LrWpanPhy>
sender = CreateObject<LrWpanPhy>();
79
Ptr<LrWpanPhy>
receiver = CreateObject<LrWpanPhy>();
80
81
Ptr<SingleModelSpectrumChannel>
channel = CreateObject<SingleModelSpectrumChannel>();
82
sender->SetChannel(channel);
83
receiver->SetChannel(channel);
84
85
receiver->SetPdDataIndicationCallback(
86
MakeCallback
(&
LrWpanPlmeAndPdInterfaceTestCase::ReceivePdDataIndication
,
this
));
87
88
uint32_t
n = 10;
89
Ptr<Packet>
p = Create<Packet>(n);
90
sender->PdDataRequest(p->GetSize(), p);
91
92
Simulator::Destroy
();
93
}
94
95
/**
96
* \ingroup lr-wpan-test
97
* \ingroup tests
98
*
99
* \brief LrWpan PLME and PD Interfaces TestSuite
100
*/
101
class
LrWpanPlmeAndPdInterfaceTestSuite
:
public
TestSuite
102
{
103
public
:
104
LrWpanPlmeAndPdInterfaceTestSuite
();
105
};
106
107
LrWpanPlmeAndPdInterfaceTestSuite::LrWpanPlmeAndPdInterfaceTestSuite
()
108
:
TestSuite
(
"lr-wpan-plme-pd-sap"
,
Type
::UNIT)
109
{
110
AddTestCase
(
new
LrWpanPlmeAndPdInterfaceTestCase
, TestCase::Duration::QUICK);
111
}
112
113
// Do not forget to allocate an instance of this TestSuite
114
static
LrWpanPlmeAndPdInterfaceTestSuite
115
g_lrWpanPlmeAndPdInterfaceTestSuite
;
//!< Static variable for test initialization
LrWpanPlmeAndPdInterfaceTestCase
LrWpan PLME and PD Interfaces Test.
Definition:
lr-wpan-pd-plme-sap-test.cc:37
LrWpanPlmeAndPdInterfaceTestCase::LrWpanPlmeAndPdInterfaceTestCase
LrWpanPlmeAndPdInterfaceTestCase()
Definition:
lr-wpan-pd-plme-sap-test.cc:54
LrWpanPlmeAndPdInterfaceTestCase::~LrWpanPlmeAndPdInterfaceTestCase
~LrWpanPlmeAndPdInterfaceTestCase() override
Definition:
lr-wpan-pd-plme-sap-test.cc:59
LrWpanPlmeAndPdInterfaceTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
lr-wpan-pd-plme-sap-test.cc:73
LrWpanPlmeAndPdInterfaceTestCase::ReceivePdDataIndication
void ReceivePdDataIndication(uint32_t psduLength, Ptr< Packet > p, uint8_t lqi)
Receives a PdData indication.
Definition:
lr-wpan-pd-plme-sap-test.cc:64
LrWpanPlmeAndPdInterfaceTestSuite
LrWpan PLME and PD Interfaces TestSuite.
Definition:
lr-wpan-pd-plme-sap-test.cc:102
LrWpanPlmeAndPdInterfaceTestSuite::LrWpanPlmeAndPdInterfaceTestSuite
LrWpanPlmeAndPdInterfaceTestSuite()
Definition:
lr-wpan-pd-plme-sap-test.cc:107
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::Simulator::Destroy
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition:
simulator.cc:142
ns3::Simulator::Now
static Time Now()
Return the current simulation virtual time.
Definition:
simulator.cc:208
ns3::TestCase
encapsulates test code
Definition:
test.h:1061
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:302
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1273
ns3::TestSuite::Type
Type
Type of test.
Definition:
test.h:1280
uint32_t
NS_LOG_UNCOND
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
Definition:
log-macros-enabled.h:264
g_lrWpanPlmeAndPdInterfaceTestSuite
static LrWpanPlmeAndPdInterfaceTestSuite g_lrWpanPlmeAndPdInterfaceTestSuite
Static variable for test initialization.
Definition:
lr-wpan-pd-plme-sap-test.cc:115
ns3::lrwpan
Definition:
lr-wpan-constants.h:34
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::LogComponentEnable
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition:
log.cc:302
ns3::MakeCallback
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition:
callback.h:700
ns3::LOG_LEVEL_ALL
@ LOG_LEVEL_ALL
Print everything.
Definition:
log.h:116
ns3::LOG_PREFIX_FUNC
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
Definition:
log.h:118
ns3::LogComponentEnableAll
void LogComponentEnableAll(LogLevel level)
Enable the logging output for all registered log components.
Definition:
log.cc:320
src
lr-wpan
test
lr-wpan-pd-plme-sap-test.cc
Generated on Tue May 28 2024 23:36:58 for ns-3 by
1.9.6