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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Gary Pei <guangyu.pei@boeing.com>
7
*/
8
#include <ns3/log.h>
9
#include <ns3/lr-wpan-mac.h>
10
#include <ns3/lr-wpan-phy.h>
11
#include <ns3/packet.h>
12
#include <ns3/simulator.h>
13
#include <ns3/single-model-spectrum-channel.h>
14
#include <ns3/test.h>
15
16
using namespace
ns3
;
17
using namespace
ns3::lrwpan
;
18
19
/**
20
* \ingroup lr-wpan-test
21
* \ingroup tests
22
*
23
* \brief LrWpan PLME and PD Interfaces Test
24
*/
25
class
LrWpanPlmeAndPdInterfaceTestCase
:
public
TestCase
26
{
27
public
:
28
LrWpanPlmeAndPdInterfaceTestCase
();
29
~LrWpanPlmeAndPdInterfaceTestCase
()
override
;
30
31
private
:
32
void
DoRun
()
override
;
33
34
/**
35
* \brief Receives a PdData indication
36
* \param psduLength The PSDU length.
37
* \param p The packet.
38
* \param lqi The LQI.
39
*/
40
void
ReceivePdDataIndication
(
uint32_t
psduLength,
Ptr<Packet>
p, uint8_t lqi);
41
};
42
43
LrWpanPlmeAndPdInterfaceTestCase::LrWpanPlmeAndPdInterfaceTestCase
()
44
:
TestCase
(
"Test the PLME and PD SAP per IEEE 802.15.4"
)
45
{
46
}
47
48
LrWpanPlmeAndPdInterfaceTestCase::~LrWpanPlmeAndPdInterfaceTestCase
()
49
{
50
}
51
52
void
53
LrWpanPlmeAndPdInterfaceTestCase::ReceivePdDataIndication
(
uint32_t
psduLength,
54
Ptr<Packet>
p,
55
uint8_t lqi)
56
{
57
NS_LOG_UNCOND
(
"At: "
<<
Simulator::Now
() <<
" Received frame size: "
<< psduLength
58
<<
" LQI: "
<< lqi);
59
}
60
61
void
62
LrWpanPlmeAndPdInterfaceTestCase::DoRun
()
63
{
64
LogComponentEnableAll
(
LOG_PREFIX_FUNC
);
65
LogComponentEnable
(
"LrWpanPhy"
,
LOG_LEVEL_ALL
);
66
67
Ptr<LrWpanPhy>
sender =
CreateObject<LrWpanPhy>
();
68
Ptr<LrWpanPhy>
receiver =
CreateObject<LrWpanPhy>
();
69
70
Ptr<SingleModelSpectrumChannel>
channel =
CreateObject<SingleModelSpectrumChannel>
();
71
sender->SetChannel(channel);
72
receiver->SetChannel(channel);
73
74
receiver->SetPdDataIndicationCallback(
75
MakeCallback
(&
LrWpanPlmeAndPdInterfaceTestCase::ReceivePdDataIndication
,
this
));
76
77
uint32_t
n = 10;
78
Ptr<Packet>
p =
Create<Packet>
(n);
79
sender->PdDataRequest(p->GetSize(), p);
80
81
Simulator::Destroy
();
82
}
83
84
/**
85
* \ingroup lr-wpan-test
86
* \ingroup tests
87
*
88
* \brief LrWpan PLME and PD Interfaces TestSuite
89
*/
90
class
LrWpanPlmeAndPdInterfaceTestSuite
:
public
TestSuite
91
{
92
public
:
93
LrWpanPlmeAndPdInterfaceTestSuite
();
94
};
95
96
LrWpanPlmeAndPdInterfaceTestSuite::LrWpanPlmeAndPdInterfaceTestSuite
()
97
:
TestSuite
(
"lr-wpan-plme-pd-sap"
,
Type
::UNIT)
98
{
99
AddTestCase
(
new
LrWpanPlmeAndPdInterfaceTestCase
, TestCase::Duration::QUICK);
100
}
101
102
// Do not forget to allocate an instance of this TestSuite
103
static
LrWpanPlmeAndPdInterfaceTestSuite
104
g_lrWpanPlmeAndPdInterfaceTestSuite
;
//!< Static variable for test initialization
LrWpanPlmeAndPdInterfaceTestCase
LrWpan PLME and PD Interfaces Test.
Definition
lr-wpan-pd-plme-sap-test.cc:26
LrWpanPlmeAndPdInterfaceTestCase::LrWpanPlmeAndPdInterfaceTestCase
LrWpanPlmeAndPdInterfaceTestCase()
Definition
lr-wpan-pd-plme-sap-test.cc:43
LrWpanPlmeAndPdInterfaceTestCase::~LrWpanPlmeAndPdInterfaceTestCase
~LrWpanPlmeAndPdInterfaceTestCase() override
Definition
lr-wpan-pd-plme-sap-test.cc:48
LrWpanPlmeAndPdInterfaceTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
lr-wpan-pd-plme-sap-test.cc:62
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:53
LrWpanPlmeAndPdInterfaceTestSuite
LrWpan PLME and PD Interfaces TestSuite.
Definition
lr-wpan-pd-plme-sap-test.cc:91
LrWpanPlmeAndPdInterfaceTestSuite::LrWpanPlmeAndPdInterfaceTestSuite
LrWpanPlmeAndPdInterfaceTestSuite()
Definition
lr-wpan-pd-plme-sap-test.cc:96
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::Simulator::Destroy
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition
simulator.cc:131
ns3::Simulator::Now
static Time Now()
Return the current simulation virtual time.
Definition
simulator.cc:197
ns3::TestCase
encapsulates test code
Definition
test.h:1050
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition
test.cc:292
ns3::TestSuite
A suite of tests to run.
Definition
test.h:1267
ns3::TestSuite::Type
Type
Type of test.
Definition
test.h:1274
uint32_t
NS_LOG_UNCOND
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
Definition
log-macros-enabled.h:253
ns3::CreateObject
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition
object.h:619
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
g_lrWpanPlmeAndPdInterfaceTestSuite
static LrWpanPlmeAndPdInterfaceTestSuite g_lrWpanPlmeAndPdInterfaceTestSuite
Static variable for test initialization.
Definition
lr-wpan-pd-plme-sap-test.cc:104
ns3::lrwpan
Definition
lr-wpan-constants.h:23
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:291
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:684
ns3::LOG_LEVEL_ALL
@ LOG_LEVEL_ALL
Print everything.
Definition
log.h:105
ns3::LOG_PREFIX_FUNC
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
Definition
log.h:107
ns3::LogComponentEnableAll
void LogComponentEnableAll(LogLevel level)
Enable the logging output for all registered log components.
Definition
log.cc:309
src
lr-wpan
test
lr-wpan-pd-plme-sap-test.cc
Generated on Fri Nov 8 2024 13:59:02 for ns-3 by
1.11.0